##// END OF EJS Templates
Major cleanups and changes, see changelog/changeset for full details.
fperez -
Show More
@@ -1,187 +1,221 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 Logger class for IPython's logging facilities.
3 Logger class for IPython's logging facilities.
4
4
5 $Id: Logger.py 958 2005-12-27 23:17:51Z fperez $
5 $Id: Logger.py 966 2005-12-29 08:34:07Z fperez $
6 """
6 """
7
7
8 #*****************************************************************************
8 #*****************************************************************************
9 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
9 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
10 # Copyright (C) 2001-2004 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 #****************************************************************************
16 #****************************************************************************
17 # Modules and globals
17 # Modules and globals
18
18
19 from IPython import Release
19 from IPython import Release
20 __author__ = '%s <%s>\n%s <%s>' % \
20 __author__ = '%s <%s>\n%s <%s>' % \
21 ( Release.authors['Janko'] + Release.authors['Fernando'] )
21 ( Release.authors['Janko'] + Release.authors['Fernando'] )
22 __license__ = Release.license
22 __license__ = Release.license
23
23
24 # Python standard modules
24 # Python standard modules
25 import glob
25 import glob
26 import os
26 import os
27 import sys
27 import time
28
29 # Homebrewed
30 from IPython.genutils import *
31
28
32 #****************************************************************************
29 #****************************************************************************
33 # FIXME: The logger class shouldn't be a mixin, it throws too many things into
30 # FIXME: This class isn't a mixin anymore, but it still needs attributes from
34 # the InteractiveShell namespace. Rather make it a standalone tool, and create
31 # ipython and does input cache management. Finish cleanup later...
35 # a Logger instance in InteractiveShell that uses it. Doing this will require
32
36 # tracking down a *lot* of nasty uses of the Logger attributes in
33 class Logger(object):
37 # InteractiveShell, but will clean up things quite a bit.
34 """A Logfile class with different policies for file creation"""
38
35
39 class Logger:
36 def __init__(self,shell,logfname='Logger.log',loghead='',logmode='over'):
40 """A Logfile Mixin class with different policies for file creation"""
37
41
42 # FIXME: once this isn't a mixin, log_ns should just be 'namespace', since the
43 # names won't collide anymore.
44 def __init__(self,log_ns):
45 self._i00,self._i,self._ii,self._iii = '','','',''
38 self._i00,self._i,self._ii,self._iii = '','','',''
46 self.do_full_cache = 0 # FIXME. There's also a do_full.. in OutputCache
47 self.log_ns = log_ns
48 # defaults
49 self.LOGMODE = 'backup'
50 self.defname = 'logfile'
51
52 def create_log(self,header='',fname='',defname='.Logger.log'):
53 """Generate a new log-file with a default header"""
54 if fname:
55 self.LOG = fname
56
39
57 if self.LOG:
40 # this is the full ipython instance, we need some attributes from it
58 self.logfname = self.LOG
41 # which won't exist until later. What a mess, clean up later...
59 else:
42 self.shell = shell
60 self.logfname = defname
43
44 self.logfname = logfname
45 self.loghead = loghead
46 self.logmode = logmode
47 self.logfile = None
48
49 # whether to also log output
50 self.log_output = False
51
52 # whether to put timestamps before each log entry
53 self.timestamp = False
54
55 # activity control flags
56 self.log_active = False
57
58 # logmode is a validated property
59 def _set_mode(self,mode):
60 if mode not in ['append','backup','global','over','rotate']:
61 raise ValueError,'invalid log mode %s given' % mode
62 self._logmode = mode
63
64 def _get_mode(self):
65 return self._logmode
66
67 logmode = property(_get_mode,_set_mode)
68
69 def logstart(self,logfname=None,loghead=None,logmode=None,
70 log_output=False,timestamp=False):
71 """Generate a new log-file with a default header.
72
73 Raises RuntimeError if the log has already been started"""
74
75 if self.logfile is not None:
76 raise RuntimeError('Log file is already active: %s' %
77 self.logfname)
61
78
62 if self.LOGMODE == 'over':
79 self.log_active = True
63 if os.path.isfile(self.logfname):
80
64 os.remove(self.logfname)
81 # The three parameters can override constructor defaults
65 self.logfile = open(self.logfname,'w')
82 if logfname: self.logfname = logfname
66 if self.LOGMODE == 'backup':
83 if loghead: self.loghead = loghead
67 if os.path.isfile(self.logfname):
84 if logmode: self.logmode = logmode
85 self.timestamp = timestamp
86 self.log_output = log_output
87
88 # init depending on the log mode requested
89 isfile = os.path.isfile
90 logmode = self.logmode
91
92 if logmode == 'append':
93 self.logfile = open(self.logfname,'a')
94
95 elif logmode == 'backup':
96 if isfile(self.logfname):
68 backup_logname = self.logfname+'~'
97 backup_logname = self.logfname+'~'
69 # Manually remove any old backup, since os.rename may fail
98 # Manually remove any old backup, since os.rename may fail
70 # under Windows.
99 # under Windows.
71 if os.path.isfile(backup_logname):
100 if isfile(backup_logname):
72 os.remove(backup_logname)
101 os.remove(backup_logname)
73 os.rename(self.logfname,backup_logname)
102 os.rename(self.logfname,backup_logname)
74 self.logfile = open(self.logfname,'w')
103 self.logfile = open(self.logfname,'w')
75 elif self.LOGMODE == 'global':
104
76 self.logfname = os.path.join(self.home_dir, self.defname)
105 elif logmode == 'global':
106 self.logfname = os.path.join(self.shell.home_dir,self.logfname)
77 self.logfile = open(self.logfname, 'a')
107 self.logfile = open(self.logfname, 'a')
78 self.LOG = self.logfname
108
79 elif self.LOGMODE == 'rotate':
109 elif logmode == 'over':
80 if os.path.isfile(self.logfname):
110 if isfile(self.logfname):
81 if os.path.isfile(self.logfname+'.001~'):
111 os.remove(self.logfname)
112 self.logfile = open(self.logfname,'w')
113
114 elif logmode == 'rotate':
115 if isfile(self.logfname):
116 if isfile(self.logfname+'.001~'):
82 old = glob.glob(self.logfname+'.*~')
117 old = glob.glob(self.logfname+'.*~')
83 old.sort()
118 old.sort()
84 old.reverse()
119 old.reverse()
85 for f in old:
120 for f in old:
86 root, ext = os.path.splitext(f)
121 root, ext = os.path.splitext(f)
87 num = int(ext[1:-1])+1
122 num = int(ext[1:-1])+1
88 os.rename(f, root+'.'+`num`.zfill(3)+'~')
123 os.rename(f, root+'.'+`num`.zfill(3)+'~')
89 os.rename(self.logfname, self.logfname+'.001~')
124 os.rename(self.logfname, self.logfname+'.001~')
90 self.logfile = open(self.logfname,'w')
125 self.logfile = open(self.logfname,'w')
91 elif self.LOGMODE == 'append':
92 self.logfile = open(self.logfname,'a')
93
126
94 if self.LOGMODE != 'append':
127 if logmode != 'append':
95 self.logfile.write(header)
128 self.logfile.write(self.loghead)
96 self.logfile.flush()
97
129
98 def logstart(self, header='',parameter_s = ''):
130 self.logfile.flush()
99 if not hasattr(self, 'LOG'):
100 logfname = self.LOG or parameter_s or './'+self.defname
101 self.create_log(header,logfname)
102 elif parameter_s and hasattr(self,'logfname') and \
103 parameter_s != self.logfname:
104 self.close_log()
105 self.create_log(header,parameter_s)
106
107 self._dolog = 1
108
131
109 def switch_log(self,val):
132 def switch_log(self,val):
110 """Switch logging on/off. val should be ONLY 0 or 1."""
133 """Switch logging on/off. val should be ONLY a boolean."""
111
134
112 if not val in [0,1]:
135 if val not in [False,True,0,1]:
113 raise ValueError, \
136 raise ValueError, \
114 'Call switch_log ONLY with 0 or 1 as argument, not with:',val
137 'Call switch_log ONLY with a boolean argument, not with:',val
115
138
116 label = {0:'OFF',1:'ON'}
139 label = {0:'OFF',1:'ON',False:'OFF',True:'ON'}
117
140
118 try:
141 if self.logfile is None:
119 _ = self.logfile
120 except AttributeError:
121 print """
142 print """
122 Logging hasn't been started yet (use %logstart for that).
143 Logging hasn't been started yet (use logstart for that).
123
144
124 %logon/%logoff are for temporarily starting and stopping logging for a logfile
145 %logon/%logoff are for temporarily starting and stopping logging for a logfile
125 which already exists. But you must first start the logging process with
146 which already exists. But you must first start the logging process with
126 %logstart (optionally giving a logfile name)."""
147 %logstart (optionally giving a logfile name)."""
127
148
128 else:
149 else:
129 if self._dolog == val:
150 if self.log_active == val:
130 print 'Logging is already',label[val]
151 print 'Logging is already',label[val]
131 else:
152 else:
132 print 'Switching logging',label[val]
153 print 'Switching logging',label[val]
133 self._dolog = 1 - self._dolog
154 self.log_active = not self.log_active
155 self.log_active_out = self.log_active
134
156
135 def logstate(self):
157 def logstate(self):
136 """Print a status message about the logger."""
158 """Print a status message about the logger."""
137 try:
159 if self.logfile is None:
138 logfile = self.logfname
139 except:
140 print 'Logging has not been activated.'
160 print 'Logging has not been activated.'
141 else:
161 else:
142 state = self._dolog and 'active' or 'temporarily suspended'
162 state = self.log_active and 'active' or 'temporarily suspended'
143 print """
163 print 'Filename :',self.logfname
144 File:\t%s
164 print 'Mode :',self.logmode
145 Mode:\t%s
165 print 'Output logging:',self.log_output
146 State:\t%s """ % (logfile,self.LOGMODE,state)
166 print 'Timestamping :',self.timestamp
167 print 'State :',state
147
168
148
149 def log(self, line,continuation=None):
169 def log(self, line,continuation=None):
150 """Write the line to a log and create input cache variables _i*."""
170 """Write the line to a log and create input cache variables _i*."""
151
171
152 # update the auto _i tables
172 # update the auto _i tables
153 #print '***logging line',line # dbg
173 #print '***logging line',line # dbg
154 #print '***cache_count', self.outputcache.prompt_count # dbg
174 #print '***cache_count', self.shell.outputcache.prompt_count # dbg
155 input_hist = self.log_ns['_ih']
175 input_hist = self.shell.user_ns['_ih']
156 if not continuation and line:
176 if not continuation and line:
157 self._iii = self._ii
177 self._iii = self._ii
158 self._ii = self._i
178 self._ii = self._i
159 self._i = self._i00
179 self._i = self._i00
160 # put back the final \n of every input line
180 # put back the final \n of every input line
161 self._i00 = line+'\n'
181 self._i00 = line+'\n'
162 #print 'Logging input:<%s>' % line # dbg
182 #print 'Logging input:<%s>' % line # dbg
163 input_hist.append(self._i00)
183 input_hist.append(self._i00)
164
184
165 # hackish access to top-level namespace to create _i1,_i2... dynamically
185 # hackish access to top-level namespace to create _i1,_i2... dynamically
166 to_main = {'_i':self._i,'_ii':self._ii,'_iii':self._iii}
186 to_main = {'_i':self._i,'_ii':self._ii,'_iii':self._iii}
167 if self.do_full_cache:
187 if self.shell.outputcache.do_full_cache:
168 in_num = self.outputcache.prompt_count
188 in_num = self.shell.outputcache.prompt_count
169 # add blank lines if the input cache fell out of sync. This can happen
189 # add blank lines if the input cache fell out of sync. This can
170 # for embedded instances which get killed via C-D and then get resumed.
190 # happen for embedded instances which get killed via C-D and then
191 # get resumed.
171 while in_num >= len(input_hist):
192 while in_num >= len(input_hist):
172 input_hist.append('\n')
193 input_hist.append('\n')
173 new_i = '_i%s' % in_num
194 new_i = '_i%s' % in_num
174 if continuation:
195 if continuation:
175 self._i00 = '%s%s\n' % (self.log_ns[new_i],line)
196 self._i00 = '%s%s\n' % (self.shell.user_ns[new_i],line)
176 input_hist[in_num] = self._i00
197 input_hist[in_num] = self._i00
177 to_main[new_i] = self._i00
198 to_main[new_i] = self._i00
178 self.log_ns.update(to_main)
199 self.shell.user_ns.update(to_main)
179
200 self.log_write(line)
180 if self._dolog and line:
201
181 self.logfile.write(line+'\n')
202 def log_write(self,data,kind='input'):
203 """Write data to the log file, if active"""
204
205 if self.log_active and data:
206 write = self.logfile.write
207 if kind=='input':
208 if self.timestamp:
209 write(time.strftime('# %a, %d %b %Y %H:%M:%S\n',
210 time.localtime()))
211 write('%s\n' % data)
212 elif kind=='output' and self.log_output:
213 odata = '\n'.join(['#[Out]# %s' % s
214 for s in data.split('\n')])
215 write('%s\n' % odata)
182 self.logfile.flush()
216 self.logfile.flush()
183
217
184 def close_log(self):
218 def close_log(self):
185 if hasattr(self, 'logfile'):
219 self.logfile.close()
186 self.logfile.close()
220 self.logfile = None
187 self.logfname = ''
221 self.logfname = ''
@@ -1,2620 +1,2594 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 965 2005-12-28 23:23:09Z fperez $"""
4 $Id: Magic.py 966 2005-12-29 08:34:07Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #*****************************************************************************
12 #*****************************************************************************
13
13
14 #****************************************************************************
14 #****************************************************************************
15 # Modules and globals
15 # Modules and globals
16
16
17 from IPython import Release
17 from IPython import Release
18 __author__ = '%s <%s>\n%s <%s>' % \
18 __author__ = '%s <%s>\n%s <%s>' % \
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 __license__ = Release.license
20 __license__ = Release.license
21
21
22 # Python standard modules
22 # Python standard modules
23 import __builtin__
23 import __builtin__
24 import bdb
24 import bdb
25 import inspect
25 import inspect
26 import os
26 import os
27 import pdb
27 import pdb
28 import pydoc
28 import pydoc
29 import sys
29 import sys
30 import re
30 import re
31 import tempfile
31 import tempfile
32 import time
32 import time
33 from cStringIO import StringIO
33 from cStringIO import StringIO
34 from getopt import getopt
34 from getopt import getopt
35 from pprint import pprint, pformat
35 from pprint import pprint, pformat
36
36
37 # profile isn't bundled by default in Debian for license reasons
37 # profile isn't bundled by default in Debian for license reasons
38 try:
38 try:
39 import profile,pstats
39 import profile,pstats
40 except ImportError:
40 except ImportError:
41 profile = pstats = None
41 profile = pstats = None
42
42
43 # Homebrewed
43 # Homebrewed
44 from IPython import Debugger, OInspect, wildcard
44 from IPython import Debugger, OInspect, wildcard
45 from IPython.FakeModule import FakeModule
45 from IPython.FakeModule import FakeModule
46 from IPython.Itpl import Itpl, itpl, printpl,itplns
46 from IPython.Itpl import Itpl, itpl, printpl,itplns
47 from IPython.PyColorize import Parser
47 from IPython.PyColorize import Parser
48 from IPython.Struct import Struct
48 from IPython.Struct import Struct
49 from IPython.genutils import *
49 from IPython.genutils import *
50
50
51 # Globals to be set later by Magic constructor
52 MAGIC_PREFIX = ''
53 MAGIC_ESCAPE = ''
54
55 #***************************************************************************
51 #***************************************************************************
56 # Utility functions
52 # Utility functions
57 def magic2python(cmd):
58 """Convert a command string of magic syntax to valid Python code."""
59
60 if cmd.startswith('#'+MAGIC_ESCAPE) or \
61 cmd.startswith(MAGIC_ESCAPE):
62 if cmd[0]=='#':
63 cmd = cmd[1:]
64 # we need to return the proper line end later
65 if cmd[-1] == '\n':
66 endl = '\n'
67 else:
68 endl = ''
69 try:
70 func,args = cmd[1:].split(' ',1)
71 except:
72 func,args = cmd[1:].rstrip(),''
73 args = args.replace('"','\\"').replace("'","\\'").rstrip()
74 return '%s%s ("%s")%s' % (MAGIC_PREFIX,func,args,endl)
75 else:
76 return cmd
77
78 def on_off(tag):
53 def on_off(tag):
79 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
54 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
80 return ['OFF','ON'][tag]
55 return ['OFF','ON'][tag]
81
56
82
57
83 #****************************************************************************
58 #****************************************************************************
84 # Utility classes
59 # Utility classes
85 class Macro:
60 class Macro(list):
86 """Simple class to store the value of macros as strings.
61 """Simple class to store the value of macros as strings.
87
62
88 This allows us to later exec them by checking when something is an
63 This allows us to later exec them by checking when something is an
89 instance of this class."""
64 instance of this class."""
90
91 def __init__(self,cmds):
92 """Build a macro from a list of commands."""
93
65
94 # Since the list may include multi-line entries, first make sure that
66 def __init__(self,data):
95 # they've been all broken up before passing it to magic2python
67 list.__init__(self,data)
96 cmdlist = map(magic2python,''.join(cmds).split('\n'))
68 self.value = ''.join(data)
97 self.value = '\n'.join(cmdlist)
98
99 def __str__(self):
100 return self.value
101
69
102 #***************************************************************************
70 #***************************************************************************
103 # Main class implementing Magic functionality
71 # Main class implementing Magic functionality
104 class Magic:
72 class Magic:
105 """Magic functions for InteractiveShell.
73 """Magic functions for InteractiveShell.
106
74
107 Shell functions which can be reached as %function_name. All magic
75 Shell functions which can be reached as %function_name. All magic
108 functions should accept a string, which they can parse for their own
76 functions should accept a string, which they can parse for their own
109 needs. This can make some functions easier to type, eg `%cd ../`
77 needs. This can make some functions easier to type, eg `%cd ../`
110 vs. `%cd("../")`
78 vs. `%cd("../")`
111
79
112 ALL definitions MUST begin with the prefix magic_. The user won't need it
80 ALL definitions MUST begin with the prefix magic_. The user won't need it
113 at the command line, but it is is needed in the definition. """
81 at the command line, but it is is needed in the definition. """
114
82
115 # class globals
83 # class globals
116 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
84 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
117 'Automagic is ON, % prefix NOT needed for magic functions.']
85 'Automagic is ON, % prefix NOT needed for magic functions.']
118
86
119 #......................................................................
87 #......................................................................
120 # some utility functions
88 # some utility functions
121
89
122 def __init__(self,shell):
90 def __init__(self,shell):
123 # XXX This is hackish, clean up later to avoid these messy globals
124 global MAGIC_PREFIX, MAGIC_ESCAPE
125
91
126 self.options_table = {}
92 self.options_table = {}
127 MAGIC_PREFIX = shell.name+'.magic_'
128 MAGIC_ESCAPE = shell.ESC_MAGIC
129 if profile is None:
93 if profile is None:
130 self.magic_prun = self.profile_missing_notice
94 self.magic_prun = self.profile_missing_notice
95 self.shell = shell
131
96
132 def profile_missing_notice(self, *args, **kwargs):
97 def profile_missing_notice(self, *args, **kwargs):
133 error("""\
98 error("""\
134 The profile module could not be found. If you are a Debian user,
99 The profile module could not be found. If you are a Debian user,
135 it has been removed from the standard Debian package because of its non-free
100 it has been removed from the standard Debian package because of its non-free
136 license. To use profiling, please install"python2.3-profiler" from non-free.""")
101 license. To use profiling, please install"python2.3-profiler" from non-free.""")
137
102
138 def default_option(self,fn,optstr):
103 def default_option(self,fn,optstr):
139 """Make an entry in the options_table for fn, with value optstr"""
104 """Make an entry in the options_table for fn, with value optstr"""
140
105
141 if fn not in self.lsmagic():
106 if fn not in self.lsmagic():
142 error("%s is not a magic function" % fn)
107 error("%s is not a magic function" % fn)
143 self.options_table[fn] = optstr
108 self.options_table[fn] = optstr
144
109
145 def lsmagic(self):
110 def lsmagic(self):
146 """Return a list of currently available magic functions.
111 """Return a list of currently available magic functions.
147
112
148 Gives a list of the bare names after mangling (['ls','cd', ...], not
113 Gives a list of the bare names after mangling (['ls','cd', ...], not
149 ['magic_ls','magic_cd',...]"""
114 ['magic_ls','magic_cd',...]"""
150
115
151 # FIXME. This needs a cleanup, in the way the magics list is built.
116 # FIXME. This needs a cleanup, in the way the magics list is built.
152
117
153 # magics in class definition
118 # magics in class definition
154 class_magic = lambda fn: fn.startswith('magic_') and \
119 class_magic = lambda fn: fn.startswith('magic_') and \
155 callable(Magic.__dict__[fn])
120 callable(Magic.__dict__[fn])
156 # in instance namespace (run-time user additions)
121 # in instance namespace (run-time user additions)
157 inst_magic = lambda fn: fn.startswith('magic_') and \
122 inst_magic = lambda fn: fn.startswith('magic_') and \
158 callable(self.__dict__[fn])
123 callable(self.__dict__[fn])
159 # and bound magics by user (so they can access self):
124 # and bound magics by user (so they can access self):
160 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
125 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
161 callable(self.__class__.__dict__[fn])
126 callable(self.__class__.__dict__[fn])
162 magics = filter(class_magic,Magic.__dict__.keys()) + \
127 magics = filter(class_magic,Magic.__dict__.keys()) + \
163 filter(inst_magic,self.__dict__.keys()) + \
128 filter(inst_magic,self.__dict__.keys()) + \
164 filter(inst_bound_magic,self.__class__.__dict__.keys())
129 filter(inst_bound_magic,self.__class__.__dict__.keys())
165 out = []
130 out = []
166 for fn in magics:
131 for fn in magics:
167 out.append(fn.replace('magic_','',1))
132 out.append(fn.replace('magic_','',1))
168 out.sort()
133 out.sort()
169 return out
134 return out
170
135
171 def set_shell(self,shell):
172 self.shell = shell
173 self.alias_table = shell.alias_table
174
175 def extract_input_slices(self,slices):
136 def extract_input_slices(self,slices):
176 """Return as a string a set of input history slices.
137 """Return as a string a set of input history slices.
177
138
178 The set of slices is given as a list of strings (like ['1','4:8','9'],
139 The set of slices is given as a list of strings (like ['1','4:8','9'],
179 since this function is for use by magic functions which get their
140 since this function is for use by magic functions which get their
180 arguments as strings."""
141 arguments as strings."""
181
142
182 cmds = []
143 cmds = []
183 for chunk in slices:
144 for chunk in slices:
184 if ':' in chunk:
145 if ':' in chunk:
185 ini,fin = map(int,chunk.split(':'))
146 ini,fin = map(int,chunk.split(':'))
186 else:
147 else:
187 ini = int(chunk)
148 ini = int(chunk)
188 fin = ini+1
149 fin = ini+1
189 cmds.append(self.shell.input_hist[ini:fin])
150 cmds.append(self.shell.input_hist[ini:fin])
190 return cmds
151 return cmds
191
152
192 def _ofind(self,oname):
153 def _ofind(self,oname):
193 """Find an object in the available namespaces.
154 """Find an object in the available namespaces.
194
155
195 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
156 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
196
157
197 Has special code to detect magic functions.
158 Has special code to detect magic functions.
198 """
159 """
199
160
200 oname = oname.strip()
161 oname = oname.strip()
201
162
202 # Namespaces to search in:
163 # Namespaces to search in:
203 user_ns = self.shell.user_ns
164 user_ns = self.shell.user_ns
204 internal_ns = self.shell.internal_ns
165 internal_ns = self.shell.internal_ns
205 builtin_ns = __builtin__.__dict__
166 builtin_ns = __builtin__.__dict__
206 alias_ns = self.shell.alias_table
167 alias_ns = self.shell.alias_table
207
168
208 # Put them in a list. The order is important so that we find things in
169 # Put them in a list. The order is important so that we find things in
209 # the same order that Python finds them.
170 # the same order that Python finds them.
210 namespaces = [ ('Interactive',user_ns),
171 namespaces = [ ('Interactive',user_ns),
211 ('IPython internal',internal_ns),
172 ('IPython internal',internal_ns),
212 ('Python builtin',builtin_ns),
173 ('Python builtin',builtin_ns),
213 ('Alias',alias_ns),
174 ('Alias',alias_ns),
214 ]
175 ]
215
176
216 # initialize results to 'null'
177 # initialize results to 'null'
217 found = 0; obj = None; ospace = None; ds = None;
178 found = 0; obj = None; ospace = None; ds = None;
218 ismagic = 0; isalias = 0
179 ismagic = 0; isalias = 0
219
180
220 # Look for the given name by splitting it in parts. If the head is
181 # Look for the given name by splitting it in parts. If the head is
221 # found, then we look for all the remaining parts as members, and only
182 # found, then we look for all the remaining parts as members, and only
222 # declare success if we can find them all.
183 # declare success if we can find them all.
223 oname_parts = oname.split('.')
184 oname_parts = oname.split('.')
224 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
185 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
225 for nsname,ns in namespaces:
186 for nsname,ns in namespaces:
226 try:
187 try:
227 obj = ns[oname_head]
188 obj = ns[oname_head]
228 except KeyError:
189 except KeyError:
229 continue
190 continue
230 else:
191 else:
231 for part in oname_rest:
192 for part in oname_rest:
232 try:
193 try:
233 obj = getattr(obj,part)
194 obj = getattr(obj,part)
234 except:
195 except:
235 # Blanket except b/c some badly implemented objects
196 # Blanket except b/c some badly implemented objects
236 # allow __getattr__ to raise exceptions other than
197 # allow __getattr__ to raise exceptions other than
237 # AttributeError, which then crashes IPython.
198 # AttributeError, which then crashes IPython.
238 break
199 break
239 else:
200 else:
240 # If we finish the for loop (no break), we got all members
201 # If we finish the for loop (no break), we got all members
241 found = 1
202 found = 1
242 ospace = nsname
203 ospace = nsname
243 if ns == alias_ns:
204 if ns == alias_ns:
244 isalias = 1
205 isalias = 1
245 break # namespace loop
206 break # namespace loop
246
207
247 # Try to see if it's magic
208 # Try to see if it's magic
248 if not found:
209 if not found:
249 if oname.startswith(self.shell.ESC_MAGIC):
210 if oname.startswith(self.shell.ESC_MAGIC):
250 oname = oname[1:]
211 oname = oname[1:]
251 obj = getattr(self,'magic_'+oname,None)
212 obj = getattr(self,'magic_'+oname,None)
252 if obj is not None:
213 if obj is not None:
253 found = 1
214 found = 1
254 ospace = 'IPython internal'
215 ospace = 'IPython internal'
255 ismagic = 1
216 ismagic = 1
256
217
257 # Last try: special-case some literals like '', [], {}, etc:
218 # Last try: special-case some literals like '', [], {}, etc:
258 if not found and oname_head in ["''",'""','[]','{}','()']:
219 if not found and oname_head in ["''",'""','[]','{}','()']:
259 obj = eval(oname_head)
220 obj = eval(oname_head)
260 found = 1
221 found = 1
261 ospace = 'Interactive'
222 ospace = 'Interactive'
262
223
263 return {'found':found, 'obj':obj, 'namespace':ospace,
224 return {'found':found, 'obj':obj, 'namespace':ospace,
264 'ismagic':ismagic, 'isalias':isalias}
225 'ismagic':ismagic, 'isalias':isalias}
265
226
266 def arg_err(self,func):
227 def arg_err(self,func):
267 """Print docstring if incorrect arguments were passed"""
228 """Print docstring if incorrect arguments were passed"""
268 print 'Error in arguments:'
229 print 'Error in arguments:'
269 print OInspect.getdoc(func)
230 print OInspect.getdoc(func)
270
231
271
232
272 def format_latex(self,str):
233 def format_latex(self,str):
273 """Format a string for latex inclusion."""
234 """Format a string for latex inclusion."""
274
235
275 # Characters that need to be escaped for latex:
236 # Characters that need to be escaped for latex:
276 escape_re = re.compile(r'(%|_|\$)',re.MULTILINE)
237 escape_re = re.compile(r'(%|_|\$)',re.MULTILINE)
277 # Magic command names as headers:
238 # Magic command names as headers:
278 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
239 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
279 re.MULTILINE)
240 re.MULTILINE)
280 # Magic commands
241 # Magic commands
281 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
242 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
282 re.MULTILINE)
243 re.MULTILINE)
283 # Paragraph continue
244 # Paragraph continue
284 par_re = re.compile(r'\\$',re.MULTILINE)
245 par_re = re.compile(r'\\$',re.MULTILINE)
285
246
286 str = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',str)
247 str = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',str)
287 str = cmd_re.sub(r'\\texttt{\g<cmd>}',str)
248 str = cmd_re.sub(r'\\texttt{\g<cmd>}',str)
288 str = par_re.sub(r'\\\\',str)
249 str = par_re.sub(r'\\\\',str)
289 str = escape_re.sub(r'\\\1',str)
250 str = escape_re.sub(r'\\\1',str)
290 return str
251 return str
291
252
292 def format_screen(self,str):
253 def format_screen(self,str):
293 """Format a string for screen printing.
254 """Format a string for screen printing.
294
255
295 This removes some latex-type format codes."""
256 This removes some latex-type format codes."""
296 # Paragraph continue
257 # Paragraph continue
297 par_re = re.compile(r'\\$',re.MULTILINE)
258 par_re = re.compile(r'\\$',re.MULTILINE)
298 str = par_re.sub('',str)
259 str = par_re.sub('',str)
299 return str
260 return str
300
261
301 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
262 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
302 """Parse options passed to an argument string.
263 """Parse options passed to an argument string.
303
264
304 The interface is similar to that of getopt(), but it returns back a
265 The interface is similar to that of getopt(), but it returns back a
305 Struct with the options as keys and the stripped argument string still
266 Struct with the options as keys and the stripped argument string still
306 as a string.
267 as a string.
307
268
308 arg_str is quoted as a true sys.argv vector by using shlex.split.
269 arg_str is quoted as a true sys.argv vector by using shlex.split.
309 This allows us to easily expand variables, glob files, quote
270 This allows us to easily expand variables, glob files, quote
310 arguments, etc.
271 arguments, etc.
311
272
312 Options:
273 Options:
313 -mode: default 'string'. If given as 'list', the argument string is
274 -mode: default 'string'. If given as 'list', the argument string is
314 returned as a list (split on whitespace) instead of a string.
275 returned as a list (split on whitespace) instead of a string.
315
276
316 -list_all: put all option values in lists. Normally only options
277 -list_all: put all option values in lists. Normally only options
317 appearing more than once are put in a list."""
278 appearing more than once are put in a list."""
318
279
319 # inject default options at the beginning of the input line
280 # inject default options at the beginning of the input line
320 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
281 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
321 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
282 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
322
283
323 mode = kw.get('mode','string')
284 mode = kw.get('mode','string')
324 if mode not in ['string','list']:
285 if mode not in ['string','list']:
325 raise ValueError,'incorrect mode given: %s' % mode
286 raise ValueError,'incorrect mode given: %s' % mode
326 # Get options
287 # Get options
327 list_all = kw.get('list_all',0)
288 list_all = kw.get('list_all',0)
328
289
329 # Check if we have more than one argument to warrant extra processing:
290 # Check if we have more than one argument to warrant extra processing:
330 odict = {} # Dictionary with options
291 odict = {} # Dictionary with options
331 args = arg_str.split()
292 args = arg_str.split()
332 if len(args) >= 1:
293 if len(args) >= 1:
333 # If the list of inputs only has 0 or 1 thing in it, there's no
294 # If the list of inputs only has 0 or 1 thing in it, there's no
334 # need to look for options
295 # need to look for options
335 argv = shlex_split(arg_str)
296 argv = shlex_split(arg_str)
336 # Do regular option processing
297 # Do regular option processing
337 opts,args = getopt(argv,opt_str,*long_opts)
298 opts,args = getopt(argv,opt_str,*long_opts)
338 for o,a in opts:
299 for o,a in opts:
339 if o.startswith('--'):
300 if o.startswith('--'):
340 o = o[2:]
301 o = o[2:]
341 else:
302 else:
342 o = o[1:]
303 o = o[1:]
343 try:
304 try:
344 odict[o].append(a)
305 odict[o].append(a)
345 except AttributeError:
306 except AttributeError:
346 odict[o] = [odict[o],a]
307 odict[o] = [odict[o],a]
347 except KeyError:
308 except KeyError:
348 if list_all:
309 if list_all:
349 odict[o] = [a]
310 odict[o] = [a]
350 else:
311 else:
351 odict[o] = a
312 odict[o] = a
352
313
353 # Prepare opts,args for return
314 # Prepare opts,args for return
354 opts = Struct(odict)
315 opts = Struct(odict)
355 if mode == 'string':
316 if mode == 'string':
356 args = ' '.join(args)
317 args = ' '.join(args)
357
318
358 return opts,args
319 return opts,args
359
320
360 #......................................................................
321 #......................................................................
361 # And now the actual magic functions
322 # And now the actual magic functions
362
323
363 # Functions for IPython shell work (vars,funcs, config, etc)
324 # Functions for IPython shell work (vars,funcs, config, etc)
364 def magic_lsmagic(self, parameter_s = ''):
325 def magic_lsmagic(self, parameter_s = ''):
365 """List currently available magic functions."""
326 """List currently available magic functions."""
366 mesc = self.shell.ESC_MAGIC
327 mesc = self.shell.ESC_MAGIC
367 print 'Available magic functions:\n'+mesc+\
328 print 'Available magic functions:\n'+mesc+\
368 (' '+mesc).join(self.lsmagic())
329 (' '+mesc).join(self.lsmagic())
369 print '\n' + Magic.auto_status[self.shell.rc.automagic]
330 print '\n' + Magic.auto_status[self.shell.rc.automagic]
370 return None
331 return None
371
332
372 def magic_magic(self, parameter_s = ''):
333 def magic_magic(self, parameter_s = ''):
373 """Print information about the magic function system."""
334 """Print information about the magic function system."""
374
335
375 mode = ''
336 mode = ''
376 try:
337 try:
377 if parameter_s.split()[0] == '-latex':
338 if parameter_s.split()[0] == '-latex':
378 mode = 'latex'
339 mode = 'latex'
379 except:
340 except:
380 pass
341 pass
381
342
382 magic_docs = []
343 magic_docs = []
383 for fname in self.lsmagic():
344 for fname in self.lsmagic():
384 mname = 'magic_' + fname
345 mname = 'magic_' + fname
385 for space in (Magic,self,self.__class__):
346 for space in (Magic,self,self.__class__):
386 try:
347 try:
387 fn = space.__dict__[mname]
348 fn = space.__dict__[mname]
388 except KeyError:
349 except KeyError:
389 pass
350 pass
390 else:
351 else:
391 break
352 break
392 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
353 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
393 fname,fn.__doc__))
354 fname,fn.__doc__))
394 magic_docs = ''.join(magic_docs)
355 magic_docs = ''.join(magic_docs)
395
356
396 if mode == 'latex':
357 if mode == 'latex':
397 print self.format_latex(magic_docs)
358 print self.format_latex(magic_docs)
398 return
359 return
399 else:
360 else:
400 magic_docs = self.format_screen(magic_docs)
361 magic_docs = self.format_screen(magic_docs)
401
362
402 outmsg = """
363 outmsg = """
403 IPython's 'magic' functions
364 IPython's 'magic' functions
404 ===========================
365 ===========================
405
366
406 The magic function system provides a series of functions which allow you to
367 The magic function system provides a series of functions which allow you to
407 control the behavior of IPython itself, plus a lot of system-type
368 control the behavior of IPython itself, plus a lot of system-type
408 features. All these functions are prefixed with a % character, but parameters
369 features. All these functions are prefixed with a % character, but parameters
409 are given without parentheses or quotes.
370 are given without parentheses or quotes.
410
371
411 NOTE: If you have 'automagic' enabled (via the command line option or with the
372 NOTE: If you have 'automagic' enabled (via the command line option or with the
412 %automagic function), you don't need to type in the % explicitly. By default,
373 %automagic function), you don't need to type in the % explicitly. By default,
413 IPython ships with automagic on, so you should only rarely need the % escape.
374 IPython ships with automagic on, so you should only rarely need the % escape.
414
375
415 Example: typing '%cd mydir' (without the quotes) changes you working directory
376 Example: typing '%cd mydir' (without the quotes) changes you working directory
416 to 'mydir', if it exists.
377 to 'mydir', if it exists.
417
378
418 You can define your own magic functions to extend the system. See the supplied
379 You can define your own magic functions to extend the system. See the supplied
419 ipythonrc and example-magic.py files for details (in your ipython
380 ipythonrc and example-magic.py files for details (in your ipython
420 configuration directory, typically $HOME/.ipython/).
381 configuration directory, typically $HOME/.ipython/).
421
382
422 You can also define your own aliased names for magic functions. In your
383 You can also define your own aliased names for magic functions. In your
423 ipythonrc file, placing a line like:
384 ipythonrc file, placing a line like:
424
385
425 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
386 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
426
387
427 will define %pf as a new name for %profile.
388 will define %pf as a new name for %profile.
428
389
429 You can also call magics in code using the ipmagic() function, which IPython
390 You can also call magics in code using the ipmagic() function, which IPython
430 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
391 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
431
392
432 For a list of the available magic functions, use %lsmagic. For a description
393 For a list of the available magic functions, use %lsmagic. For a description
433 of any of them, type %magic_name?, e.g. '%cd?'.
394 of any of them, type %magic_name?, e.g. '%cd?'.
434
395
435 Currently the magic system has the following functions:\n"""
396 Currently the magic system has the following functions:\n"""
436
397
437 mesc = self.shell.ESC_MAGIC
398 mesc = self.shell.ESC_MAGIC
438 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
399 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
439 "\n\n%s%s\n\n%s" % (outmsg,
400 "\n\n%s%s\n\n%s" % (outmsg,
440 magic_docs,mesc,mesc,
401 magic_docs,mesc,mesc,
441 (' '+mesc).join(self.lsmagic()),
402 (' '+mesc).join(self.lsmagic()),
442 Magic.auto_status[self.shell.rc.automagic] ) )
403 Magic.auto_status[self.shell.rc.automagic] ) )
443
404
444 page(outmsg,screen_lines=self.shell.rc.screen_length)
405 page(outmsg,screen_lines=self.shell.rc.screen_length)
445
406
446 def magic_automagic(self, parameter_s = ''):
407 def magic_automagic(self, parameter_s = ''):
447 """Make magic functions callable without having to type the initial %.
408 """Make magic functions callable without having to type the initial %.
448
409
449 Toggles on/off (when off, you must call it as %automagic, of
410 Toggles on/off (when off, you must call it as %automagic, of
450 course). Note that magic functions have lowest priority, so if there's
411 course). Note that magic functions have lowest priority, so if there's
451 a variable whose name collides with that of a magic fn, automagic
412 a variable whose name collides with that of a magic fn, automagic
452 won't work for that function (you get the variable instead). However,
413 won't work for that function (you get the variable instead). However,
453 if you delete the variable (del var), the previously shadowed magic
414 if you delete the variable (del var), the previously shadowed magic
454 function becomes visible to automagic again."""
415 function becomes visible to automagic again."""
455
416
456 rc = self.shell.rc
417 rc = self.shell.rc
457 rc.automagic = not rc.automagic
418 rc.automagic = not rc.automagic
458 print '\n' + Magic.auto_status[rc.automagic]
419 print '\n' + Magic.auto_status[rc.automagic]
459
420
460 def magic_autocall(self, parameter_s = ''):
421 def magic_autocall(self, parameter_s = ''):
461 """Make functions callable without having to type parentheses.
422 """Make functions callable without having to type parentheses.
462
423
463 This toggles the autocall command line option on and off."""
424 This toggles the autocall command line option on and off."""
464
425
465 rc = self.shell.rc
426 rc = self.shell.rc
466 rc.autocall = not rc.autocall
427 rc.autocall = not rc.autocall
467 print "Automatic calling is:",['OFF','ON'][rc.autocall]
428 print "Automatic calling is:",['OFF','ON'][rc.autocall]
468
429
469 def magic_autoindent(self, parameter_s = ''):
430 def magic_autoindent(self, parameter_s = ''):
470 """Toggle autoindent on/off (if available)."""
431 """Toggle autoindent on/off (if available)."""
471
432
472 self.shell.set_autoindent()
433 self.shell.set_autoindent()
473 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
434 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
474
435
475 def magic_system_verbose(self, parameter_s = ''):
436 def magic_system_verbose(self, parameter_s = ''):
476 """Toggle verbose printing of system calls on/off."""
437 """Toggle verbose printing of system calls on/off."""
477
438
478 self.shell.rc_set_toggle('system_verbose')
439 self.shell.rc_set_toggle('system_verbose')
479 print "System verbose printing is:",\
440 print "System verbose printing is:",\
480 ['OFF','ON'][self.shell.rc.system_verbose]
441 ['OFF','ON'][self.shell.rc.system_verbose]
481
442
482 def magic_history(self, parameter_s = ''):
443 def magic_history(self, parameter_s = ''):
483 """Print input history (_i<n> variables), with most recent last.
444 """Print input history (_i<n> variables), with most recent last.
484
445
485 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
446 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
486 %history [-n] n -> print at most n inputs\\
447 %history [-n] n -> print at most n inputs\\
487 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
448 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
488
449
489 Each input's number <n> is shown, and is accessible as the
450 Each input's number <n> is shown, and is accessible as the
490 automatically generated variable _i<n>. Multi-line statements are
451 automatically generated variable _i<n>. Multi-line statements are
491 printed starting at a new line for easy copy/paste.
452 printed starting at a new line for easy copy/paste.
492
453
493 If option -n is used, input numbers are not printed. This is useful if
454 If option -n is used, input numbers are not printed. This is useful if
494 you want to get a printout of many lines which can be directly pasted
455 you want to get a printout of many lines which can be directly pasted
495 into a text editor.
456 into a text editor.
496
457
497 This feature is only available if numbered prompts are in use."""
458 This feature is only available if numbered prompts are in use."""
498
459
499 if not self.do_full_cache:
460 if not self.shell.outputcache.do_full_cache:
500 print 'This feature is only available if numbered prompts are in use.'
461 print 'This feature is only available if numbered prompts are in use.'
501 return
462 return
502 opts,args = self.parse_options(parameter_s,'n',mode='list')
463 opts,args = self.parse_options(parameter_s,'n',mode='list')
503
464
504 default_length = 40
465 default_length = 40
505 if len(args) == 0:
466 if len(args) == 0:
506 final = self.outputcache.prompt_count
467 final = self.shell.outputcache.prompt_count
507 init = max(1,final-default_length)
468 init = max(1,final-default_length)
508 elif len(args) == 1:
469 elif len(args) == 1:
509 final = self.outputcache.prompt_count
470 final = self.shell.outputcache.prompt_count
510 init = max(1,final-int(args[0]))
471 init = max(1,final-int(args[0]))
511 elif len(args) == 2:
472 elif len(args) == 2:
512 init,final = map(int,args)
473 init,final = map(int,args)
513 else:
474 else:
514 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
475 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
515 print self.magic_hist.__doc__
476 print self.magic_hist.__doc__
516 return
477 return
517 width = len(str(final))
478 width = len(str(final))
518 line_sep = ['','\n']
479 line_sep = ['','\n']
519 input_hist = self.shell.input_hist
480 input_hist = self.shell.input_hist
520 print_nums = not opts.has_key('n')
481 print_nums = not opts.has_key('n')
521 for in_num in range(init,final):
482 for in_num in range(init,final):
522 inline = input_hist[in_num]
483 inline = input_hist[in_num]
523 multiline = inline.count('\n') > 1
484 multiline = inline.count('\n') > 1
524 if print_nums:
485 if print_nums:
525 print str(in_num).ljust(width)+':'+ line_sep[multiline],
486 print str(in_num).ljust(width)+':'+ line_sep[multiline],
526 if inline.startswith('#'+self.shell.ESC_MAGIC) or \
487 if inline.startswith('#'+self.shell.ESC_MAGIC) or \
527 inline.startswith('#!'):
488 inline.startswith('#!'):
528 print inline[1:],
489 print inline[1:],
529 else:
490 else:
530 print inline,
491 print inline,
531
492
532 def magic_hist(self, parameter_s=''):
493 def magic_hist(self, parameter_s=''):
533 """Alternate name for %history."""
494 """Alternate name for %history."""
534 return self.magic_history(parameter_s)
495 return self.magic_history(parameter_s)
535
496
536 def magic_p(self, parameter_s=''):
497 def magic_p(self, parameter_s=''):
537 """Just a short alias for Python's 'print'."""
498 """Just a short alias for Python's 'print'."""
538 exec 'print ' + parameter_s in self.shell.user_ns
499 exec 'print ' + parameter_s in self.shell.user_ns
539
500
540 def magic_r(self, parameter_s=''):
501 def magic_r(self, parameter_s=''):
541 """Repeat previous input.
502 """Repeat previous input.
542
503
543 If given an argument, repeats the previous command which starts with
504 If given an argument, repeats the previous command which starts with
544 the same string, otherwise it just repeats the previous input.
505 the same string, otherwise it just repeats the previous input.
545
506
546 Shell escaped commands (with ! as first character) are not recognized
507 Shell escaped commands (with ! as first character) are not recognized
547 by this system, only pure python code and magic commands.
508 by this system, only pure python code and magic commands.
548 """
509 """
549
510
550 start = parameter_s.strip()
511 start = parameter_s.strip()
551 esc_magic = self.shell.ESC_MAGIC
512 esc_magic = self.shell.ESC_MAGIC
552 # Identify magic commands even if automagic is on (which means
513 # Identify magic commands even if automagic is on (which means
553 # the in-memory version is different from that typed by the user).
514 # the in-memory version is different from that typed by the user).
554 if self.shell.rc.automagic:
515 if self.shell.rc.automagic:
555 start_magic = esc_magic+start
516 start_magic = esc_magic+start
556 else:
517 else:
557 start_magic = start
518 start_magic = start
558 # Look through the input history in reverse
519 # Look through the input history in reverse
559 for n in range(len(self.shell.input_hist)-2,0,-1):
520 for n in range(len(self.shell.input_hist)-2,0,-1):
560 input = self.shell.input_hist[n]
521 input = self.shell.input_hist[n]
561 # skip plain 'r' lines so we don't recurse to infinity
522 # skip plain 'r' lines so we don't recurse to infinity
562 if input != 'ipmagic("r")\n' and \
523 if input != 'ipmagic("r")\n' and \
563 (input.startswith(start) or input.startswith(start_magic)):
524 (input.startswith(start) or input.startswith(start_magic)):
564 #print 'match',`input` # dbg
525 #print 'match',`input` # dbg
565 if input.startswith(esc_magic):
566 input = magic2python(input)
567 #print 'modified',`input` # dbg
568 print 'Executing:',input,
526 print 'Executing:',input,
569 exec input in self.shell.user_ns
527 self.shell.runlines(input)
570 return
528 return
571 print 'No previous input matching `%s` found.' % start
529 print 'No previous input matching `%s` found.' % start
572
530
573 def magic_page(self, parameter_s=''):
531 def magic_page(self, parameter_s=''):
574 """Pretty print the object and display it through a pager.
532 """Pretty print the object and display it through a pager.
575
533
576 If no parameter is given, use _ (last output)."""
534 If no parameter is given, use _ (last output)."""
577 # After a function contributed by Olivier Aubert, slightly modified.
535 # After a function contributed by Olivier Aubert, slightly modified.
578
536
579 oname = parameter_s and parameter_s or '_'
537 oname = parameter_s and parameter_s or '_'
580 info = self._ofind(oname)
538 info = self._ofind(oname)
581 if info['found']:
539 if info['found']:
582 page(pformat(info['obj']))
540 page(pformat(info['obj']))
583 else:
541 else:
584 print 'Object `%s` not found' % oname
542 print 'Object `%s` not found' % oname
585
543
586 def magic_profile(self, parameter_s=''):
544 def magic_profile(self, parameter_s=''):
587 """Print your currently active IPyhton profile."""
545 """Print your currently active IPyhton profile."""
588 if self.shell.rc.profile:
546 if self.shell.rc.profile:
589 printpl('Current IPython profile: $self.shell.rc.profile.')
547 printpl('Current IPython profile: $self.shell.rc.profile.')
590 else:
548 else:
591 print 'No profile active.'
549 print 'No profile active.'
592
550
593 def _inspect(self,meth,oname,**kw):
551 def _inspect(self,meth,oname,**kw):
594 """Generic interface to the inspector system.
552 """Generic interface to the inspector system.
595
553
596 This function is meant to be called by pdef, pdoc & friends."""
554 This function is meant to be called by pdef, pdoc & friends."""
597
555
598 oname = oname.strip()
556 oname = oname.strip()
599 info = Struct(self._ofind(oname))
557 info = Struct(self._ofind(oname))
600 if info.found:
558 if info.found:
601 pmethod = getattr(self.shell.inspector,meth)
559 pmethod = getattr(self.shell.inspector,meth)
602 formatter = info.ismagic and self.format_screen or None
560 formatter = info.ismagic and self.format_screen or None
603 if meth == 'pdoc':
561 if meth == 'pdoc':
604 pmethod(info.obj,oname,formatter)
562 pmethod(info.obj,oname,formatter)
605 elif meth == 'pinfo':
563 elif meth == 'pinfo':
606 pmethod(info.obj,oname,formatter,info,**kw)
564 pmethod(info.obj,oname,formatter,info,**kw)
607 else:
565 else:
608 pmethod(info.obj,oname)
566 pmethod(info.obj,oname)
609 else:
567 else:
610 print 'Object `%s` not found.' % oname
568 print 'Object `%s` not found.' % oname
611 return 'not found' # so callers can take other action
569 return 'not found' # so callers can take other action
612
570
613 def magic_pdef(self, parameter_s=''):
571 def magic_pdef(self, parameter_s=''):
614 """Print the definition header for any callable object.
572 """Print the definition header for any callable object.
615
573
616 If the object is a class, print the constructor information."""
574 If the object is a class, print the constructor information."""
617 self._inspect('pdef',parameter_s)
575 self._inspect('pdef',parameter_s)
618
576
619 def magic_pdoc(self, parameter_s=''):
577 def magic_pdoc(self, parameter_s=''):
620 """Print the docstring for an object.
578 """Print the docstring for an object.
621
579
622 If the given object is a class, it will print both the class and the
580 If the given object is a class, it will print both the class and the
623 constructor docstrings."""
581 constructor docstrings."""
624 self._inspect('pdoc',parameter_s)
582 self._inspect('pdoc',parameter_s)
625
583
626 def magic_psource(self, parameter_s=''):
584 def magic_psource(self, parameter_s=''):
627 """Print (or run through pager) the source code for an object."""
585 """Print (or run through pager) the source code for an object."""
628 self._inspect('psource',parameter_s)
586 self._inspect('psource',parameter_s)
629
587
630 def magic_pfile(self, parameter_s=''):
588 def magic_pfile(self, parameter_s=''):
631 """Print (or run through pager) the file where an object is defined.
589 """Print (or run through pager) the file where an object is defined.
632
590
633 The file opens at the line where the object definition begins. IPython
591 The file opens at the line where the object definition begins. IPython
634 will honor the environment variable PAGER if set, and otherwise will
592 will honor the environment variable PAGER if set, and otherwise will
635 do its best to print the file in a convenient form.
593 do its best to print the file in a convenient form.
636
594
637 If the given argument is not an object currently defined, IPython will
595 If the given argument is not an object currently defined, IPython will
638 try to interpret it as a filename (automatically adding a .py extension
596 try to interpret it as a filename (automatically adding a .py extension
639 if needed). You can thus use %pfile as a syntax highlighting code
597 if needed). You can thus use %pfile as a syntax highlighting code
640 viewer."""
598 viewer."""
641
599
642 # first interpret argument as an object name
600 # first interpret argument as an object name
643 out = self._inspect('pfile',parameter_s)
601 out = self._inspect('pfile',parameter_s)
644 # if not, try the input as a filename
602 # if not, try the input as a filename
645 if out == 'not found':
603 if out == 'not found':
646 try:
604 try:
647 filename = get_py_filename(parameter_s)
605 filename = get_py_filename(parameter_s)
648 except IOError,msg:
606 except IOError,msg:
649 print msg
607 print msg
650 return
608 return
651 page(self.shell.inspector.format(file(filename).read()))
609 page(self.shell.inspector.format(file(filename).read()))
652
610
653 def magic_pinfo(self, parameter_s=''):
611 def magic_pinfo(self, parameter_s=''):
654 """Provide detailed information about an object.
612 """Provide detailed information about an object.
655
613
656 '%pinfo object' is just a synonym for object? or ?object."""
614 '%pinfo object' is just a synonym for object? or ?object."""
657
615
658 #print 'pinfo par: <%s>' % parameter_s # dbg
616 #print 'pinfo par: <%s>' % parameter_s # dbg
659
617
660 # detail_level: 0 -> obj? , 1 -> obj??
618 # detail_level: 0 -> obj? , 1 -> obj??
661 detail_level = 0
619 detail_level = 0
662 # We need to detect if we got called as 'pinfo pinfo foo', which can
620 # We need to detect if we got called as 'pinfo pinfo foo', which can
663 # happen if the user types 'pinfo foo?' at the cmd line.
621 # happen if the user types 'pinfo foo?' at the cmd line.
664 pinfo,qmark1,oname,qmark2 = \
622 pinfo,qmark1,oname,qmark2 = \
665 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
623 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
666 if pinfo or qmark1 or qmark2:
624 if pinfo or qmark1 or qmark2:
667 detail_level = 1
625 detail_level = 1
668 if "*" in oname:
626 if "*" in oname:
669 self.magic_psearch(oname)
627 self.magic_psearch(oname)
670 else:
628 else:
671 self._inspect('pinfo',oname,detail_level=detail_level)
629 self._inspect('pinfo',oname,detail_level=detail_level)
672
630
673 def magic_psearch(self, parameter_s=''):
631 def magic_psearch(self, parameter_s=''):
674 """Search for object in namespaces by wildcard.
632 """Search for object in namespaces by wildcard.
675
633
676 %psearch [options] PATTERN [OBJECT TYPE]
634 %psearch [options] PATTERN [OBJECT TYPE]
677
635
678 Note: ? can be used as a synonym for %psearch, at the beginning or at
636 Note: ? can be used as a synonym for %psearch, at the beginning or at
679 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
637 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
680 rest of the command line must be unchanged (options come first), so
638 rest of the command line must be unchanged (options come first), so
681 for example the following forms are equivalent
639 for example the following forms are equivalent
682
640
683 %psearch -i a* function
641 %psearch -i a* function
684 -i a* function?
642 -i a* function?
685 ?-i a* function
643 ?-i a* function
686
644
687 Arguments:
645 Arguments:
688
646
689 PATTERN
647 PATTERN
690
648
691 where PATTERN is a string containing * as a wildcard similar to its
649 where PATTERN is a string containing * as a wildcard similar to its
692 use in a shell. The pattern is matched in all namespaces on the
650 use in a shell. The pattern is matched in all namespaces on the
693 search path. By default objects starting with a single _ are not
651 search path. By default objects starting with a single _ are not
694 matched, many IPython generated objects have a single
652 matched, many IPython generated objects have a single
695 underscore. The default is case insensitive matching. Matching is
653 underscore. The default is case insensitive matching. Matching is
696 also done on the attributes of objects and not only on the objects
654 also done on the attributes of objects and not only on the objects
697 in a module.
655 in a module.
698
656
699 [OBJECT TYPE]
657 [OBJECT TYPE]
700
658
701 Is the name of a python type from the types module. The name is
659 Is the name of a python type from the types module. The name is
702 given in lowercase without the ending type, ex. StringType is
660 given in lowercase without the ending type, ex. StringType is
703 written string. By adding a type here only objects matching the
661 written string. By adding a type here only objects matching the
704 given type are matched. Using all here makes the pattern match all
662 given type are matched. Using all here makes the pattern match all
705 types (this is the default).
663 types (this is the default).
706
664
707 Options:
665 Options:
708
666
709 -a: makes the pattern match even objects whose names start with a
667 -a: makes the pattern match even objects whose names start with a
710 single underscore. These names are normally ommitted from the
668 single underscore. These names are normally ommitted from the
711 search.
669 search.
712
670
713 -i/-c: make the pattern case insensitive/sensitive. If neither of
671 -i/-c: make the pattern case insensitive/sensitive. If neither of
714 these options is given, the default is read from your ipythonrc
672 these options is given, the default is read from your ipythonrc
715 file. The option name which sets this value is
673 file. The option name which sets this value is
716 'wildcards_case_sensitive'. If this option is not specified in your
674 'wildcards_case_sensitive'. If this option is not specified in your
717 ipythonrc file, IPython's internal default is to do a case sensitive
675 ipythonrc file, IPython's internal default is to do a case sensitive
718 search.
676 search.
719
677
720 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
678 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
721 specifiy can be searched in any of the following namespaces:
679 specifiy can be searched in any of the following namespaces:
722 'builtin', 'user', 'user_global','internal', 'alias', where
680 'builtin', 'user', 'user_global','internal', 'alias', where
723 'builtin' and 'user' are the search defaults. Note that you should
681 'builtin' and 'user' are the search defaults. Note that you should
724 not use quotes when specifying namespaces.
682 not use quotes when specifying namespaces.
725
683
726 'Builtin' contains the python module builtin, 'user' contains all
684 'Builtin' contains the python module builtin, 'user' contains all
727 user data, 'alias' only contain the shell aliases and no python
685 user data, 'alias' only contain the shell aliases and no python
728 objects, 'internal' contains objects used by IPython. The
686 objects, 'internal' contains objects used by IPython. The
729 'user_global' namespace is only used by embedded IPython instances,
687 'user_global' namespace is only used by embedded IPython instances,
730 and it contains module-level globals. You can add namespaces to the
688 and it contains module-level globals. You can add namespaces to the
731 search with -s or exclude them with -e (these options can be given
689 search with -s or exclude them with -e (these options can be given
732 more than once).
690 more than once).
733
691
734 Examples:
692 Examples:
735
693
736 %psearch a* -> objects beginning with an a
694 %psearch a* -> objects beginning with an a
737 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
695 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
738 %psearch a* function -> all functions beginning with an a
696 %psearch a* function -> all functions beginning with an a
739 %psearch re.e* -> objects beginning with an e in module re
697 %psearch re.e* -> objects beginning with an e in module re
740 %psearch r*.e* -> objects that start with e in modules starting in r
698 %psearch r*.e* -> objects that start with e in modules starting in r
741 %psearch r*.* string -> all strings in modules beginning with r
699 %psearch r*.* string -> all strings in modules beginning with r
742
700
743 Case sensitve search:
701 Case sensitve search:
744
702
745 %psearch -c a* list all object beginning with lower case a
703 %psearch -c a* list all object beginning with lower case a
746
704
747 Show objects beginning with a single _:
705 Show objects beginning with a single _:
748
706
749 %psearch -a _* list objects beginning with a single underscore"""
707 %psearch -a _* list objects beginning with a single underscore"""
750
708
751 # default namespaces to be searched
709 # default namespaces to be searched
752 def_search = ['user','builtin']
710 def_search = ['user','builtin']
753
711
754 # Process options/args
712 # Process options/args
755 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
713 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
756 opt = opts.get
714 opt = opts.get
757 shell = self.shell
715 shell = self.shell
758 psearch = shell.inspector.psearch
716 psearch = shell.inspector.psearch
759
717
760 # select case options
718 # select case options
761 if opts.has_key('i'):
719 if opts.has_key('i'):
762 ignore_case = True
720 ignore_case = True
763 elif opts.has_key('c'):
721 elif opts.has_key('c'):
764 ignore_case = False
722 ignore_case = False
765 else:
723 else:
766 ignore_case = not shell.rc.wildcards_case_sensitive
724 ignore_case = not shell.rc.wildcards_case_sensitive
767
725
768 # Build list of namespaces to search from user options
726 # Build list of namespaces to search from user options
769 def_search.extend(opt('s',[]))
727 def_search.extend(opt('s',[]))
770 ns_exclude = ns_exclude=opt('e',[])
728 ns_exclude = ns_exclude=opt('e',[])
771 ns_search = [nm for nm in def_search if nm not in ns_exclude]
729 ns_search = [nm for nm in def_search if nm not in ns_exclude]
772
730
773 # Call the actual search
731 # Call the actual search
774 try:
732 try:
775 psearch(args,shell.ns_table,ns_search,
733 psearch(args,shell.ns_table,ns_search,
776 show_all=opt('a'),ignore_case=ignore_case)
734 show_all=opt('a'),ignore_case=ignore_case)
777 except:
735 except:
778 shell.showtraceback()
736 shell.showtraceback()
779
737
780 def magic_who_ls(self, parameter_s=''):
738 def magic_who_ls(self, parameter_s=''):
781 """Return a sorted list of all interactive variables.
739 """Return a sorted list of all interactive variables.
782
740
783 If arguments are given, only variables of types matching these
741 If arguments are given, only variables of types matching these
784 arguments are returned."""
742 arguments are returned."""
785
743
786 user_ns = self.shell.user_ns
744 user_ns = self.shell.user_ns
787 out = []
745 out = []
788 typelist = parameter_s.split()
746 typelist = parameter_s.split()
789 for i in self.shell.user_ns.keys():
747 for i in self.shell.user_ns.keys():
790 if not (i.startswith('_') or i.startswith('_i')) \
748 if not (i.startswith('_') or i.startswith('_i')) \
791 and not (self.internal_ns.has_key(i) or
749 and not (self.shell.internal_ns.has_key(i) or
792 self.user_config_ns.has_key(i)):
750 self.shell.user_config_ns.has_key(i)):
793 if typelist:
751 if typelist:
794 if type(user_ns[i]).__name__ in typelist:
752 if type(user_ns[i]).__name__ in typelist:
795 out.append(i)
753 out.append(i)
796 else:
754 else:
797 out.append(i)
755 out.append(i)
798 out.sort()
756 out.sort()
799 return out
757 return out
800
758
801 def magic_who(self, parameter_s=''):
759 def magic_who(self, parameter_s=''):
802 """Print all interactive variables, with some minimal formatting.
760 """Print all interactive variables, with some minimal formatting.
803
761
804 If any arguments are given, only variables whose type matches one of
762 If any arguments are given, only variables whose type matches one of
805 these are printed. For example:
763 these are printed. For example:
806
764
807 %who function str
765 %who function str
808
766
809 will only list functions and strings, excluding all other types of
767 will only list functions and strings, excluding all other types of
810 variables. To find the proper type names, simply use type(var) at a
768 variables. To find the proper type names, simply use type(var) at a
811 command line to see how python prints type names. For example:
769 command line to see how python prints type names. For example:
812
770
813 In [1]: type('hello')\\
771 In [1]: type('hello')\\
814 Out[1]: <type 'str'>
772 Out[1]: <type 'str'>
815
773
816 indicates that the type name for strings is 'str'.
774 indicates that the type name for strings is 'str'.
817
775
818 %who always excludes executed names loaded through your configuration
776 %who always excludes executed names loaded through your configuration
819 file and things which are internal to IPython.
777 file and things which are internal to IPython.
820
778
821 This is deliberate, as typically you may load many modules and the
779 This is deliberate, as typically you may load many modules and the
822 purpose of %who is to show you only what you've manually defined."""
780 purpose of %who is to show you only what you've manually defined."""
823
781
824 varlist = self.magic_who_ls(parameter_s)
782 varlist = self.magic_who_ls(parameter_s)
825 if not varlist:
783 if not varlist:
826 print 'Interactive namespace is empty.'
784 print 'Interactive namespace is empty.'
827 return
785 return
828
786
829 # if we have variables, move on...
787 # if we have variables, move on...
830
788
831 # stupid flushing problem: when prompts have no separators, stdout is
789 # stupid flushing problem: when prompts have no separators, stdout is
832 # getting lost. I'm starting to think this is a python bug. I'm having
790 # getting lost. I'm starting to think this is a python bug. I'm having
833 # to force a flush with a print because even a sys.stdout.flush
791 # to force a flush with a print because even a sys.stdout.flush
834 # doesn't seem to do anything!
792 # doesn't seem to do anything!
835
793
836 count = 0
794 count = 0
837 for i in varlist:
795 for i in varlist:
838 print i+'\t',
796 print i+'\t',
839 count += 1
797 count += 1
840 if count > 8:
798 if count > 8:
841 count = 0
799 count = 0
842 print
800 print
843 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
801 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
844
802
845 print # well, this does force a flush at the expense of an extra \n
803 print # well, this does force a flush at the expense of an extra \n
846
804
847 def magic_whos(self, parameter_s=''):
805 def magic_whos(self, parameter_s=''):
848 """Like %who, but gives some extra information about each variable.
806 """Like %who, but gives some extra information about each variable.
849
807
850 The same type filtering of %who can be applied here.
808 The same type filtering of %who can be applied here.
851
809
852 For all variables, the type is printed. Additionally it prints:
810 For all variables, the type is printed. Additionally it prints:
853
811
854 - For {},[],(): their length.
812 - For {},[],(): their length.
855
813
856 - For Numeric arrays, a summary with shape, number of elements,
814 - For Numeric arrays, a summary with shape, number of elements,
857 typecode and size in memory.
815 typecode and size in memory.
858
816
859 - Everything else: a string representation, snipping their middle if
817 - Everything else: a string representation, snipping their middle if
860 too long."""
818 too long."""
861
819
862 varnames = self.magic_who_ls(parameter_s)
820 varnames = self.magic_who_ls(parameter_s)
863 if not varnames:
821 if not varnames:
864 print 'Interactive namespace is empty.'
822 print 'Interactive namespace is empty.'
865 return
823 return
866
824
867 # if we have variables, move on...
825 # if we have variables, move on...
868
826
869 # for these types, show len() instead of data:
827 # for these types, show len() instead of data:
870 seq_types = [types.DictType,types.ListType,types.TupleType]
828 seq_types = [types.DictType,types.ListType,types.TupleType]
871
829
872 # for Numeric arrays, display summary info
830 # for Numeric arrays, display summary info
873 try:
831 try:
874 import Numeric
832 import Numeric
875 except ImportError:
833 except ImportError:
876 array_type = None
834 array_type = None
877 else:
835 else:
878 array_type = Numeric.ArrayType.__name__
836 array_type = Numeric.ArrayType.__name__
879
837
880 # Find all variable names and types so we can figure out column sizes
838 # Find all variable names and types so we can figure out column sizes
881 get_vars = lambda i: self.shell.user_ns[i]
839 get_vars = lambda i: self.shell.user_ns[i]
882 type_name = lambda v: type(v).__name__
840 type_name = lambda v: type(v).__name__
883 varlist = map(get_vars,varnames)
841 varlist = map(get_vars,varnames)
884 typelist = map(type_name,varlist)
842 typelist = map(type_name,varlist)
885 # column labels and # of spaces as separator
843 # column labels and # of spaces as separator
886 varlabel = 'Variable'
844 varlabel = 'Variable'
887 typelabel = 'Type'
845 typelabel = 'Type'
888 datalabel = 'Data/Info'
846 datalabel = 'Data/Info'
889 colsep = 3
847 colsep = 3
890 # variable format strings
848 # variable format strings
891 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
849 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
892 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
850 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
893 aformat = "%s: %s elems, type `%s`, %s bytes"
851 aformat = "%s: %s elems, type `%s`, %s bytes"
894 # find the size of the columns to format the output nicely
852 # find the size of the columns to format the output nicely
895 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
853 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
896 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
854 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
897 # table header
855 # table header
898 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
856 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
899 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
857 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
900 # and the table itself
858 # and the table itself
901 kb = 1024
859 kb = 1024
902 Mb = 1048576 # kb**2
860 Mb = 1048576 # kb**2
903 for vname,var,vtype in zip(varnames,varlist,typelist):
861 for vname,var,vtype in zip(varnames,varlist,typelist):
904 print itpl(vformat),
862 print itpl(vformat),
905 if vtype in seq_types:
863 if vtype in seq_types:
906 print len(var)
864 print len(var)
907 elif vtype==array_type:
865 elif vtype==array_type:
908 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
866 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
909 vsize = Numeric.size(var)
867 vsize = Numeric.size(var)
910 vbytes = vsize*var.itemsize()
868 vbytes = vsize*var.itemsize()
911 if vbytes < 100000:
869 if vbytes < 100000:
912 print aformat % (vshape,vsize,var.typecode(),vbytes)
870 print aformat % (vshape,vsize,var.typecode(),vbytes)
913 else:
871 else:
914 print aformat % (vshape,vsize,var.typecode(),vbytes),
872 print aformat % (vshape,vsize,var.typecode(),vbytes),
915 if vbytes < Mb:
873 if vbytes < Mb:
916 print '(%s kb)' % (vbytes/kb,)
874 print '(%s kb)' % (vbytes/kb,)
917 else:
875 else:
918 print '(%s Mb)' % (vbytes/Mb,)
876 print '(%s Mb)' % (vbytes/Mb,)
919 else:
877 else:
920 vstr = str(var)
878 vstr = str(var)
921 if len(vstr) < 50:
879 if len(vstr) < 50:
922 print vstr
880 print vstr
923 else:
881 else:
924 printpl(vfmt_short)
882 printpl(vfmt_short)
925
883
926 def magic_reset(self, parameter_s=''):
884 def magic_reset(self, parameter_s=''):
927 """Resets the namespace by removing all names defined by the user.
885 """Resets the namespace by removing all names defined by the user.
928
886
929 Input/Output history are left around in case you need them."""
887 Input/Output history are left around in case you need them."""
930
888
931 ans = raw_input(
889 ans = raw_input(
932 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
890 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
933 if not ans.lower() == 'y':
891 if not ans.lower() == 'y':
934 print 'Nothing done.'
892 print 'Nothing done.'
935 return
893 return
936 user_ns = self.shell.user_ns
894 user_ns = self.shell.user_ns
937 for i in self.magic_who_ls():
895 for i in self.magic_who_ls():
938 del(user_ns[i])
896 del(user_ns[i])
939
897
940 def magic_config(self,parameter_s=''):
898 def magic_config(self,parameter_s=''):
941 """Show IPython's internal configuration."""
899 """Show IPython's internal configuration."""
942
900
943 page('Current configuration structure:\n'+
901 page('Current configuration structure:\n'+
944 pformat(self.shell.rc.dict()))
902 pformat(self.shell.rc.dict()))
945
903
946 def magic_logstart(self,parameter_s=''):
904 def magic_logstart(self,parameter_s=''):
947 """Start logging anywhere in a session.
905 """Start logging anywhere in a session.
948
906
949 %logstart [log_name [log_mode]]
907 %logstart [-o|-t] [log_name [log_mode]]
950
908
951 If no name is given, it defaults to a file named 'ipython.log' in your
909 If no name is given, it defaults to a file named 'ipython_log.py' in your
952 current directory, in 'rotate' mode (see below).
910 current directory, in 'rotate' mode (see below).
953
911
954 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
912 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
955 history up to that point and then continues logging.
913 history up to that point and then continues logging.
956
914
957 %logstart takes a second optional parameter: logging mode. This can be one
915 %logstart takes a second optional parameter: logging mode. This can be one
958 of (note that the modes are given unquoted):\\
916 of (note that the modes are given unquoted):\\
959 over: overwrite existing log.\\
960 backup: rename (if exists) to name~ and start name.\\
961 append: well, that says it.\\
917 append: well, that says it.\\
918 backup: rename (if exists) to name~ and start name.\\
919 global: single logfile in your home dir, appended to.\\
920 over : overwrite existing log.\\
962 rotate: create rotating logs name.1~, name.2~, etc.
921 rotate: create rotating logs name.1~, name.2~, etc.
963 """
964
922
965 #FIXME. This function should all be moved to the Logger class.
923 Options:
924
925 -o: log also IPython's output. In this mode, all commands which
926 generate an Out[NN] prompt are recorded to the logfile, right after
927 their corresponding input line. The output lines are always
928 prepended with a #[Out]# marker, so that the log remains valid
929 Python code.
930
931 -t: put timestamps before each input line logged (these are put in
932 comments)."""
966
933
967 valid_modes = qw('over backup append rotate')
934 opts,par = self.parse_options(parameter_s,'ot')
968 if self.LOG:
935 log_output = 'o' in opts
969 print 'Logging is already in place. Logfile:',self.LOG
936 timestamp = 't' in opts
970 return
971
937
972 par = parameter_s.strip()
938 rc = self.shell.rc
973 if not par:
939 logger = self.shell.logger
974 logname = self.LOGDEF
940
975 logmode = 'rotate' # use rotate for the auto-generated logs
941 # if no args are given, the defaults set in the logger constructor by
976 else:
942 # ipytohn remain valid
943 if par:
977 try:
944 try:
978 logname,logmode = par.split()
945 logfname,logmode = par.split()
979 except:
946 except:
980 try:
947 logfname = par
981 logname = par
948 logmode = 'backup'
982 logmode = 'backup'
949 else:
983 except:
950 logfname = logger.logfname
984 warn('Usage: %log [log_name [log_mode]]')
951 logmode = logger.logmode
985 return
952 # put logfname into rc struct as if it had been called on the command
986 if not logmode in valid_modes:
953 # line, so it ends up saved in the log header Save it in case we need
987 warn('Logging NOT activated.\n'
954 # to restore it...
988 'Usage: %log [log_name [log_mode]]\n'
955 old_logfile = rc.opts.get('logfile','')
989 'Valid modes: '+str(valid_modes))
956 if logfname:
990 return
957 logfname = os.path.expanduser(logfname)
991
958 rc.opts.logfile = logfname
992 # If we made it this far, I think we're ok:
959 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
993 print 'Activating auto-logging.'
994 print 'Current session state plus future input saved to:',logname
995 print 'Logging mode: ',logmode
996 # put logname into rc struct as if it had been called on the command line,
997 # so it ends up saved in the log header
998 # Save it in case we need to restore it...
999 old_logfile = self.shell.rc.opts.get('logfile','')
1000 logname = os.path.expanduser(logname)
1001 self.shell.rc.opts.logfile = logname
1002 self.LOGMODE = logmode # FIXME: this should be set through a function.
1003 try:
960 try:
1004 header = str(self.LOGHEAD)
961 started = logger.logstart(logfname,loghead,logmode,
1005 self.create_log(header,logname)
962 log_output,timestamp)
1006 self.logstart(header,logname)
1007 except:
963 except:
1008 self.LOG = '' # we are NOT logging, something went wrong
964 rc.opts.logfile = old_logfile
1009 self.shell.rc.opts.logfile = old_logfile
965 warn("Couldn't start log: %s" % sys.exc_info()[1])
1010 warn("Couldn't start log: "+str(sys.exc_info()[1]))
966 else:
1011 else: # log input history up to this point
967 # log input history up to this point, optionally interleaving
1012 self.logfile.write(self.shell.user_ns['_ih'][1:])
968 # output if requested
1013 self.logfile.flush()
969
1014
970 if timestamp:
971 # disable timestamping for the previous history, since we've
972 # lost those already (no time machine here).
973 logger.timestamp = False
974 if log_output:
975 log_write = logger.log_write
976 input_hist = self.shell.input_hist
977 output_hist = self.shell.output_hist
978 for n in range(1,len(input_hist)-1):
979 log_write(input_hist[n].rstrip())
980 if n in output_hist:
981 log_write(repr(output_hist[n]),'output')
982 else:
983 logger.log_write(self.shell.input_hist[1:])
984 if timestamp:
985 # re-enable timestamping
986 logger.timestamp = True
987
988 print ('Activating auto-logging. '
989 'Current session state plus future input saved.')
990 logger.logstate()
991
1015 def magic_logoff(self,parameter_s=''):
992 def magic_logoff(self,parameter_s=''):
1016 """Temporarily stop logging.
993 """Temporarily stop logging.
1017
994
1018 You must have previously started logging."""
995 You must have previously started logging."""
1019 self.switch_log(0)
996 self.shell.logger.switch_log(0)
1020
997
1021 def magic_logon(self,parameter_s=''):
998 def magic_logon(self,parameter_s=''):
1022 """Restart logging.
999 """Restart logging.
1023
1000
1024 This function is for restarting logging which you've temporarily
1001 This function is for restarting logging which you've temporarily
1025 stopped with %logoff. For starting logging for the first time, you
1002 stopped with %logoff. For starting logging for the first time, you
1026 must use the %logstart function, which allows you to specify an
1003 must use the %logstart function, which allows you to specify an
1027 optional log filename."""
1004 optional log filename."""
1028
1005
1029 self.switch_log(1)
1006 self.shell.logger.switch_log(1)
1030
1007
1031 def magic_logstate(self,parameter_s=''):
1008 def magic_logstate(self,parameter_s=''):
1032 """Print the status of the logging system."""
1009 """Print the status of the logging system."""
1033
1010
1034 self.logstate()
1011 self.shell.logger.logstate()
1035
1012
1036 def magic_pdb(self, parameter_s=''):
1013 def magic_pdb(self, parameter_s=''):
1037 """Control the calling of the pdb interactive debugger.
1014 """Control the calling of the pdb interactive debugger.
1038
1015
1039 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1016 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1040 argument it works as a toggle.
1017 argument it works as a toggle.
1041
1018
1042 When an exception is triggered, IPython can optionally call the
1019 When an exception is triggered, IPython can optionally call the
1043 interactive pdb debugger after the traceback printout. %pdb toggles
1020 interactive pdb debugger after the traceback printout. %pdb toggles
1044 this feature on and off."""
1021 this feature on and off."""
1045
1022
1046 par = parameter_s.strip().lower()
1023 par = parameter_s.strip().lower()
1047
1024
1048 if par:
1025 if par:
1049 try:
1026 try:
1050 pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1027 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1051 except KeyError:
1028 except KeyError:
1052 print 'Incorrect argument. Use on/1, off/0, or nothing for a toggle.'
1029 print ('Incorrect argument. Use on/1, off/0, '
1030 'or nothing for a toggle.')
1053 return
1031 return
1054 else:
1055 self.shell.InteractiveTB.call_pdb = pdb
1056 else:
1032 else:
1033 # toggle
1057 new_pdb = not self.shell.InteractiveTB.call_pdb
1034 new_pdb = not self.shell.InteractiveTB.call_pdb
1058 self.shell.InteractiveTB.call_pdb = new_pdb
1059 if self.shell.isthreaded:
1060 try:
1061 self.sys_excepthook.call_pdb = new_pdb
1062 except:
1063 warn('Failed to activate pdb for threaded exception handler')
1064
1065 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1066
1067
1035
1036 # set on the shell
1037 self.shell.call_pdb = new_pdb
1038 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1068
1039
1069 def magic_prun(self, parameter_s ='',user_mode=1,
1040 def magic_prun(self, parameter_s ='',user_mode=1,
1070 opts=None,arg_lst=None,prog_ns=None):
1041 opts=None,arg_lst=None,prog_ns=None):
1071
1042
1072 """Run a statement through the python code profiler.
1043 """Run a statement through the python code profiler.
1073
1044
1074 Usage:\\
1045 Usage:\\
1075 %prun [options] statement
1046 %prun [options] statement
1076
1047
1077 The given statement (which doesn't require quote marks) is run via the
1048 The given statement (which doesn't require quote marks) is run via the
1078 python profiler in a manner similar to the profile.run() function.
1049 python profiler in a manner similar to the profile.run() function.
1079 Namespaces are internally managed to work correctly; profile.run
1050 Namespaces are internally managed to work correctly; profile.run
1080 cannot be used in IPython because it makes certain assumptions about
1051 cannot be used in IPython because it makes certain assumptions about
1081 namespaces which do not hold under IPython.
1052 namespaces which do not hold under IPython.
1082
1053
1083 Options:
1054 Options:
1084
1055
1085 -l <limit>: you can place restrictions on what or how much of the
1056 -l <limit>: you can place restrictions on what or how much of the
1086 profile gets printed. The limit value can be:
1057 profile gets printed. The limit value can be:
1087
1058
1088 * A string: only information for function names containing this string
1059 * A string: only information for function names containing this string
1089 is printed.
1060 is printed.
1090
1061
1091 * An integer: only these many lines are printed.
1062 * An integer: only these many lines are printed.
1092
1063
1093 * A float (between 0 and 1): this fraction of the report is printed
1064 * A float (between 0 and 1): this fraction of the report is printed
1094 (for example, use a limit of 0.4 to see the topmost 40% only).
1065 (for example, use a limit of 0.4 to see the topmost 40% only).
1095
1066
1096 You can combine several limits with repeated use of the option. For
1067 You can combine several limits with repeated use of the option. For
1097 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1068 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1098 information about class constructors.
1069 information about class constructors.
1099
1070
1100 -r: return the pstats.Stats object generated by the profiling. This
1071 -r: return the pstats.Stats object generated by the profiling. This
1101 object has all the information about the profile in it, and you can
1072 object has all the information about the profile in it, and you can
1102 later use it for further analysis or in other functions.
1073 later use it for further analysis or in other functions.
1103
1074
1104 Since magic functions have a particular form of calling which prevents
1075 Since magic functions have a particular form of calling which prevents
1105 you from writing something like:\\
1076 you from writing something like:\\
1106 In [1]: p = %prun -r print 4 # invalid!\\
1077 In [1]: p = %prun -r print 4 # invalid!\\
1107 you must instead use IPython's automatic variables to assign this:\\
1078 you must instead use IPython's automatic variables to assign this:\\
1108 In [1]: %prun -r print 4 \\
1079 In [1]: %prun -r print 4 \\
1109 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1080 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1110 In [2]: stats = _
1081 In [2]: stats = _
1111
1082
1112 If you really need to assign this value via an explicit function call,
1083 If you really need to assign this value via an explicit function call,
1113 you can always tap directly into the true name of the magic function
1084 you can always tap directly into the true name of the magic function
1114 by using the ipmagic function (which IPython automatically adds to the
1085 by using the ipmagic function (which IPython automatically adds to the
1115 builtins):\\
1086 builtins):\\
1116 In [3]: stats = ipmagic('prun','-r print 4')
1087 In [3]: stats = ipmagic('prun','-r print 4')
1117
1088
1118 You can type ipmagic? for more details on ipmagic.
1089 You can type ipmagic? for more details on ipmagic.
1119
1090
1120 -s <key>: sort profile by given key. You can provide more than one key
1091 -s <key>: sort profile by given key. You can provide more than one key
1121 by using the option several times: '-s key1 -s key2 -s key3...'. The
1092 by using the option several times: '-s key1 -s key2 -s key3...'. The
1122 default sorting key is 'time'.
1093 default sorting key is 'time'.
1123
1094
1124 The following is copied verbatim from the profile documentation
1095 The following is copied verbatim from the profile documentation
1125 referenced below:
1096 referenced below:
1126
1097
1127 When more than one key is provided, additional keys are used as
1098 When more than one key is provided, additional keys are used as
1128 secondary criteria when the there is equality in all keys selected
1099 secondary criteria when the there is equality in all keys selected
1129 before them.
1100 before them.
1130
1101
1131 Abbreviations can be used for any key names, as long as the
1102 Abbreviations can be used for any key names, as long as the
1132 abbreviation is unambiguous. The following are the keys currently
1103 abbreviation is unambiguous. The following are the keys currently
1133 defined:
1104 defined:
1134
1105
1135 Valid Arg Meaning\\
1106 Valid Arg Meaning\\
1136 "calls" call count\\
1107 "calls" call count\\
1137 "cumulative" cumulative time\\
1108 "cumulative" cumulative time\\
1138 "file" file name\\
1109 "file" file name\\
1139 "module" file name\\
1110 "module" file name\\
1140 "pcalls" primitive call count\\
1111 "pcalls" primitive call count\\
1141 "line" line number\\
1112 "line" line number\\
1142 "name" function name\\
1113 "name" function name\\
1143 "nfl" name/file/line\\
1114 "nfl" name/file/line\\
1144 "stdname" standard name\\
1115 "stdname" standard name\\
1145 "time" internal time
1116 "time" internal time
1146
1117
1147 Note that all sorts on statistics are in descending order (placing
1118 Note that all sorts on statistics are in descending order (placing
1148 most time consuming items first), where as name, file, and line number
1119 most time consuming items first), where as name, file, and line number
1149 searches are in ascending order (i.e., alphabetical). The subtle
1120 searches are in ascending order (i.e., alphabetical). The subtle
1150 distinction between "nfl" and "stdname" is that the standard name is a
1121 distinction between "nfl" and "stdname" is that the standard name is a
1151 sort of the name as printed, which means that the embedded line
1122 sort of the name as printed, which means that the embedded line
1152 numbers get compared in an odd way. For example, lines 3, 20, and 40
1123 numbers get compared in an odd way. For example, lines 3, 20, and 40
1153 would (if the file names were the same) appear in the string order
1124 would (if the file names were the same) appear in the string order
1154 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1125 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1155 line numbers. In fact, sort_stats("nfl") is the same as
1126 line numbers. In fact, sort_stats("nfl") is the same as
1156 sort_stats("name", "file", "line").
1127 sort_stats("name", "file", "line").
1157
1128
1158 -T <filename>: save profile results as shown on screen to a text
1129 -T <filename>: save profile results as shown on screen to a text
1159 file. The profile is still shown on screen.
1130 file. The profile is still shown on screen.
1160
1131
1161 -D <filename>: save (via dump_stats) profile statistics to given
1132 -D <filename>: save (via dump_stats) profile statistics to given
1162 filename. This data is in a format understod by the pstats module, and
1133 filename. This data is in a format understod by the pstats module, and
1163 is generated by a call to the dump_stats() method of profile
1134 is generated by a call to the dump_stats() method of profile
1164 objects. The profile is still shown on screen.
1135 objects. The profile is still shown on screen.
1165
1136
1166 If you want to run complete programs under the profiler's control, use
1137 If you want to run complete programs under the profiler's control, use
1167 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1138 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1168 contains profiler specific options as described here.
1139 contains profiler specific options as described here.
1169
1140
1170 You can read the complete documentation for the profile module with:\\
1141 You can read the complete documentation for the profile module with:\\
1171 In [1]: import profile; profile.help() """
1142 In [1]: import profile; profile.help() """
1172
1143
1173 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1144 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1174 # protect user quote marks
1145 # protect user quote marks
1175 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1146 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1176
1147
1177 if user_mode: # regular user call
1148 if user_mode: # regular user call
1178 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1149 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1179 list_all=1)
1150 list_all=1)
1180 namespace = self.shell.user_ns
1151 namespace = self.shell.user_ns
1181 else: # called to run a program by %run -p
1152 else: # called to run a program by %run -p
1182 try:
1153 try:
1183 filename = get_py_filename(arg_lst[0])
1154 filename = get_py_filename(arg_lst[0])
1184 except IOError,msg:
1155 except IOError,msg:
1185 error(msg)
1156 error(msg)
1186 return
1157 return
1187
1158
1188 arg_str = 'execfile(filename,prog_ns)'
1159 arg_str = 'execfile(filename,prog_ns)'
1189 namespace = locals()
1160 namespace = locals()
1190
1161
1191 opts.merge(opts_def)
1162 opts.merge(opts_def)
1192
1163
1193 prof = profile.Profile()
1164 prof = profile.Profile()
1194 try:
1165 try:
1195 prof = prof.runctx(arg_str,namespace,namespace)
1166 prof = prof.runctx(arg_str,namespace,namespace)
1196 sys_exit = ''
1167 sys_exit = ''
1197 except SystemExit:
1168 except SystemExit:
1198 sys_exit = """*** SystemExit exception caught in code being profiled."""
1169 sys_exit = """*** SystemExit exception caught in code being profiled."""
1199
1170
1200 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1171 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1201
1172
1202 lims = opts.l
1173 lims = opts.l
1203 if lims:
1174 if lims:
1204 lims = [] # rebuild lims with ints/floats/strings
1175 lims = [] # rebuild lims with ints/floats/strings
1205 for lim in opts.l:
1176 for lim in opts.l:
1206 try:
1177 try:
1207 lims.append(int(lim))
1178 lims.append(int(lim))
1208 except ValueError:
1179 except ValueError:
1209 try:
1180 try:
1210 lims.append(float(lim))
1181 lims.append(float(lim))
1211 except ValueError:
1182 except ValueError:
1212 lims.append(lim)
1183 lims.append(lim)
1213
1184
1214 # trap output
1185 # trap output
1215 sys_stdout = sys.stdout
1186 sys_stdout = sys.stdout
1216 stdout_trap = StringIO()
1187 stdout_trap = StringIO()
1217 try:
1188 try:
1218 sys.stdout = stdout_trap
1189 sys.stdout = stdout_trap
1219 stats.print_stats(*lims)
1190 stats.print_stats(*lims)
1220 finally:
1191 finally:
1221 sys.stdout = sys_stdout
1192 sys.stdout = sys_stdout
1222 output = stdout_trap.getvalue()
1193 output = stdout_trap.getvalue()
1223 output = output.rstrip()
1194 output = output.rstrip()
1224
1195
1225 page(output,screen_lines=self.shell.rc.screen_length)
1196 page(output,screen_lines=self.shell.rc.screen_length)
1226 print sys_exit,
1197 print sys_exit,
1227
1198
1228 dump_file = opts.D[0]
1199 dump_file = opts.D[0]
1229 text_file = opts.T[0]
1200 text_file = opts.T[0]
1230 if dump_file:
1201 if dump_file:
1231 prof.dump_stats(dump_file)
1202 prof.dump_stats(dump_file)
1232 print '\n*** Profile stats marshalled to file',\
1203 print '\n*** Profile stats marshalled to file',\
1233 `dump_file`+'.',sys_exit
1204 `dump_file`+'.',sys_exit
1234 if text_file:
1205 if text_file:
1235 file(text_file,'w').write(output)
1206 file(text_file,'w').write(output)
1236 print '\n*** Profile printout saved to text file',\
1207 print '\n*** Profile printout saved to text file',\
1237 `text_file`+'.',sys_exit
1208 `text_file`+'.',sys_exit
1238
1209
1239 if opts.has_key('r'):
1210 if opts.has_key('r'):
1240 return stats
1211 return stats
1241 else:
1212 else:
1242 return None
1213 return None
1243
1214
1244 def magic_run(self, parameter_s ='',runner=None):
1215 def magic_run(self, parameter_s ='',runner=None):
1245 """Run the named file inside IPython as a program.
1216 """Run the named file inside IPython as a program.
1246
1217
1247 Usage:\\
1218 Usage:\\
1248 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1219 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1249
1220
1250 Parameters after the filename are passed as command-line arguments to
1221 Parameters after the filename are passed as command-line arguments to
1251 the program (put in sys.argv). Then, control returns to IPython's
1222 the program (put in sys.argv). Then, control returns to IPython's
1252 prompt.
1223 prompt.
1253
1224
1254 This is similar to running at a system prompt:\\
1225 This is similar to running at a system prompt:\\
1255 $ python file args\\
1226 $ python file args\\
1256 but with the advantage of giving you IPython's tracebacks, and of
1227 but with the advantage of giving you IPython's tracebacks, and of
1257 loading all variables into your interactive namespace for further use
1228 loading all variables into your interactive namespace for further use
1258 (unless -p is used, see below).
1229 (unless -p is used, see below).
1259
1230
1260 The file is executed in a namespace initially consisting only of
1231 The file is executed in a namespace initially consisting only of
1261 __name__=='__main__' and sys.argv constructed as indicated. It thus
1232 __name__=='__main__' and sys.argv constructed as indicated. It thus
1262 sees its environment as if it were being run as a stand-alone
1233 sees its environment as if it were being run as a stand-alone
1263 program. But after execution, the IPython interactive namespace gets
1234 program. But after execution, the IPython interactive namespace gets
1264 updated with all variables defined in the program (except for __name__
1235 updated with all variables defined in the program (except for __name__
1265 and sys.argv). This allows for very convenient loading of code for
1236 and sys.argv). This allows for very convenient loading of code for
1266 interactive work, while giving each program a 'clean sheet' to run in.
1237 interactive work, while giving each program a 'clean sheet' to run in.
1267
1238
1268 Options:
1239 Options:
1269
1240
1270 -n: __name__ is NOT set to '__main__', but to the running file's name
1241 -n: __name__ is NOT set to '__main__', but to the running file's name
1271 without extension (as python does under import). This allows running
1242 without extension (as python does under import). This allows running
1272 scripts and reloading the definitions in them without calling code
1243 scripts and reloading the definitions in them without calling code
1273 protected by an ' if __name__ == "__main__" ' clause.
1244 protected by an ' if __name__ == "__main__" ' clause.
1274
1245
1275 -i: run the file in IPython's namespace instead of an empty one. This
1246 -i: run the file in IPython's namespace instead of an empty one. This
1276 is useful if you are experimenting with code written in a text editor
1247 is useful if you are experimenting with code written in a text editor
1277 which depends on variables defined interactively.
1248 which depends on variables defined interactively.
1278
1249
1279 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1250 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1280 being run. This is particularly useful if IPython is being used to
1251 being run. This is particularly useful if IPython is being used to
1281 run unittests, which always exit with a sys.exit() call. In such
1252 run unittests, which always exit with a sys.exit() call. In such
1282 cases you are interested in the output of the test results, not in
1253 cases you are interested in the output of the test results, not in
1283 seeing a traceback of the unittest module.
1254 seeing a traceback of the unittest module.
1284
1255
1285 -t: print timing information at the end of the run. IPython will give
1256 -t: print timing information at the end of the run. IPython will give
1286 you an estimated CPU time consumption for your script, which under
1257 you an estimated CPU time consumption for your script, which under
1287 Unix uses the resource module to avoid the wraparound problems of
1258 Unix uses the resource module to avoid the wraparound problems of
1288 time.clock(). Under Unix, an estimate of time spent on system tasks
1259 time.clock(). Under Unix, an estimate of time spent on system tasks
1289 is also given (for Windows platforms this is reported as 0.0).
1260 is also given (for Windows platforms this is reported as 0.0).
1290
1261
1291 If -t is given, an additional -N<N> option can be given, where <N>
1262 If -t is given, an additional -N<N> option can be given, where <N>
1292 must be an integer indicating how many times you want the script to
1263 must be an integer indicating how many times you want the script to
1293 run. The final timing report will include total and per run results.
1264 run. The final timing report will include total and per run results.
1294
1265
1295 For example (testing the script uniq_stable.py):
1266 For example (testing the script uniq_stable.py):
1296
1267
1297 In [1]: run -t uniq_stable
1268 In [1]: run -t uniq_stable
1298
1269
1299 IPython CPU timings (estimated):\\
1270 IPython CPU timings (estimated):\\
1300 User : 0.19597 s.\\
1271 User : 0.19597 s.\\
1301 System: 0.0 s.\\
1272 System: 0.0 s.\\
1302
1273
1303 In [2]: run -t -N5 uniq_stable
1274 In [2]: run -t -N5 uniq_stable
1304
1275
1305 IPython CPU timings (estimated):\\
1276 IPython CPU timings (estimated):\\
1306 Total runs performed: 5\\
1277 Total runs performed: 5\\
1307 Times : Total Per run\\
1278 Times : Total Per run\\
1308 User : 0.910862 s, 0.1821724 s.\\
1279 User : 0.910862 s, 0.1821724 s.\\
1309 System: 0.0 s, 0.0 s.
1280 System: 0.0 s, 0.0 s.
1310
1281
1311 -d: run your program under the control of pdb, the Python debugger.
1282 -d: run your program under the control of pdb, the Python debugger.
1312 This allows you to execute your program step by step, watch variables,
1283 This allows you to execute your program step by step, watch variables,
1313 etc. Internally, what IPython does is similar to calling:
1284 etc. Internally, what IPython does is similar to calling:
1314
1285
1315 pdb.run('execfile("YOURFILENAME")')
1286 pdb.run('execfile("YOURFILENAME")')
1316
1287
1317 with a breakpoint set on line 1 of your file. You can change the line
1288 with a breakpoint set on line 1 of your file. You can change the line
1318 number for this automatic breakpoint to be <N> by using the -bN option
1289 number for this automatic breakpoint to be <N> by using the -bN option
1319 (where N must be an integer). For example:
1290 (where N must be an integer). For example:
1320
1291
1321 %run -d -b40 myscript
1292 %run -d -b40 myscript
1322
1293
1323 will set the first breakpoint at line 40 in myscript.py. Note that
1294 will set the first breakpoint at line 40 in myscript.py. Note that
1324 the first breakpoint must be set on a line which actually does
1295 the first breakpoint must be set on a line which actually does
1325 something (not a comment or docstring) for it to stop execution.
1296 something (not a comment or docstring) for it to stop execution.
1326
1297
1327 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1298 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1328 first enter 'c' (without qoutes) to start execution up to the first
1299 first enter 'c' (without qoutes) to start execution up to the first
1329 breakpoint.
1300 breakpoint.
1330
1301
1331 Entering 'help' gives information about the use of the debugger. You
1302 Entering 'help' gives information about the use of the debugger. You
1332 can easily see pdb's full documentation with "import pdb;pdb.help()"
1303 can easily see pdb's full documentation with "import pdb;pdb.help()"
1333 at a prompt.
1304 at a prompt.
1334
1305
1335 -p: run program under the control of the Python profiler module (which
1306 -p: run program under the control of the Python profiler module (which
1336 prints a detailed report of execution times, function calls, etc).
1307 prints a detailed report of execution times, function calls, etc).
1337
1308
1338 You can pass other options after -p which affect the behavior of the
1309 You can pass other options after -p which affect the behavior of the
1339 profiler itself. See the docs for %prun for details.
1310 profiler itself. See the docs for %prun for details.
1340
1311
1341 In this mode, the program's variables do NOT propagate back to the
1312 In this mode, the program's variables do NOT propagate back to the
1342 IPython interactive namespace (because they remain in the namespace
1313 IPython interactive namespace (because they remain in the namespace
1343 where the profiler executes them).
1314 where the profiler executes them).
1344
1315
1345 Internally this triggers a call to %prun, see its documentation for
1316 Internally this triggers a call to %prun, see its documentation for
1346 details on the options available specifically for profiling."""
1317 details on the options available specifically for profiling."""
1347
1318
1348 # get arguments and set sys.argv for program to be run.
1319 # get arguments and set sys.argv for program to be run.
1349 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1320 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1350 mode='list',list_all=1)
1321 mode='list',list_all=1)
1351
1322
1352 try:
1323 try:
1353 filename = get_py_filename(arg_lst[0])
1324 filename = get_py_filename(arg_lst[0])
1354 except IndexError:
1325 except IndexError:
1355 warn('you must provide at least a filename.')
1326 warn('you must provide at least a filename.')
1356 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1327 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1357 return
1328 return
1358 except IOError,msg:
1329 except IOError,msg:
1359 error(msg)
1330 error(msg)
1360 return
1331 return
1361
1332
1362 # Control the response to exit() calls made by the script being run
1333 # Control the response to exit() calls made by the script being run
1363 exit_ignore = opts.has_key('e')
1334 exit_ignore = opts.has_key('e')
1364
1335
1365 # Make sure that the running script gets a proper sys.argv as if it
1336 # Make sure that the running script gets a proper sys.argv as if it
1366 # were run from a system shell.
1337 # were run from a system shell.
1367 save_argv = sys.argv # save it for later restoring
1338 save_argv = sys.argv # save it for later restoring
1368 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1339 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1369
1340
1370 if opts.has_key('i'):
1341 if opts.has_key('i'):
1371 prog_ns = self.shell.user_ns
1342 prog_ns = self.shell.user_ns
1372 __name__save = self.shell.user_ns['__name__']
1343 __name__save = self.shell.user_ns['__name__']
1373 prog_ns['__name__'] = '__main__'
1344 prog_ns['__name__'] = '__main__'
1374 else:
1345 else:
1375 if opts.has_key('n'):
1346 if opts.has_key('n'):
1376 name = os.path.splitext(os.path.basename(filename))[0]
1347 name = os.path.splitext(os.path.basename(filename))[0]
1377 else:
1348 else:
1378 name = '__main__'
1349 name = '__main__'
1379 prog_ns = {'__name__':name}
1350 prog_ns = {'__name__':name}
1380
1351
1381 # pickle fix. See iplib for an explanation
1352 # pickle fix. See iplib for an explanation
1382 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1353 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1383
1354
1384 stats = None
1355 stats = None
1385 try:
1356 try:
1386 if opts.has_key('p'):
1357 if opts.has_key('p'):
1387 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1358 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1388 else:
1359 else:
1389 if opts.has_key('d'):
1360 if opts.has_key('d'):
1390 deb = Debugger.Pdb(self.shell.rc.colors)
1361 deb = Debugger.Pdb(self.shell.rc.colors)
1391 # reset Breakpoint state, which is moronically kept
1362 # reset Breakpoint state, which is moronically kept
1392 # in a class
1363 # in a class
1393 bdb.Breakpoint.next = 1
1364 bdb.Breakpoint.next = 1
1394 bdb.Breakpoint.bplist = {}
1365 bdb.Breakpoint.bplist = {}
1395 bdb.Breakpoint.bpbynumber = [None]
1366 bdb.Breakpoint.bpbynumber = [None]
1396 # Set an initial breakpoint to stop execution
1367 # Set an initial breakpoint to stop execution
1397 maxtries = 10
1368 maxtries = 10
1398 bp = int(opts.get('b',[1])[0])
1369 bp = int(opts.get('b',[1])[0])
1399 checkline = deb.checkline(filename,bp)
1370 checkline = deb.checkline(filename,bp)
1400 if not checkline:
1371 if not checkline:
1401 for bp in range(bp+1,bp+maxtries+1):
1372 for bp in range(bp+1,bp+maxtries+1):
1402 if deb.checkline(filename,bp):
1373 if deb.checkline(filename,bp):
1403 break
1374 break
1404 else:
1375 else:
1405 msg = ("\nI failed to find a valid line to set "
1376 msg = ("\nI failed to find a valid line to set "
1406 "a breakpoint\n"
1377 "a breakpoint\n"
1407 "after trying up to line: %s.\n"
1378 "after trying up to line: %s.\n"
1408 "Please set a valid breakpoint manually "
1379 "Please set a valid breakpoint manually "
1409 "with the -b option." % bp)
1380 "with the -b option." % bp)
1410 error(msg)
1381 error(msg)
1411 return
1382 return
1412 # if we find a good linenumber, set the breakpoint
1383 # if we find a good linenumber, set the breakpoint
1413 deb.do_break('%s:%s' % (filename,bp))
1384 deb.do_break('%s:%s' % (filename,bp))
1414 # Start file run
1385 # Start file run
1415 print "NOTE: Enter 'c' at the",
1386 print "NOTE: Enter 'c' at the",
1416 print "ipdb> prompt to start your script."
1387 print "ipdb> prompt to start your script."
1417 try:
1388 try:
1418 deb.run('execfile("%s")' % filename,prog_ns)
1389 deb.run('execfile("%s")' % filename,prog_ns)
1419 except:
1390 except:
1420 etype, value, tb = sys.exc_info()
1391 etype, value, tb = sys.exc_info()
1421 # Skip three frames in the traceback: the %run one,
1392 # Skip three frames in the traceback: the %run one,
1422 # one inside bdb.py, and the command-line typed by the
1393 # one inside bdb.py, and the command-line typed by the
1423 # user (run by exec in pdb itself).
1394 # user (run by exec in pdb itself).
1424 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1395 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1425 else:
1396 else:
1426 if runner is None:
1397 if runner is None:
1427 runner = self.shell.safe_execfile
1398 runner = self.shell.safe_execfile
1428 if opts.has_key('t'):
1399 if opts.has_key('t'):
1429 try:
1400 try:
1430 nruns = int(opts['N'][0])
1401 nruns = int(opts['N'][0])
1431 if nruns < 1:
1402 if nruns < 1:
1432 error('Number of runs must be >=1')
1403 error('Number of runs must be >=1')
1433 return
1404 return
1434 except (KeyError):
1405 except (KeyError):
1435 nruns = 1
1406 nruns = 1
1436 if nruns == 1:
1407 if nruns == 1:
1437 t0 = clock2()
1408 t0 = clock2()
1438 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1409 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1439 t1 = clock2()
1410 t1 = clock2()
1440 t_usr = t1[0]-t0[0]
1411 t_usr = t1[0]-t0[0]
1441 t_sys = t1[1]-t1[1]
1412 t_sys = t1[1]-t1[1]
1442 print "\nIPython CPU timings (estimated):"
1413 print "\nIPython CPU timings (estimated):"
1443 print " User : %10s s." % t_usr
1414 print " User : %10s s." % t_usr
1444 print " System: %10s s." % t_sys
1415 print " System: %10s s." % t_sys
1445 else:
1416 else:
1446 runs = range(nruns)
1417 runs = range(nruns)
1447 t0 = clock2()
1418 t0 = clock2()
1448 for nr in runs:
1419 for nr in runs:
1449 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1420 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1450 t1 = clock2()
1421 t1 = clock2()
1451 t_usr = t1[0]-t0[0]
1422 t_usr = t1[0]-t0[0]
1452 t_sys = t1[1]-t1[1]
1423 t_sys = t1[1]-t1[1]
1453 print "\nIPython CPU timings (estimated):"
1424 print "\nIPython CPU timings (estimated):"
1454 print "Total runs performed:",nruns
1425 print "Total runs performed:",nruns
1455 print " Times : %10s %10s" % ('Total','Per run')
1426 print " Times : %10s %10s" % ('Total','Per run')
1456 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1427 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1457 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1428 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1458
1429
1459 else:
1430 else:
1460 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1431 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1461 if opts.has_key('i'):
1432 if opts.has_key('i'):
1462 self.shell.user_ns['__name__'] = __name__save
1433 self.shell.user_ns['__name__'] = __name__save
1463 else:
1434 else:
1464 # update IPython interactive namespace
1435 # update IPython interactive namespace
1465 del prog_ns['__name__']
1436 del prog_ns['__name__']
1466 self.shell.user_ns.update(prog_ns)
1437 self.shell.user_ns.update(prog_ns)
1467 finally:
1438 finally:
1468 sys.argv = save_argv
1439 sys.argv = save_argv
1469 return stats
1440 return stats
1470
1441
1471 def magic_runlog(self, parameter_s =''):
1442 def magic_runlog(self, parameter_s =''):
1472 """Run files as logs.
1443 """Run files as logs.
1473
1444
1474 Usage:\\
1445 Usage:\\
1475 %runlog file1 file2 ...
1446 %runlog file1 file2 ...
1476
1447
1477 Run the named files (treating them as log files) in sequence inside
1448 Run the named files (treating them as log files) in sequence inside
1478 the interpreter, and return to the prompt. This is much slower than
1449 the interpreter, and return to the prompt. This is much slower than
1479 %run because each line is executed in a try/except block, but it
1450 %run because each line is executed in a try/except block, but it
1480 allows running files with syntax errors in them.
1451 allows running files with syntax errors in them.
1481
1452
1482 Normally IPython will guess when a file is one of its own logfiles, so
1453 Normally IPython will guess when a file is one of its own logfiles, so
1483 you can typically use %run even for logs. This shorthand allows you to
1454 you can typically use %run even for logs. This shorthand allows you to
1484 force any file to be treated as a log file."""
1455 force any file to be treated as a log file."""
1485
1456
1486 for f in parameter_s.split():
1457 for f in parameter_s.split():
1487 self.shell.safe_execfile(f,self.shell.user_ns,
1458 self.shell.safe_execfile(f,self.shell.user_ns,
1488 self.shell.user_ns,islog=1)
1459 self.shell.user_ns,islog=1)
1489
1460
1490 def magic_time(self,parameter_s = ''):
1461 def magic_time(self,parameter_s = ''):
1491 """Time execution of a Python statement or expression.
1462 """Time execution of a Python statement or expression.
1492
1463
1493 The CPU and wall clock times are printed, and the value of the
1464 The CPU and wall clock times are printed, and the value of the
1494 expression (if any) is returned. Note that under Win32, system time
1465 expression (if any) is returned. Note that under Win32, system time
1495 is always reported as 0, since it can not be measured.
1466 is always reported as 0, since it can not be measured.
1496
1467
1497 This function provides very basic timing functionality. In Python
1468 This function provides very basic timing functionality. In Python
1498 2.3, the timeit module offers more control and sophistication, but for
1469 2.3, the timeit module offers more control and sophistication, but for
1499 now IPython supports Python 2.2, so we can not rely on timeit being
1470 now IPython supports Python 2.2, so we can not rely on timeit being
1500 present.
1471 present.
1501
1472
1502 Some examples:
1473 Some examples:
1503
1474
1504 In [1]: time 2**128
1475 In [1]: time 2**128
1505 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1476 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1506 Wall time: 0.00
1477 Wall time: 0.00
1507 Out[1]: 340282366920938463463374607431768211456L
1478 Out[1]: 340282366920938463463374607431768211456L
1508
1479
1509 In [2]: n = 1000000
1480 In [2]: n = 1000000
1510
1481
1511 In [3]: time sum(range(n))
1482 In [3]: time sum(range(n))
1512 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1483 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1513 Wall time: 1.37
1484 Wall time: 1.37
1514 Out[3]: 499999500000L
1485 Out[3]: 499999500000L
1515
1486
1516 In [4]: time print 'hello world'
1487 In [4]: time print 'hello world'
1517 hello world
1488 hello world
1518 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1489 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1519 Wall time: 0.00
1490 Wall time: 0.00
1520 """
1491 """
1521
1492
1522 # fail immediately if the given expression can't be compiled
1493 # fail immediately if the given expression can't be compiled
1523 try:
1494 try:
1524 mode = 'eval'
1495 mode = 'eval'
1525 code = compile(parameter_s,'<timed eval>',mode)
1496 code = compile(parameter_s,'<timed eval>',mode)
1526 except SyntaxError:
1497 except SyntaxError:
1527 mode = 'exec'
1498 mode = 'exec'
1528 code = compile(parameter_s,'<timed exec>',mode)
1499 code = compile(parameter_s,'<timed exec>',mode)
1529 # skew measurement as little as possible
1500 # skew measurement as little as possible
1530 glob = self.shell.user_ns
1501 glob = self.shell.user_ns
1531 clk = clock2
1502 clk = clock2
1532 wtime = time.time
1503 wtime = time.time
1533 # time execution
1504 # time execution
1534 wall_st = wtime()
1505 wall_st = wtime()
1535 if mode=='eval':
1506 if mode=='eval':
1536 st = clk()
1507 st = clk()
1537 out = eval(code,glob)
1508 out = eval(code,glob)
1538 end = clk()
1509 end = clk()
1539 else:
1510 else:
1540 st = clk()
1511 st = clk()
1541 exec code in glob
1512 exec code in glob
1542 end = clk()
1513 end = clk()
1543 out = None
1514 out = None
1544 wall_end = wtime()
1515 wall_end = wtime()
1545 # Compute actual times and report
1516 # Compute actual times and report
1546 wall_time = wall_end-wall_st
1517 wall_time = wall_end-wall_st
1547 cpu_user = end[0]-st[0]
1518 cpu_user = end[0]-st[0]
1548 cpu_sys = end[1]-st[1]
1519 cpu_sys = end[1]-st[1]
1549 cpu_tot = cpu_user+cpu_sys
1520 cpu_tot = cpu_user+cpu_sys
1550 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1521 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1551 (cpu_user,cpu_sys,cpu_tot)
1522 (cpu_user,cpu_sys,cpu_tot)
1552 print "Wall time: %.2f" % wall_time
1523 print "Wall time: %.2f" % wall_time
1553 return out
1524 return out
1554
1525
1555 def magic_macro(self,parameter_s = ''):
1526 def magic_macro(self,parameter_s = ''):
1556 """Define a set of input lines as a macro for future re-execution.
1527 """Define a set of input lines as a macro for future re-execution.
1557
1528
1558 Usage:\\
1529 Usage:\\
1559 %macro name n1:n2 n3:n4 ... n5 .. n6 ...
1530 %macro name n1:n2 n3:n4 ... n5 .. n6 ...
1560
1531
1561 This will define a global variable called `name` which is a string
1532 This will define a global variable called `name` which is a string
1562 made of joining the slices and lines you specify (n1,n2,... numbers
1533 made of joining the slices and lines you specify (n1,n2,... numbers
1563 above) from your input history into a single string. This variable
1534 above) from your input history into a single string. This variable
1564 acts like an automatic function which re-executes those lines as if
1535 acts like an automatic function which re-executes those lines as if
1565 you had typed them. You just type 'name' at the prompt and the code
1536 you had typed them. You just type 'name' at the prompt and the code
1566 executes.
1537 executes.
1567
1538
1568 Note that the slices use the standard Python slicing notation (5:8
1539 Note that the slices use the standard Python slicing notation (5:8
1569 means include lines numbered 5,6,7).
1540 means include lines numbered 5,6,7).
1570
1541
1571 For example, if your history contains (%hist prints it):
1542 For example, if your history contains (%hist prints it):
1572
1543
1573 44: x=1\\
1544 44: x=1\\
1574 45: y=3\\
1545 45: y=3\\
1575 46: z=x+y\\
1546 46: z=x+y\\
1576 47: print x\\
1547 47: print x\\
1577 48: a=5\\
1548 48: a=5\\
1578 49: print 'x',x,'y',y\\
1549 49: print 'x',x,'y',y\\
1579
1550
1580 you can create a macro with lines 44 through 47 (included) and line 49
1551 you can create a macro with lines 44 through 47 (included) and line 49
1581 called my_macro with:
1552 called my_macro with:
1582
1553
1583 In [51]: %macro my_macro 44:48 49
1554 In [51]: %macro my_macro 44:48 49
1584
1555
1585 Now, typing `my_macro` (without quotes) will re-execute all this code
1556 Now, typing `my_macro` (without quotes) will re-execute all this code
1586 in one pass.
1557 in one pass.
1587
1558
1588 You don't need to give the line-numbers in order, and any given line
1559 You don't need to give the line-numbers in order, and any given line
1589 number can appear multiple times. You can assemble macros with any
1560 number can appear multiple times. You can assemble macros with any
1590 lines from your input history in any order.
1561 lines from your input history in any order.
1591
1562
1592 The macro is a simple object which holds its value in an attribute,
1563 The macro is a simple object which holds its value in an attribute,
1593 but IPython's display system checks for macros and executes them as
1564 but IPython's display system checks for macros and executes them as
1594 code instead of printing them when you type their name.
1565 code instead of printing them when you type their name.
1595
1566
1596 You can view a macro's contents by explicitly printing it with:
1567 You can view a macro's contents by explicitly printing it with:
1597
1568
1598 'print macro_name'.
1569 'print macro_name'.
1599
1570
1600 For one-off cases which DON'T contain magic function calls in them you
1571 For one-off cases which DON'T contain magic function calls in them you
1601 can obtain similar results by explicitly executing slices from your
1572 can obtain similar results by explicitly executing slices from your
1602 input history with:
1573 input history with:
1603
1574
1604 In [60]: exec In[44:48]+In[49]"""
1575 In [60]: exec In[44:48]+In[49]"""
1605
1576
1606 args = parameter_s.split()
1577 args = parameter_s.split()
1607 name,ranges = args[0], args[1:]
1578 name,ranges = args[0], args[1:]
1608 #print 'rng',ranges # dbg
1579 #print 'rng',ranges # dbg
1609 cmds = self.extract_input_slices(ranges)
1580 lines = self.extract_input_slices(ranges)
1610 macro = Macro(cmds)
1581 macro = Macro(lines)
1611 self.shell.user_ns.update({name:macro})
1582 self.shell.user_ns.update({name:macro})
1612 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1583 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1613 print 'Macro contents:'
1584 print 'Macro contents:'
1614 print str(macro).rstrip(),
1585 print macro
1615
1586
1616 def magic_save(self,parameter_s = ''):
1587 def magic_save(self,parameter_s = ''):
1617 """Save a set of lines to a given filename.
1588 """Save a set of lines to a given filename.
1618
1589
1619 Usage:\\
1590 Usage:\\
1620 %save filename n1:n2 n3:n4 ... n5 .. n6 ...
1591 %save filename n1:n2 n3:n4 ... n5 .. n6 ...
1621
1592
1622 This function uses the same syntax as %macro for line extraction, but
1593 This function uses the same syntax as %macro for line extraction, but
1623 instead of creating a macro it saves the resulting string to the
1594 instead of creating a macro it saves the resulting string to the
1624 filename you specify.
1595 filename you specify.
1625
1596
1626 It adds a '.py' extension to the file if you don't do so yourself, and
1597 It adds a '.py' extension to the file if you don't do so yourself, and
1627 it asks for confirmation before overwriting existing files."""
1598 it asks for confirmation before overwriting existing files."""
1628
1599
1629 args = parameter_s.split()
1600 args = parameter_s.split()
1630 fname,ranges = args[0], args[1:]
1601 fname,ranges = args[0], args[1:]
1631 if not fname.endswith('.py'):
1602 if not fname.endswith('.py'):
1632 fname += '.py'
1603 fname += '.py'
1633 if os.path.isfile(fname):
1604 if os.path.isfile(fname):
1634 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1605 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1635 if ans.lower() not in ['y','yes']:
1606 if ans.lower() not in ['y','yes']:
1636 print 'Operation cancelled.'
1607 print 'Operation cancelled.'
1637 return
1608 return
1638 cmds = ''.join(self.extract_input_slices(ranges))
1609 cmds = ''.join(self.extract_input_slices(ranges))
1639 f = file(fname,'w')
1610 f = file(fname,'w')
1640 f.write(cmds)
1611 f.write(cmds)
1641 f.close()
1612 f.close()
1642 print 'The following commands were written to file `%s`:' % fname
1613 print 'The following commands were written to file `%s`:' % fname
1643 print cmds
1614 print cmds
1644
1615
1645 def magic_ed(self,parameter_s = ''):
1616 def magic_ed(self,parameter_s = ''):
1646 """Alias to %edit."""
1617 """Alias to %edit."""
1647 return self.magic_edit(parameter_s)
1618 return self.magic_edit(parameter_s)
1648
1619
1649 def magic_edit(self,parameter_s = '',last_call=['','']):
1620 def magic_edit(self,parameter_s = '',last_call=['','']):
1650 """Bring up an editor and execute the resulting code.
1621 """Bring up an editor and execute the resulting code.
1651
1622
1652 Usage:
1623 Usage:
1653 %edit [options] [args]
1624 %edit [options] [args]
1654
1625
1655 %edit runs IPython's editor hook. The default version of this hook is
1626 %edit runs IPython's editor hook. The default version of this hook is
1656 set to call the __IPYTHON__.rc.editor command. This is read from your
1627 set to call the __IPYTHON__.rc.editor command. This is read from your
1657 environment variable $EDITOR. If this isn't found, it will default to
1628 environment variable $EDITOR. If this isn't found, it will default to
1658 vi under Linux/Unix and to notepad under Windows. See the end of this
1629 vi under Linux/Unix and to notepad under Windows. See the end of this
1659 docstring for how to change the editor hook.
1630 docstring for how to change the editor hook.
1660
1631
1661 You can also set the value of this editor via the command line option
1632 You can also set the value of this editor via the command line option
1662 '-editor' or in your ipythonrc file. This is useful if you wish to use
1633 '-editor' or in your ipythonrc file. This is useful if you wish to use
1663 specifically for IPython an editor different from your typical default
1634 specifically for IPython an editor different from your typical default
1664 (and for Windows users who typically don't set environment variables).
1635 (and for Windows users who typically don't set environment variables).
1665
1636
1666 This command allows you to conveniently edit multi-line code right in
1637 This command allows you to conveniently edit multi-line code right in
1667 your IPython session.
1638 your IPython session.
1668
1639
1669 If called without arguments, %edit opens up an empty editor with a
1640 If called without arguments, %edit opens up an empty editor with a
1670 temporary file and will execute the contents of this file when you
1641 temporary file and will execute the contents of this file when you
1671 close it (don't forget to save it!).
1642 close it (don't forget to save it!).
1672
1643
1673 Options:
1644 Options:
1674
1645
1675 -p: this will call the editor with the same data as the previous time
1646 -p: this will call the editor with the same data as the previous time
1676 it was used, regardless of how long ago (in your current session) it
1647 it was used, regardless of how long ago (in your current session) it
1677 was.
1648 was.
1678
1649
1679 -x: do not execute the edited code immediately upon exit. This is
1650 -x: do not execute the edited code immediately upon exit. This is
1680 mainly useful if you are editing programs which need to be called with
1651 mainly useful if you are editing programs which need to be called with
1681 command line arguments, which you can then do using %run.
1652 command line arguments, which you can then do using %run.
1682
1653
1683 Arguments:
1654 Arguments:
1684
1655
1685 If arguments are given, the following possibilites exist:
1656 If arguments are given, the following possibilites exist:
1686
1657
1687 - The arguments are numbers or pairs of colon-separated numbers (like
1658 - The arguments are numbers or pairs of colon-separated numbers (like
1688 1 4:8 9). These are interpreted as lines of previous input to be
1659 1 4:8 9). These are interpreted as lines of previous input to be
1689 loaded into the editor. The syntax is the same of the %macro command.
1660 loaded into the editor. The syntax is the same of the %macro command.
1690
1661
1691 - If the argument doesn't start with a number, it is evaluated as a
1662 - If the argument doesn't start with a number, it is evaluated as a
1692 variable and its contents loaded into the editor. You can thus edit
1663 variable and its contents loaded into the editor. You can thus edit
1693 any string which contains python code (including the result of
1664 any string which contains python code (including the result of
1694 previous edits).
1665 previous edits).
1695
1666
1696 - If the argument is the name of an object (other than a string),
1667 - If the argument is the name of an object (other than a string),
1697 IPython will try to locate the file where it was defined and open the
1668 IPython will try to locate the file where it was defined and open the
1698 editor at the point where it is defined. You can use `%edit function`
1669 editor at the point where it is defined. You can use `%edit function`
1699 to load an editor exactly at the point where 'function' is defined,
1670 to load an editor exactly at the point where 'function' is defined,
1700 edit it and have the file be executed automatically.
1671 edit it and have the file be executed automatically.
1701
1672
1702 Note: opening at an exact line is only supported under Unix, and some
1673 Note: opening at an exact line is only supported under Unix, and some
1703 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1674 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1704 '+NUMBER' parameter necessary for this feature. Good editors like
1675 '+NUMBER' parameter necessary for this feature. Good editors like
1705 (X)Emacs, vi, jed, pico and joe all do.
1676 (X)Emacs, vi, jed, pico and joe all do.
1706
1677
1707 - If the argument is not found as a variable, IPython will look for a
1678 - If the argument is not found as a variable, IPython will look for a
1708 file with that name (adding .py if necessary) and load it into the
1679 file with that name (adding .py if necessary) and load it into the
1709 editor. It will execute its contents with execfile() when you exit,
1680 editor. It will execute its contents with execfile() when you exit,
1710 loading any code in the file into your interactive namespace.
1681 loading any code in the file into your interactive namespace.
1711
1682
1712 After executing your code, %edit will return as output the code you
1683 After executing your code, %edit will return as output the code you
1713 typed in the editor (except when it was an existing file). This way
1684 typed in the editor (except when it was an existing file). This way
1714 you can reload the code in further invocations of %edit as a variable,
1685 you can reload the code in further invocations of %edit as a variable,
1715 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1686 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1716 the output.
1687 the output.
1717
1688
1718 Note that %edit is also available through the alias %ed.
1689 Note that %edit is also available through the alias %ed.
1719
1690
1720 This is an example of creating a simple function inside the editor and
1691 This is an example of creating a simple function inside the editor and
1721 then modifying it. First, start up the editor:
1692 then modifying it. First, start up the editor:
1722
1693
1723 In [1]: ed\\
1694 In [1]: ed\\
1724 Editing... done. Executing edited code...\\
1695 Editing... done. Executing edited code...\\
1725 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1696 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1726
1697
1727 We can then call the function foo():
1698 We can then call the function foo():
1728
1699
1729 In [2]: foo()\\
1700 In [2]: foo()\\
1730 foo() was defined in an editing session
1701 foo() was defined in an editing session
1731
1702
1732 Now we edit foo. IPython automatically loads the editor with the
1703 Now we edit foo. IPython automatically loads the editor with the
1733 (temporary) file where foo() was previously defined:
1704 (temporary) file where foo() was previously defined:
1734
1705
1735 In [3]: ed foo\\
1706 In [3]: ed foo\\
1736 Editing... done. Executing edited code...
1707 Editing... done. Executing edited code...
1737
1708
1738 And if we call foo() again we get the modified version:
1709 And if we call foo() again we get the modified version:
1739
1710
1740 In [4]: foo()\\
1711 In [4]: foo()\\
1741 foo() has now been changed!
1712 foo() has now been changed!
1742
1713
1743 Here is an example of how to edit a code snippet successive
1714 Here is an example of how to edit a code snippet successive
1744 times. First we call the editor:
1715 times. First we call the editor:
1745
1716
1746 In [8]: ed\\
1717 In [8]: ed\\
1747 Editing... done. Executing edited code...\\
1718 Editing... done. Executing edited code...\\
1748 hello\\
1719 hello\\
1749 Out[8]: "print 'hello'\\n"
1720 Out[8]: "print 'hello'\\n"
1750
1721
1751 Now we call it again with the previous output (stored in _):
1722 Now we call it again with the previous output (stored in _):
1752
1723
1753 In [9]: ed _\\
1724 In [9]: ed _\\
1754 Editing... done. Executing edited code...\\
1725 Editing... done. Executing edited code...\\
1755 hello world\\
1726 hello world\\
1756 Out[9]: "print 'hello world'\\n"
1727 Out[9]: "print 'hello world'\\n"
1757
1728
1758 Now we call it with the output #8 (stored in _8, also as Out[8]):
1729 Now we call it with the output #8 (stored in _8, also as Out[8]):
1759
1730
1760 In [10]: ed _8\\
1731 In [10]: ed _8\\
1761 Editing... done. Executing edited code...\\
1732 Editing... done. Executing edited code...\\
1762 hello again\\
1733 hello again\\
1763 Out[10]: "print 'hello again'\\n"
1734 Out[10]: "print 'hello again'\\n"
1764
1735
1765
1736
1766 Changing the default editor hook:
1737 Changing the default editor hook:
1767
1738
1768 If you wish to write your own editor hook, you can put it in a
1739 If you wish to write your own editor hook, you can put it in a
1769 configuration file which you load at startup time. The default hook
1740 configuration file which you load at startup time. The default hook
1770 is defined in the IPython.hooks module, and you can use that as a
1741 is defined in the IPython.hooks module, and you can use that as a
1771 starting example for further modifications. That file also has
1742 starting example for further modifications. That file also has
1772 general instructions on how to set a new hook for use once you've
1743 general instructions on how to set a new hook for use once you've
1773 defined it."""
1744 defined it."""
1774
1745
1775 # FIXME: This function has become a convoluted mess. It needs a
1746 # FIXME: This function has become a convoluted mess. It needs a
1776 # ground-up rewrite with clean, simple logic.
1747 # ground-up rewrite with clean, simple logic.
1777
1748
1778 def make_filename(arg):
1749 def make_filename(arg):
1779 "Make a filename from the given args"
1750 "Make a filename from the given args"
1780 try:
1751 try:
1781 filename = get_py_filename(arg)
1752 filename = get_py_filename(arg)
1782 except IOError:
1753 except IOError:
1783 if args.endswith('.py'):
1754 if args.endswith('.py'):
1784 filename = arg
1755 filename = arg
1785 else:
1756 else:
1786 filename = None
1757 filename = None
1787 return filename
1758 return filename
1788
1759
1789 # custom exceptions
1760 # custom exceptions
1790 class DataIsObject(Exception): pass
1761 class DataIsObject(Exception): pass
1791
1762
1792 opts,args = self.parse_options(parameter_s,'px')
1763 opts,args = self.parse_options(parameter_s,'px')
1793
1764
1794 # Default line number value
1765 # Default line number value
1795 lineno = None
1766 lineno = None
1796 if opts.has_key('p'):
1767 if opts.has_key('p'):
1797 args = '_%s' % last_call[0]
1768 args = '_%s' % last_call[0]
1798 if not self.shell.user_ns.has_key(args):
1769 if not self.shell.user_ns.has_key(args):
1799 args = last_call[1]
1770 args = last_call[1]
1800
1771
1801 # use last_call to remember the state of the previous call, but don't
1772 # use last_call to remember the state of the previous call, but don't
1802 # let it be clobbered by successive '-p' calls.
1773 # let it be clobbered by successive '-p' calls.
1803 try:
1774 try:
1804 last_call[0] = self.shell.outputcache.prompt_count
1775 last_call[0] = self.shell.outputcache.prompt_count
1805 if not opts.has_key('p'):
1776 if not opts.has_key('p'):
1806 last_call[1] = parameter_s
1777 last_call[1] = parameter_s
1807 except:
1778 except:
1808 pass
1779 pass
1809
1780
1810 # by default this is done with temp files, except when the given
1781 # by default this is done with temp files, except when the given
1811 # arg is a filename
1782 # arg is a filename
1812 use_temp = 1
1783 use_temp = 1
1813
1784
1814 if re.match(r'\d',args):
1785 if re.match(r'\d',args):
1815 # Mode where user specifies ranges of lines, like in %macro.
1786 # Mode where user specifies ranges of lines, like in %macro.
1816 # This means that you can't edit files whose names begin with
1787 # This means that you can't edit files whose names begin with
1817 # numbers this way. Tough.
1788 # numbers this way. Tough.
1818 ranges = args.split()
1789 ranges = args.split()
1819 data = ''.join(self.extract_input_slices(ranges))
1790 data = ''.join(self.extract_input_slices(ranges))
1820 elif args.endswith('.py'):
1791 elif args.endswith('.py'):
1821 filename = make_filename(args)
1792 filename = make_filename(args)
1822 data = ''
1793 data = ''
1823 use_temp = 0
1794 use_temp = 0
1824 elif args:
1795 elif args:
1825 try:
1796 try:
1826 # Load the parameter given as a variable. If not a string,
1797 # Load the parameter given as a variable. If not a string,
1827 # process it as an object instead (below)
1798 # process it as an object instead (below)
1828
1799
1829 #print '*** args',args,'type',type(args) # dbg
1800 #print '*** args',args,'type',type(args) # dbg
1830 data = eval(args,self.shell.user_ns)
1801 data = eval(args,self.shell.user_ns)
1831 if not type(data) in StringTypes:
1802 if not type(data) in StringTypes:
1832 raise DataIsObject
1803 raise DataIsObject
1833 except (NameError,SyntaxError):
1804 except (NameError,SyntaxError):
1834 # given argument is not a variable, try as a filename
1805 # given argument is not a variable, try as a filename
1835 filename = make_filename(args)
1806 filename = make_filename(args)
1836 if filename is None:
1807 if filename is None:
1837 warn("Argument given (%s) can't be found as a variable "
1808 warn("Argument given (%s) can't be found as a variable "
1838 "or as a filename." % args)
1809 "or as a filename." % args)
1839 return
1810 return
1840 data = ''
1811 data = ''
1841 use_temp = 0
1812 use_temp = 0
1842 except DataIsObject:
1813 except DataIsObject:
1843 # For objects, try to edit the file where they are defined
1814 # For objects, try to edit the file where they are defined
1844 try:
1815 try:
1845 filename = inspect.getabsfile(data)
1816 filename = inspect.getabsfile(data)
1846 datafile = 1
1817 datafile = 1
1847 except TypeError:
1818 except TypeError:
1848 filename = make_filename(args)
1819 filename = make_filename(args)
1849 datafile = 1
1820 datafile = 1
1850 warn('Could not find file where `%s` is defined.\n'
1821 warn('Could not find file where `%s` is defined.\n'
1851 'Opening a file named `%s`' % (args,filename))
1822 'Opening a file named `%s`' % (args,filename))
1852 # Now, make sure we can actually read the source (if it was in
1823 # Now, make sure we can actually read the source (if it was in
1853 # a temp file it's gone by now).
1824 # a temp file it's gone by now).
1854 if datafile:
1825 if datafile:
1855 try:
1826 try:
1856 lineno = inspect.getsourcelines(data)[1]
1827 lineno = inspect.getsourcelines(data)[1]
1857 except IOError:
1828 except IOError:
1858 filename = make_filename(args)
1829 filename = make_filename(args)
1859 if filename is None:
1830 if filename is None:
1860 warn('The file `%s` where `%s` was defined cannot '
1831 warn('The file `%s` where `%s` was defined cannot '
1861 'be read.' % (filename,data))
1832 'be read.' % (filename,data))
1862 return
1833 return
1863 use_temp = 0
1834 use_temp = 0
1864 else:
1835 else:
1865 data = ''
1836 data = ''
1866
1837
1867 if use_temp:
1838 if use_temp:
1868 filename = tempfile.mktemp('.py')
1839 filename = tempfile.mktemp('.py')
1869 self.shell.tempfiles.append(filename)
1840 self.shell.tempfiles.append(filename)
1870
1841
1871 if data and use_temp:
1842 if data and use_temp:
1872 tmp_file = open(filename,'w')
1843 tmp_file = open(filename,'w')
1873 tmp_file.write(data)
1844 tmp_file.write(data)
1874 tmp_file.close()
1845 tmp_file.close()
1875
1846
1876 # do actual editing here
1847 # do actual editing here
1877 print 'Editing...',
1848 print 'Editing...',
1878 sys.stdout.flush()
1849 sys.stdout.flush()
1879 self.shell.hooks.editor(filename,lineno)
1850 self.shell.hooks.editor(filename,lineno)
1880 if opts.has_key('x'): # -x prevents actual execution
1851 if opts.has_key('x'): # -x prevents actual execution
1881 print
1852 print
1882 else:
1853 else:
1883 print 'done. Executing edited code...'
1854 print 'done. Executing edited code...'
1884 try:
1855 try:
1885 self.shell.safe_execfile(filename,self.shell.user_ns)
1856 self.shell.safe_execfile(filename,self.shell.user_ns)
1886 except IOError,msg:
1857 except IOError,msg:
1887 if msg.filename == filename:
1858 if msg.filename == filename:
1888 warn('File not found. Did you forget to save?')
1859 warn('File not found. Did you forget to save?')
1889 return
1860 return
1890 else:
1861 else:
1891 self.shell.showtraceback()
1862 self.shell.showtraceback()
1892 except:
1863 except:
1893 self.shell.showtraceback()
1864 self.shell.showtraceback()
1894 if use_temp:
1865 if use_temp:
1895 contents = open(filename).read()
1866 contents = open(filename).read()
1896 return contents
1867 return contents
1897
1868
1898 def magic_xmode(self,parameter_s = ''):
1869 def magic_xmode(self,parameter_s = ''):
1899 """Switch modes for the exception handlers.
1870 """Switch modes for the exception handlers.
1900
1871
1901 Valid modes: Plain, Context and Verbose.
1872 Valid modes: Plain, Context and Verbose.
1902
1873
1903 If called without arguments, acts as a toggle."""
1874 If called without arguments, acts as a toggle."""
1904
1875
1905 def xmode_switch_err(name):
1876 def xmode_switch_err(name):
1906 warn('Error changing %s exception modes.\n%s' %
1877 warn('Error changing %s exception modes.\n%s' %
1907 (name,sys.exc_info()[1]))
1878 (name,sys.exc_info()[1]))
1908
1879
1880 shell = self.shell
1909 new_mode = parameter_s.strip().capitalize()
1881 new_mode = parameter_s.strip().capitalize()
1910 try:
1882 try:
1911 self.InteractiveTB.set_mode(mode=new_mode)
1883 shell.InteractiveTB.set_mode(mode=new_mode)
1912 print 'Exception reporting mode:',self.InteractiveTB.mode
1884 print 'Exception reporting mode:',shell.InteractiveTB.mode
1913 except:
1885 except:
1914 xmode_switch_err('user')
1886 xmode_switch_err('user')
1915
1887
1916 # threaded shells use a special handler in sys.excepthook
1888 # threaded shells use a special handler in sys.excepthook
1917 if self.isthreaded:
1889 if shell.isthreaded:
1918 try:
1890 try:
1919 self.shell.sys_excepthook.set_mode(mode=new_mode)
1891 shell.sys_excepthook.set_mode(mode=new_mode)
1920 except:
1892 except:
1921 xmode_switch_err('threaded')
1893 xmode_switch_err('threaded')
1922
1894
1923 def magic_colors(self,parameter_s = ''):
1895 def magic_colors(self,parameter_s = ''):
1924 """Switch color scheme for prompts, info system and exception handlers.
1896 """Switch color scheme for prompts, info system and exception handlers.
1925
1897
1926 Currently implemented schemes: NoColor, Linux, LightBG.
1898 Currently implemented schemes: NoColor, Linux, LightBG.
1927
1899
1928 Color scheme names are not case-sensitive."""
1900 Color scheme names are not case-sensitive."""
1929
1901
1930 def color_switch_err(name):
1902 def color_switch_err(name):
1931 warn('Error changing %s color schemes.\n%s' %
1903 warn('Error changing %s color schemes.\n%s' %
1932 (name,sys.exc_info()[1]))
1904 (name,sys.exc_info()[1]))
1933
1905
1934
1906
1935 new_scheme = parameter_s.strip()
1907 new_scheme = parameter_s.strip()
1936 if not new_scheme:
1908 if not new_scheme:
1937 print 'You must specify a color scheme.'
1909 print 'You must specify a color scheme.'
1938 return
1910 return
1939 # Under Windows, check for Gary Bishop's readline, which is necessary
1911 # Under Windows, check for Gary Bishop's readline, which is necessary
1940 # for ANSI coloring
1912 # for ANSI coloring
1941 if os.name in ['nt','dos']:
1913 if os.name in ['nt','dos']:
1942 try:
1914 try:
1943 import readline
1915 import readline
1944 except ImportError:
1916 except ImportError:
1945 has_readline = 0
1917 has_readline = 0
1946 else:
1918 else:
1947 try:
1919 try:
1948 readline.GetOutputFile()
1920 readline.GetOutputFile()
1949 except AttributeError:
1921 except AttributeError:
1950 has_readline = 0
1922 has_readline = 0
1951 else:
1923 else:
1952 has_readline = 1
1924 has_readline = 1
1953 if not has_readline:
1925 if not has_readline:
1954 msg = """\
1926 msg = """\
1955 Proper color support under MS Windows requires Gary Bishop's readline library.
1927 Proper color support under MS Windows requires Gary Bishop's readline library.
1956 You can find it at:
1928 You can find it at:
1957 http://sourceforge.net/projects/uncpythontools
1929 http://sourceforge.net/projects/uncpythontools
1958 Gary's readline needs the ctypes module, from:
1930 Gary's readline needs the ctypes module, from:
1959 http://starship.python.net/crew/theller/ctypes
1931 http://starship.python.net/crew/theller/ctypes
1960
1932
1961 Defaulting color scheme to 'NoColor'"""
1933 Defaulting color scheme to 'NoColor'"""
1962 new_scheme = 'NoColor'
1934 new_scheme = 'NoColor'
1963 warn(msg)
1935 warn(msg)
1936 # local shortcut
1937 shell = self.shell
1964
1938
1965 # Set prompt colors
1939 # Set prompt colors
1966 try:
1940 try:
1967 self.shell.outputcache.set_colors(new_scheme)
1941 shell.outputcache.set_colors(new_scheme)
1968 except:
1942 except:
1969 color_switch_err('prompt')
1943 color_switch_err('prompt')
1970 else:
1944 else:
1971 self.shell.rc.colors = \
1945 shell.rc.colors = \
1972 self.shell.outputcache.color_table.active_scheme_name
1946 shell.outputcache.color_table.active_scheme_name
1973 # Set exception colors
1947 # Set exception colors
1974 try:
1948 try:
1975 self.shell.InteractiveTB.set_colors(scheme = new_scheme)
1949 shell.InteractiveTB.set_colors(scheme = new_scheme)
1976 self.shell.SyntaxTB.set_colors(scheme = new_scheme)
1950 shell.SyntaxTB.set_colors(scheme = new_scheme)
1977 except:
1951 except:
1978 color_switch_err('exception')
1952 color_switch_err('exception')
1979
1953
1980 # threaded shells use a verbose traceback in sys.excepthook
1954 # threaded shells use a verbose traceback in sys.excepthook
1981 if self.isthreaded:
1955 if shell.isthreaded:
1982 try:
1956 try:
1983 self.shell.sys_excepthook.set_colors(scheme=new_scheme)
1957 shell.sys_excepthook.set_colors(scheme=new_scheme)
1984 except:
1958 except:
1985 color_switch_err('system exception handler')
1959 color_switch_err('system exception handler')
1986
1960
1987 # Set info (for 'object?') colors
1961 # Set info (for 'object?') colors
1988 if self.shell.rc.color_info:
1962 if shell.rc.color_info:
1989 try:
1963 try:
1990 self.shell.inspector.set_active_scheme(new_scheme)
1964 shell.inspector.set_active_scheme(new_scheme)
1991 except:
1965 except:
1992 color_switch_err('object inspector')
1966 color_switch_err('object inspector')
1993 else:
1967 else:
1994 self.shell.inspector.set_active_scheme('NoColor')
1968 shell.inspector.set_active_scheme('NoColor')
1995
1969
1996 def magic_color_info(self,parameter_s = ''):
1970 def magic_color_info(self,parameter_s = ''):
1997 """Toggle color_info.
1971 """Toggle color_info.
1998
1972
1999 The color_info configuration parameter controls whether colors are
1973 The color_info configuration parameter controls whether colors are
2000 used for displaying object details (by things like %psource, %pfile or
1974 used for displaying object details (by things like %psource, %pfile or
2001 the '?' system). This function toggles this value with each call.
1975 the '?' system). This function toggles this value with each call.
2002
1976
2003 Note that unless you have a fairly recent pager (less works better
1977 Note that unless you have a fairly recent pager (less works better
2004 than more) in your system, using colored object information displays
1978 than more) in your system, using colored object information displays
2005 will not work properly. Test it and see."""
1979 will not work properly. Test it and see."""
2006
1980
2007 self.shell.rc.color_info = 1 - self.shell.rc.color_info
1981 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2008 self.magic_colors(self.shell.rc.colors)
1982 self.magic_colors(self.shell.rc.colors)
2009 print 'Object introspection functions have now coloring:',
1983 print 'Object introspection functions have now coloring:',
2010 print ['OFF','ON'][self.shell.rc.color_info]
1984 print ['OFF','ON'][self.shell.rc.color_info]
2011
1985
2012 def magic_Pprint(self, parameter_s=''):
1986 def magic_Pprint(self, parameter_s=''):
2013 """Toggle pretty printing on/off."""
1987 """Toggle pretty printing on/off."""
2014
1988
2015 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
1989 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
2016 print 'Pretty printing has been turned', \
1990 print 'Pretty printing has been turned', \
2017 ['OFF','ON'][self.shell.outputcache.Pprint]
1991 ['OFF','ON'][self.shell.outputcache.Pprint]
2018
1992
2019 def magic_exit(self, parameter_s=''):
1993 def magic_exit(self, parameter_s=''):
2020 """Exit IPython, confirming if configured to do so.
1994 """Exit IPython, confirming if configured to do so.
2021
1995
2022 You can configure whether IPython asks for confirmation upon exit by
1996 You can configure whether IPython asks for confirmation upon exit by
2023 setting the confirm_exit flag in the ipythonrc file."""
1997 setting the confirm_exit flag in the ipythonrc file."""
2024
1998
2025 self.shell.exit()
1999 self.shell.exit()
2026
2000
2027 def magic_quit(self, parameter_s=''):
2001 def magic_quit(self, parameter_s=''):
2028 """Exit IPython, confirming if configured to do so (like %exit)"""
2002 """Exit IPython, confirming if configured to do so (like %exit)"""
2029
2003
2030 self.shell.exit()
2004 self.shell.exit()
2031
2005
2032 def magic_Exit(self, parameter_s=''):
2006 def magic_Exit(self, parameter_s=''):
2033 """Exit IPython without confirmation."""
2007 """Exit IPython without confirmation."""
2034
2008
2035 self.shell.exit_now = True
2009 self.shell.exit_now = True
2036
2010
2037 def magic_Quit(self, parameter_s=''):
2011 def magic_Quit(self, parameter_s=''):
2038 """Exit IPython without confirmation (like %Exit)."""
2012 """Exit IPython without confirmation (like %Exit)."""
2039
2013
2040 self.shell.exit_now = True
2014 self.shell.exit_now = True
2041
2015
2042 #......................................................................
2016 #......................................................................
2043 # Functions to implement unix shell-type things
2017 # Functions to implement unix shell-type things
2044
2018
2045 def magic_alias(self, parameter_s = ''):
2019 def magic_alias(self, parameter_s = ''):
2046 """Define an alias for a system command.
2020 """Define an alias for a system command.
2047
2021
2048 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2022 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2049
2023
2050 Then, typing 'alias_name params' will execute the system command 'cmd
2024 Then, typing 'alias_name params' will execute the system command 'cmd
2051 params' (from your underlying operating system).
2025 params' (from your underlying operating system).
2052
2026
2053 Aliases have lower precedence than magic functions and Python normal
2027 Aliases have lower precedence than magic functions and Python normal
2054 variables, so if 'foo' is both a Python variable and an alias, the
2028 variables, so if 'foo' is both a Python variable and an alias, the
2055 alias can not be executed until 'del foo' removes the Python variable.
2029 alias can not be executed until 'del foo' removes the Python variable.
2056
2030
2057 You can use the %l specifier in an alias definition to represent the
2031 You can use the %l specifier in an alias definition to represent the
2058 whole line when the alias is called. For example:
2032 whole line when the alias is called. For example:
2059
2033
2060 In [2]: alias all echo "Input in brackets: <%l>"\\
2034 In [2]: alias all echo "Input in brackets: <%l>"\\
2061 In [3]: all hello world\\
2035 In [3]: all hello world\\
2062 Input in brackets: <hello world>
2036 Input in brackets: <hello world>
2063
2037
2064 You can also define aliases with parameters using %s specifiers (one
2038 You can also define aliases with parameters using %s specifiers (one
2065 per parameter):
2039 per parameter):
2066
2040
2067 In [1]: alias parts echo first %s second %s\\
2041 In [1]: alias parts echo first %s second %s\\
2068 In [2]: %parts A B\\
2042 In [2]: %parts A B\\
2069 first A second B\\
2043 first A second B\\
2070 In [3]: %parts A\\
2044 In [3]: %parts A\\
2071 Incorrect number of arguments: 2 expected.\\
2045 Incorrect number of arguments: 2 expected.\\
2072 parts is an alias to: 'echo first %s second %s'
2046 parts is an alias to: 'echo first %s second %s'
2073
2047
2074 Note that %l and %s are mutually exclusive. You can only use one or
2048 Note that %l and %s are mutually exclusive. You can only use one or
2075 the other in your aliases.
2049 the other in your aliases.
2076
2050
2077 Aliases expand Python variables just like system calls using ! or !!
2051 Aliases expand Python variables just like system calls using ! or !!
2078 do: all expressions prefixed with '$' get expanded. For details of
2052 do: all expressions prefixed with '$' get expanded. For details of
2079 the semantic rules, see PEP-215:
2053 the semantic rules, see PEP-215:
2080 http://www.python.org/peps/pep-0215.html. This is the library used by
2054 http://www.python.org/peps/pep-0215.html. This is the library used by
2081 IPython for variable expansion. If you want to access a true shell
2055 IPython for variable expansion. If you want to access a true shell
2082 variable, an extra $ is necessary to prevent its expansion by IPython:
2056 variable, an extra $ is necessary to prevent its expansion by IPython:
2083
2057
2084 In [6]: alias show echo\\
2058 In [6]: alias show echo\\
2085 In [7]: PATH='A Python string'\\
2059 In [7]: PATH='A Python string'\\
2086 In [8]: show $PATH\\
2060 In [8]: show $PATH\\
2087 A Python string\\
2061 A Python string\\
2088 In [9]: show $$PATH\\
2062 In [9]: show $$PATH\\
2089 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2063 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2090
2064
2091 You can use the alias facility to acess all of $PATH. See the %rehash
2065 You can use the alias facility to acess all of $PATH. See the %rehash
2092 and %rehashx functions, which automatically create aliases for the
2066 and %rehashx functions, which automatically create aliases for the
2093 contents of your $PATH.
2067 contents of your $PATH.
2094
2068
2095 If called with no parameters, %alias prints the current alias table."""
2069 If called with no parameters, %alias prints the current alias table."""
2096
2070
2097 par = parameter_s.strip()
2071 par = parameter_s.strip()
2098 if not par:
2072 if not par:
2099 if self.shell.rc.automagic:
2073 if self.shell.rc.automagic:
2100 prechar = ''
2074 prechar = ''
2101 else:
2075 else:
2102 prechar = self.shell.ESC_MAGIC
2076 prechar = self.shell.ESC_MAGIC
2103 print 'Alias\t\tSystem Command\n'+'-'*30
2077 print 'Alias\t\tSystem Command\n'+'-'*30
2104 atab = self.shell.alias_table
2078 atab = self.shell.alias_table
2105 aliases = atab.keys()
2079 aliases = atab.keys()
2106 aliases.sort()
2080 aliases.sort()
2107 for alias in aliases:
2081 for alias in aliases:
2108 print prechar+alias+'\t\t'+atab[alias][1]
2082 print prechar+alias+'\t\t'+atab[alias][1]
2109 print '-'*30+'\nTotal number of aliases:',len(aliases)
2083 print '-'*30+'\nTotal number of aliases:',len(aliases)
2110 return
2084 return
2111 try:
2085 try:
2112 alias,cmd = par.split(None,1)
2086 alias,cmd = par.split(None,1)
2113 except:
2087 except:
2114 print OInspect.getdoc(self.magic_alias)
2088 print OInspect.getdoc(self.magic_alias)
2115 else:
2089 else:
2116 nargs = cmd.count('%s')
2090 nargs = cmd.count('%s')
2117 if nargs>0 and cmd.find('%l')>=0:
2091 if nargs>0 and cmd.find('%l')>=0:
2118 error('The %s and %l specifiers are mutually exclusive '
2092 error('The %s and %l specifiers are mutually exclusive '
2119 'in alias definitions.')
2093 'in alias definitions.')
2120 else: # all looks OK
2094 else: # all looks OK
2121 self.shell.alias_table[alias] = (nargs,cmd)
2095 self.shell.alias_table[alias] = (nargs,cmd)
2122 self.shell.alias_table_validate(verbose=1)
2096 self.shell.alias_table_validate(verbose=1)
2123 # end magic_alias
2097 # end magic_alias
2124
2098
2125 def magic_unalias(self, parameter_s = ''):
2099 def magic_unalias(self, parameter_s = ''):
2126 """Remove an alias"""
2100 """Remove an alias"""
2127
2101
2128 aname = parameter_s.strip()
2102 aname = parameter_s.strip()
2129 if aname in self.shell.alias_table:
2103 if aname in self.shell.alias_table:
2130 del self.shell.alias_table[aname]
2104 del self.shell.alias_table[aname]
2131
2105
2132 def magic_rehash(self, parameter_s = ''):
2106 def magic_rehash(self, parameter_s = ''):
2133 """Update the alias table with all entries in $PATH.
2107 """Update the alias table with all entries in $PATH.
2134
2108
2135 This version does no checks on execute permissions or whether the
2109 This version does no checks on execute permissions or whether the
2136 contents of $PATH are truly files (instead of directories or something
2110 contents of $PATH are truly files (instead of directories or something
2137 else). For such a safer (but slower) version, use %rehashx."""
2111 else). For such a safer (but slower) version, use %rehashx."""
2138
2112
2139 # This function (and rehashx) manipulate the alias_table directly
2113 # This function (and rehashx) manipulate the alias_table directly
2140 # rather than calling magic_alias, for speed reasons. A rehash on a
2114 # rather than calling magic_alias, for speed reasons. A rehash on a
2141 # typical Linux box involves several thousand entries, so efficiency
2115 # typical Linux box involves several thousand entries, so efficiency
2142 # here is a top concern.
2116 # here is a top concern.
2143
2117
2144 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2118 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2145 alias_table = self.shell.alias_table
2119 alias_table = self.shell.alias_table
2146 for pdir in path:
2120 for pdir in path:
2147 for ff in os.listdir(pdir):
2121 for ff in os.listdir(pdir):
2148 # each entry in the alias table must be (N,name), where
2122 # each entry in the alias table must be (N,name), where
2149 # N is the number of positional arguments of the alias.
2123 # N is the number of positional arguments of the alias.
2150 alias_table[ff] = (0,ff)
2124 alias_table[ff] = (0,ff)
2151 # Make sure the alias table doesn't contain keywords or builtins
2125 # Make sure the alias table doesn't contain keywords or builtins
2152 self.shell.alias_table_validate()
2126 self.shell.alias_table_validate()
2153 # Call again init_auto_alias() so we get 'rm -i' and other modified
2127 # Call again init_auto_alias() so we get 'rm -i' and other modified
2154 # aliases since %rehash will probably clobber them
2128 # aliases since %rehash will probably clobber them
2155 self.shell.init_auto_alias()
2129 self.shell.init_auto_alias()
2156
2130
2157 def magic_rehashx(self, parameter_s = ''):
2131 def magic_rehashx(self, parameter_s = ''):
2158 """Update the alias table with all executable files in $PATH.
2132 """Update the alias table with all executable files in $PATH.
2159
2133
2160 This version explicitly checks that every entry in $PATH is a file
2134 This version explicitly checks that every entry in $PATH is a file
2161 with execute access (os.X_OK), so it is much slower than %rehash.
2135 with execute access (os.X_OK), so it is much slower than %rehash.
2162
2136
2163 Under Windows, it checks executability as a match agains a
2137 Under Windows, it checks executability as a match agains a
2164 '|'-separated string of extensions, stored in the IPython config
2138 '|'-separated string of extensions, stored in the IPython config
2165 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2139 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2166
2140
2167 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2141 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2168 alias_table = self.shell.alias_table
2142 alias_table = self.shell.alias_table
2169
2143
2170 if os.name == 'posix':
2144 if os.name == 'posix':
2171 isexec = lambda fname:os.path.isfile(fname) and \
2145 isexec = lambda fname:os.path.isfile(fname) and \
2172 os.access(fname,os.X_OK)
2146 os.access(fname,os.X_OK)
2173 else:
2147 else:
2174
2148
2175 try:
2149 try:
2176 winext = os.environ['pathext'].replace(';','|').replace('.','')
2150 winext = os.environ['pathext'].replace(';','|').replace('.','')
2177 except KeyError:
2151 except KeyError:
2178 winext = 'exe|com|bat'
2152 winext = 'exe|com|bat'
2179
2153
2180 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2154 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2181 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2155 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2182 savedir = os.getcwd()
2156 savedir = os.getcwd()
2183 try:
2157 try:
2184 # write the whole loop for posix/Windows so we don't have an if in
2158 # write the whole loop for posix/Windows so we don't have an if in
2185 # the innermost part
2159 # the innermost part
2186 if os.name == 'posix':
2160 if os.name == 'posix':
2187 for pdir in path:
2161 for pdir in path:
2188 os.chdir(pdir)
2162 os.chdir(pdir)
2189 for ff in os.listdir(pdir):
2163 for ff in os.listdir(pdir):
2190 if isexec(ff):
2164 if isexec(ff):
2191 # each entry in the alias table must be (N,name),
2165 # each entry in the alias table must be (N,name),
2192 # where N is the number of positional arguments of the
2166 # where N is the number of positional arguments of the
2193 # alias.
2167 # alias.
2194 alias_table[ff] = (0,ff)
2168 alias_table[ff] = (0,ff)
2195 else:
2169 else:
2196 for pdir in path:
2170 for pdir in path:
2197 os.chdir(pdir)
2171 os.chdir(pdir)
2198 for ff in os.listdir(pdir):
2172 for ff in os.listdir(pdir):
2199 if isexec(ff):
2173 if isexec(ff):
2200 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2174 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2201 # Make sure the alias table doesn't contain keywords or builtins
2175 # Make sure the alias table doesn't contain keywords or builtins
2202 self.shell.alias_table_validate()
2176 self.shell.alias_table_validate()
2203 # Call again init_auto_alias() so we get 'rm -i' and other
2177 # Call again init_auto_alias() so we get 'rm -i' and other
2204 # modified aliases since %rehashx will probably clobber them
2178 # modified aliases since %rehashx will probably clobber them
2205 self.shell.init_auto_alias()
2179 self.shell.init_auto_alias()
2206 finally:
2180 finally:
2207 os.chdir(savedir)
2181 os.chdir(savedir)
2208
2182
2209 def magic_pwd(self, parameter_s = ''):
2183 def magic_pwd(self, parameter_s = ''):
2210 """Return the current working directory path."""
2184 """Return the current working directory path."""
2211 return os.getcwd()
2185 return os.getcwd()
2212
2186
2213 def magic_cd(self, parameter_s=''):
2187 def magic_cd(self, parameter_s=''):
2214 """Change the current working directory.
2188 """Change the current working directory.
2215
2189
2216 This command automatically maintains an internal list of directories
2190 This command automatically maintains an internal list of directories
2217 you visit during your IPython session, in the variable _dh. The
2191 you visit during your IPython session, in the variable _dh. The
2218 command %dhist shows this history nicely formatted.
2192 command %dhist shows this history nicely formatted.
2219
2193
2220 Usage:
2194 Usage:
2221
2195
2222 cd 'dir': changes to directory 'dir'.
2196 cd 'dir': changes to directory 'dir'.
2223
2197
2224 cd -: changes to the last visited directory.
2198 cd -: changes to the last visited directory.
2225
2199
2226 cd -<n>: changes to the n-th directory in the directory history.
2200 cd -<n>: changes to the n-th directory in the directory history.
2227
2201
2228 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2202 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2229 (note: cd <bookmark_name> is enough if there is no
2203 (note: cd <bookmark_name> is enough if there is no
2230 directory <bookmark_name>, but a bookmark with the name exists.)
2204 directory <bookmark_name>, but a bookmark with the name exists.)
2231
2205
2232 Options:
2206 Options:
2233
2207
2234 -q: quiet. Do not print the working directory after the cd command is
2208 -q: quiet. Do not print the working directory after the cd command is
2235 executed. By default IPython's cd command does print this directory,
2209 executed. By default IPython's cd command does print this directory,
2236 since the default prompts do not display path information.
2210 since the default prompts do not display path information.
2237
2211
2238 Note that !cd doesn't work for this purpose because the shell where
2212 Note that !cd doesn't work for this purpose because the shell where
2239 !command runs is immediately discarded after executing 'command'."""
2213 !command runs is immediately discarded after executing 'command'."""
2240
2214
2241 parameter_s = parameter_s.strip()
2215 parameter_s = parameter_s.strip()
2242 bkms = self.shell.persist.get("bookmarks",{})
2216 bkms = self.shell.persist.get("bookmarks",{})
2243
2217
2244 numcd = re.match(r'(-)(\d+)$',parameter_s)
2218 numcd = re.match(r'(-)(\d+)$',parameter_s)
2245 # jump in directory history by number
2219 # jump in directory history by number
2246 if numcd:
2220 if numcd:
2247 nn = int(numcd.group(2))
2221 nn = int(numcd.group(2))
2248 try:
2222 try:
2249 ps = self.shell.user_ns['_dh'][nn]
2223 ps = self.shell.user_ns['_dh'][nn]
2250 except IndexError:
2224 except IndexError:
2251 print 'The requested directory does not exist in history.'
2225 print 'The requested directory does not exist in history.'
2252 return
2226 return
2253 else:
2227 else:
2254 opts = {}
2228 opts = {}
2255 else:
2229 else:
2256 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2230 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2257 # jump to previous
2231 # jump to previous
2258 if ps == '-':
2232 if ps == '-':
2259 try:
2233 try:
2260 ps = self.shell.user_ns['_dh'][-2]
2234 ps = self.shell.user_ns['_dh'][-2]
2261 except IndexError:
2235 except IndexError:
2262 print 'No previous directory to change to.'
2236 print 'No previous directory to change to.'
2263 return
2237 return
2264 # jump to bookmark
2238 # jump to bookmark
2265 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2239 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2266 if bkms.has_key(ps):
2240 if bkms.has_key(ps):
2267 target = bkms[ps]
2241 target = bkms[ps]
2268 print '(bookmark:%s) -> %s' % (ps,target)
2242 print '(bookmark:%s) -> %s' % (ps,target)
2269 ps = target
2243 ps = target
2270 else:
2244 else:
2271 if bkms:
2245 if bkms:
2272 error("Bookmark '%s' not found. "
2246 error("Bookmark '%s' not found. "
2273 "Use '%bookmark -l' to see your bookmarks." % ps)
2247 "Use '%bookmark -l' to see your bookmarks." % ps)
2274 else:
2248 else:
2275 print "Bookmarks not set - use %bookmark <bookmarkname>"
2249 print "Bookmarks not set - use %bookmark <bookmarkname>"
2276 return
2250 return
2277
2251
2278 # at this point ps should point to the target dir
2252 # at this point ps should point to the target dir
2279 if ps:
2253 if ps:
2280 try:
2254 try:
2281 os.chdir(os.path.expanduser(ps))
2255 os.chdir(os.path.expanduser(ps))
2282 except OSError:
2256 except OSError:
2283 print sys.exc_info()[1]
2257 print sys.exc_info()[1]
2284 else:
2258 else:
2285 self.shell.user_ns['_dh'].append(os.getcwd())
2259 self.shell.user_ns['_dh'].append(os.getcwd())
2286 else:
2260 else:
2287 os.chdir(self.home_dir)
2261 os.chdir(self.shell.home_dir)
2288 self.shell.user_ns['_dh'].append(os.getcwd())
2262 self.shell.user_ns['_dh'].append(os.getcwd())
2289 if not 'q' in opts:
2263 if not 'q' in opts:
2290 print self.shell.user_ns['_dh'][-1]
2264 print self.shell.user_ns['_dh'][-1]
2291
2265
2292 def magic_dhist(self, parameter_s=''):
2266 def magic_dhist(self, parameter_s=''):
2293 """Print your history of visited directories.
2267 """Print your history of visited directories.
2294
2268
2295 %dhist -> print full history\\
2269 %dhist -> print full history\\
2296 %dhist n -> print last n entries only\\
2270 %dhist n -> print last n entries only\\
2297 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2271 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2298
2272
2299 This history is automatically maintained by the %cd command, and
2273 This history is automatically maintained by the %cd command, and
2300 always available as the global list variable _dh. You can use %cd -<n>
2274 always available as the global list variable _dh. You can use %cd -<n>
2301 to go to directory number <n>."""
2275 to go to directory number <n>."""
2302
2276
2303 dh = self.shell.user_ns['_dh']
2277 dh = self.shell.user_ns['_dh']
2304 if parameter_s:
2278 if parameter_s:
2305 try:
2279 try:
2306 args = map(int,parameter_s.split())
2280 args = map(int,parameter_s.split())
2307 except:
2281 except:
2308 self.arg_err(Magic.magic_dhist)
2282 self.arg_err(Magic.magic_dhist)
2309 return
2283 return
2310 if len(args) == 1:
2284 if len(args) == 1:
2311 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2285 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2312 elif len(args) == 2:
2286 elif len(args) == 2:
2313 ini,fin = args
2287 ini,fin = args
2314 else:
2288 else:
2315 self.arg_err(Magic.magic_dhist)
2289 self.arg_err(Magic.magic_dhist)
2316 return
2290 return
2317 else:
2291 else:
2318 ini,fin = 0,len(dh)
2292 ini,fin = 0,len(dh)
2319 nlprint(dh,
2293 nlprint(dh,
2320 header = 'Directory history (kept in _dh)',
2294 header = 'Directory history (kept in _dh)',
2321 start=ini,stop=fin)
2295 start=ini,stop=fin)
2322
2296
2323 def magic_env(self, parameter_s=''):
2297 def magic_env(self, parameter_s=''):
2324 """List environment variables."""
2298 """List environment variables."""
2325
2299
2326 # environ is an instance of UserDict
2327 return os.environ.data
2300 return os.environ.data
2328
2301
2329 def magic_pushd(self, parameter_s=''):
2302 def magic_pushd(self, parameter_s=''):
2330 """Place the current dir on stack and change directory.
2303 """Place the current dir on stack and change directory.
2331
2304
2332 Usage:\\
2305 Usage:\\
2333 %pushd ['dirname']
2306 %pushd ['dirname']
2334
2307
2335 %pushd with no arguments does a %pushd to your home directory.
2308 %pushd with no arguments does a %pushd to your home directory.
2336 """
2309 """
2337 if parameter_s == '': parameter_s = '~'
2310 if parameter_s == '': parameter_s = '~'
2338 if len(self.dir_stack)>0 and os.path.expanduser(parameter_s) != \
2311 dir_s = self.shell.dir_stack
2339 os.path.expanduser(self.dir_stack[0]):
2312 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2313 os.path.expanduser(self.shell.dir_stack[0]):
2340 try:
2314 try:
2341 self.magic_cd(parameter_s)
2315 self.magic_cd(parameter_s)
2342 self.dir_stack.insert(0,os.getcwd().replace(self.home_dir,'~'))
2316 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2343 self.magic_dirs()
2317 self.magic_dirs()
2344 except:
2318 except:
2345 print 'Invalid directory'
2319 print 'Invalid directory'
2346 else:
2320 else:
2347 print 'You are already there!'
2321 print 'You are already there!'
2348
2322
2349 def magic_popd(self, parameter_s=''):
2323 def magic_popd(self, parameter_s=''):
2350 """Change to directory popped off the top of the stack.
2324 """Change to directory popped off the top of the stack.
2351 """
2325 """
2352 if len (self.dir_stack) > 1:
2326 if len (self.shell.dir_stack) > 1:
2353 self.dir_stack.pop(0)
2327 self.shell.dir_stack.pop(0)
2354 self.magic_cd(self.dir_stack[0])
2328 self.magic_cd(self.shell.dir_stack[0])
2355 print self.dir_stack[0]
2329 print self.shell.dir_stack[0]
2356 else:
2330 else:
2357 print "You can't remove the starting directory from the stack:",\
2331 print "You can't remove the starting directory from the stack:",\
2358 self.dir_stack
2332 self.shell.dir_stack
2359
2333
2360 def magic_dirs(self, parameter_s=''):
2334 def magic_dirs(self, parameter_s=''):
2361 """Return the current directory stack."""
2335 """Return the current directory stack."""
2362
2336
2363 return self.dir_stack[:]
2337 return self.shell.dir_stack[:]
2364
2338
2365 def magic_sc(self, parameter_s=''):
2339 def magic_sc(self, parameter_s=''):
2366 """Shell capture - execute a shell command and capture its output.
2340 """Shell capture - execute a shell command and capture its output.
2367
2341
2368 %sc [options] varname=command
2342 %sc [options] varname=command
2369
2343
2370 IPython will run the given command using commands.getoutput(), and
2344 IPython will run the given command using commands.getoutput(), and
2371 will then update the user's interactive namespace with a variable
2345 will then update the user's interactive namespace with a variable
2372 called varname, containing the value of the call. Your command can
2346 called varname, containing the value of the call. Your command can
2373 contain shell wildcards, pipes, etc.
2347 contain shell wildcards, pipes, etc.
2374
2348
2375 The '=' sign in the syntax is mandatory, and the variable name you
2349 The '=' sign in the syntax is mandatory, and the variable name you
2376 supply must follow Python's standard conventions for valid names.
2350 supply must follow Python's standard conventions for valid names.
2377
2351
2378 Options:
2352 Options:
2379
2353
2380 -l: list output. Split the output on newlines into a list before
2354 -l: list output. Split the output on newlines into a list before
2381 assigning it to the given variable. By default the output is stored
2355 assigning it to the given variable. By default the output is stored
2382 as a single string.
2356 as a single string.
2383
2357
2384 -v: verbose. Print the contents of the variable.
2358 -v: verbose. Print the contents of the variable.
2385
2359
2386 In most cases you should not need to split as a list, because the
2360 In most cases you should not need to split as a list, because the
2387 returned value is a special type of string which can automatically
2361 returned value is a special type of string which can automatically
2388 provide its contents either as a list (split on newlines) or as a
2362 provide its contents either as a list (split on newlines) or as a
2389 space-separated string. These are convenient, respectively, either
2363 space-separated string. These are convenient, respectively, either
2390 for sequential processing or to be passed to a shell command.
2364 for sequential processing or to be passed to a shell command.
2391
2365
2392 For example:
2366 For example:
2393
2367
2394 # Capture into variable a
2368 # Capture into variable a
2395 In [9]: sc a=ls *py
2369 In [9]: sc a=ls *py
2396
2370
2397 # a is a string with embedded newlines
2371 # a is a string with embedded newlines
2398 In [10]: a
2372 In [10]: a
2399 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2373 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2400
2374
2401 # which can be seen as a list:
2375 # which can be seen as a list:
2402 In [11]: a.l
2376 In [11]: a.l
2403 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2377 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2404
2378
2405 # or as a whitespace-separated string:
2379 # or as a whitespace-separated string:
2406 In [12]: a.s
2380 In [12]: a.s
2407 Out[12]: 'setup.py win32_manual_post_install.py'
2381 Out[12]: 'setup.py win32_manual_post_install.py'
2408
2382
2409 # a.s is useful to pass as a single command line:
2383 # a.s is useful to pass as a single command line:
2410 In [13]: !wc -l $a.s
2384 In [13]: !wc -l $a.s
2411 146 setup.py
2385 146 setup.py
2412 130 win32_manual_post_install.py
2386 130 win32_manual_post_install.py
2413 276 total
2387 276 total
2414
2388
2415 # while the list form is useful to loop over:
2389 # while the list form is useful to loop over:
2416 In [14]: for f in a.l:
2390 In [14]: for f in a.l:
2417 ....: !wc -l $f
2391 ....: !wc -l $f
2418 ....:
2392 ....:
2419 146 setup.py
2393 146 setup.py
2420 130 win32_manual_post_install.py
2394 130 win32_manual_post_install.py
2421
2395
2422 Similiarly, the lists returned by the -l option are also special, in
2396 Similiarly, the lists returned by the -l option are also special, in
2423 the sense that you can equally invoke the .s attribute on them to
2397 the sense that you can equally invoke the .s attribute on them to
2424 automatically get a whitespace-separated string from their contents:
2398 automatically get a whitespace-separated string from their contents:
2425
2399
2426 In [1]: sc -l b=ls *py
2400 In [1]: sc -l b=ls *py
2427
2401
2428 In [2]: b
2402 In [2]: b
2429 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2403 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2430
2404
2431 In [3]: b.s
2405 In [3]: b.s
2432 Out[3]: 'setup.py win32_manual_post_install.py'
2406 Out[3]: 'setup.py win32_manual_post_install.py'
2433
2407
2434 In summary, both the lists and strings used for ouptut capture have
2408 In summary, both the lists and strings used for ouptut capture have
2435 the following special attributes:
2409 the following special attributes:
2436
2410
2437 .l (or .list) : value as list.
2411 .l (or .list) : value as list.
2438 .n (or .nlstr): value as newline-separated string.
2412 .n (or .nlstr): value as newline-separated string.
2439 .s (or .spstr): value as space-separated string.
2413 .s (or .spstr): value as space-separated string.
2440 """
2414 """
2441
2415
2442 opts,args = self.parse_options(parameter_s,'lv')
2416 opts,args = self.parse_options(parameter_s,'lv')
2443 # Try to get a variable name and command to run
2417 # Try to get a variable name and command to run
2444 try:
2418 try:
2445 # the variable name must be obtained from the parse_options
2419 # the variable name must be obtained from the parse_options
2446 # output, which uses shlex.split to strip options out.
2420 # output, which uses shlex.split to strip options out.
2447 var,_ = args.split('=',1)
2421 var,_ = args.split('=',1)
2448 var = var.strip()
2422 var = var.strip()
2449 # But the the command has to be extracted from the original input
2423 # But the the command has to be extracted from the original input
2450 # parameter_s, not on what parse_options returns, to avoid the
2424 # parameter_s, not on what parse_options returns, to avoid the
2451 # quote stripping which shlex.split performs on it.
2425 # quote stripping which shlex.split performs on it.
2452 _,cmd = parameter_s.split('=',1)
2426 _,cmd = parameter_s.split('=',1)
2453 except ValueError:
2427 except ValueError:
2454 var,cmd = '',''
2428 var,cmd = '',''
2455 if not var:
2429 if not var:
2456 error('you must specify a variable to assign the command to.')
2430 error('you must specify a variable to assign the command to.')
2457 return
2431 return
2458 # If all looks ok, proceed
2432 # If all looks ok, proceed
2459 out,err = self.shell.getoutputerror(cmd)
2433 out,err = self.shell.getoutputerror(cmd)
2460 if err:
2434 if err:
2461 print >> Term.cerr,err
2435 print >> Term.cerr,err
2462 if opts.has_key('l'):
2436 if opts.has_key('l'):
2463 out = SList(out.split('\n'))
2437 out = SList(out.split('\n'))
2464 else:
2438 else:
2465 out = LSString(out)
2439 out = LSString(out)
2466 if opts.has_key('v'):
2440 if opts.has_key('v'):
2467 print '%s ==\n%s' % (var,pformat(out))
2441 print '%s ==\n%s' % (var,pformat(out))
2468 self.shell.user_ns.update({var:out})
2442 self.shell.user_ns.update({var:out})
2469
2443
2470 def magic_sx(self, parameter_s=''):
2444 def magic_sx(self, parameter_s=''):
2471 """Shell execute - run a shell command and capture its output.
2445 """Shell execute - run a shell command and capture its output.
2472
2446
2473 %sx command
2447 %sx command
2474
2448
2475 IPython will run the given command using commands.getoutput(), and
2449 IPython will run the given command using commands.getoutput(), and
2476 return the result formatted as a list (split on '\\n'). Since the
2450 return the result formatted as a list (split on '\\n'). Since the
2477 output is _returned_, it will be stored in ipython's regular output
2451 output is _returned_, it will be stored in ipython's regular output
2478 cache Out[N] and in the '_N' automatic variables.
2452 cache Out[N] and in the '_N' automatic variables.
2479
2453
2480 Notes:
2454 Notes:
2481
2455
2482 1) If an input line begins with '!!', then %sx is automatically
2456 1) If an input line begins with '!!', then %sx is automatically
2483 invoked. That is, while:
2457 invoked. That is, while:
2484 !ls
2458 !ls
2485 causes ipython to simply issue system('ls'), typing
2459 causes ipython to simply issue system('ls'), typing
2486 !!ls
2460 !!ls
2487 is a shorthand equivalent to:
2461 is a shorthand equivalent to:
2488 %sx ls
2462 %sx ls
2489
2463
2490 2) %sx differs from %sc in that %sx automatically splits into a list,
2464 2) %sx differs from %sc in that %sx automatically splits into a list,
2491 like '%sc -l'. The reason for this is to make it as easy as possible
2465 like '%sc -l'. The reason for this is to make it as easy as possible
2492 to process line-oriented shell output via further python commands.
2466 to process line-oriented shell output via further python commands.
2493 %sc is meant to provide much finer control, but requires more
2467 %sc is meant to provide much finer control, but requires more
2494 typing.
2468 typing.
2495
2469
2496 3) Just like %sc -l, this is a list with special attributes:
2470 3) Just like %sc -l, this is a list with special attributes:
2497
2471
2498 .l (or .list) : value as list.
2472 .l (or .list) : value as list.
2499 .n (or .nlstr): value as newline-separated string.
2473 .n (or .nlstr): value as newline-separated string.
2500 .s (or .spstr): value as whitespace-separated string.
2474 .s (or .spstr): value as whitespace-separated string.
2501
2475
2502 This is very useful when trying to use such lists as arguments to
2476 This is very useful when trying to use such lists as arguments to
2503 system commands."""
2477 system commands."""
2504
2478
2505 if parameter_s:
2479 if parameter_s:
2506 out,err = self.shell.getoutputerror(parameter_s)
2480 out,err = self.shell.getoutputerror(parameter_s)
2507 if err:
2481 if err:
2508 print >> Term.cerr,err
2482 print >> Term.cerr,err
2509 return SList(out.split('\n'))
2483 return SList(out.split('\n'))
2510
2484
2511 def magic_bg(self, parameter_s=''):
2485 def magic_bg(self, parameter_s=''):
2512 """Run a job in the background, in a separate thread.
2486 """Run a job in the background, in a separate thread.
2513
2487
2514 For example,
2488 For example,
2515
2489
2516 %bg myfunc(x,y,z=1)
2490 %bg myfunc(x,y,z=1)
2517
2491
2518 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2492 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2519 execution starts, a message will be printed indicating the job
2493 execution starts, a message will be printed indicating the job
2520 number. If your job number is 5, you can use
2494 number. If your job number is 5, you can use
2521
2495
2522 myvar = jobs.result(5) or myvar = jobs[5].result
2496 myvar = jobs.result(5) or myvar = jobs[5].result
2523
2497
2524 to assign this result to variable 'myvar'.
2498 to assign this result to variable 'myvar'.
2525
2499
2526 IPython has a job manager, accessible via the 'jobs' object. You can
2500 IPython has a job manager, accessible via the 'jobs' object. You can
2527 type jobs? to get more information about it, and use jobs.<TAB> to see
2501 type jobs? to get more information about it, and use jobs.<TAB> to see
2528 its attributes. All attributes not starting with an underscore are
2502 its attributes. All attributes not starting with an underscore are
2529 meant for public use.
2503 meant for public use.
2530
2504
2531 In particular, look at the jobs.new() method, which is used to create
2505 In particular, look at the jobs.new() method, which is used to create
2532 new jobs. This magic %bg function is just a convenience wrapper
2506 new jobs. This magic %bg function is just a convenience wrapper
2533 around jobs.new(), for expression-based jobs. If you want to create a
2507 around jobs.new(), for expression-based jobs. If you want to create a
2534 new job with an explicit function object and arguments, you must call
2508 new job with an explicit function object and arguments, you must call
2535 jobs.new() directly.
2509 jobs.new() directly.
2536
2510
2537 The jobs.new docstring also describes in detail several important
2511 The jobs.new docstring also describes in detail several important
2538 caveats associated with a thread-based model for background job
2512 caveats associated with a thread-based model for background job
2539 execution. Type jobs.new? for details.
2513 execution. Type jobs.new? for details.
2540
2514
2541 You can check the status of all jobs with jobs.status().
2515 You can check the status of all jobs with jobs.status().
2542
2516
2543 The jobs variable is set by IPython into the Python builtin namespace.
2517 The jobs variable is set by IPython into the Python builtin namespace.
2544 If you ever declare a variable named 'jobs', you will shadow this
2518 If you ever declare a variable named 'jobs', you will shadow this
2545 name. You can either delete your global jobs variable to regain
2519 name. You can either delete your global jobs variable to regain
2546 access to the job manager, or make a new name and assign it manually
2520 access to the job manager, or make a new name and assign it manually
2547 to the manager (stored in IPython's namespace). For example, to
2521 to the manager (stored in IPython's namespace). For example, to
2548 assign the job manager to the Jobs name, use:
2522 assign the job manager to the Jobs name, use:
2549
2523
2550 Jobs = __builtins__.jobs"""
2524 Jobs = __builtins__.jobs"""
2551
2525
2552 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2526 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2553
2527
2554 def magic_bookmark(self, parameter_s=''):
2528 def magic_bookmark(self, parameter_s=''):
2555 """Manage IPython's bookmark system.
2529 """Manage IPython's bookmark system.
2556
2530
2557 %bookmark <name> - set bookmark to current dir
2531 %bookmark <name> - set bookmark to current dir
2558 %bookmark <name> <dir> - set bookmark to <dir>
2532 %bookmark <name> <dir> - set bookmark to <dir>
2559 %bookmark -l - list all bookmarks
2533 %bookmark -l - list all bookmarks
2560 %bookmark -d <name> - remove bookmark
2534 %bookmark -d <name> - remove bookmark
2561 %bookmark -r - remove all bookmarks
2535 %bookmark -r - remove all bookmarks
2562
2536
2563 You can later on access a bookmarked folder with:
2537 You can later on access a bookmarked folder with:
2564 %cd -b <name>
2538 %cd -b <name>
2565 or simply '%cd <name>' if there is no directory called <name> AND
2539 or simply '%cd <name>' if there is no directory called <name> AND
2566 there is such a bookmark defined.
2540 there is such a bookmark defined.
2567
2541
2568 Your bookmarks persist through IPython sessions, but they are
2542 Your bookmarks persist through IPython sessions, but they are
2569 associated with each profile."""
2543 associated with each profile."""
2570
2544
2571 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2545 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2572 if len(args) > 2:
2546 if len(args) > 2:
2573 error('You can only give at most two arguments')
2547 error('You can only give at most two arguments')
2574 return
2548 return
2575
2549
2576 bkms = self.shell.persist.get('bookmarks',{})
2550 bkms = self.shell.persist.get('bookmarks',{})
2577
2551
2578 if opts.has_key('d'):
2552 if opts.has_key('d'):
2579 try:
2553 try:
2580 todel = args[0]
2554 todel = args[0]
2581 except IndexError:
2555 except IndexError:
2582 error('You must provide a bookmark to delete')
2556 error('You must provide a bookmark to delete')
2583 else:
2557 else:
2584 try:
2558 try:
2585 del bkms[todel]
2559 del bkms[todel]
2586 except:
2560 except:
2587 error("Can't delete bookmark '%s'" % todel)
2561 error("Can't delete bookmark '%s'" % todel)
2588 elif opts.has_key('r'):
2562 elif opts.has_key('r'):
2589 bkms = {}
2563 bkms = {}
2590 elif opts.has_key('l'):
2564 elif opts.has_key('l'):
2591 bks = bkms.keys()
2565 bks = bkms.keys()
2592 bks.sort()
2566 bks.sort()
2593 if bks:
2567 if bks:
2594 size = max(map(len,bks))
2568 size = max(map(len,bks))
2595 else:
2569 else:
2596 size = 0
2570 size = 0
2597 fmt = '%-'+str(size)+'s -> %s'
2571 fmt = '%-'+str(size)+'s -> %s'
2598 print 'Current bookmarks:'
2572 print 'Current bookmarks:'
2599 for bk in bks:
2573 for bk in bks:
2600 print fmt % (bk,bkms[bk])
2574 print fmt % (bk,bkms[bk])
2601 else:
2575 else:
2602 if not args:
2576 if not args:
2603 error("You must specify the bookmark name")
2577 error("You must specify the bookmark name")
2604 elif len(args)==1:
2578 elif len(args)==1:
2605 bkms[args[0]] = os.getcwd()
2579 bkms[args[0]] = os.getcwd()
2606 elif len(args)==2:
2580 elif len(args)==2:
2607 bkms[args[0]] = args[1]
2581 bkms[args[0]] = args[1]
2608 self.persist['bookmarks'] = bkms
2582 self.shell.persist['bookmarks'] = bkms
2609
2583
2610 def magic_pycat(self, parameter_s=''):
2584 def magic_pycat(self, parameter_s=''):
2611 """Show a syntax-highlighted file through a pager.
2585 """Show a syntax-highlighted file through a pager.
2612
2586
2613 This magic is similar to the cat utility, but it will assume the file
2587 This magic is similar to the cat utility, but it will assume the file
2614 to be Python source and will show it with syntax highlighting. """
2588 to be Python source and will show it with syntax highlighting. """
2615
2589
2616 filename = get_py_filename(parameter_s)
2590 filename = get_py_filename(parameter_s)
2617 page(self.shell.colorize(file_read(filename)),
2591 page(self.shell.colorize(file_read(filename)),
2618 screen_lines=self.shell.rc.screen_length)
2592 screen_lines=self.shell.rc.screen_length)
2619
2593
2620 # end Magic
2594 # end Magic
@@ -1,578 +1,583 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 Classes for handling input/output prompts.
3 Classes for handling input/output prompts.
4
4
5 $Id: Prompts.py 960 2005-12-28 06:51:01Z fperez $"""
5 $Id: Prompts.py 966 2005-12-29 08:34:07Z fperez $"""
6
6
7 #*****************************************************************************
7 #*****************************************************************************
8 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #*****************************************************************************
12 #*****************************************************************************
13
13
14 from IPython import Release
14 from IPython import Release
15 __author__ = '%s <%s>' % Release.authors['Fernando']
15 __author__ = '%s <%s>' % Release.authors['Fernando']
16 __license__ = Release.license
16 __license__ = Release.license
17 __version__ = Release.version
17 __version__ = Release.version
18
18
19 #****************************************************************************
19 #****************************************************************************
20 # Required modules
20 # Required modules
21 import __builtin__
21 import __builtin__
22 import os
22 import os
23 import socket
23 import socket
24 import sys
24 import sys
25 import time
25 import time
26 from pprint import pprint,pformat
26 from pprint import pprint,pformat
27
27
28 # IPython's own
28 # IPython's own
29 from IPython.genutils import *
29 from IPython.genutils import *
30 from IPython.Struct import Struct
30 from IPython.Struct import Struct
31 from IPython.Magic import Macro
31 from IPython.Magic import Macro
32 from IPython.Itpl import ItplNS
32 from IPython.Itpl import ItplNS
33 from IPython import ColorANSI
33 from IPython import ColorANSI
34
34
35 #****************************************************************************
35 #****************************************************************************
36 #Color schemes for Prompts.
36 #Color schemes for Prompts.
37
37
38 PromptColors = ColorANSI.ColorSchemeTable()
38 PromptColors = ColorANSI.ColorSchemeTable()
39 InputColors = ColorANSI.InputTermColors # just a shorthand
39 InputColors = ColorANSI.InputTermColors # just a shorthand
40 Colors = ColorANSI.TermColors # just a shorthand
40 Colors = ColorANSI.TermColors # just a shorthand
41
41
42 PromptColors.add_scheme(ColorANSI.ColorScheme(
42 PromptColors.add_scheme(ColorANSI.ColorScheme(
43 'NoColor',
43 'NoColor',
44 in_prompt = InputColors.NoColor, # Input prompt
44 in_prompt = InputColors.NoColor, # Input prompt
45 in_number = InputColors.NoColor, # Input prompt number
45 in_number = InputColors.NoColor, # Input prompt number
46 in_prompt2 = InputColors.NoColor, # Continuation prompt
46 in_prompt2 = InputColors.NoColor, # Continuation prompt
47 in_normal = InputColors.NoColor, # color off (usu. Colors.Normal)
47 in_normal = InputColors.NoColor, # color off (usu. Colors.Normal)
48
48
49 out_prompt = Colors.NoColor, # Output prompt
49 out_prompt = Colors.NoColor, # Output prompt
50 out_number = Colors.NoColor, # Output prompt number
50 out_number = Colors.NoColor, # Output prompt number
51
51
52 normal = Colors.NoColor # color off (usu. Colors.Normal)
52 normal = Colors.NoColor # color off (usu. Colors.Normal)
53 ))
53 ))
54
54
55 # make some schemes as instances so we can copy them for modification easily:
55 # make some schemes as instances so we can copy them for modification easily:
56 __PColLinux = ColorANSI.ColorScheme(
56 __PColLinux = ColorANSI.ColorScheme(
57 'Linux',
57 'Linux',
58 in_prompt = InputColors.Green,
58 in_prompt = InputColors.Green,
59 in_number = InputColors.LightGreen,
59 in_number = InputColors.LightGreen,
60 in_prompt2 = InputColors.Green,
60 in_prompt2 = InputColors.Green,
61 in_normal = InputColors.Normal, # color off (usu. Colors.Normal)
61 in_normal = InputColors.Normal, # color off (usu. Colors.Normal)
62
62
63 out_prompt = Colors.Red,
63 out_prompt = Colors.Red,
64 out_number = Colors.LightRed,
64 out_number = Colors.LightRed,
65
65
66 normal = Colors.Normal
66 normal = Colors.Normal
67 )
67 )
68 # Don't forget to enter it into the table!
68 # Don't forget to enter it into the table!
69 PromptColors.add_scheme(__PColLinux)
69 PromptColors.add_scheme(__PColLinux)
70
70
71 # Slightly modified Linux for light backgrounds
71 # Slightly modified Linux for light backgrounds
72 __PColLightBG = __PColLinux.copy('LightBG')
72 __PColLightBG = __PColLinux.copy('LightBG')
73
73
74 __PColLightBG.colors.update(
74 __PColLightBG.colors.update(
75 in_prompt = InputColors.Blue,
75 in_prompt = InputColors.Blue,
76 in_number = InputColors.LightBlue,
76 in_number = InputColors.LightBlue,
77 in_prompt2 = InputColors.Blue
77 in_prompt2 = InputColors.Blue
78 )
78 )
79 PromptColors.add_scheme(__PColLightBG)
79 PromptColors.add_scheme(__PColLightBG)
80
80
81 del Colors,InputColors
81 del Colors,InputColors
82
82
83 #-----------------------------------------------------------------------------
83 #-----------------------------------------------------------------------------
84 def multiple_replace(dict, text):
84 def multiple_replace(dict, text):
85 """ Replace in 'text' all occurences of any key in the given
85 """ Replace in 'text' all occurences of any key in the given
86 dictionary by its corresponding value. Returns the new string."""
86 dictionary by its corresponding value. Returns the new string."""
87
87
88 # Function by Xavier Defrang, originally found at:
88 # Function by Xavier Defrang, originally found at:
89 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81330
89 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81330
90
90
91 # Create a regular expression from the dictionary keys
91 # Create a regular expression from the dictionary keys
92 regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))
92 regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))
93 # For each match, look-up corresponding value in dictionary
93 # For each match, look-up corresponding value in dictionary
94 return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)
94 return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)
95
95
96 #-----------------------------------------------------------------------------
96 #-----------------------------------------------------------------------------
97 # Special characters that can be used in prompt templates, mainly bash-like
97 # Special characters that can be used in prompt templates, mainly bash-like
98
98
99 # If $HOME isn't defined (Windows), make it an absurd string so that it can
99 # If $HOME isn't defined (Windows), make it an absurd string so that it can
100 # never be expanded out into '~'. Basically anything which can never be a
100 # never be expanded out into '~'. Basically anything which can never be a
101 # reasonable directory name will do, we just want the $HOME -> '~' operation
101 # reasonable directory name will do, we just want the $HOME -> '~' operation
102 # to become a no-op. We pre-compute $HOME here so it's not done on every
102 # to become a no-op. We pre-compute $HOME here so it's not done on every
103 # prompt call.
103 # prompt call.
104
104
105 # FIXME:
105 # FIXME:
106
106
107 # - This should be turned into a class which does proper namespace management,
107 # - This should be turned into a class which does proper namespace management,
108 # since the prompt specials need to be evaluated in a certain namespace.
108 # since the prompt specials need to be evaluated in a certain namespace.
109 # Currently it's just globals, which need to be managed manually by code
109 # Currently it's just globals, which need to be managed manually by code
110 # below.
110 # below.
111
111
112 # - I also need to split up the color schemes from the prompt specials
112 # - I also need to split up the color schemes from the prompt specials
113 # somehow. I don't have a clean design for that quite yet.
113 # somehow. I don't have a clean design for that quite yet.
114
114
115 HOME = os.environ.get("HOME","//////:::::ZZZZZ,,,~~~")
115 HOME = os.environ.get("HOME","//////:::::ZZZZZ,,,~~~")
116
116
117 # We precompute a few more strings here for the prompt_specials, which are
117 # We precompute a few more strings here for the prompt_specials, which are
118 # fixed once ipython starts. This reduces the runtime overhead of computing
118 # fixed once ipython starts. This reduces the runtime overhead of computing
119 # prompt strings.
119 # prompt strings.
120 USER = os.environ.get("USER")
120 USER = os.environ.get("USER")
121 HOSTNAME = socket.gethostname()
121 HOSTNAME = socket.gethostname()
122 HOSTNAME_SHORT = HOSTNAME.split(".")[0]
122 HOSTNAME_SHORT = HOSTNAME.split(".")[0]
123 ROOT_SYMBOL = "$#"[os.name=='nt' or os.getuid()==0]
123 ROOT_SYMBOL = "$#"[os.name=='nt' or os.getuid()==0]
124
124
125 prompt_specials_color = {
125 prompt_specials_color = {
126 # Prompt/history count
126 # Prompt/history count
127 '%n' : '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
127 '%n' : '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
128 '\\#': '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
128 '\\#': '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
129 # Prompt/history count, with the actual digits replaced by dots. Used
129 # Prompt/history count, with the actual digits replaced by dots. Used
130 # mainly in continuation prompts (prompt_in2)
130 # mainly in continuation prompts (prompt_in2)
131 '\\D': '${"."*len(str(self.cache.prompt_count))}',
131 '\\D': '${"."*len(str(self.cache.prompt_count))}',
132 # Current working directory
132 # Current working directory
133 '\\w': '${os.getcwd()}',
133 '\\w': '${os.getcwd()}',
134 # Current time
134 # Current time
135 '\\t' : '${time.strftime("%H:%M:%S")}',
135 '\\t' : '${time.strftime("%H:%M:%S")}',
136 # Basename of current working directory.
136 # Basename of current working directory.
137 # (use os.sep to make this portable across OSes)
137 # (use os.sep to make this portable across OSes)
138 '\\W' : '${os.getcwd().split("%s")[-1]}' % os.sep,
138 '\\W' : '${os.getcwd().split("%s")[-1]}' % os.sep,
139 # These X<N> are an extension to the normal bash prompts. They return
139 # These X<N> are an extension to the normal bash prompts. They return
140 # N terms of the path, after replacing $HOME with '~'
140 # N terms of the path, after replacing $HOME with '~'
141 '\\X0': '${os.getcwd().replace("%s","~")}' % HOME,
141 '\\X0': '${os.getcwd().replace("%s","~")}' % HOME,
142 '\\X1': '${self.cwd_filt(1)}',
142 '\\X1': '${self.cwd_filt(1)}',
143 '\\X2': '${self.cwd_filt(2)}',
143 '\\X2': '${self.cwd_filt(2)}',
144 '\\X3': '${self.cwd_filt(3)}',
144 '\\X3': '${self.cwd_filt(3)}',
145 '\\X4': '${self.cwd_filt(4)}',
145 '\\X4': '${self.cwd_filt(4)}',
146 '\\X5': '${self.cwd_filt(5)}',
146 '\\X5': '${self.cwd_filt(5)}',
147 # Y<N> are similar to X<N>, but they show '~' if it's the directory
147 # Y<N> are similar to X<N>, but they show '~' if it's the directory
148 # N+1 in the list. Somewhat like %cN in tcsh.
148 # N+1 in the list. Somewhat like %cN in tcsh.
149 '\\Y0': '${self.cwd_filt2(0)}',
149 '\\Y0': '${self.cwd_filt2(0)}',
150 '\\Y1': '${self.cwd_filt2(1)}',
150 '\\Y1': '${self.cwd_filt2(1)}',
151 '\\Y2': '${self.cwd_filt2(2)}',
151 '\\Y2': '${self.cwd_filt2(2)}',
152 '\\Y3': '${self.cwd_filt2(3)}',
152 '\\Y3': '${self.cwd_filt2(3)}',
153 '\\Y4': '${self.cwd_filt2(4)}',
153 '\\Y4': '${self.cwd_filt2(4)}',
154 '\\Y5': '${self.cwd_filt2(5)}',
154 '\\Y5': '${self.cwd_filt2(5)}',
155 # Hostname up to first .
155 # Hostname up to first .
156 '\\h': HOSTNAME_SHORT,
156 '\\h': HOSTNAME_SHORT,
157 # Full hostname
157 # Full hostname
158 '\\H': HOSTNAME,
158 '\\H': HOSTNAME,
159 # Username of current user
159 # Username of current user
160 '\\u': USER,
160 '\\u': USER,
161 # Escaped '\'
161 # Escaped '\'
162 '\\\\': '\\',
162 '\\\\': '\\',
163 # Newline
163 # Newline
164 '\\n': '\n',
164 '\\n': '\n',
165 # Carriage return
165 # Carriage return
166 '\\r': '\r',
166 '\\r': '\r',
167 # Release version
167 # Release version
168 '\\v': __version__,
168 '\\v': __version__,
169 # Root symbol ($ or #)
169 # Root symbol ($ or #)
170 '\\$': ROOT_SYMBOL,
170 '\\$': ROOT_SYMBOL,
171 }
171 }
172
172
173 # A copy of the prompt_specials dictionary but with all color escapes removed,
173 # A copy of the prompt_specials dictionary but with all color escapes removed,
174 # so we can correctly compute the prompt length for the auto_rewrite method.
174 # so we can correctly compute the prompt length for the auto_rewrite method.
175 prompt_specials_nocolor = prompt_specials_color.copy()
175 prompt_specials_nocolor = prompt_specials_color.copy()
176 prompt_specials_nocolor['%n'] = '${self.cache.prompt_count}'
176 prompt_specials_nocolor['%n'] = '${self.cache.prompt_count}'
177 prompt_specials_nocolor['\\#'] = '${self.cache.prompt_count}'
177 prompt_specials_nocolor['\\#'] = '${self.cache.prompt_count}'
178
178
179 # Add in all the InputTermColors color escapes as valid prompt characters.
179 # Add in all the InputTermColors color escapes as valid prompt characters.
180 # They all get added as \\C_COLORNAME, so that we don't have any conflicts
180 # They all get added as \\C_COLORNAME, so that we don't have any conflicts
181 # with a color name which may begin with a letter used by any other of the
181 # with a color name which may begin with a letter used by any other of the
182 # allowed specials. This of course means that \\C will never be allowed for
182 # allowed specials. This of course means that \\C will never be allowed for
183 # anything else.
183 # anything else.
184 input_colors = ColorANSI.InputTermColors
184 input_colors = ColorANSI.InputTermColors
185 for _color in dir(input_colors):
185 for _color in dir(input_colors):
186 if _color[0] != '_':
186 if _color[0] != '_':
187 c_name = '\\C_'+_color
187 c_name = '\\C_'+_color
188 prompt_specials_color[c_name] = getattr(input_colors,_color)
188 prompt_specials_color[c_name] = getattr(input_colors,_color)
189 prompt_specials_nocolor[c_name] = ''
189 prompt_specials_nocolor[c_name] = ''
190
190
191 # we default to no color for safety. Note that prompt_specials is a global
191 # we default to no color for safety. Note that prompt_specials is a global
192 # variable used by all prompt objects.
192 # variable used by all prompt objects.
193 prompt_specials = prompt_specials_nocolor
193 prompt_specials = prompt_specials_nocolor
194
194
195 #-----------------------------------------------------------------------------
195 #-----------------------------------------------------------------------------
196 def str_safe(arg):
196 def str_safe(arg):
197 """Convert to a string, without ever raising an exception.
197 """Convert to a string, without ever raising an exception.
198
198
199 If str(arg) fails, <ERROR: ... > is returned, where ... is the exception
199 If str(arg) fails, <ERROR: ... > is returned, where ... is the exception
200 error message."""
200 error message."""
201
201
202 try:
202 try:
203 out = str(arg)
203 out = str(arg)
204 except UnicodeError:
204 except UnicodeError:
205 try:
205 try:
206 out = arg.encode('utf_8','replace')
206 out = arg.encode('utf_8','replace')
207 except Exception,msg:
207 except Exception,msg:
208 # let's keep this little duplication here, so that the most common
208 # let's keep this little duplication here, so that the most common
209 # case doesn't suffer from a double try wrapping.
209 # case doesn't suffer from a double try wrapping.
210 out = '<ERROR: %s>' % msg
210 out = '<ERROR: %s>' % msg
211 except Exception,msg:
211 except Exception,msg:
212 out = '<ERROR: %s>' % msg
212 out = '<ERROR: %s>' % msg
213 return out
213 return out
214
214
215 class BasePrompt:
215 class BasePrompt:
216 """Interactive prompt similar to Mathematica's."""
216 """Interactive prompt similar to Mathematica's."""
217 def __init__(self,cache,sep,prompt,pad_left=False):
217 def __init__(self,cache,sep,prompt,pad_left=False):
218
218
219 # Hack: we access information about the primary prompt through the
219 # Hack: we access information about the primary prompt through the
220 # cache argument. We need this, because we want the secondary prompt
220 # cache argument. We need this, because we want the secondary prompt
221 # to be aligned with the primary one. Color table info is also shared
221 # to be aligned with the primary one. Color table info is also shared
222 # by all prompt classes through the cache. Nice OO spaghetti code!
222 # by all prompt classes through the cache. Nice OO spaghetti code!
223 self.cache = cache
223 self.cache = cache
224 self.sep = sep
224 self.sep = sep
225
225
226 # regexp to count the number of spaces at the end of a prompt
226 # regexp to count the number of spaces at the end of a prompt
227 # expression, useful for prompt auto-rewriting
227 # expression, useful for prompt auto-rewriting
228 self.rspace = re.compile(r'(\s*)$')
228 self.rspace = re.compile(r'(\s*)$')
229 # Flag to left-pad prompt strings to match the length of the primary
229 # Flag to left-pad prompt strings to match the length of the primary
230 # prompt
230 # prompt
231 self.pad_left = pad_left
231 self.pad_left = pad_left
232 # Set template to create each actual prompt (where numbers change)
232 # Set template to create each actual prompt (where numbers change)
233 self.p_template = prompt
233 self.p_template = prompt
234 self.set_p_str()
234 self.set_p_str()
235
235
236 def set_p_str(self):
236 def set_p_str(self):
237 """ Set the interpolating prompt strings.
237 """ Set the interpolating prompt strings.
238
238
239 This must be called every time the color settings change, because the
239 This must be called every time the color settings change, because the
240 prompt_specials global may have changed."""
240 prompt_specials global may have changed."""
241
241
242 import os,time # needed in locals for prompt string handling
242 import os,time # needed in locals for prompt string handling
243 loc = locals()
243 loc = locals()
244 self.p_str = ItplNS('%s%s%s' %
244 self.p_str = ItplNS('%s%s%s' %
245 ('${self.sep}${self.col_p}',
245 ('${self.sep}${self.col_p}',
246 multiple_replace(prompt_specials, self.p_template),
246 multiple_replace(prompt_specials, self.p_template),
247 '${self.col_norm}'),self.cache.user_ns,loc)
247 '${self.col_norm}'),self.cache.user_ns,loc)
248
248
249 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
249 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
250 self.p_template),
250 self.p_template),
251 self.cache.user_ns,loc)
251 self.cache.user_ns,loc)
252
252
253 def write(self,msg): # dbg
253 def write(self,msg): # dbg
254 sys.stdout.write(msg)
254 sys.stdout.write(msg)
255 return ''
255 return ''
256
256
257 def __str__(self):
257 def __str__(self):
258 """Return a string form of the prompt.
258 """Return a string form of the prompt.
259
259
260 This for is useful for continuation and output prompts, since it is
260 This for is useful for continuation and output prompts, since it is
261 left-padded to match lengths with the primary one (if the
261 left-padded to match lengths with the primary one (if the
262 self.pad_left attribute is set)."""
262 self.pad_left attribute is set)."""
263
263
264 out_str = str_safe(self.p_str)
264 out_str = str_safe(self.p_str)
265 if self.pad_left:
265 if self.pad_left:
266 # We must find the amount of padding required to match lengths,
266 # We must find the amount of padding required to match lengths,
267 # taking the color escapes (which are invisible on-screen) into
267 # taking the color escapes (which are invisible on-screen) into
268 # account.
268 # account.
269 esc_pad = len(out_str) - len(str_safe(self.p_str_nocolor))
269 esc_pad = len(out_str) - len(str_safe(self.p_str_nocolor))
270 format = '%%%ss' % (len(str(self.cache.last_prompt))+esc_pad)
270 format = '%%%ss' % (len(str(self.cache.last_prompt))+esc_pad)
271 return format % out_str
271 return format % out_str
272 else:
272 else:
273 return out_str
273 return out_str
274
274
275 # these path filters are put in as methods so that we can control the
275 # these path filters are put in as methods so that we can control the
276 # namespace where the prompt strings get evaluated
276 # namespace where the prompt strings get evaluated
277 def cwd_filt(self,depth):
277 def cwd_filt(self,depth):
278 """Return the last depth elements of the current working directory.
278 """Return the last depth elements of the current working directory.
279
279
280 $HOME is always replaced with '~'.
280 $HOME is always replaced with '~'.
281 If depth==0, the full path is returned."""
281 If depth==0, the full path is returned."""
282
282
283 cwd = os.getcwd().replace(HOME,"~")
283 cwd = os.getcwd().replace(HOME,"~")
284 out = os.sep.join(cwd.split(os.sep)[-depth:])
284 out = os.sep.join(cwd.split(os.sep)[-depth:])
285 if out:
285 if out:
286 return out
286 return out
287 else:
287 else:
288 return os.sep
288 return os.sep
289
289
290 def cwd_filt2(self,depth):
290 def cwd_filt2(self,depth):
291 """Return the last depth elements of the current working directory.
291 """Return the last depth elements of the current working directory.
292
292
293 $HOME is always replaced with '~'.
293 $HOME is always replaced with '~'.
294 If depth==0, the full path is returned."""
294 If depth==0, the full path is returned."""
295
295
296 cwd = os.getcwd().replace(HOME,"~").split(os.sep)
296 cwd = os.getcwd().replace(HOME,"~").split(os.sep)
297 if '~' in cwd and len(cwd) == depth+1:
297 if '~' in cwd and len(cwd) == depth+1:
298 depth += 1
298 depth += 1
299 out = os.sep.join(cwd[-depth:])
299 out = os.sep.join(cwd[-depth:])
300 if out:
300 if out:
301 return out
301 return out
302 else:
302 else:
303 return os.sep
303 return os.sep
304
304
305 class Prompt1(BasePrompt):
305 class Prompt1(BasePrompt):
306 """Input interactive prompt similar to Mathematica's."""
306 """Input interactive prompt similar to Mathematica's."""
307
307
308 def __init__(self,cache,sep='\n',prompt='In [\\#]: ',pad_left=True):
308 def __init__(self,cache,sep='\n',prompt='In [\\#]: ',pad_left=True):
309 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
309 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
310
310
311 def set_colors(self):
311 def set_colors(self):
312 self.set_p_str()
312 self.set_p_str()
313 Colors = self.cache.color_table.active_colors # shorthand
313 Colors = self.cache.color_table.active_colors # shorthand
314 self.col_p = Colors.in_prompt
314 self.col_p = Colors.in_prompt
315 self.col_num = Colors.in_number
315 self.col_num = Colors.in_number
316 self.col_norm = Colors.in_normal
316 self.col_norm = Colors.in_normal
317 # We need a non-input version of these escapes for the '--->'
317 # We need a non-input version of these escapes for the '--->'
318 # auto-call prompts used in the auto_rewrite() method.
318 # auto-call prompts used in the auto_rewrite() method.
319 self.col_p_ni = self.col_p.replace('\001','').replace('\002','')
319 self.col_p_ni = self.col_p.replace('\001','').replace('\002','')
320 self.col_norm_ni = Colors.normal
320 self.col_norm_ni = Colors.normal
321
321
322 def __str__(self):
322 def __str__(self):
323 self.cache.prompt_count += 1
323 self.cache.prompt_count += 1
324 self.cache.last_prompt = str_safe(self.p_str_nocolor).split('\n')[-1]
324 self.cache.last_prompt = str_safe(self.p_str_nocolor).split('\n')[-1]
325 return str_safe(self.p_str)
325 return str_safe(self.p_str)
326
326
327 def auto_rewrite(self):
327 def auto_rewrite(self):
328 """Print a string of the form '--->' which lines up with the previous
328 """Print a string of the form '--->' which lines up with the previous
329 input string. Useful for systems which re-write the user input when
329 input string. Useful for systems which re-write the user input when
330 handling automatically special syntaxes."""
330 handling automatically special syntaxes."""
331
331
332 curr = str(self.cache.last_prompt)
332 curr = str(self.cache.last_prompt)
333 nrspaces = len(self.rspace.search(curr).group())
333 nrspaces = len(self.rspace.search(curr).group())
334 return '%s%s>%s%s' % (self.col_p_ni,'-'*(len(curr)-nrspaces-1),
334 return '%s%s>%s%s' % (self.col_p_ni,'-'*(len(curr)-nrspaces-1),
335 ' '*nrspaces,self.col_norm_ni)
335 ' '*nrspaces,self.col_norm_ni)
336
336
337 class PromptOut(BasePrompt):
337 class PromptOut(BasePrompt):
338 """Output interactive prompt similar to Mathematica's."""
338 """Output interactive prompt similar to Mathematica's."""
339
339
340 def __init__(self,cache,sep='',prompt='Out[\\#]: ',pad_left=True):
340 def __init__(self,cache,sep='',prompt='Out[\\#]: ',pad_left=True):
341 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
341 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
342 if not self.p_template:
342 if not self.p_template:
343 self.__str__ = lambda: ''
343 self.__str__ = lambda: ''
344
344
345 def set_colors(self):
345 def set_colors(self):
346 self.set_p_str()
346 self.set_p_str()
347 Colors = self.cache.color_table.active_colors # shorthand
347 Colors = self.cache.color_table.active_colors # shorthand
348 self.col_p = Colors.out_prompt
348 self.col_p = Colors.out_prompt
349 self.col_num = Colors.out_number
349 self.col_num = Colors.out_number
350 self.col_norm = Colors.normal
350 self.col_norm = Colors.normal
351
351
352 class Prompt2(BasePrompt):
352 class Prompt2(BasePrompt):
353 """Interactive continuation prompt."""
353 """Interactive continuation prompt."""
354
354
355 def __init__(self,cache,prompt=' .\\D.: ',pad_left=True):
355 def __init__(self,cache,prompt=' .\\D.: ',pad_left=True):
356 self.cache = cache
356 self.cache = cache
357 self.p_template = prompt
357 self.p_template = prompt
358 self.pad_left = pad_left
358 self.pad_left = pad_left
359 self.set_p_str()
359 self.set_p_str()
360
360
361 def set_p_str(self):
361 def set_p_str(self):
362 import os,time # needed in locals for prompt string handling
362 import os,time # needed in locals for prompt string handling
363 loc = locals()
363 loc = locals()
364 self.p_str = ItplNS('%s%s%s' %
364 self.p_str = ItplNS('%s%s%s' %
365 ('${self.col_p2}',
365 ('${self.col_p2}',
366 multiple_replace(prompt_specials, self.p_template),
366 multiple_replace(prompt_specials, self.p_template),
367 '$self.col_norm'),
367 '$self.col_norm'),
368 self.cache.user_ns,loc)
368 self.cache.user_ns,loc)
369 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
369 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
370 self.p_template),
370 self.p_template),
371 self.cache.user_ns,loc)
371 self.cache.user_ns,loc)
372
372
373 def set_colors(self):
373 def set_colors(self):
374 self.set_p_str()
374 self.set_p_str()
375 Colors = self.cache.color_table.active_colors
375 Colors = self.cache.color_table.active_colors
376 self.col_p2 = Colors.in_prompt2
376 self.col_p2 = Colors.in_prompt2
377 self.col_norm = Colors.in_normal
377 self.col_norm = Colors.in_normal
378 # FIXME (2004-06-16) HACK: prevent crashes for users who haven't
378 # FIXME (2004-06-16) HACK: prevent crashes for users who haven't
379 # updated their prompt_in2 definitions. Remove eventually.
379 # updated their prompt_in2 definitions. Remove eventually.
380 self.col_p = Colors.out_prompt
380 self.col_p = Colors.out_prompt
381 self.col_num = Colors.out_number
381 self.col_num = Colors.out_number
382
382
383 #-----------------------------------------------------------------------------
383 #-----------------------------------------------------------------------------
384 class CachedOutput:
384 class CachedOutput:
385 """Class for printing output from calculations while keeping a cache of
385 """Class for printing output from calculations while keeping a cache of
386 reults. It dynamically creates global variables prefixed with _ which
386 reults. It dynamically creates global variables prefixed with _ which
387 contain these results.
387 contain these results.
388
388
389 Meant to be used as a sys.displayhook replacement, providing numbered
389 Meant to be used as a sys.displayhook replacement, providing numbered
390 prompts and cache services.
390 prompts and cache services.
391
391
392 Initialize with initial and final values for cache counter (this defines
392 Initialize with initial and final values for cache counter (this defines
393 the maximum size of the cache."""
393 the maximum size of the cache."""
394
394
395 def __init__(self,cache_size,Pprint,colors='NoColor',input_sep='\n',
395 def __init__(self,shell,cache_size,Pprint,
396 output_sep='\n',output_sep2='',user_ns={},
396 colors='NoColor',input_sep='\n',
397 ps1 = None, ps2 = None,ps_out = None,
397 output_sep='\n',output_sep2='',
398 input_hist = None,pad_left=True):
398 ps1 = None, ps2 = None,ps_out = None,pad_left=True):
399
399
400 cache_size_min = 20
400 cache_size_min = 20
401 if cache_size <= 0:
401 if cache_size <= 0:
402 self.do_full_cache = 0
402 self.do_full_cache = 0
403 cache_size = 0
403 cache_size = 0
404 elif cache_size < cache_size_min:
404 elif cache_size < cache_size_min:
405 self.do_full_cache = 0
405 self.do_full_cache = 0
406 cache_size = 0
406 cache_size = 0
407 warn('caching was disabled (min value for cache size is %s).' %
407 warn('caching was disabled (min value for cache size is %s).' %
408 cache_size_min,level=3)
408 cache_size_min,level=3)
409 else:
409 else:
410 self.do_full_cache = 1
410 self.do_full_cache = 1
411
411
412 self.cache_size = cache_size
412 self.cache_size = cache_size
413 self.input_sep = input_sep
413 self.input_sep = input_sep
414
414
415 # we need a reference to the user-level namespace
415 # we need a reference to the user-level namespace
416 self.user_ns = user_ns
416 self.shell = shell
417 self.user_ns = shell.user_ns
417 # and to the user's input
418 # and to the user's input
418 self.input_hist = input_hist
419 self.input_hist = shell.input_hist
420 # and to the user's logger, for logging output
421 self.logger = shell.logger
419
422
420 # Set input prompt strings and colors
423 # Set input prompt strings and colors
421 if cache_size == 0:
424 if cache_size == 0:
422 if ps1.find('%n') > -1 or ps1.find('\\#') > -1: ps1 = '>>> '
425 if ps1.find('%n') > -1 or ps1.find('\\#') > -1: ps1 = '>>> '
423 if ps2.find('%n') > -1 or ps2.find('\\#') > -1: ps2 = '... '
426 if ps2.find('%n') > -1 or ps2.find('\\#') > -1: ps2 = '... '
424 self.ps1_str = self._set_prompt_str(ps1,'In [\\#]: ','>>> ')
427 self.ps1_str = self._set_prompt_str(ps1,'In [\\#]: ','>>> ')
425 self.ps2_str = self._set_prompt_str(ps2,' .\\D.: ','... ')
428 self.ps2_str = self._set_prompt_str(ps2,' .\\D.: ','... ')
426 self.ps_out_str = self._set_prompt_str(ps_out,'Out[\\#]: ','')
429 self.ps_out_str = self._set_prompt_str(ps_out,'Out[\\#]: ','')
427
430
428 self.color_table = PromptColors
431 self.color_table = PromptColors
429 self.prompt1 = Prompt1(self,sep=input_sep,prompt=self.ps1_str,
432 self.prompt1 = Prompt1(self,sep=input_sep,prompt=self.ps1_str,
430 pad_left=pad_left)
433 pad_left=pad_left)
431 self.prompt2 = Prompt2(self,prompt=self.ps2_str,pad_left=pad_left)
434 self.prompt2 = Prompt2(self,prompt=self.ps2_str,pad_left=pad_left)
432 self.prompt_out = PromptOut(self,sep='',prompt=self.ps_out_str,
435 self.prompt_out = PromptOut(self,sep='',prompt=self.ps_out_str,
433 pad_left=pad_left)
436 pad_left=pad_left)
434 self.set_colors(colors)
437 self.set_colors(colors)
435
438
436 # other more normal stuff
439 # other more normal stuff
437 # b/c each call to the In[] prompt raises it by 1, even the first.
440 # b/c each call to the In[] prompt raises it by 1, even the first.
438 self.prompt_count = 0
441 self.prompt_count = 0
439 self.cache_count = 1
442 self.cache_count = 1
440 # Store the last prompt string each time, we need it for aligning
443 # Store the last prompt string each time, we need it for aligning
441 # continuation and auto-rewrite prompts
444 # continuation and auto-rewrite prompts
442 self.last_prompt = ''
445 self.last_prompt = ''
443 self.entries = [None] # output counter starts at 1 for the user
446 self.entries = [None] # output counter starts at 1 for the user
444 self.Pprint = Pprint
447 self.Pprint = Pprint
445 self.output_sep = output_sep
448 self.output_sep = output_sep
446 self.output_sep2 = output_sep2
449 self.output_sep2 = output_sep2
447 self._,self.__,self.___ = '','',''
450 self._,self.__,self.___ = '','',''
448 self.pprint_types = map(type,[(),[],{}])
451 self.pprint_types = map(type,[(),[],{}])
449
452
450 # these are deliberately global:
453 # these are deliberately global:
451 to_user_ns = {'_':self._,'__':self.__,'___':self.___}
454 to_user_ns = {'_':self._,'__':self.__,'___':self.___}
452 self.user_ns.update(to_user_ns)
455 self.user_ns.update(to_user_ns)
453
456
454 def _set_prompt_str(self,p_str,cache_def,no_cache_def):
457 def _set_prompt_str(self,p_str,cache_def,no_cache_def):
455 if p_str is None:
458 if p_str is None:
456 if self.do_full_cache:
459 if self.do_full_cache:
457 return cache_def
460 return cache_def
458 else:
461 else:
459 return no_cache_def
462 return no_cache_def
460 else:
463 else:
461 return p_str
464 return p_str
462
465
463 def set_colors(self,colors):
466 def set_colors(self,colors):
464 """Set the active color scheme and configure colors for the three
467 """Set the active color scheme and configure colors for the three
465 prompt subsystems."""
468 prompt subsystems."""
466
469
467 # FIXME: the prompt_specials global should be gobbled inside this
470 # FIXME: the prompt_specials global should be gobbled inside this
468 # class instead. Do it when cleaning up the whole 3-prompt system.
471 # class instead. Do it when cleaning up the whole 3-prompt system.
469 global prompt_specials
472 global prompt_specials
470 if colors.lower()=='nocolor':
473 if colors.lower()=='nocolor':
471 prompt_specials = prompt_specials_nocolor
474 prompt_specials = prompt_specials_nocolor
472 else:
475 else:
473 prompt_specials = prompt_specials_color
476 prompt_specials = prompt_specials_color
474
477
475 self.color_table.set_active_scheme(colors)
478 self.color_table.set_active_scheme(colors)
476 self.prompt1.set_colors()
479 self.prompt1.set_colors()
477 self.prompt2.set_colors()
480 self.prompt2.set_colors()
478 self.prompt_out.set_colors()
481 self.prompt_out.set_colors()
479
482
480 def __call__(self,arg=None):
483 def __call__(self,arg=None):
481 """Printing with history cache management.
484 """Printing with history cache management.
482
485
483 This is invoked everytime the interpreter needs to print, and is
486 This is invoked everytime the interpreter needs to print, and is
484 activated by setting the variable sys.displayhook to it."""
487 activated by setting the variable sys.displayhook to it."""
485
488
486 # If something injected a '_' variable in __builtin__, delete
489 # If something injected a '_' variable in __builtin__, delete
487 # ipython's automatic one so we don't clobber that. gettext() in
490 # ipython's automatic one so we don't clobber that. gettext() in
488 # particular uses _, so we need to stay away from it.
491 # particular uses _, so we need to stay away from it.
489 if '_' in __builtin__.__dict__:
492 if '_' in __builtin__.__dict__:
490 try:
493 try:
491 del self.user_ns['_']
494 del self.user_ns['_']
492 except KeyError:
495 except KeyError:
493 pass
496 pass
494 if arg is not None:
497 if arg is not None:
495 cout_write = Term.cout.write # fast lookup
498 cout_write = Term.cout.write # fast lookup
496 # first handle the cache and counters
499 # first handle the cache and counters
497 # but avoid recursive reference when displaying _oh/Out
500 # but avoid recursive reference when displaying _oh/Out
498 if arg is not self.user_ns['_oh']:
501 if arg is not self.user_ns['_oh']:
499 self.update(arg)
502 self.update(arg)
500 # do not print output if input ends in ';'
503 # do not print output if input ends in ';'
501 if self.input_hist[self.prompt_count].endswith(';\n'):
504 if self.input_hist[self.prompt_count].endswith(';\n'):
502 return
505 return
503 # don't use print, puts an extra space
506 # don't use print, puts an extra space
504 cout_write(self.output_sep)
507 cout_write(self.output_sep)
505 if self.do_full_cache:
508 if self.do_full_cache:
506 cout_write(str(self.prompt_out))
509 cout_write(str(self.prompt_out))
507
510
508 if isinstance(arg,Macro):
511 if isinstance(arg,Macro):
509 print 'Executing Macro...'
512 print 'Executing Macro...'
510 # in case the macro takes a long time to execute
513 # in case the macro takes a long time to execute
511 Term.cout.flush()
514 Term.cout.flush()
512 exec arg.value in self.user_ns
515 self.shell.runlines(arg.value)
513 return None
516 return None
514
517
515 # and now call a possibly user-defined print mechanism
518 # and now call a possibly user-defined print mechanism
516 self.display(arg)
519 self.display(arg)
520 if self.logger.log_output:
521 self.logger.log_write(repr(arg),'output')
517 cout_write(self.output_sep2)
522 cout_write(self.output_sep2)
518 Term.cout.flush()
523 Term.cout.flush()
519
524
520 def _display(self,arg):
525 def _display(self,arg):
521 """Default printer method, uses pprint.
526 """Default printer method, uses pprint.
522
527
523 This can be over-ridden by the users to implement special formatting
528 This can be over-ridden by the users to implement special formatting
524 of certain types of output."""
529 of certain types of output."""
525
530
526 if self.Pprint:
531 if self.Pprint:
527 out = pformat(arg)
532 out = pformat(arg)
528 if '\n' in out:
533 if '\n' in out:
529 # So that multi-line strings line up with the left column of
534 # So that multi-line strings line up with the left column of
530 # the screen, instead of having the output prompt mess up
535 # the screen, instead of having the output prompt mess up
531 # their first line.
536 # their first line.
532 Term.cout.write('\n')
537 Term.cout.write('\n')
533 print >>Term.cout, out
538 print >>Term.cout, out
534 else:
539 else:
535 print >>Term.cout, arg
540 print >>Term.cout, arg
536
541
537 # Assign the default display method:
542 # Assign the default display method:
538 display = _display
543 display = _display
539
544
540 def update(self,arg):
545 def update(self,arg):
541 #print '***cache_count', self.cache_count # dbg
546 #print '***cache_count', self.cache_count # dbg
542 if self.cache_count >= self.cache_size and self.do_full_cache:
547 if self.cache_count >= self.cache_size and self.do_full_cache:
543 self.flush()
548 self.flush()
544 # Don't overwrite '_' and friends if '_' is in __builtin__ (otherwise
549 # Don't overwrite '_' and friends if '_' is in __builtin__ (otherwise
545 # we cause buggy behavior for things like gettext).
550 # we cause buggy behavior for things like gettext).
546 if '_' not in __builtin__.__dict__:
551 if '_' not in __builtin__.__dict__:
547 self.___ = self.__
552 self.___ = self.__
548 self.__ = self._
553 self.__ = self._
549 self._ = arg
554 self._ = arg
550 self.user_ns.update({'_':self._,'__':self.__,'___':self.___})
555 self.user_ns.update({'_':self._,'__':self.__,'___':self.___})
551
556
552 # hackish access to top-level namespace to create _1,_2... dynamically
557 # hackish access to top-level namespace to create _1,_2... dynamically
553 to_main = {}
558 to_main = {}
554 if self.do_full_cache:
559 if self.do_full_cache:
555 self.cache_count += 1
560 self.cache_count += 1
556 self.entries.append(arg)
561 self.entries.append(arg)
557 new_result = '_'+`self.prompt_count`
562 new_result = '_'+`self.prompt_count`
558 to_main[new_result] = self.entries[-1]
563 to_main[new_result] = self.entries[-1]
559 self.user_ns.update(to_main)
564 self.user_ns.update(to_main)
560 self.user_ns['_oh'][self.prompt_count] = arg
565 self.user_ns['_oh'][self.prompt_count] = arg
561
566
562 def flush(self):
567 def flush(self):
563 if not self.do_full_cache:
568 if not self.do_full_cache:
564 raise ValueError,"You shouldn't have reached the cache flush "\
569 raise ValueError,"You shouldn't have reached the cache flush "\
565 "if full caching is not enabled!"
570 "if full caching is not enabled!"
566 warn('Output cache limit (currently '+\
571 warn('Output cache limit (currently '+\
567 `self.cache_count`+' entries) hit.\n'
572 `self.cache_count`+' entries) hit.\n'
568 'Flushing cache and resetting history counter...\n'
573 'Flushing cache and resetting history counter...\n'
569 'The only history variables available will be _,__,___ and _1\n'
574 'The only history variables available will be _,__,___ and _1\n'
570 'with the current result.')
575 'with the current result.')
571 # delete auto-generated vars from global namespace
576 # delete auto-generated vars from global namespace
572 for n in range(1,self.prompt_count + 1):
577 for n in range(1,self.prompt_count + 1):
573 key = '_'+`n`
578 key = '_'+`n`
574 try:
579 try:
575 del self.user_ns[key]
580 del self.user_ns[key]
576 except: pass
581 except: pass
577 self.prompt_count = 1
582 self.prompt_count = 1
578 self.cache_count = 1
583 self.cache_count = 1
@@ -1,1997 +1,2060 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.1 or newer.
5 Requires Python 2.1 or newer.
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 965 2005-12-28 23:23:09Z fperez $
9 $Id: iplib.py 966 2005-12-29 08:34:07Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 # Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu>
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #
18 #
19 # Note: this code originally subclassed code.InteractiveConsole from the
19 # Note: this code originally subclassed code.InteractiveConsole from the
20 # Python standard library. Over time, all of that class has been copied
20 # Python standard library. Over time, all of that class has been copied
21 # verbatim here for modifications which could not be accomplished by
21 # verbatim here for modifications which could not be accomplished by
22 # subclassing. At this point, there are no dependencies at all on the code
22 # subclassing. At this point, there are no dependencies at all on the code
23 # module anymore (it is not even imported). The Python License (sec. 2)
23 # module anymore (it is not even imported). The Python License (sec. 2)
24 # allows for this, but it's always nice to acknowledge credit where credit is
24 # allows for this, but it's always nice to acknowledge credit where credit is
25 # due.
25 # due.
26 #*****************************************************************************
26 #*****************************************************************************
27
27
28 #****************************************************************************
28 #****************************************************************************
29 # Modules and globals
29 # Modules and globals
30
30
31 from __future__ import generators # for 2.2 backwards-compatibility
31 from __future__ import generators # for 2.2 backwards-compatibility
32
32
33 from IPython import Release
33 from IPython import Release
34 __author__ = '%s <%s>\n%s <%s>' % \
34 __author__ = '%s <%s>\n%s <%s>' % \
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
36 __license__ = Release.license
36 __license__ = Release.license
37 __version__ = Release.version
37 __version__ = Release.version
38
38
39 # Python standard modules
39 # Python standard modules
40 import __main__
40 import __main__
41 import __builtin__
41 import __builtin__
42 import StringIO
42 import StringIO
43 import bdb
43 import bdb
44 import cPickle as pickle
44 import cPickle as pickle
45 import codeop
45 import codeop
46 import exceptions
46 import exceptions
47 import glob
47 import glob
48 import inspect
48 import inspect
49 import keyword
49 import keyword
50 import new
50 import new
51 import os
51 import os
52 import pdb
52 import pdb
53 import pydoc
53 import pydoc
54 import re
54 import re
55 import shutil
55 import shutil
56 import string
56 import string
57 import sys
57 import sys
58 import traceback
58 import traceback
59 import types
59 import types
60
60
61 from pprint import pprint, pformat
61 from pprint import pprint, pformat
62
62
63 # IPython's own modules
63 # IPython's own modules
64 import IPython
64 import IPython
65 from IPython import OInspect,PyColorize,ultraTB
65 from IPython import OInspect,PyColorize,ultraTB
66 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
66 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
67 from IPython.FakeModule import FakeModule
67 from IPython.FakeModule import FakeModule
68 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
68 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
69 from IPython.Logger import Logger
69 from IPython.Logger import Logger
70 from IPython.Magic import Magic,magic2python
70 from IPython.Magic import Magic
71 from IPython.Prompts import CachedOutput
71 from IPython.Struct import Struct
72 from IPython.Struct import Struct
72 from IPython.background_jobs import BackgroundJobManager
73 from IPython.background_jobs import BackgroundJobManager
73 from IPython.usage import cmd_line_usage,interactive_usage
74 from IPython.usage import cmd_line_usage,interactive_usage
74 from IPython.genutils import *
75 from IPython.genutils import *
75
76
76 # store the builtin raw_input globally, and use this always, in case user code
77 # store the builtin raw_input globally, and use this always, in case user code
77 # overwrites it (like wx.py.PyShell does)
78 # overwrites it (like wx.py.PyShell does)
78 raw_input_original = raw_input
79 raw_input_original = raw_input
79
80
80 #****************************************************************************
81 #****************************************************************************
81 # Some utility function definitions
82 # Some utility function definitions
82
83
83 # This can be replaced with an isspace() call once we drop 2.2 compatibility
84 # This can be replaced with an isspace() call once we drop 2.2 compatibility
84 _isspace_match = re.compile(r'^\s+$').match
85 _isspace_match = re.compile(r'^\s+$').match
85 def isspace(s):
86 def isspace(s):
86 return bool(_isspace_match(s))
87 return bool(_isspace_match(s))
87
88
88 def esc_quotes(strng):
89 def esc_quotes(strng):
89 """Return the input string with single and double quotes escaped out"""
90 """Return the input string with single and double quotes escaped out"""
90
91
91 return strng.replace('"','\\"').replace("'","\\'")
92 return strng.replace('"','\\"').replace("'","\\'")
92
93
93 def import_fail_info(mod_name,fns=None):
94 def import_fail_info(mod_name,fns=None):
94 """Inform load failure for a module."""
95 """Inform load failure for a module."""
95
96
96 if fns == None:
97 if fns == None:
97 warn("Loading of %s failed.\n" % (mod_name,))
98 warn("Loading of %s failed.\n" % (mod_name,))
98 else:
99 else:
99 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
100 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
100
101
101 def qw_lol(indata):
102 def qw_lol(indata):
102 """qw_lol('a b') -> [['a','b']],
103 """qw_lol('a b') -> [['a','b']],
103 otherwise it's just a call to qw().
104 otherwise it's just a call to qw().
104
105
105 We need this to make sure the modules_some keys *always* end up as a
106 We need this to make sure the modules_some keys *always* end up as a
106 list of lists."""
107 list of lists."""
107
108
108 if type(indata) in StringTypes:
109 if type(indata) in StringTypes:
109 return [qw(indata)]
110 return [qw(indata)]
110 else:
111 else:
111 return qw(indata)
112 return qw(indata)
112
113
113 def ipmagic(arg_s):
114 def ipmagic(arg_s):
114 """Call a magic function by name.
115 """Call a magic function by name.
115
116
116 Input: a string containing the name of the magic function to call and any
117 Input: a string containing the name of the magic function to call and any
117 additional arguments to be passed to the magic.
118 additional arguments to be passed to the magic.
118
119
119 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
120 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
120 prompt:
121 prompt:
121
122
122 In[1]: %name -opt foo bar
123 In[1]: %name -opt foo bar
123
124
124 To call a magic without arguments, simply use ipmagic('name').
125 To call a magic without arguments, simply use ipmagic('name').
125
126
126 This provides a proper Python function to call IPython's magics in any
127 This provides a proper Python function to call IPython's magics in any
127 valid Python code you can type at the interpreter, including loops and
128 valid Python code you can type at the interpreter, including loops and
128 compound statements. It is added by IPython to the Python builtin
129 compound statements. It is added by IPython to the Python builtin
129 namespace upon initialization."""
130 namespace upon initialization."""
130
131
131 args = arg_s.split(' ',1)
132 args = arg_s.split(' ',1)
132 magic_name = args[0]
133 magic_name = args[0]
133 if magic_name.startswith(__IPYTHON__.ESC_MAGIC):
134 if magic_name.startswith(__IPYTHON__.ESC_MAGIC):
134 magic_name = magic_name[1:]
135 magic_name = magic_name[1:]
135 try:
136 try:
136 magic_args = args[1]
137 magic_args = args[1]
137 except IndexError:
138 except IndexError:
138 magic_args = ''
139 magic_args = ''
139 fn = getattr(__IPYTHON__,'magic_'+magic_name,None)
140 fn = getattr(__IPYTHON__,'magic_'+magic_name,None)
140 if fn is None:
141 if fn is None:
141 error("Magic function `%s` not found." % magic_name)
142 error("Magic function `%s` not found." % magic_name)
142 else:
143 else:
143 magic_args = __IPYTHON__.var_expand(magic_args)
144 magic_args = __IPYTHON__.var_expand(magic_args)
144 return fn(magic_args)
145 return fn(magic_args)
145
146
146 def ipalias(arg_s):
147 def ipalias(arg_s):
147 """Call an alias by name.
148 """Call an alias by name.
148
149
149 Input: a string containing the name of the alias to call and any
150 Input: a string containing the name of the alias to call and any
150 additional arguments to be passed to the magic.
151 additional arguments to be passed to the magic.
151
152
152 ipalias('name -opt foo bar') is equivalent to typing at the ipython
153 ipalias('name -opt foo bar') is equivalent to typing at the ipython
153 prompt:
154 prompt:
154
155
155 In[1]: name -opt foo bar
156 In[1]: name -opt foo bar
156
157
157 To call an alias without arguments, simply use ipalias('name').
158 To call an alias without arguments, simply use ipalias('name').
158
159
159 This provides a proper Python function to call IPython's aliases in any
160 This provides a proper Python function to call IPython's aliases in any
160 valid Python code you can type at the interpreter, including loops and
161 valid Python code you can type at the interpreter, including loops and
161 compound statements. It is added by IPython to the Python builtin
162 compound statements. It is added by IPython to the Python builtin
162 namespace upon initialization."""
163 namespace upon initialization."""
163
164
164 args = arg_s.split(' ',1)
165 args = arg_s.split(' ',1)
165 alias_name = args[0]
166 alias_name = args[0]
166 try:
167 try:
167 alias_args = args[1]
168 alias_args = args[1]
168 except IndexError:
169 except IndexError:
169 alias_args = ''
170 alias_args = ''
170 if alias_name in __IPYTHON__.alias_table:
171 if alias_name in __IPYTHON__.alias_table:
171 __IPYTHON__.call_alias(alias_name,alias_args)
172 __IPYTHON__.call_alias(alias_name,alias_args)
172 else:
173 else:
173 error("Alias `%s` not found." % alias_name)
174 error("Alias `%s` not found." % alias_name)
174
175
175 def softspace(file, newvalue):
176 def softspace(file, newvalue):
176 """Copied from code.py, to remove the dependency"""
177 """Copied from code.py, to remove the dependency"""
177 oldvalue = 0
178 oldvalue = 0
178 try:
179 try:
179 oldvalue = file.softspace
180 oldvalue = file.softspace
180 except AttributeError:
181 except AttributeError:
181 pass
182 pass
182 try:
183 try:
183 file.softspace = newvalue
184 file.softspace = newvalue
184 except (AttributeError, TypeError):
185 except (AttributeError, TypeError):
185 # "attribute-less object" or "read-only attributes"
186 # "attribute-less object" or "read-only attributes"
186 pass
187 pass
187 return oldvalue
188 return oldvalue
188
189
189
190
190 #****************************************************************************
191 #****************************************************************************
191 # Local use exceptions
192 # Local use exceptions
192 class SpaceInInput(exceptions.Exception): pass
193 class SpaceInInput(exceptions.Exception): pass
193
194
194 #****************************************************************************
195 #****************************************************************************
195 # Local use classes
196 # Local use classes
196 class Bunch: pass
197 class Bunch: pass
197
198
198 class InputList(list):
199 class InputList(list):
199 """Class to store user input.
200 """Class to store user input.
200
201
201 It's basically a list, but slices return a string instead of a list, thus
202 It's basically a list, but slices return a string instead of a list, thus
202 allowing things like (assuming 'In' is an instance):
203 allowing things like (assuming 'In' is an instance):
203
204
204 exec In[4:7]
205 exec In[4:7]
205
206
206 or
207 or
207
208
208 exec In[5:9] + In[14] + In[21:25]"""
209 exec In[5:9] + In[14] + In[21:25]"""
209
210
210 def __getslice__(self,i,j):
211 def __getslice__(self,i,j):
211 return ''.join(list.__getslice__(self,i,j))
212 return ''.join(list.__getslice__(self,i,j))
212
213
213 class SyntaxTB(ultraTB.ListTB):
214 class SyntaxTB(ultraTB.ListTB):
214 """Extension which holds some state: the last exception value"""
215 """Extension which holds some state: the last exception value"""
215
216
216 def __init__(self,color_scheme = 'NoColor'):
217 def __init__(self,color_scheme = 'NoColor'):
217 ultraTB.ListTB.__init__(self,color_scheme)
218 ultraTB.ListTB.__init__(self,color_scheme)
218 self.last_syntax_error = None
219 self.last_syntax_error = None
219
220
220 def __call__(self, etype, value, elist):
221 def __call__(self, etype, value, elist):
221 self.last_syntax_error = value
222 self.last_syntax_error = value
222 ultraTB.ListTB.__call__(self,etype,value,elist)
223 ultraTB.ListTB.__call__(self,etype,value,elist)
223
224
224 def clear_err_state(self):
225 def clear_err_state(self):
225 """Return the current error state and clear it"""
226 """Return the current error state and clear it"""
226 e = self.last_syntax_error
227 e = self.last_syntax_error
227 self.last_syntax_error = None
228 self.last_syntax_error = None
228 return e
229 return e
229
230
230 #****************************************************************************
231 #****************************************************************************
231 # Main IPython class
232 # Main IPython class
232 class InteractiveShell(Logger, Magic):
233
234 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
235 # until a full rewrite is made. I've cleaned all cross-class uses of
236 # attributes and methods, but too much user code out there relies on the
237 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
238 #
239 # But at least now, all the pieces have been separated and we could, in
240 # principle, stop using the mixin. This will ease the transition to the
241 # chainsaw branch.
242
243 # For reference, the following is the list of 'self.foo' uses in the Magic
244 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
245 # class, to prevent clashes.
246
247 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
248 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
249 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
250 # 'self.value']
251
252
253 class InteractiveShell(Magic):
233 """An enhanced console for Python."""
254 """An enhanced console for Python."""
234
255
235 # class attribute to indicate whether the class supports threads or not.
256 # class attribute to indicate whether the class supports threads or not.
236 # Subclasses with thread support should override this as needed.
257 # Subclasses with thread support should override this as needed.
237 isthreaded = False
258 isthreaded = False
238
259
239 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
260 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
240 user_ns = None,user_global_ns=None,banner2='',
261 user_ns = None,user_global_ns=None,banner2='',
241 custom_exceptions=((),None),embedded=False):
262 custom_exceptions=((),None),embedded=False):
242
263
243 # some minimal strict typechecks. For some core data structures, I
264 # some minimal strict typechecks. For some core data structures, I
244 # want actual basic python types, not just anything that looks like
265 # want actual basic python types, not just anything that looks like
245 # one. This is especially true for namespaces.
266 # one. This is especially true for namespaces.
246 for ns in (user_ns,user_global_ns):
267 for ns in (user_ns,user_global_ns):
247 if ns is not None and type(ns) != types.DictType:
268 if ns is not None and type(ns) != types.DictType:
248 raise TypeError,'namespace must be a dictionary'
269 raise TypeError,'namespace must be a dictionary'
249
270
250 # Put a reference to self in builtins so that any form of embedded or
271 # Put a reference to self in builtins so that any form of embedded or
251 # imported code can test for being inside IPython.
272 # imported code can test for being inside IPython.
252 __builtin__.__IPYTHON__ = self
273 __builtin__.__IPYTHON__ = self
253
274
254 # And load into builtins ipmagic/ipalias as well
275 # And load into builtins ipmagic/ipalias as well
255 __builtin__.ipmagic = ipmagic
276 __builtin__.ipmagic = ipmagic
256 __builtin__.ipalias = ipalias
277 __builtin__.ipalias = ipalias
257
278
258 # Add to __builtin__ other parts of IPython's public API
279 # Add to __builtin__ other parts of IPython's public API
259 __builtin__.ip_set_hook = self.set_hook
280 __builtin__.ip_set_hook = self.set_hook
260
281
261 # Keep in the builtins a flag for when IPython is active. We set it
282 # Keep in the builtins a flag for when IPython is active. We set it
262 # with setdefault so that multiple nested IPythons don't clobber one
283 # with setdefault so that multiple nested IPythons don't clobber one
263 # another. Each will increase its value by one upon being activated,
284 # another. Each will increase its value by one upon being activated,
264 # which also gives us a way to determine the nesting level.
285 # which also gives us a way to determine the nesting level.
265 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
286 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
266
287
267 # Do the intuitively correct thing for quit/exit: we remove the
288 # Do the intuitively correct thing for quit/exit: we remove the
268 # builtins if they exist, and our own prefilter routine will handle
289 # builtins if they exist, and our own prefilter routine will handle
269 # these special cases
290 # these special cases
270 try:
291 try:
271 del __builtin__.exit, __builtin__.quit
292 del __builtin__.exit, __builtin__.quit
272 except AttributeError:
293 except AttributeError:
273 pass
294 pass
274
295
275 # Store the actual shell's name
296 # Store the actual shell's name
276 self.name = name
297 self.name = name
277
298
278 # We need to know whether the instance is meant for embedding, since
299 # We need to know whether the instance is meant for embedding, since
279 # global/local namespaces need to be handled differently in that case
300 # global/local namespaces need to be handled differently in that case
280 self.embedded = embedded
301 self.embedded = embedded
281
302
282 # command compiler
303 # command compiler
283 self.compile = codeop.CommandCompiler()
304 self.compile = codeop.CommandCompiler()
284
305
285 # User input buffer
306 # User input buffer
286 self.buffer = []
307 self.buffer = []
287
308
288 # Default name given in compilation of code
309 # Default name given in compilation of code
289 self.filename = '<ipython console>'
310 self.filename = '<ipython console>'
290
311
291 # Create the namespace where the user will operate. user_ns is
312 # Create the namespace where the user will operate. user_ns is
292 # normally the only one used, and it is passed to the exec calls as
313 # normally the only one used, and it is passed to the exec calls as
293 # the locals argument. But we do carry a user_global_ns namespace
314 # the locals argument. But we do carry a user_global_ns namespace
294 # given as the exec 'globals' argument, This is useful in embedding
315 # given as the exec 'globals' argument, This is useful in embedding
295 # situations where the ipython shell opens in a context where the
316 # situations where the ipython shell opens in a context where the
296 # distinction between locals and globals is meaningful.
317 # distinction between locals and globals is meaningful.
297
318
298 # FIXME. For some strange reason, __builtins__ is showing up at user
319 # FIXME. For some strange reason, __builtins__ is showing up at user
299 # level as a dict instead of a module. This is a manual fix, but I
320 # level as a dict instead of a module. This is a manual fix, but I
300 # should really track down where the problem is coming from. Alex
321 # should really track down where the problem is coming from. Alex
301 # Schmolck reported this problem first.
322 # Schmolck reported this problem first.
302
323
303 # A useful post by Alex Martelli on this topic:
324 # A useful post by Alex Martelli on this topic:
304 # Re: inconsistent value from __builtins__
325 # Re: inconsistent value from __builtins__
305 # Von: Alex Martelli <aleaxit@yahoo.com>
326 # Von: Alex Martelli <aleaxit@yahoo.com>
306 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
327 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
307 # Gruppen: comp.lang.python
328 # Gruppen: comp.lang.python
308 # Referenzen: 1
309
329
310 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
330 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
311 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
331 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
312 # > <type 'dict'>
332 # > <type 'dict'>
313 # > >>> print type(__builtins__)
333 # > >>> print type(__builtins__)
314 # > <type 'module'>
334 # > <type 'module'>
315 # > Is this difference in return value intentional?
335 # > Is this difference in return value intentional?
316
336
317 # Well, it's documented that '__builtins__' can be either a dictionary
337 # Well, it's documented that '__builtins__' can be either a dictionary
318 # or a module, and it's been that way for a long time. Whether it's
338 # or a module, and it's been that way for a long time. Whether it's
319 # intentional (or sensible), I don't know. In any case, the idea is
339 # intentional (or sensible), I don't know. In any case, the idea is
320 # that if you need to access the built-in namespace directly, you
340 # that if you need to access the built-in namespace directly, you
321 # should start with "import __builtin__" (note, no 's') which will
341 # should start with "import __builtin__" (note, no 's') which will
322 # definitely give you a module. Yeah, it's somewhat confusing:-(.
342 # definitely give you a module. Yeah, it's somewhat confusing:-(.
323
343
324 if user_ns is None:
344 if user_ns is None:
325 # Set __name__ to __main__ to better match the behavior of the
345 # Set __name__ to __main__ to better match the behavior of the
326 # normal interpreter.
346 # normal interpreter.
327 user_ns = {'__name__' :'__main__',
347 user_ns = {'__name__' :'__main__',
328 '__builtins__' : __builtin__,
348 '__builtins__' : __builtin__,
329 }
349 }
330
350
331 if user_global_ns is None:
351 if user_global_ns is None:
332 user_global_ns = {}
352 user_global_ns = {}
333
353
334 # Assign namespaces
354 # Assign namespaces
335 # This is the namespace where all normal user variables live
355 # This is the namespace where all normal user variables live
336 self.user_ns = user_ns
356 self.user_ns = user_ns
337 # Embedded instances require a separate namespace for globals.
357 # Embedded instances require a separate namespace for globals.
338 # Normally this one is unused by non-embedded instances.
358 # Normally this one is unused by non-embedded instances.
339 self.user_global_ns = user_global_ns
359 self.user_global_ns = user_global_ns
340 # A namespace to keep track of internal data structures to prevent
360 # A namespace to keep track of internal data structures to prevent
341 # them from cluttering user-visible stuff. Will be updated later
361 # them from cluttering user-visible stuff. Will be updated later
342 self.internal_ns = {}
362 self.internal_ns = {}
343
363
344 # Namespace of system aliases. Each entry in the alias
364 # Namespace of system aliases. Each entry in the alias
345 # table must be a 2-tuple of the form (N,name), where N is the number
365 # table must be a 2-tuple of the form (N,name), where N is the number
346 # of positional arguments of the alias.
366 # of positional arguments of the alias.
347 self.alias_table = {}
367 self.alias_table = {}
348
368
349 # A table holding all the namespaces IPython deals with, so that
369 # A table holding all the namespaces IPython deals with, so that
350 # introspection facilities can search easily.
370 # introspection facilities can search easily.
351 self.ns_table = {'user':user_ns,
371 self.ns_table = {'user':user_ns,
352 'user_global':user_global_ns,
372 'user_global':user_global_ns,
353 'alias':self.alias_table,
373 'alias':self.alias_table,
354 'internal':self.internal_ns,
374 'internal':self.internal_ns,
355 'builtin':__builtin__.__dict__
375 'builtin':__builtin__.__dict__
356 }
376 }
357
377
358 # The user namespace MUST have a pointer to the shell itself.
378 # The user namespace MUST have a pointer to the shell itself.
359 self.user_ns[name] = self
379 self.user_ns[name] = self
360
380
361 # We need to insert into sys.modules something that looks like a
381 # We need to insert into sys.modules something that looks like a
362 # module but which accesses the IPython namespace, for shelve and
382 # module but which accesses the IPython namespace, for shelve and
363 # pickle to work interactively. Normally they rely on getting
383 # pickle to work interactively. Normally they rely on getting
364 # everything out of __main__, but for embedding purposes each IPython
384 # everything out of __main__, but for embedding purposes each IPython
365 # instance has its own private namespace, so we can't go shoving
385 # instance has its own private namespace, so we can't go shoving
366 # everything into __main__.
386 # everything into __main__.
367
387
368 # note, however, that we should only do this for non-embedded
388 # note, however, that we should only do this for non-embedded
369 # ipythons, which really mimic the __main__.__dict__ with their own
389 # ipythons, which really mimic the __main__.__dict__ with their own
370 # namespace. Embedded instances, on the other hand, should not do
390 # namespace. Embedded instances, on the other hand, should not do
371 # this because they need to manage the user local/global namespaces
391 # this because they need to manage the user local/global namespaces
372 # only, but they live within a 'normal' __main__ (meaning, they
392 # only, but they live within a 'normal' __main__ (meaning, they
373 # shouldn't overtake the execution environment of the script they're
393 # shouldn't overtake the execution environment of the script they're
374 # embedded in).
394 # embedded in).
375
395
376 if not embedded:
396 if not embedded:
377 try:
397 try:
378 main_name = self.user_ns['__name__']
398 main_name = self.user_ns['__name__']
379 except KeyError:
399 except KeyError:
380 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
400 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
381 else:
401 else:
382 #print "pickle hack in place" # dbg
402 #print "pickle hack in place" # dbg
383 sys.modules[main_name] = FakeModule(self.user_ns)
403 sys.modules[main_name] = FakeModule(self.user_ns)
384
404
385 # List of input with multi-line handling.
405 # List of input with multi-line handling.
386 # Fill its zero entry, user counter starts at 1
406 # Fill its zero entry, user counter starts at 1
387 self.input_hist = InputList(['\n'])
407 self.input_hist = InputList(['\n'])
388
408
389 # list of visited directories
409 # list of visited directories
390 try:
410 try:
391 self.dir_hist = [os.getcwd()]
411 self.dir_hist = [os.getcwd()]
392 except IOError, e:
412 except IOError, e:
393 self.dir_hist = []
413 self.dir_hist = []
394
414
395 # dict of output history
415 # dict of output history
396 self.output_hist = {}
416 self.output_hist = {}
397
417
398 # dict of things NOT to alias (keywords, builtins and some magics)
418 # dict of things NOT to alias (keywords, builtins and some magics)
399 no_alias = {}
419 no_alias = {}
400 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
420 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
401 for key in keyword.kwlist + no_alias_magics:
421 for key in keyword.kwlist + no_alias_magics:
402 no_alias[key] = 1
422 no_alias[key] = 1
403 no_alias.update(__builtin__.__dict__)
423 no_alias.update(__builtin__.__dict__)
404 self.no_alias = no_alias
424 self.no_alias = no_alias
405
425
406 # make global variables for user access to these
426 # make global variables for user access to these
407 self.user_ns['_ih'] = self.input_hist
427 self.user_ns['_ih'] = self.input_hist
408 self.user_ns['_oh'] = self.output_hist
428 self.user_ns['_oh'] = self.output_hist
409 self.user_ns['_dh'] = self.dir_hist
429 self.user_ns['_dh'] = self.dir_hist
410
430
411 # user aliases to input and output histories
431 # user aliases to input and output histories
412 self.user_ns['In'] = self.input_hist
432 self.user_ns['In'] = self.input_hist
413 self.user_ns['Out'] = self.output_hist
433 self.user_ns['Out'] = self.output_hist
414
434
415 # Object variable to store code object waiting execution. This is
435 # Object variable to store code object waiting execution. This is
416 # used mainly by the multithreaded shells, but it can come in handy in
436 # used mainly by the multithreaded shells, but it can come in handy in
417 # other situations. No need to use a Queue here, since it's a single
437 # other situations. No need to use a Queue here, since it's a single
418 # item which gets cleared once run.
438 # item which gets cleared once run.
419 self.code_to_run = None
439 self.code_to_run = None
420
440
421 # Job manager (for jobs run as background threads)
441 # Job manager (for jobs run as background threads)
422 self.jobs = BackgroundJobManager()
442 self.jobs = BackgroundJobManager()
423 # Put the job manager into builtins so it's always there.
443 # Put the job manager into builtins so it's always there.
424 __builtin__.jobs = self.jobs
444 __builtin__.jobs = self.jobs
425
445
426 # escapes for automatic behavior on the command line
446 # escapes for automatic behavior on the command line
427 self.ESC_SHELL = '!'
447 self.ESC_SHELL = '!'
428 self.ESC_HELP = '?'
448 self.ESC_HELP = '?'
429 self.ESC_MAGIC = '%'
449 self.ESC_MAGIC = '%'
430 self.ESC_QUOTE = ','
450 self.ESC_QUOTE = ','
431 self.ESC_QUOTE2 = ';'
451 self.ESC_QUOTE2 = ';'
432 self.ESC_PAREN = '/'
452 self.ESC_PAREN = '/'
433
453
434 # And their associated handlers
454 # And their associated handlers
435 self.esc_handlers = {self.ESC_PAREN:self.handle_auto,
455 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
436 self.ESC_QUOTE:self.handle_auto,
456 self.ESC_QUOTE : self.handle_auto,
437 self.ESC_QUOTE2:self.handle_auto,
457 self.ESC_QUOTE2 : self.handle_auto,
438 self.ESC_MAGIC:self.handle_magic,
458 self.ESC_MAGIC : self.handle_magic,
439 self.ESC_HELP:self.handle_help,
459 self.ESC_HELP : self.handle_help,
440 self.ESC_SHELL:self.handle_shell_escape,
460 self.ESC_SHELL : self.handle_shell_escape,
441 }
461 }
442
462
443 # class initializations
463 # class initializations
444 Logger.__init__(self,log_ns = self.user_ns)
445 Magic.__init__(self,self)
464 Magic.__init__(self,self)
446
465
447 # an ugly hack to get a pointer to the shell, so I can start writing
448 # magic code via this pointer instead of the current mixin salad.
449 Magic.set_shell(self,self)
450
451 # Python source parser/formatter for syntax highlighting
466 # Python source parser/formatter for syntax highlighting
452 pyformat = PyColorize.Parser().format
467 pyformat = PyColorize.Parser().format
453 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
468 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
454
469
455 # hooks holds pointers used for user-side customizations
470 # hooks holds pointers used for user-side customizations
456 self.hooks = Struct()
471 self.hooks = Struct()
457
472
458 # Set all default hooks, defined in the IPython.hooks module.
473 # Set all default hooks, defined in the IPython.hooks module.
459 hooks = IPython.hooks
474 hooks = IPython.hooks
460 for hook_name in hooks.__all__:
475 for hook_name in hooks.__all__:
461 self.set_hook(hook_name,getattr(hooks,hook_name))
476 self.set_hook(hook_name,getattr(hooks,hook_name))
462
477
463 # Flag to mark unconditional exit
478 # Flag to mark unconditional exit
464 self.exit_now = False
479 self.exit_now = False
465
480
466 self.usage_min = """\
481 self.usage_min = """\
467 An enhanced console for Python.
482 An enhanced console for Python.
468 Some of its features are:
483 Some of its features are:
469 - Readline support if the readline library is present.
484 - Readline support if the readline library is present.
470 - Tab completion in the local namespace.
485 - Tab completion in the local namespace.
471 - Logging of input, see command-line options.
486 - Logging of input, see command-line options.
472 - System shell escape via ! , eg !ls.
487 - System shell escape via ! , eg !ls.
473 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
488 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
474 - Keeps track of locally defined variables via %who, %whos.
489 - Keeps track of locally defined variables via %who, %whos.
475 - Show object information with a ? eg ?x or x? (use ?? for more info).
490 - Show object information with a ? eg ?x or x? (use ?? for more info).
476 """
491 """
477 if usage: self.usage = usage
492 if usage: self.usage = usage
478 else: self.usage = self.usage_min
493 else: self.usage = self.usage_min
479
494
480 # Storage
495 # Storage
481 self.rc = rc # This will hold all configuration information
496 self.rc = rc # This will hold all configuration information
482 self.inputcache = []
497 self.inputcache = []
483 self._boundcache = []
498 self._boundcache = []
484 self.pager = 'less'
499 self.pager = 'less'
485 # temporary files used for various purposes. Deleted at exit.
500 # temporary files used for various purposes. Deleted at exit.
486 self.tempfiles = []
501 self.tempfiles = []
487
502
488 # Keep track of readline usage (later set by init_readline)
503 # Keep track of readline usage (later set by init_readline)
489 self.has_readline = False
504 self.has_readline = False
490
505
506 # template for logfile headers. It gets resolved at runtime by the
507 # logstart method.
508 self.loghead_tpl = \
509 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
510 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
511 #log# opts = %s
512 #log# args = %s
513 #log# It is safe to make manual edits below here.
514 #log#-----------------------------------------------------------------------
515 """
491 # for pushd/popd management
516 # for pushd/popd management
492 try:
517 try:
493 self.home_dir = get_home_dir()
518 self.home_dir = get_home_dir()
494 except HomeDirError,msg:
519 except HomeDirError,msg:
495 fatal(msg)
520 fatal(msg)
496
521
497 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
522 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
498
523
499 # Functions to call the underlying shell.
524 # Functions to call the underlying shell.
500
525
501 # utility to expand user variables via Itpl
526 # utility to expand user variables via Itpl
502 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
527 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
503 self.user_ns))
528 self.user_ns))
504 # The first is similar to os.system, but it doesn't return a value,
529 # The first is similar to os.system, but it doesn't return a value,
505 # and it allows interpolation of variables in the user's namespace.
530 # and it allows interpolation of variables in the user's namespace.
506 self.system = lambda cmd: shell(self.var_expand(cmd),
531 self.system = lambda cmd: shell(self.var_expand(cmd),
507 header='IPython system call: ',
532 header='IPython system call: ',
508 verbose=self.rc.system_verbose)
533 verbose=self.rc.system_verbose)
509 # These are for getoutput and getoutputerror:
534 # These are for getoutput and getoutputerror:
510 self.getoutput = lambda cmd: \
535 self.getoutput = lambda cmd: \
511 getoutput(self.var_expand(cmd),
536 getoutput(self.var_expand(cmd),
512 header='IPython system call: ',
537 header='IPython system call: ',
513 verbose=self.rc.system_verbose)
538 verbose=self.rc.system_verbose)
514 self.getoutputerror = lambda cmd: \
539 self.getoutputerror = lambda cmd: \
515 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
540 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
516 self.user_ns)),
541 self.user_ns)),
517 header='IPython system call: ',
542 header='IPython system call: ',
518 verbose=self.rc.system_verbose)
543 verbose=self.rc.system_verbose)
519
544
520 # RegExp for splitting line contents into pre-char//first
545 # RegExp for splitting line contents into pre-char//first
521 # word-method//rest. For clarity, each group in on one line.
546 # word-method//rest. For clarity, each group in on one line.
522
547
523 # WARNING: update the regexp if the above escapes are changed, as they
548 # WARNING: update the regexp if the above escapes are changed, as they
524 # are hardwired in.
549 # are hardwired in.
525
550
526 # Don't get carried away with trying to make the autocalling catch too
551 # Don't get carried away with trying to make the autocalling catch too
527 # much: it's better to be conservative rather than to trigger hidden
552 # much: it's better to be conservative rather than to trigger hidden
528 # evals() somewhere and end up causing side effects.
553 # evals() somewhere and end up causing side effects.
529
554
530 self.line_split = re.compile(r'^([\s*,;/])'
555 self.line_split = re.compile(r'^([\s*,;/])'
531 r'([\?\w\.]+\w*\s*)'
556 r'([\?\w\.]+\w*\s*)'
532 r'(\(?.*$)')
557 r'(\(?.*$)')
533
558
534 # Original re, keep around for a while in case changes break something
559 # Original re, keep around for a while in case changes break something
535 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
560 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
536 # r'(\s*[\?\w\.]+\w*\s*)'
561 # r'(\s*[\?\w\.]+\w*\s*)'
537 # r'(\(?.*$)')
562 # r'(\(?.*$)')
538
563
539 # RegExp to identify potential function names
564 # RegExp to identify potential function names
540 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
565 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
541 # RegExp to exclude strings with this start from autocalling
566 # RegExp to exclude strings with this start from autocalling
542 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
567 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
543
568
544 # try to catch also methods for stuff in lists/tuples/dicts: off
569 # try to catch also methods for stuff in lists/tuples/dicts: off
545 # (experimental). For this to work, the line_split regexp would need
570 # (experimental). For this to work, the line_split regexp would need
546 # to be modified so it wouldn't break things at '['. That line is
571 # to be modified so it wouldn't break things at '['. That line is
547 # nasty enough that I shouldn't change it until I can test it _well_.
572 # nasty enough that I shouldn't change it until I can test it _well_.
548 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
573 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
549
574
550 # keep track of where we started running (mainly for crash post-mortem)
575 # keep track of where we started running (mainly for crash post-mortem)
551 self.starting_dir = os.getcwd()
576 self.starting_dir = os.getcwd()
552
577
553 # Attributes for Logger mixin class, make defaults here
554 self._dolog = False
555 self.LOG = ''
556 self.LOGDEF = '.InteractiveShell.log'
557 self.LOGMODE = 'over'
558 self.LOGHEAD = Itpl(
559 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
560 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
561 #log# opts = $self.rc.opts
562 #log# args = $self.rc.args
563 #log# It is safe to make manual edits below here.
564 #log#-----------------------------------------------------------------------
565 """)
566 # Various switches which can be set
578 # Various switches which can be set
567 self.CACHELENGTH = 5000 # this is cheap, it's just text
579 self.CACHELENGTH = 5000 # this is cheap, it's just text
568 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
580 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
569 self.banner2 = banner2
581 self.banner2 = banner2
570
582
571 # TraceBack handlers:
583 # TraceBack handlers:
572
584
573 # Syntax error handler.
585 # Syntax error handler.
574 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
586 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
575
587
576 # The interactive one is initialized with an offset, meaning we always
588 # The interactive one is initialized with an offset, meaning we always
577 # want to remove the topmost item in the traceback, which is our own
589 # want to remove the topmost item in the traceback, which is our own
578 # internal code. Valid modes: ['Plain','Context','Verbose']
590 # internal code. Valid modes: ['Plain','Context','Verbose']
579 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
591 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
580 color_scheme='NoColor',
592 color_scheme='NoColor',
581 tb_offset = 1)
593 tb_offset = 1)
582
594
583 # IPython itself shouldn't crash. This will produce a detailed
595 # IPython itself shouldn't crash. This will produce a detailed
584 # post-mortem if it does. But we only install the crash handler for
596 # post-mortem if it does. But we only install the crash handler for
585 # non-threaded shells, the threaded ones use a normal verbose reporter
597 # non-threaded shells, the threaded ones use a normal verbose reporter
586 # and lose the crash handler. This is because exceptions in the main
598 # and lose the crash handler. This is because exceptions in the main
587 # thread (such as in GUI code) propagate directly to sys.excepthook,
599 # thread (such as in GUI code) propagate directly to sys.excepthook,
588 # and there's no point in printing crash dumps for every user exception.
600 # and there's no point in printing crash dumps for every user exception.
589 if self.isthreaded:
601 if self.isthreaded:
590 sys.excepthook = ultraTB.FormattedTB()
602 sys.excepthook = ultraTB.FormattedTB()
591 else:
603 else:
592 from IPython import CrashHandler
604 from IPython import CrashHandler
593 sys.excepthook = CrashHandler.CrashHandler(self)
605 sys.excepthook = CrashHandler.CrashHandler(self)
594
606
595 # The instance will store a pointer to this, so that runtime code
607 # The instance will store a pointer to this, so that runtime code
596 # (such as magics) can access it. This is because during the
608 # (such as magics) can access it. This is because during the
597 # read-eval loop, it gets temporarily overwritten (to deal with GUI
609 # read-eval loop, it gets temporarily overwritten (to deal with GUI
598 # frameworks).
610 # frameworks).
599 self.sys_excepthook = sys.excepthook
611 self.sys_excepthook = sys.excepthook
600
612
601 # and add any custom exception handlers the user may have specified
613 # and add any custom exception handlers the user may have specified
602 self.set_custom_exc(*custom_exceptions)
614 self.set_custom_exc(*custom_exceptions)
603
615
604 # Object inspector
616 # Object inspector
605 self.inspector = OInspect.Inspector(OInspect.InspectColors,
617 self.inspector = OInspect.Inspector(OInspect.InspectColors,
606 PyColorize.ANSICodeColors,
618 PyColorize.ANSICodeColors,
607 'NoColor')
619 'NoColor')
608 # indentation management
620 # indentation management
609 self.autoindent = False
621 self.autoindent = False
610 self.indent_current_nsp = 0
622 self.indent_current_nsp = 0
611 self.indent_current = '' # actual indent string
623 self.indent_current = '' # actual indent string
612
624
613 # Make some aliases automatically
625 # Make some aliases automatically
614 # Prepare list of shell aliases to auto-define
626 # Prepare list of shell aliases to auto-define
615 if os.name == 'posix':
627 if os.name == 'posix':
616 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
628 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
617 'mv mv -i','rm rm -i','cp cp -i',
629 'mv mv -i','rm rm -i','cp cp -i',
618 'cat cat','less less','clear clear',
630 'cat cat','less less','clear clear',
619 # a better ls
631 # a better ls
620 'ls ls -F',
632 'ls ls -F',
621 # long ls
633 # long ls
622 'll ls -lF',
634 'll ls -lF',
623 # color ls
635 # color ls
624 'lc ls -F -o --color',
636 'lc ls -F -o --color',
625 # ls normal files only
637 # ls normal files only
626 'lf ls -F -o --color %l | grep ^-',
638 'lf ls -F -o --color %l | grep ^-',
627 # ls symbolic links
639 # ls symbolic links
628 'lk ls -F -o --color %l | grep ^l',
640 'lk ls -F -o --color %l | grep ^l',
629 # directories or links to directories,
641 # directories or links to directories,
630 'ldir ls -F -o --color %l | grep /$',
642 'ldir ls -F -o --color %l | grep /$',
631 # things which are executable
643 # things which are executable
632 'lx ls -F -o --color %l | grep ^-..x',
644 'lx ls -F -o --color %l | grep ^-..x',
633 )
645 )
634 elif os.name in ['nt','dos']:
646 elif os.name in ['nt','dos']:
635 auto_alias = ('dir dir /on', 'ls dir /on',
647 auto_alias = ('dir dir /on', 'ls dir /on',
636 'ddir dir /ad /on', 'ldir dir /ad /on',
648 'ddir dir /ad /on', 'ldir dir /ad /on',
637 'mkdir mkdir','rmdir rmdir','echo echo',
649 'mkdir mkdir','rmdir rmdir','echo echo',
638 'ren ren','cls cls','copy copy')
650 'ren ren','cls cls','copy copy')
639 else:
651 else:
640 auto_alias = ()
652 auto_alias = ()
641 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
653 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
642 # Call the actual (public) initializer
654 # Call the actual (public) initializer
643 self.init_auto_alias()
655 self.init_auto_alias()
644 # end __init__
656 # end __init__
645
657
646 def post_config_initialization(self):
658 def post_config_initialization(self):
647 """Post configuration init method
659 """Post configuration init method
648
660
649 This is called after the configuration files have been processed to
661 This is called after the configuration files have been processed to
650 'finalize' the initialization."""
662 'finalize' the initialization."""
651
663
652 rc = self.rc
664 rc = self.rc
653
665
654 # Load readline proper
666 # Load readline proper
655 if rc.readline:
667 if rc.readline:
656 self.init_readline()
668 self.init_readline()
657
669
670 # log system
671 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
672 # local shortcut, this is used a LOT
673 self.log = self.logger.log
674
675 # Initialize cache, set in/out prompts and printing system
676 self.outputcache = CachedOutput(self,
677 rc.cache_size,
678 rc.pprint,
679 input_sep = rc.separate_in,
680 output_sep = rc.separate_out,
681 output_sep2 = rc.separate_out2,
682 ps1 = rc.prompt_in1,
683 ps2 = rc.prompt_in2,
684 ps_out = rc.prompt_out,
685 pad_left = rc.prompts_pad_left)
686
687 # user may have over-ridden the default print hook:
688 try:
689 self.outputcache.__class__.display = self.hooks.display
690 except AttributeError:
691 pass
692
693 # I don't like assigning globally to sys, because it means when embedding
694 # instances, each embedded instance overrides the previous choice. But
695 # sys.displayhook seems to be called internally by exec, so I don't see a
696 # way around it.
697 sys.displayhook = self.outputcache
698
658 # Set user colors (don't do it in the constructor above so that it
699 # Set user colors (don't do it in the constructor above so that it
659 # doesn't crash if colors option is invalid)
700 # doesn't crash if colors option is invalid)
660 self.magic_colors(rc.colors)
701 self.magic_colors(rc.colors)
661
702
703 # Set calling of pdb on exceptions
704 self.call_pdb = rc.pdb
705
662 # Load user aliases
706 # Load user aliases
663 for alias in rc.alias:
707 for alias in rc.alias:
664 self.magic_alias(alias)
708 self.magic_alias(alias)
665
709
666 # dynamic data that survives through sessions
710 # dynamic data that survives through sessions
667 # XXX make the filename a config option?
711 # XXX make the filename a config option?
668 persist_base = 'persist'
712 persist_base = 'persist'
669 if rc.profile:
713 if rc.profile:
670 persist_base += '_%s' % rc.profile
714 persist_base += '_%s' % rc.profile
671 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
715 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
672
716
673 try:
717 try:
674 self.persist = pickle.load(file(self.persist_fname))
718 self.persist = pickle.load(file(self.persist_fname))
675 except:
719 except:
676 self.persist = {}
720 self.persist = {}
677
721
678 def set_hook(self,name,hook):
722 def set_hook(self,name,hook):
679 """set_hook(name,hook) -> sets an internal IPython hook.
723 """set_hook(name,hook) -> sets an internal IPython hook.
680
724
681 IPython exposes some of its internal API as user-modifiable hooks. By
725 IPython exposes some of its internal API as user-modifiable hooks. By
682 resetting one of these hooks, you can modify IPython's behavior to
726 resetting one of these hooks, you can modify IPython's behavior to
683 call at runtime your own routines."""
727 call at runtime your own routines."""
684
728
685 # At some point in the future, this should validate the hook before it
729 # At some point in the future, this should validate the hook before it
686 # accepts it. Probably at least check that the hook takes the number
730 # accepts it. Probably at least check that the hook takes the number
687 # of args it's supposed to.
731 # of args it's supposed to.
688 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
732 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
689
733
690 def set_custom_exc(self,exc_tuple,handler):
734 def set_custom_exc(self,exc_tuple,handler):
691 """set_custom_exc(exc_tuple,handler)
735 """set_custom_exc(exc_tuple,handler)
692
736
693 Set a custom exception handler, which will be called if any of the
737 Set a custom exception handler, which will be called if any of the
694 exceptions in exc_tuple occur in the mainloop (specifically, in the
738 exceptions in exc_tuple occur in the mainloop (specifically, in the
695 runcode() method.
739 runcode() method.
696
740
697 Inputs:
741 Inputs:
698
742
699 - exc_tuple: a *tuple* of valid exceptions to call the defined
743 - exc_tuple: a *tuple* of valid exceptions to call the defined
700 handler for. It is very important that you use a tuple, and NOT A
744 handler for. It is very important that you use a tuple, and NOT A
701 LIST here, because of the way Python's except statement works. If
745 LIST here, because of the way Python's except statement works. If
702 you only want to trap a single exception, use a singleton tuple:
746 you only want to trap a single exception, use a singleton tuple:
703
747
704 exc_tuple == (MyCustomException,)
748 exc_tuple == (MyCustomException,)
705
749
706 - handler: this must be defined as a function with the following
750 - handler: this must be defined as a function with the following
707 basic interface: def my_handler(self,etype,value,tb).
751 basic interface: def my_handler(self,etype,value,tb).
708
752
709 This will be made into an instance method (via new.instancemethod)
753 This will be made into an instance method (via new.instancemethod)
710 of IPython itself, and it will be called if any of the exceptions
754 of IPython itself, and it will be called if any of the exceptions
711 listed in the exc_tuple are caught. If the handler is None, an
755 listed in the exc_tuple are caught. If the handler is None, an
712 internal basic one is used, which just prints basic info.
756 internal basic one is used, which just prints basic info.
713
757
714 WARNING: by putting in your own exception handler into IPython's main
758 WARNING: by putting in your own exception handler into IPython's main
715 execution loop, you run a very good chance of nasty crashes. This
759 execution loop, you run a very good chance of nasty crashes. This
716 facility should only be used if you really know what you are doing."""
760 facility should only be used if you really know what you are doing."""
717
761
718 assert type(exc_tuple)==type(()) , \
762 assert type(exc_tuple)==type(()) , \
719 "The custom exceptions must be given AS A TUPLE."
763 "The custom exceptions must be given AS A TUPLE."
720
764
721 def dummy_handler(self,etype,value,tb):
765 def dummy_handler(self,etype,value,tb):
722 print '*** Simple custom exception handler ***'
766 print '*** Simple custom exception handler ***'
723 print 'Exception type :',etype
767 print 'Exception type :',etype
724 print 'Exception value:',value
768 print 'Exception value:',value
725 print 'Traceback :',tb
769 print 'Traceback :',tb
726 print 'Source code :','\n'.join(self.buffer)
770 print 'Source code :','\n'.join(self.buffer)
727
771
728 if handler is None: handler = dummy_handler
772 if handler is None: handler = dummy_handler
729
773
730 self.CustomTB = new.instancemethod(handler,self,self.__class__)
774 self.CustomTB = new.instancemethod(handler,self,self.__class__)
731 self.custom_exceptions = exc_tuple
775 self.custom_exceptions = exc_tuple
732
776
733 def set_custom_completer(self,completer,pos=0):
777 def set_custom_completer(self,completer,pos=0):
734 """set_custom_completer(completer,pos=0)
778 """set_custom_completer(completer,pos=0)
735
779
736 Adds a new custom completer function.
780 Adds a new custom completer function.
737
781
738 The position argument (defaults to 0) is the index in the completers
782 The position argument (defaults to 0) is the index in the completers
739 list where you want the completer to be inserted."""
783 list where you want the completer to be inserted."""
740
784
741 newcomp = new.instancemethod(completer,self.Completer,
785 newcomp = new.instancemethod(completer,self.Completer,
742 self.Completer.__class__)
786 self.Completer.__class__)
743 self.Completer.matchers.insert(pos,newcomp)
787 self.Completer.matchers.insert(pos,newcomp)
744
788
789 def _get_call_pdb(self):
790 return self._call_pdb
791
792 def _set_call_pdb(self,val):
793
794 if val not in (0,1,False,True):
795 raise ValueError,'new call_pdb value must be boolean'
796
797 # store value in instance
798 self._call_pdb = val
799
800 # notify the actual exception handlers
801 self.InteractiveTB.call_pdb = val
802 if self.isthreaded:
803 try:
804 self.sys_excepthook.call_pdb = val
805 except:
806 warn('Failed to activate pdb for threaded exception handler')
807
808 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
809 'Control auto-activation of pdb at exceptions')
810
745 def complete(self,text):
811 def complete(self,text):
746 """Return a sorted list of all possible completions on text.
812 """Return a sorted list of all possible completions on text.
747
813
748 Inputs:
814 Inputs:
749
815
750 - text: a string of text to be completed on.
816 - text: a string of text to be completed on.
751
817
752 This is a wrapper around the completion mechanism, similar to what
818 This is a wrapper around the completion mechanism, similar to what
753 readline does at the command line when the TAB key is hit. By
819 readline does at the command line when the TAB key is hit. By
754 exposing it as a method, it can be used by other non-readline
820 exposing it as a method, it can be used by other non-readline
755 environments (such as GUIs) for text completion.
821 environments (such as GUIs) for text completion.
756
822
757 Simple usage example:
823 Simple usage example:
758
824
759 In [1]: x = 'hello'
825 In [1]: x = 'hello'
760
826
761 In [2]: __IP.complete('x.l')
827 In [2]: __IP.complete('x.l')
762 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
828 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
763
829
764 complete = self.Completer.complete
830 complete = self.Completer.complete
765 state = 0
831 state = 0
766 # use a dict so we get unique keys, since ipyhton's multiple
832 # use a dict so we get unique keys, since ipyhton's multiple
767 # completers can return duplicates.
833 # completers can return duplicates.
768 comps = {}
834 comps = {}
769 while True:
835 while True:
770 newcomp = complete(text,state)
836 newcomp = complete(text,state)
771 if newcomp is None:
837 if newcomp is None:
772 break
838 break
773 comps[newcomp] = 1
839 comps[newcomp] = 1
774 state += 1
840 state += 1
775 outcomps = comps.keys()
841 outcomps = comps.keys()
776 outcomps.sort()
842 outcomps.sort()
777 return outcomps
843 return outcomps
778
844
779 def set_completer_frame(self, frame):
845 def set_completer_frame(self, frame):
780 if frame:
846 if frame:
781 self.Completer.namespace = frame.f_locals
847 self.Completer.namespace = frame.f_locals
782 self.Completer.global_namespace = frame.f_globals
848 self.Completer.global_namespace = frame.f_globals
783 else:
849 else:
784 self.Completer.namespace = self.user_ns
850 self.Completer.namespace = self.user_ns
785 self.Completer.global_namespace = self.user_global_ns
851 self.Completer.global_namespace = self.user_global_ns
786
852
787 def init_auto_alias(self):
853 def init_auto_alias(self):
788 """Define some aliases automatically.
854 """Define some aliases automatically.
789
855
790 These are ALL parameter-less aliases"""
856 These are ALL parameter-less aliases"""
791 for alias,cmd in self.auto_alias:
857 for alias,cmd in self.auto_alias:
792 self.alias_table[alias] = (0,cmd)
858 self.alias_table[alias] = (0,cmd)
793
859
794 def alias_table_validate(self,verbose=0):
860 def alias_table_validate(self,verbose=0):
795 """Update information about the alias table.
861 """Update information about the alias table.
796
862
797 In particular, make sure no Python keywords/builtins are in it."""
863 In particular, make sure no Python keywords/builtins are in it."""
798
864
799 no_alias = self.no_alias
865 no_alias = self.no_alias
800 for k in self.alias_table.keys():
866 for k in self.alias_table.keys():
801 if k in no_alias:
867 if k in no_alias:
802 del self.alias_table[k]
868 del self.alias_table[k]
803 if verbose:
869 if verbose:
804 print ("Deleting alias <%s>, it's a Python "
870 print ("Deleting alias <%s>, it's a Python "
805 "keyword or builtin." % k)
871 "keyword or builtin." % k)
806
872
807 def set_autoindent(self,value=None):
873 def set_autoindent(self,value=None):
808 """Set the autoindent flag, checking for readline support.
874 """Set the autoindent flag, checking for readline support.
809
875
810 If called with no arguments, it acts as a toggle."""
876 If called with no arguments, it acts as a toggle."""
811
877
812 if not self.has_readline:
878 if not self.has_readline:
813 if os.name == 'posix':
879 if os.name == 'posix':
814 warn("The auto-indent feature requires the readline library")
880 warn("The auto-indent feature requires the readline library")
815 self.autoindent = 0
881 self.autoindent = 0
816 return
882 return
817 if value is None:
883 if value is None:
818 self.autoindent = not self.autoindent
884 self.autoindent = not self.autoindent
819 else:
885 else:
820 self.autoindent = value
886 self.autoindent = value
821
887
822 def rc_set_toggle(self,rc_field,value=None):
888 def rc_set_toggle(self,rc_field,value=None):
823 """Set or toggle a field in IPython's rc config. structure.
889 """Set or toggle a field in IPython's rc config. structure.
824
890
825 If called with no arguments, it acts as a toggle.
891 If called with no arguments, it acts as a toggle.
826
892
827 If called with a non-existent field, the resulting AttributeError
893 If called with a non-existent field, the resulting AttributeError
828 exception will propagate out."""
894 exception will propagate out."""
829
895
830 rc_val = getattr(self.rc,rc_field)
896 rc_val = getattr(self.rc,rc_field)
831 if value is None:
897 if value is None:
832 value = not rc_val
898 value = not rc_val
833 setattr(self.rc,rc_field,value)
899 setattr(self.rc,rc_field,value)
834
900
835 def user_setup(self,ipythondir,rc_suffix,mode='install'):
901 def user_setup(self,ipythondir,rc_suffix,mode='install'):
836 """Install the user configuration directory.
902 """Install the user configuration directory.
837
903
838 Can be called when running for the first time or to upgrade the user's
904 Can be called when running for the first time or to upgrade the user's
839 .ipython/ directory with the mode parameter. Valid modes are 'install'
905 .ipython/ directory with the mode parameter. Valid modes are 'install'
840 and 'upgrade'."""
906 and 'upgrade'."""
841
907
842 def wait():
908 def wait():
843 try:
909 try:
844 raw_input("Please press <RETURN> to start IPython.")
910 raw_input("Please press <RETURN> to start IPython.")
845 except EOFError:
911 except EOFError:
846 print >> Term.cout
912 print >> Term.cout
847 print '*'*70
913 print '*'*70
848
914
849 cwd = os.getcwd() # remember where we started
915 cwd = os.getcwd() # remember where we started
850 glb = glob.glob
916 glb = glob.glob
851 print '*'*70
917 print '*'*70
852 if mode == 'install':
918 if mode == 'install':
853 print \
919 print \
854 """Welcome to IPython. I will try to create a personal configuration directory
920 """Welcome to IPython. I will try to create a personal configuration directory
855 where you can customize many aspects of IPython's functionality in:\n"""
921 where you can customize many aspects of IPython's functionality in:\n"""
856 else:
922 else:
857 print 'I am going to upgrade your configuration in:'
923 print 'I am going to upgrade your configuration in:'
858
924
859 print ipythondir
925 print ipythondir
860
926
861 rcdirend = os.path.join('IPython','UserConfig')
927 rcdirend = os.path.join('IPython','UserConfig')
862 cfg = lambda d: os.path.join(d,rcdirend)
928 cfg = lambda d: os.path.join(d,rcdirend)
863 try:
929 try:
864 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
930 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
865 except IOError:
931 except IOError:
866 warning = """
932 warning = """
867 Installation error. IPython's directory was not found.
933 Installation error. IPython's directory was not found.
868
934
869 Check the following:
935 Check the following:
870
936
871 The ipython/IPython directory should be in a directory belonging to your
937 The ipython/IPython directory should be in a directory belonging to your
872 PYTHONPATH environment variable (that is, it should be in a directory
938 PYTHONPATH environment variable (that is, it should be in a directory
873 belonging to sys.path). You can copy it explicitly there or just link to it.
939 belonging to sys.path). You can copy it explicitly there or just link to it.
874
940
875 IPython will proceed with builtin defaults.
941 IPython will proceed with builtin defaults.
876 """
942 """
877 warn(warning)
943 warn(warning)
878 wait()
944 wait()
879 return
945 return
880
946
881 if mode == 'install':
947 if mode == 'install':
882 try:
948 try:
883 shutil.copytree(rcdir,ipythondir)
949 shutil.copytree(rcdir,ipythondir)
884 os.chdir(ipythondir)
950 os.chdir(ipythondir)
885 rc_files = glb("ipythonrc*")
951 rc_files = glb("ipythonrc*")
886 for rc_file in rc_files:
952 for rc_file in rc_files:
887 os.rename(rc_file,rc_file+rc_suffix)
953 os.rename(rc_file,rc_file+rc_suffix)
888 except:
954 except:
889 warning = """
955 warning = """
890
956
891 There was a problem with the installation:
957 There was a problem with the installation:
892 %s
958 %s
893 Try to correct it or contact the developers if you think it's a bug.
959 Try to correct it or contact the developers if you think it's a bug.
894 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
960 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
895 warn(warning)
961 warn(warning)
896 wait()
962 wait()
897 return
963 return
898
964
899 elif mode == 'upgrade':
965 elif mode == 'upgrade':
900 try:
966 try:
901 os.chdir(ipythondir)
967 os.chdir(ipythondir)
902 except:
968 except:
903 print """
969 print """
904 Can not upgrade: changing to directory %s failed. Details:
970 Can not upgrade: changing to directory %s failed. Details:
905 %s
971 %s
906 """ % (ipythondir,sys.exc_info()[1])
972 """ % (ipythondir,sys.exc_info()[1])
907 wait()
973 wait()
908 return
974 return
909 else:
975 else:
910 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
976 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
911 for new_full_path in sources:
977 for new_full_path in sources:
912 new_filename = os.path.basename(new_full_path)
978 new_filename = os.path.basename(new_full_path)
913 if new_filename.startswith('ipythonrc'):
979 if new_filename.startswith('ipythonrc'):
914 new_filename = new_filename + rc_suffix
980 new_filename = new_filename + rc_suffix
915 # The config directory should only contain files, skip any
981 # The config directory should only contain files, skip any
916 # directories which may be there (like CVS)
982 # directories which may be there (like CVS)
917 if os.path.isdir(new_full_path):
983 if os.path.isdir(new_full_path):
918 continue
984 continue
919 if os.path.exists(new_filename):
985 if os.path.exists(new_filename):
920 old_file = new_filename+'.old'
986 old_file = new_filename+'.old'
921 if os.path.exists(old_file):
987 if os.path.exists(old_file):
922 os.remove(old_file)
988 os.remove(old_file)
923 os.rename(new_filename,old_file)
989 os.rename(new_filename,old_file)
924 shutil.copy(new_full_path,new_filename)
990 shutil.copy(new_full_path,new_filename)
925 else:
991 else:
926 raise ValueError,'unrecognized mode for install:',`mode`
992 raise ValueError,'unrecognized mode for install:',`mode`
927
993
928 # Fix line-endings to those native to each platform in the config
994 # Fix line-endings to those native to each platform in the config
929 # directory.
995 # directory.
930 try:
996 try:
931 os.chdir(ipythondir)
997 os.chdir(ipythondir)
932 except:
998 except:
933 print """
999 print """
934 Problem: changing to directory %s failed.
1000 Problem: changing to directory %s failed.
935 Details:
1001 Details:
936 %s
1002 %s
937
1003
938 Some configuration files may have incorrect line endings. This should not
1004 Some configuration files may have incorrect line endings. This should not
939 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1005 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
940 wait()
1006 wait()
941 else:
1007 else:
942 for fname in glb('ipythonrc*'):
1008 for fname in glb('ipythonrc*'):
943 try:
1009 try:
944 native_line_ends(fname,backup=0)
1010 native_line_ends(fname,backup=0)
945 except IOError:
1011 except IOError:
946 pass
1012 pass
947
1013
948 if mode == 'install':
1014 if mode == 'install':
949 print """
1015 print """
950 Successful installation!
1016 Successful installation!
951
1017
952 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1018 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
953 IPython manual (there are both HTML and PDF versions supplied with the
1019 IPython manual (there are both HTML and PDF versions supplied with the
954 distribution) to make sure that your system environment is properly configured
1020 distribution) to make sure that your system environment is properly configured
955 to take advantage of IPython's features."""
1021 to take advantage of IPython's features."""
956 else:
1022 else:
957 print """
1023 print """
958 Successful upgrade!
1024 Successful upgrade!
959
1025
960 All files in your directory:
1026 All files in your directory:
961 %(ipythondir)s
1027 %(ipythondir)s
962 which would have been overwritten by the upgrade were backed up with a .old
1028 which would have been overwritten by the upgrade were backed up with a .old
963 extension. If you had made particular customizations in those files you may
1029 extension. If you had made particular customizations in those files you may
964 want to merge them back into the new files.""" % locals()
1030 want to merge them back into the new files.""" % locals()
965 wait()
1031 wait()
966 os.chdir(cwd)
1032 os.chdir(cwd)
967 # end user_setup()
1033 # end user_setup()
968
1034
969 def atexit_operations(self):
1035 def atexit_operations(self):
970 """This will be executed at the time of exit.
1036 """This will be executed at the time of exit.
971
1037
972 Saving of persistent data should be performed here. """
1038 Saving of persistent data should be performed here. """
973
1039
974 # input history
1040 # input history
975 self.savehist()
1041 self.savehist()
976
1042
977 # Cleanup all tempfiles left around
1043 # Cleanup all tempfiles left around
978 for tfile in self.tempfiles:
1044 for tfile in self.tempfiles:
979 try:
1045 try:
980 os.unlink(tfile)
1046 os.unlink(tfile)
981 except OSError:
1047 except OSError:
982 pass
1048 pass
983
1049
984 # save the "persistent data" catch-all dictionary
1050 # save the "persistent data" catch-all dictionary
985 try:
1051 try:
986 pickle.dump(self.persist, open(self.persist_fname,"w"))
1052 pickle.dump(self.persist, open(self.persist_fname,"w"))
987 except:
1053 except:
988 print "*** ERROR *** persistent data saving failed."
1054 print "*** ERROR *** persistent data saving failed."
989
1055
990 def savehist(self):
1056 def savehist(self):
991 """Save input history to a file (via readline library)."""
1057 """Save input history to a file (via readline library)."""
992 try:
1058 try:
993 self.readline.write_history_file(self.histfile)
1059 self.readline.write_history_file(self.histfile)
994 except:
1060 except:
995 print 'Unable to save IPython command history to file: ' + \
1061 print 'Unable to save IPython command history to file: ' + \
996 `self.histfile`
1062 `self.histfile`
997
1063
998 def pre_readline(self):
1064 def pre_readline(self):
999 """readline hook to be used at the start of each line.
1065 """readline hook to be used at the start of each line.
1000
1066
1001 Currently it handles auto-indent only."""
1067 Currently it handles auto-indent only."""
1002
1068
1003 self.readline.insert_text(self.indent_current)
1069 self.readline.insert_text(self.indent_current)
1004
1070
1005 def init_readline(self):
1071 def init_readline(self):
1006 """Command history completion/saving/reloading."""
1072 """Command history completion/saving/reloading."""
1007 try:
1073 try:
1008 import readline
1074 import readline
1009 except ImportError:
1075 except ImportError:
1010 self.has_readline = 0
1076 self.has_readline = 0
1011 self.readline = None
1077 self.readline = None
1012 # no point in bugging windows users with this every time:
1078 # no point in bugging windows users with this every time:
1013 if os.name == 'posix':
1079 if os.name == 'posix':
1014 warn('Readline services not available on this platform.')
1080 warn('Readline services not available on this platform.')
1015 else:
1081 else:
1016 import atexit
1082 import atexit
1017 from IPython.completer import IPCompleter
1083 from IPython.completer import IPCompleter
1018 self.Completer = IPCompleter(self,
1084 self.Completer = IPCompleter(self,
1019 self.user_ns,
1085 self.user_ns,
1020 self.user_global_ns,
1086 self.user_global_ns,
1021 self.rc.readline_omit__names,
1087 self.rc.readline_omit__names,
1022 self.alias_table)
1088 self.alias_table)
1023
1089
1024 # Platform-specific configuration
1090 # Platform-specific configuration
1025 if os.name == 'nt':
1091 if os.name == 'nt':
1026 self.readline_startup_hook = readline.set_pre_input_hook
1092 self.readline_startup_hook = readline.set_pre_input_hook
1027 else:
1093 else:
1028 self.readline_startup_hook = readline.set_startup_hook
1094 self.readline_startup_hook = readline.set_startup_hook
1029
1095
1030 # Load user's initrc file (readline config)
1096 # Load user's initrc file (readline config)
1031 inputrc_name = os.environ.get('INPUTRC')
1097 inputrc_name = os.environ.get('INPUTRC')
1032 if inputrc_name is None:
1098 if inputrc_name is None:
1033 home_dir = get_home_dir()
1099 home_dir = get_home_dir()
1034 if home_dir is not None:
1100 if home_dir is not None:
1035 inputrc_name = os.path.join(home_dir,'.inputrc')
1101 inputrc_name = os.path.join(home_dir,'.inputrc')
1036 if os.path.isfile(inputrc_name):
1102 if os.path.isfile(inputrc_name):
1037 try:
1103 try:
1038 readline.read_init_file(inputrc_name)
1104 readline.read_init_file(inputrc_name)
1039 except:
1105 except:
1040 warn('Problems reading readline initialization file <%s>'
1106 warn('Problems reading readline initialization file <%s>'
1041 % inputrc_name)
1107 % inputrc_name)
1042
1108
1043 self.has_readline = 1
1109 self.has_readline = 1
1044 self.readline = readline
1110 self.readline = readline
1045 # save this in sys so embedded copies can restore it properly
1111 # save this in sys so embedded copies can restore it properly
1046 sys.ipcompleter = self.Completer.complete
1112 sys.ipcompleter = self.Completer.complete
1047 readline.set_completer(self.Completer.complete)
1113 readline.set_completer(self.Completer.complete)
1048
1114
1049 # Configure readline according to user's prefs
1115 # Configure readline according to user's prefs
1050 for rlcommand in self.rc.readline_parse_and_bind:
1116 for rlcommand in self.rc.readline_parse_and_bind:
1051 readline.parse_and_bind(rlcommand)
1117 readline.parse_and_bind(rlcommand)
1052
1118
1053 # remove some chars from the delimiters list
1119 # remove some chars from the delimiters list
1054 delims = readline.get_completer_delims()
1120 delims = readline.get_completer_delims()
1055 delims = delims.translate(string._idmap,
1121 delims = delims.translate(string._idmap,
1056 self.rc.readline_remove_delims)
1122 self.rc.readline_remove_delims)
1057 readline.set_completer_delims(delims)
1123 readline.set_completer_delims(delims)
1058 # otherwise we end up with a monster history after a while:
1124 # otherwise we end up with a monster history after a while:
1059 readline.set_history_length(1000)
1125 readline.set_history_length(1000)
1060 try:
1126 try:
1061 #print '*** Reading readline history' # dbg
1127 #print '*** Reading readline history' # dbg
1062 readline.read_history_file(self.histfile)
1128 readline.read_history_file(self.histfile)
1063 except IOError:
1129 except IOError:
1064 pass # It doesn't exist yet.
1130 pass # It doesn't exist yet.
1065
1131
1066 atexit.register(self.atexit_operations)
1132 atexit.register(self.atexit_operations)
1067 del atexit
1133 del atexit
1068
1134
1069 # Configure auto-indent for all platforms
1135 # Configure auto-indent for all platforms
1070 self.set_autoindent(self.rc.autoindent)
1136 self.set_autoindent(self.rc.autoindent)
1071
1137
1072 def _should_recompile(self,e):
1138 def _should_recompile(self,e):
1073 """Utility routine for edit_syntax_error"""
1139 """Utility routine for edit_syntax_error"""
1074
1140
1075 if e.filename in ('<ipython console>','<input>','<string>',
1141 if e.filename in ('<ipython console>','<input>','<string>',
1076 '<console>'):
1142 '<console>'):
1077 return False
1143 return False
1078 try:
1144 try:
1079 if not ask_yes_no('Return to editor to correct syntax error? '
1145 if not ask_yes_no('Return to editor to correct syntax error? '
1080 '[Y/n] ','y'):
1146 '[Y/n] ','y'):
1081 return False
1147 return False
1082 except EOFError:
1148 except EOFError:
1083 return False
1149 return False
1084 self.hooks.fix_error_editor(e.filename,e.lineno,e.offset,e.msg)
1150 self.hooks.fix_error_editor(e.filename,e.lineno,e.offset,e.msg)
1085 return True
1151 return True
1086
1152
1087 def edit_syntax_error(self):
1153 def edit_syntax_error(self):
1088 """The bottom half of the syntax error handler called in the main loop.
1154 """The bottom half of the syntax error handler called in the main loop.
1089
1155
1090 Loop until syntax error is fixed or user cancels.
1156 Loop until syntax error is fixed or user cancels.
1091 """
1157 """
1092
1158
1093 while self.SyntaxTB.last_syntax_error:
1159 while self.SyntaxTB.last_syntax_error:
1094 # copy and clear last_syntax_error
1160 # copy and clear last_syntax_error
1095 err = self.SyntaxTB.clear_err_state()
1161 err = self.SyntaxTB.clear_err_state()
1096 if not self._should_recompile(err):
1162 if not self._should_recompile(err):
1097 return
1163 return
1098 try:
1164 try:
1099 # may set last_syntax_error again if a SyntaxError is raised
1165 # may set last_syntax_error again if a SyntaxError is raised
1100 self.safe_execfile(err.filename,self.shell.user_ns)
1166 self.safe_execfile(err.filename,self.shell.user_ns)
1101 except:
1167 except:
1102 self.showtraceback()
1168 self.showtraceback()
1103 else:
1169 else:
1104 f = file(err.filename)
1170 f = file(err.filename)
1105 try:
1171 try:
1106 sys.displayhook(f.read())
1172 sys.displayhook(f.read())
1107 finally:
1173 finally:
1108 f.close()
1174 f.close()
1109
1175
1110 def showsyntaxerror(self, filename=None):
1176 def showsyntaxerror(self, filename=None):
1111 """Display the syntax error that just occurred.
1177 """Display the syntax error that just occurred.
1112
1178
1113 This doesn't display a stack trace because there isn't one.
1179 This doesn't display a stack trace because there isn't one.
1114
1180
1115 If a filename is given, it is stuffed in the exception instead
1181 If a filename is given, it is stuffed in the exception instead
1116 of what was there before (because Python's parser always uses
1182 of what was there before (because Python's parser always uses
1117 "<string>" when reading from a string).
1183 "<string>" when reading from a string).
1118 """
1184 """
1119 type, value, sys.last_traceback = sys.exc_info()
1185 type, value, sys.last_traceback = sys.exc_info()
1120 sys.last_type = type
1186 sys.last_type = type
1121 sys.last_value = value
1187 sys.last_value = value
1122 if filename and type is SyntaxError:
1188 if filename and type is SyntaxError:
1123 # Work hard to stuff the correct filename in the exception
1189 # Work hard to stuff the correct filename in the exception
1124 try:
1190 try:
1125 msg, (dummy_filename, lineno, offset, line) = value
1191 msg, (dummy_filename, lineno, offset, line) = value
1126 except:
1192 except:
1127 # Not the format we expect; leave it alone
1193 # Not the format we expect; leave it alone
1128 pass
1194 pass
1129 else:
1195 else:
1130 # Stuff in the right filename
1196 # Stuff in the right filename
1131 try:
1197 try:
1132 # Assume SyntaxError is a class exception
1198 # Assume SyntaxError is a class exception
1133 value = SyntaxError(msg, (filename, lineno, offset, line))
1199 value = SyntaxError(msg, (filename, lineno, offset, line))
1134 except:
1200 except:
1135 # If that failed, assume SyntaxError is a string
1201 # If that failed, assume SyntaxError is a string
1136 value = msg, (filename, lineno, offset, line)
1202 value = msg, (filename, lineno, offset, line)
1137 self.SyntaxTB(type,value,[])
1203 self.SyntaxTB(type,value,[])
1138
1204
1139 def debugger(self):
1205 def debugger(self):
1140 """Call the pdb debugger."""
1206 """Call the pdb debugger."""
1141
1207
1142 if not self.rc.pdb:
1208 if not self.rc.pdb:
1143 return
1209 return
1144 pdb.pm()
1210 pdb.pm()
1145
1211
1146 def showtraceback(self,exc_tuple = None,filename=None):
1212 def showtraceback(self,exc_tuple = None,filename=None):
1147 """Display the exception that just occurred."""
1213 """Display the exception that just occurred."""
1148
1214
1149 # Though this won't be called by syntax errors in the input line,
1215 # Though this won't be called by syntax errors in the input line,
1150 # there may be SyntaxError cases whith imported code.
1216 # there may be SyntaxError cases whith imported code.
1151 if exc_tuple is None:
1217 if exc_tuple is None:
1152 type, value, tb = sys.exc_info()
1218 type, value, tb = sys.exc_info()
1153 else:
1219 else:
1154 type, value, tb = exc_tuple
1220 type, value, tb = exc_tuple
1155 if type is SyntaxError:
1221 if type is SyntaxError:
1156 self.showsyntaxerror(filename)
1222 self.showsyntaxerror(filename)
1157 else:
1223 else:
1158 sys.last_type = type
1224 sys.last_type = type
1159 sys.last_value = value
1225 sys.last_value = value
1160 sys.last_traceback = tb
1226 sys.last_traceback = tb
1161 self.InteractiveTB()
1227 self.InteractiveTB()
1162 if self.InteractiveTB.call_pdb and self.has_readline:
1228 if self.InteractiveTB.call_pdb and self.has_readline:
1163 # pdb mucks up readline, fix it back
1229 # pdb mucks up readline, fix it back
1164 self.readline.set_completer(self.Completer.complete)
1230 self.readline.set_completer(self.Completer.complete)
1165
1231
1166 def update_cache(self, line):
1232 def update_cache(self, line):
1167 """puts line into cache"""
1233 """puts line into cache"""
1168 self.inputcache.insert(0, line) # This copies the cache every time ... :-(
1234 self.inputcache.insert(0, line) # This copies the cache every time ... :-(
1169 if len(self.inputcache) >= self.CACHELENGTH:
1235 if len(self.inputcache) >= self.CACHELENGTH:
1170 self.inputcache.pop() # This doesn't :-)
1236 self.inputcache.pop() # This doesn't :-)
1171
1237
1172 def mainloop(self,banner=None):
1238 def mainloop(self,banner=None):
1173 """Creates the local namespace and starts the mainloop.
1239 """Creates the local namespace and starts the mainloop.
1174
1240
1175 If an optional banner argument is given, it will override the
1241 If an optional banner argument is given, it will override the
1176 internally created default banner."""
1242 internally created default banner."""
1177
1243
1178 if self.rc.c: # Emulate Python's -c option
1244 if self.rc.c: # Emulate Python's -c option
1179 self.exec_init_cmd()
1245 self.exec_init_cmd()
1180 if banner is None:
1246 if banner is None:
1181 if self.rc.banner:
1247 if self.rc.banner:
1182 banner = self.BANNER+self.banner2
1248 banner = self.BANNER+self.banner2
1183 else:
1249 else:
1184 banner = ''
1250 banner = ''
1185 self.interact(banner)
1251 self.interact(banner)
1186
1252
1187 def exec_init_cmd(self):
1253 def exec_init_cmd(self):
1188 """Execute a command given at the command line.
1254 """Execute a command given at the command line.
1189
1255
1190 This emulates Python's -c option."""
1256 This emulates Python's -c option."""
1191
1257
1192 sys.argv = ['-c']
1258 sys.argv = ['-c']
1193 self.push(self.rc.c)
1259 self.push(self.rc.c)
1194
1260
1195 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1261 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1196 """Embeds IPython into a running python program.
1262 """Embeds IPython into a running python program.
1197
1263
1198 Input:
1264 Input:
1199
1265
1200 - header: An optional header message can be specified.
1266 - header: An optional header message can be specified.
1201
1267
1202 - local_ns, global_ns: working namespaces. If given as None, the
1268 - local_ns, global_ns: working namespaces. If given as None, the
1203 IPython-initialized one is updated with __main__.__dict__, so that
1269 IPython-initialized one is updated with __main__.__dict__, so that
1204 program variables become visible but user-specific configuration
1270 program variables become visible but user-specific configuration
1205 remains possible.
1271 remains possible.
1206
1272
1207 - stack_depth: specifies how many levels in the stack to go to
1273 - stack_depth: specifies how many levels in the stack to go to
1208 looking for namespaces (when local_ns and global_ns are None). This
1274 looking for namespaces (when local_ns and global_ns are None). This
1209 allows an intermediate caller to make sure that this function gets
1275 allows an intermediate caller to make sure that this function gets
1210 the namespace from the intended level in the stack. By default (0)
1276 the namespace from the intended level in the stack. By default (0)
1211 it will get its locals and globals from the immediate caller.
1277 it will get its locals and globals from the immediate caller.
1212
1278
1213 Warning: it's possible to use this in a program which is being run by
1279 Warning: it's possible to use this in a program which is being run by
1214 IPython itself (via %run), but some funny things will happen (a few
1280 IPython itself (via %run), but some funny things will happen (a few
1215 globals get overwritten). In the future this will be cleaned up, as
1281 globals get overwritten). In the future this will be cleaned up, as
1216 there is no fundamental reason why it can't work perfectly."""
1282 there is no fundamental reason why it can't work perfectly."""
1217
1283
1218 # Get locals and globals from caller
1284 # Get locals and globals from caller
1219 if local_ns is None or global_ns is None:
1285 if local_ns is None or global_ns is None:
1220 call_frame = sys._getframe(stack_depth).f_back
1286 call_frame = sys._getframe(stack_depth).f_back
1221
1287
1222 if local_ns is None:
1288 if local_ns is None:
1223 local_ns = call_frame.f_locals
1289 local_ns = call_frame.f_locals
1224 if global_ns is None:
1290 if global_ns is None:
1225 global_ns = call_frame.f_globals
1291 global_ns = call_frame.f_globals
1226
1292
1227 # Update namespaces and fire up interpreter
1293 # Update namespaces and fire up interpreter
1228 self.user_ns = local_ns
1294 self.user_ns = local_ns
1229 self.user_global_ns = global_ns
1295 self.user_global_ns = global_ns
1230
1296
1231 # Patch for global embedding to make sure that things don't overwrite
1297 # Patch for global embedding to make sure that things don't overwrite
1232 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1298 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1233 # FIXME. Test this a bit more carefully (the if.. is new)
1299 # FIXME. Test this a bit more carefully (the if.. is new)
1234 if local_ns is None and global_ns is None:
1300 if local_ns is None and global_ns is None:
1235 self.user_global_ns.update(__main__.__dict__)
1301 self.user_global_ns.update(__main__.__dict__)
1236
1302
1237 # make sure the tab-completer has the correct frame information, so it
1303 # make sure the tab-completer has the correct frame information, so it
1238 # actually completes using the frame's locals/globals
1304 # actually completes using the frame's locals/globals
1239 self.set_completer_frame(call_frame)
1305 self.set_completer_frame(call_frame)
1240
1306
1241 self.interact(header)
1307 self.interact(header)
1242
1308
1243 def interact(self, banner=None):
1309 def interact(self, banner=None):
1244 """Closely emulate the interactive Python console.
1310 """Closely emulate the interactive Python console.
1245
1311
1246 The optional banner argument specify the banner to print
1312 The optional banner argument specify the banner to print
1247 before the first interaction; by default it prints a banner
1313 before the first interaction; by default it prints a banner
1248 similar to the one printed by the real Python interpreter,
1314 similar to the one printed by the real Python interpreter,
1249 followed by the current class name in parentheses (so as not
1315 followed by the current class name in parentheses (so as not
1250 to confuse this with the real interpreter -- since it's so
1316 to confuse this with the real interpreter -- since it's so
1251 close!).
1317 close!).
1252
1318
1253 """
1319 """
1254 cprt = 'Type "copyright", "credits" or "license" for more information.'
1320 cprt = 'Type "copyright", "credits" or "license" for more information.'
1255 if banner is None:
1321 if banner is None:
1256 self.write("Python %s on %s\n%s\n(%s)\n" %
1322 self.write("Python %s on %s\n%s\n(%s)\n" %
1257 (sys.version, sys.platform, cprt,
1323 (sys.version, sys.platform, cprt,
1258 self.__class__.__name__))
1324 self.__class__.__name__))
1259 else:
1325 else:
1260 self.write(banner)
1326 self.write(banner)
1261
1327
1262 more = 0
1328 more = 0
1263
1329
1264 # Mark activity in the builtins
1330 # Mark activity in the builtins
1265 __builtin__.__dict__['__IPYTHON__active'] += 1
1331 __builtin__.__dict__['__IPYTHON__active'] += 1
1266
1332
1267 # compiled regexps for autoindent management
1333 # compiled regexps for autoindent management
1268 ini_spaces_re = re.compile(r'^(\s+)')
1334 ini_spaces_re = re.compile(r'^(\s+)')
1269 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
1335 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
1270
1336
1271 # exit_now is set by a call to %Exit or %Quit
1337 # exit_now is set by a call to %Exit or %Quit
1272 while not self.exit_now:
1338 while not self.exit_now:
1273 try:
1339 try:
1274 if more:
1340 if more:
1275 prompt = self.outputcache.prompt2
1341 prompt = self.outputcache.prompt2
1276 if self.autoindent:
1342 if self.autoindent:
1277 self.readline_startup_hook(self.pre_readline)
1343 self.readline_startup_hook(self.pre_readline)
1278 else:
1344 else:
1279 prompt = self.outputcache.prompt1
1345 prompt = self.outputcache.prompt1
1280 try:
1346 try:
1281 line = self.raw_input(prompt,more)
1347 line = self.raw_input(prompt,more)
1282 if self.autoindent:
1348 if self.autoindent:
1283 self.readline_startup_hook(None)
1349 self.readline_startup_hook(None)
1284 except EOFError:
1350 except EOFError:
1285 if self.autoindent:
1351 if self.autoindent:
1286 self.readline_startup_hook(None)
1352 self.readline_startup_hook(None)
1287 self.write("\n")
1353 self.write("\n")
1288 self.exit()
1354 self.exit()
1289 else:
1355 else:
1290 more = self.push(line)
1356 more = self.push(line)
1291 # Auto-indent management
1357 # Auto-indent management
1292 if self.autoindent:
1358 if self.autoindent:
1293 if line:
1359 if line:
1294 ini_spaces = ini_spaces_re.match(line)
1360 ini_spaces = ini_spaces_re.match(line)
1295 if ini_spaces:
1361 if ini_spaces:
1296 nspaces = ini_spaces.end()
1362 nspaces = ini_spaces.end()
1297 else:
1363 else:
1298 nspaces = 0
1364 nspaces = 0
1299 self.indent_current_nsp = nspaces
1365 self.indent_current_nsp = nspaces
1300
1366
1301 if line[-1] == ':':
1367 if line[-1] == ':':
1302 self.indent_current_nsp += 4
1368 self.indent_current_nsp += 4
1303 elif dedent_re.match(line):
1369 elif dedent_re.match(line):
1304 self.indent_current_nsp -= 4
1370 self.indent_current_nsp -= 4
1305 else:
1371 else:
1306 self.indent_current_nsp = 0
1372 self.indent_current_nsp = 0
1307
1373
1308 # indent_current is the actual string to be inserted
1374 # indent_current is the actual string to be inserted
1309 # by the readline hooks for indentation
1375 # by the readline hooks for indentation
1310 self.indent_current = ' '* self.indent_current_nsp
1376 self.indent_current = ' '* self.indent_current_nsp
1311
1377
1312 if (self.SyntaxTB.last_syntax_error and
1378 if (self.SyntaxTB.last_syntax_error and
1313 self.rc.autoedit_syntax):
1379 self.rc.autoedit_syntax):
1314 self.edit_syntax_error()
1380 self.edit_syntax_error()
1315
1381
1316 except KeyboardInterrupt:
1382 except KeyboardInterrupt:
1317 self.write("\nKeyboardInterrupt\n")
1383 self.write("\nKeyboardInterrupt\n")
1318 self.resetbuffer()
1384 self.resetbuffer()
1319 more = 0
1385 more = 0
1320 # keep cache in sync with the prompt counter:
1386 # keep cache in sync with the prompt counter:
1321 self.outputcache.prompt_count -= 1
1387 self.outputcache.prompt_count -= 1
1322
1388
1323 if self.autoindent:
1389 if self.autoindent:
1324 self.indent_current_nsp = 0
1390 self.indent_current_nsp = 0
1325 self.indent_current = ' '* self.indent_current_nsp
1391 self.indent_current = ' '* self.indent_current_nsp
1326
1392
1327 except bdb.BdbQuit:
1393 except bdb.BdbQuit:
1328 warn("The Python debugger has exited with a BdbQuit exception.\n"
1394 warn("The Python debugger has exited with a BdbQuit exception.\n"
1329 "Because of how pdb handles the stack, it is impossible\n"
1395 "Because of how pdb handles the stack, it is impossible\n"
1330 "for IPython to properly format this particular exception.\n"
1396 "for IPython to properly format this particular exception.\n"
1331 "IPython will resume normal operation.")
1397 "IPython will resume normal operation.")
1332
1398
1333 # We are off again...
1399 # We are off again...
1334 __builtin__.__dict__['__IPYTHON__active'] -= 1
1400 __builtin__.__dict__['__IPYTHON__active'] -= 1
1335
1401
1336 def excepthook(self, type, value, tb):
1402 def excepthook(self, type, value, tb):
1337 """One more defense for GUI apps that call sys.excepthook.
1403 """One more defense for GUI apps that call sys.excepthook.
1338
1404
1339 GUI frameworks like wxPython trap exceptions and call
1405 GUI frameworks like wxPython trap exceptions and call
1340 sys.excepthook themselves. I guess this is a feature that
1406 sys.excepthook themselves. I guess this is a feature that
1341 enables them to keep running after exceptions that would
1407 enables them to keep running after exceptions that would
1342 otherwise kill their mainloop. This is a bother for IPython
1408 otherwise kill their mainloop. This is a bother for IPython
1343 which excepts to catch all of the program exceptions with a try:
1409 which excepts to catch all of the program exceptions with a try:
1344 except: statement.
1410 except: statement.
1345
1411
1346 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1412 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1347 any app directly invokes sys.excepthook, it will look to the user like
1413 any app directly invokes sys.excepthook, it will look to the user like
1348 IPython crashed. In order to work around this, we can disable the
1414 IPython crashed. In order to work around this, we can disable the
1349 CrashHandler and replace it with this excepthook instead, which prints a
1415 CrashHandler and replace it with this excepthook instead, which prints a
1350 regular traceback using our InteractiveTB. In this fashion, apps which
1416 regular traceback using our InteractiveTB. In this fashion, apps which
1351 call sys.excepthook will generate a regular-looking exception from
1417 call sys.excepthook will generate a regular-looking exception from
1352 IPython, and the CrashHandler will only be triggered by real IPython
1418 IPython, and the CrashHandler will only be triggered by real IPython
1353 crashes.
1419 crashes.
1354
1420
1355 This hook should be used sparingly, only in places which are not likely
1421 This hook should be used sparingly, only in places which are not likely
1356 to be true IPython errors.
1422 to be true IPython errors.
1357 """
1423 """
1358
1424
1359 self.InteractiveTB(type, value, tb, tb_offset=0)
1425 self.InteractiveTB(type, value, tb, tb_offset=0)
1360 if self.InteractiveTB.call_pdb and self.has_readline:
1426 if self.InteractiveTB.call_pdb and self.has_readline:
1361 self.readline.set_completer(self.Completer.complete)
1427 self.readline.set_completer(self.Completer.complete)
1362
1428
1363 def call_alias(self,alias,rest=''):
1429 def call_alias(self,alias,rest=''):
1364 """Call an alias given its name and the rest of the line.
1430 """Call an alias given its name and the rest of the line.
1365
1431
1366 This function MUST be given a proper alias, because it doesn't make
1432 This function MUST be given a proper alias, because it doesn't make
1367 any checks when looking up into the alias table. The caller is
1433 any checks when looking up into the alias table. The caller is
1368 responsible for invoking it only with a valid alias."""
1434 responsible for invoking it only with a valid alias."""
1369
1435
1370 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1436 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1371 nargs,cmd = self.alias_table[alias]
1437 nargs,cmd = self.alias_table[alias]
1372 # Expand the %l special to be the user's input line
1438 # Expand the %l special to be the user's input line
1373 if cmd.find('%l') >= 0:
1439 if cmd.find('%l') >= 0:
1374 cmd = cmd.replace('%l',rest)
1440 cmd = cmd.replace('%l',rest)
1375 rest = ''
1441 rest = ''
1376 if nargs==0:
1442 if nargs==0:
1377 # Simple, argument-less aliases
1443 # Simple, argument-less aliases
1378 cmd = '%s %s' % (cmd,rest)
1444 cmd = '%s %s' % (cmd,rest)
1379 else:
1445 else:
1380 # Handle aliases with positional arguments
1446 # Handle aliases with positional arguments
1381 args = rest.split(None,nargs)
1447 args = rest.split(None,nargs)
1382 if len(args)< nargs:
1448 if len(args)< nargs:
1383 error('Alias <%s> requires %s arguments, %s given.' %
1449 error('Alias <%s> requires %s arguments, %s given.' %
1384 (alias,nargs,len(args)))
1450 (alias,nargs,len(args)))
1385 return
1451 return
1386 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1452 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1387 # Now call the macro, evaluating in the user's namespace
1453 # Now call the macro, evaluating in the user's namespace
1388 try:
1454 try:
1389 self.system(cmd)
1455 self.system(cmd)
1390 except:
1456 except:
1391 self.showtraceback()
1457 self.showtraceback()
1392
1458
1393 def runlines(self,lines):
1459 def runlines(self,lines):
1394 """Run a string of one or more lines of source.
1460 """Run a string of one or more lines of source.
1395
1461
1396 This method is capable of running a string containing multiple source
1462 This method is capable of running a string containing multiple source
1397 lines, as if they had been entered at the IPython prompt. Since it
1463 lines, as if they had been entered at the IPython prompt. Since it
1398 exposes IPython's processing machinery, the given strings can contain
1464 exposes IPython's processing machinery, the given strings can contain
1399 magic calls (%magic), special shell access (!cmd), etc."""
1465 magic calls (%magic), special shell access (!cmd), etc."""
1400
1466
1401 # We must start with a clean buffer, in case this is run from an
1467 # We must start with a clean buffer, in case this is run from an
1402 # interactive IPython session (via a magic, for example).
1468 # interactive IPython session (via a magic, for example).
1403 self.resetbuffer()
1469 self.resetbuffer()
1404 lines = lines.split('\n')
1470 lines = lines.split('\n')
1405 more = 0
1471 more = 0
1406 for line in lines:
1472 for line in lines:
1407 # skip blank lines so we don't mess up the prompt counter, but do
1473 # skip blank lines so we don't mess up the prompt counter, but do
1408 # NOT skip even a blank line if we are in a code block (more is
1474 # NOT skip even a blank line if we are in a code block (more is
1409 # true)
1475 # true)
1410 if line or more:
1476 if line or more:
1411 more = self.push((self.prefilter(line,more)))
1477 more = self.push((self.prefilter(line,more)))
1412 # IPython's runsource returns None if there was an error
1478 # IPython's runsource returns None if there was an error
1413 # compiling the code. This allows us to stop processing right
1479 # compiling the code. This allows us to stop processing right
1414 # away, so the user gets the error message at the right place.
1480 # away, so the user gets the error message at the right place.
1415 if more is None:
1481 if more is None:
1416 break
1482 break
1417 # final newline in case the input didn't have it, so that the code
1483 # final newline in case the input didn't have it, so that the code
1418 # actually does get executed
1484 # actually does get executed
1419 if more:
1485 if more:
1420 self.push('\n')
1486 self.push('\n')
1421
1487
1422 def runsource(self, source, filename='<input>', symbol='single'):
1488 def runsource(self, source, filename='<input>', symbol='single'):
1423 """Compile and run some source in the interpreter.
1489 """Compile and run some source in the interpreter.
1424
1490
1425 Arguments are as for compile_command().
1491 Arguments are as for compile_command().
1426
1492
1427 One several things can happen:
1493 One several things can happen:
1428
1494
1429 1) The input is incorrect; compile_command() raised an
1495 1) The input is incorrect; compile_command() raised an
1430 exception (SyntaxError or OverflowError). A syntax traceback
1496 exception (SyntaxError or OverflowError). A syntax traceback
1431 will be printed by calling the showsyntaxerror() method.
1497 will be printed by calling the showsyntaxerror() method.
1432
1498
1433 2) The input is incomplete, and more input is required;
1499 2) The input is incomplete, and more input is required;
1434 compile_command() returned None. Nothing happens.
1500 compile_command() returned None. Nothing happens.
1435
1501
1436 3) The input is complete; compile_command() returned a code
1502 3) The input is complete; compile_command() returned a code
1437 object. The code is executed by calling self.runcode() (which
1503 object. The code is executed by calling self.runcode() (which
1438 also handles run-time exceptions, except for SystemExit).
1504 also handles run-time exceptions, except for SystemExit).
1439
1505
1440 The return value is:
1506 The return value is:
1441
1507
1442 - True in case 2
1508 - True in case 2
1443
1509
1444 - False in the other cases, unless an exception is raised, where
1510 - False in the other cases, unless an exception is raised, where
1445 None is returned instead. This can be used by external callers to
1511 None is returned instead. This can be used by external callers to
1446 know whether to continue feeding input or not.
1512 know whether to continue feeding input or not.
1447
1513
1448 The return value can be used to decide whether to use sys.ps1 or
1514 The return value can be used to decide whether to use sys.ps1 or
1449 sys.ps2 to prompt the next line."""
1515 sys.ps2 to prompt the next line."""
1450
1516
1451 try:
1517 try:
1452 code = self.compile(source,filename,symbol)
1518 code = self.compile(source,filename,symbol)
1453 except (OverflowError, SyntaxError, ValueError):
1519 except (OverflowError, SyntaxError, ValueError):
1454 # Case 1
1520 # Case 1
1455 self.showsyntaxerror(filename)
1521 self.showsyntaxerror(filename)
1456 return None
1522 return None
1457
1523
1458 if code is None:
1524 if code is None:
1459 # Case 2
1525 # Case 2
1460 return True
1526 return True
1461
1527
1462 # Case 3
1528 # Case 3
1463 # We store the code object so that threaded shells and
1529 # We store the code object so that threaded shells and
1464 # custom exception handlers can access all this info if needed.
1530 # custom exception handlers can access all this info if needed.
1465 # The source corresponding to this can be obtained from the
1531 # The source corresponding to this can be obtained from the
1466 # buffer attribute as '\n'.join(self.buffer).
1532 # buffer attribute as '\n'.join(self.buffer).
1467 self.code_to_run = code
1533 self.code_to_run = code
1468 # now actually execute the code object
1534 # now actually execute the code object
1469 if self.runcode(code) == 0:
1535 if self.runcode(code) == 0:
1470 return False
1536 return False
1471 else:
1537 else:
1472 return None
1538 return None
1473
1539
1474 def runcode(self,code_obj):
1540 def runcode(self,code_obj):
1475 """Execute a code object.
1541 """Execute a code object.
1476
1542
1477 When an exception occurs, self.showtraceback() is called to display a
1543 When an exception occurs, self.showtraceback() is called to display a
1478 traceback.
1544 traceback.
1479
1545
1480 Return value: a flag indicating whether the code to be run completed
1546 Return value: a flag indicating whether the code to be run completed
1481 successfully:
1547 successfully:
1482
1548
1483 - 0: successful execution.
1549 - 0: successful execution.
1484 - 1: an error occurred.
1550 - 1: an error occurred.
1485 """
1551 """
1486
1552
1487 # Set our own excepthook in case the user code tries to call it
1553 # Set our own excepthook in case the user code tries to call it
1488 # directly, so that the IPython crash handler doesn't get triggered
1554 # directly, so that the IPython crash handler doesn't get triggered
1489 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1555 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1490
1556
1491 # we save the original sys.excepthook in the instance, in case config
1557 # we save the original sys.excepthook in the instance, in case config
1492 # code (such as magics) needs access to it.
1558 # code (such as magics) needs access to it.
1493 self.sys_excepthook = old_excepthook
1559 self.sys_excepthook = old_excepthook
1494 outflag = 1 # happens in more places, so it's easier as default
1560 outflag = 1 # happens in more places, so it's easier as default
1495 try:
1561 try:
1496 try:
1562 try:
1497 # Embedded instances require separate global/local namespaces
1563 # Embedded instances require separate global/local namespaces
1498 # so they can see both the surrounding (local) namespace and
1564 # so they can see both the surrounding (local) namespace and
1499 # the module-level globals when called inside another function.
1565 # the module-level globals when called inside another function.
1500 if self.embedded:
1566 if self.embedded:
1501 exec code_obj in self.user_global_ns, self.user_ns
1567 exec code_obj in self.user_global_ns, self.user_ns
1502 # Normal (non-embedded) instances should only have a single
1568 # Normal (non-embedded) instances should only have a single
1503 # namespace for user code execution, otherwise functions won't
1569 # namespace for user code execution, otherwise functions won't
1504 # see interactive top-level globals.
1570 # see interactive top-level globals.
1505 else:
1571 else:
1506 exec code_obj in self.user_ns
1572 exec code_obj in self.user_ns
1507 finally:
1573 finally:
1508 # Reset our crash handler in place
1574 # Reset our crash handler in place
1509 sys.excepthook = old_excepthook
1575 sys.excepthook = old_excepthook
1510 except SystemExit:
1576 except SystemExit:
1511 self.resetbuffer()
1577 self.resetbuffer()
1512 self.showtraceback()
1578 self.showtraceback()
1513 warn("Type exit or quit to exit IPython "
1579 warn("Type exit or quit to exit IPython "
1514 "(%Exit or %Quit do so unconditionally).",level=1)
1580 "(%Exit or %Quit do so unconditionally).",level=1)
1515 except self.custom_exceptions:
1581 except self.custom_exceptions:
1516 etype,value,tb = sys.exc_info()
1582 etype,value,tb = sys.exc_info()
1517 self.CustomTB(etype,value,tb)
1583 self.CustomTB(etype,value,tb)
1518 except:
1584 except:
1519 self.showtraceback()
1585 self.showtraceback()
1520 else:
1586 else:
1521 outflag = 0
1587 outflag = 0
1522 if softspace(sys.stdout, 0):
1588 if softspace(sys.stdout, 0):
1523 print
1589 print
1524 # Flush out code object which has been run (and source)
1590 # Flush out code object which has been run (and source)
1525 self.code_to_run = None
1591 self.code_to_run = None
1526 return outflag
1592 return outflag
1527
1593
1528 def push(self, line):
1594 def push(self, line):
1529 """Push a line to the interpreter.
1595 """Push a line to the interpreter.
1530
1596
1531 The line should not have a trailing newline; it may have
1597 The line should not have a trailing newline; it may have
1532 internal newlines. The line is appended to a buffer and the
1598 internal newlines. The line is appended to a buffer and the
1533 interpreter's runsource() method is called with the
1599 interpreter's runsource() method is called with the
1534 concatenated contents of the buffer as source. If this
1600 concatenated contents of the buffer as source. If this
1535 indicates that the command was executed or invalid, the buffer
1601 indicates that the command was executed or invalid, the buffer
1536 is reset; otherwise, the command is incomplete, and the buffer
1602 is reset; otherwise, the command is incomplete, and the buffer
1537 is left as it was after the line was appended. The return
1603 is left as it was after the line was appended. The return
1538 value is 1 if more input is required, 0 if the line was dealt
1604 value is 1 if more input is required, 0 if the line was dealt
1539 with in some way (this is the same as runsource()).
1605 with in some way (this is the same as runsource()).
1540
1606
1541 """
1607 """
1542 self.buffer.append(line)
1608 self.buffer.append(line)
1543 more = self.runsource('\n'.join(self.buffer), self.filename)
1609 more = self.runsource('\n'.join(self.buffer), self.filename)
1544 if not more:
1610 if not more:
1545 self.resetbuffer()
1611 self.resetbuffer()
1546 return more
1612 return more
1547
1613
1548 def resetbuffer(self):
1614 def resetbuffer(self):
1549 """Reset the input buffer."""
1615 """Reset the input buffer."""
1550 self.buffer[:] = []
1616 self.buffer[:] = []
1551
1617
1552 def raw_input(self,prompt='',continue_prompt=False):
1618 def raw_input(self,prompt='',continue_prompt=False):
1553 """Write a prompt and read a line.
1619 """Write a prompt and read a line.
1554
1620
1555 The returned line does not include the trailing newline.
1621 The returned line does not include the trailing newline.
1556 When the user enters the EOF key sequence, EOFError is raised.
1622 When the user enters the EOF key sequence, EOFError is raised.
1557
1623
1558 Optional inputs:
1624 Optional inputs:
1559
1625
1560 - prompt(''): a string to be printed to prompt the user.
1626 - prompt(''): a string to be printed to prompt the user.
1561
1627
1562 - continue_prompt(False): whether this line is the first one or a
1628 - continue_prompt(False): whether this line is the first one or a
1563 continuation in a sequence of inputs.
1629 continuation in a sequence of inputs.
1564 """
1630 """
1565
1631
1566 line = raw_input_original(prompt)
1632 line = raw_input_original(prompt)
1567 # Try to be reasonably smart about not re-indenting pasted input more
1633 # Try to be reasonably smart about not re-indenting pasted input more
1568 # than necessary. We do this by trimming out the auto-indent initial
1634 # than necessary. We do this by trimming out the auto-indent initial
1569 # spaces, if the user's actual input started itself with whitespace.
1635 # spaces, if the user's actual input started itself with whitespace.
1570 if self.autoindent:
1636 if self.autoindent:
1571 line2 = line[self.indent_current_nsp:]
1637 line2 = line[self.indent_current_nsp:]
1572 if line2[0:1] in (' ','\t'):
1638 if line2[0:1] in (' ','\t'):
1573 line = line2
1639 line = line2
1574 return self.prefilter(line,continue_prompt)
1640 return self.prefilter(line,continue_prompt)
1575
1641
1576 def split_user_input(self,line):
1642 def split_user_input(self,line):
1577 """Split user input into pre-char, function part and rest."""
1643 """Split user input into pre-char, function part and rest."""
1578
1644
1579 lsplit = self.line_split.match(line)
1645 lsplit = self.line_split.match(line)
1580 if lsplit is None: # no regexp match returns None
1646 if lsplit is None: # no regexp match returns None
1581 try:
1647 try:
1582 iFun,theRest = line.split(None,1)
1648 iFun,theRest = line.split(None,1)
1583 except ValueError:
1649 except ValueError:
1584 iFun,theRest = line,''
1650 iFun,theRest = line,''
1585 pre = re.match('^(\s*)(.*)',line).groups()[0]
1651 pre = re.match('^(\s*)(.*)',line).groups()[0]
1586 else:
1652 else:
1587 pre,iFun,theRest = lsplit.groups()
1653 pre,iFun,theRest = lsplit.groups()
1588
1654
1589 #print 'line:<%s>' % line # dbg
1655 #print 'line:<%s>' % line # dbg
1590 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1656 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1591 return pre,iFun.strip(),theRest
1657 return pre,iFun.strip(),theRest
1592
1658
1593 def _prefilter(self, line, continue_prompt):
1659 def _prefilter(self, line, continue_prompt):
1594 """Calls different preprocessors, depending on the form of line."""
1660 """Calls different preprocessors, depending on the form of line."""
1595
1661
1596 # All handlers *must* return a value, even if it's blank ('').
1662 # All handlers *must* return a value, even if it's blank ('').
1597
1663
1598 # Lines are NOT logged here. Handlers should process the line as
1664 # Lines are NOT logged here. Handlers should process the line as
1599 # needed, update the cache AND log it (so that the input cache array
1665 # needed, update the cache AND log it (so that the input cache array
1600 # stays synced).
1666 # stays synced).
1601
1667
1602 # This function is _very_ delicate, and since it's also the one which
1668 # This function is _very_ delicate, and since it's also the one which
1603 # determines IPython's response to user input, it must be as efficient
1669 # determines IPython's response to user input, it must be as efficient
1604 # as possible. For this reason it has _many_ returns in it, trying
1670 # as possible. For this reason it has _many_ returns in it, trying
1605 # always to exit as quickly as it can figure out what it needs to do.
1671 # always to exit as quickly as it can figure out what it needs to do.
1606
1672
1607 # This function is the main responsible for maintaining IPython's
1673 # This function is the main responsible for maintaining IPython's
1608 # behavior respectful of Python's semantics. So be _very_ careful if
1674 # behavior respectful of Python's semantics. So be _very_ careful if
1609 # making changes to anything here.
1675 # making changes to anything here.
1610
1676
1611 #.....................................................................
1677 #.....................................................................
1612 # Code begins
1678 # Code begins
1613
1679
1614 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1680 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1615
1681
1616 # save the line away in case we crash, so the post-mortem handler can
1682 # save the line away in case we crash, so the post-mortem handler can
1617 # record it
1683 # record it
1618 self._last_input_line = line
1684 self._last_input_line = line
1619
1685
1620 #print '***line: <%s>' % line # dbg
1686 #print '***line: <%s>' % line # dbg
1621
1687
1622 # the input history needs to track even empty lines
1688 # the input history needs to track even empty lines
1623 if not line.strip():
1689 if not line.strip():
1624 if not continue_prompt:
1690 if not continue_prompt:
1625 self.outputcache.prompt_count -= 1
1691 self.outputcache.prompt_count -= 1
1626 return self.handle_normal(line,continue_prompt)
1692 return self.handle_normal(line,continue_prompt)
1627 #return self.handle_normal('',continue_prompt)
1693 #return self.handle_normal('',continue_prompt)
1628
1694
1629 # print '***cont',continue_prompt # dbg
1695 # print '***cont',continue_prompt # dbg
1630 # special handlers are only allowed for single line statements
1696 # special handlers are only allowed for single line statements
1631 if continue_prompt and not self.rc.multi_line_specials:
1697 if continue_prompt and not self.rc.multi_line_specials:
1632 return self.handle_normal(line,continue_prompt)
1698 return self.handle_normal(line,continue_prompt)
1633
1699
1634 # For the rest, we need the structure of the input
1700 # For the rest, we need the structure of the input
1635 pre,iFun,theRest = self.split_user_input(line)
1701 pre,iFun,theRest = self.split_user_input(line)
1636 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1702 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1637
1703
1638 # First check for explicit escapes in the last/first character
1704 # First check for explicit escapes in the last/first character
1639 handler = None
1705 handler = None
1640 if line[-1] == self.ESC_HELP:
1706 if line[-1] == self.ESC_HELP:
1641 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1707 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1642 if handler is None:
1708 if handler is None:
1643 # look at the first character of iFun, NOT of line, so we skip
1709 # look at the first character of iFun, NOT of line, so we skip
1644 # leading whitespace in multiline input
1710 # leading whitespace in multiline input
1645 handler = self.esc_handlers.get(iFun[0:1])
1711 handler = self.esc_handlers.get(iFun[0:1])
1646 if handler is not None:
1712 if handler is not None:
1647 return handler(line,continue_prompt,pre,iFun,theRest)
1713 return handler(line,continue_prompt,pre,iFun,theRest)
1648 # Emacs ipython-mode tags certain input lines
1714 # Emacs ipython-mode tags certain input lines
1649 if line.endswith('# PYTHON-MODE'):
1715 if line.endswith('# PYTHON-MODE'):
1650 return self.handle_emacs(line,continue_prompt)
1716 return self.handle_emacs(line,continue_prompt)
1651
1717
1652 # Next, check if we can automatically execute this thing
1718 # Next, check if we can automatically execute this thing
1653
1719
1654 # Allow ! in multi-line statements if multi_line_specials is on:
1720 # Allow ! in multi-line statements if multi_line_specials is on:
1655 if continue_prompt and self.rc.multi_line_specials and \
1721 if continue_prompt and self.rc.multi_line_specials and \
1656 iFun.startswith(self.ESC_SHELL):
1722 iFun.startswith(self.ESC_SHELL):
1657 return self.handle_shell_escape(line,continue_prompt,
1723 return self.handle_shell_escape(line,continue_prompt,
1658 pre=pre,iFun=iFun,
1724 pre=pre,iFun=iFun,
1659 theRest=theRest)
1725 theRest=theRest)
1660
1726
1661 # Let's try to find if the input line is a magic fn
1727 # Let's try to find if the input line is a magic fn
1662 oinfo = None
1728 oinfo = None
1663 if hasattr(self,'magic_'+iFun):
1729 if hasattr(self,'magic_'+iFun):
1664 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1730 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1665 if oinfo['ismagic']:
1731 if oinfo['ismagic']:
1666 # Be careful not to call magics when a variable assignment is
1732 # Be careful not to call magics when a variable assignment is
1667 # being made (ls='hi', for example)
1733 # being made (ls='hi', for example)
1668 if self.rc.automagic and \
1734 if self.rc.automagic and \
1669 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1735 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1670 (self.rc.multi_line_specials or not continue_prompt):
1736 (self.rc.multi_line_specials or not continue_prompt):
1671 return self.handle_magic(line,continue_prompt,
1737 return self.handle_magic(line,continue_prompt,
1672 pre,iFun,theRest)
1738 pre,iFun,theRest)
1673 else:
1739 else:
1674 return self.handle_normal(line,continue_prompt)
1740 return self.handle_normal(line,continue_prompt)
1675
1741
1676 # If the rest of the line begins with an (in)equality, assginment or
1742 # If the rest of the line begins with an (in)equality, assginment or
1677 # function call, we should not call _ofind but simply execute it.
1743 # function call, we should not call _ofind but simply execute it.
1678 # This avoids spurious geattr() accesses on objects upon assignment.
1744 # This avoids spurious geattr() accesses on objects upon assignment.
1679 #
1745 #
1680 # It also allows users to assign to either alias or magic names true
1746 # It also allows users to assign to either alias or magic names true
1681 # python variables (the magic/alias systems always take second seat to
1747 # python variables (the magic/alias systems always take second seat to
1682 # true python code).
1748 # true python code).
1683 if theRest and theRest[0] in '!=()':
1749 if theRest and theRest[0] in '!=()':
1684 return self.handle_normal(line,continue_prompt)
1750 return self.handle_normal(line,continue_prompt)
1685
1751
1686 if oinfo is None:
1752 if oinfo is None:
1687 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1753 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1688
1754
1689 if not oinfo['found']:
1755 if not oinfo['found']:
1690 return self.handle_normal(line,continue_prompt)
1756 return self.handle_normal(line,continue_prompt)
1691 else:
1757 else:
1692 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1758 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1693 if oinfo['isalias']:
1759 if oinfo['isalias']:
1694 return self.handle_alias(line,continue_prompt,
1760 return self.handle_alias(line,continue_prompt,
1695 pre,iFun,theRest)
1761 pre,iFun,theRest)
1696
1762
1697 if self.rc.autocall and \
1763 if self.rc.autocall and \
1698 not self.re_exclude_auto.match(theRest) and \
1764 not self.re_exclude_auto.match(theRest) and \
1699 self.re_fun_name.match(iFun) and \
1765 self.re_fun_name.match(iFun) and \
1700 callable(oinfo['obj']) :
1766 callable(oinfo['obj']) :
1701 #print 'going auto' # dbg
1767 #print 'going auto' # dbg
1702 return self.handle_auto(line,continue_prompt,pre,iFun,theRest)
1768 return self.handle_auto(line,continue_prompt,pre,iFun,theRest)
1703 else:
1769 else:
1704 #print 'was callable?', callable(oinfo['obj']) # dbg
1770 #print 'was callable?', callable(oinfo['obj']) # dbg
1705 return self.handle_normal(line,continue_prompt)
1771 return self.handle_normal(line,continue_prompt)
1706
1772
1707 # If we get here, we have a normal Python line. Log and return.
1773 # If we get here, we have a normal Python line. Log and return.
1708 return self.handle_normal(line,continue_prompt)
1774 return self.handle_normal(line,continue_prompt)
1709
1775
1710 def _prefilter_dumb(self, line, continue_prompt):
1776 def _prefilter_dumb(self, line, continue_prompt):
1711 """simple prefilter function, for debugging"""
1777 """simple prefilter function, for debugging"""
1712 return self.handle_normal(line,continue_prompt)
1778 return self.handle_normal(line,continue_prompt)
1713
1779
1714 # Set the default prefilter() function (this can be user-overridden)
1780 # Set the default prefilter() function (this can be user-overridden)
1715 prefilter = _prefilter
1781 prefilter = _prefilter
1716
1782
1717 def handle_normal(self,line,continue_prompt=None,
1783 def handle_normal(self,line,continue_prompt=None,
1718 pre=None,iFun=None,theRest=None):
1784 pre=None,iFun=None,theRest=None):
1719 """Handle normal input lines. Use as a template for handlers."""
1785 """Handle normal input lines. Use as a template for handlers."""
1720
1786
1721 # With autoindent on, we need some way to exit the input loop, and I
1787 # With autoindent on, we need some way to exit the input loop, and I
1722 # don't want to force the user to have to backspace all the way to
1788 # don't want to force the user to have to backspace all the way to
1723 # clear the line. The rule will be in this case, that either two
1789 # clear the line. The rule will be in this case, that either two
1724 # lines of pure whitespace in a row, or a line of pure whitespace but
1790 # lines of pure whitespace in a row, or a line of pure whitespace but
1725 # of a size different to the indent level, will exit the input loop.
1791 # of a size different to the indent level, will exit the input loop.
1726 if (continue_prompt and self.autoindent and isspace(line) and
1792 if (continue_prompt and self.autoindent and isspace(line) and
1727 (line != self.indent_current or isspace(self.buffer[-1]))):
1793 (line != self.indent_current or isspace(self.buffer[-1]))):
1728 line = ''
1794 line = ''
1729
1795
1730 self.log(line,continue_prompt)
1796 self.log(line,continue_prompt)
1731 self.update_cache(line)
1797 self.update_cache(line)
1732 return line
1798 return line
1733
1799
1734 def handle_alias(self,line,continue_prompt=None,
1800 def handle_alias(self,line,continue_prompt=None,
1735 pre=None,iFun=None,theRest=None):
1801 pre=None,iFun=None,theRest=None):
1736 """Handle alias input lines. """
1802 """Handle alias input lines. """
1737
1803
1738 theRest = esc_quotes(theRest)
1804 theRest = esc_quotes(theRest)
1739 line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest)
1805 line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest)
1740 self.log(line_out,continue_prompt)
1806 self.log(line_out,continue_prompt)
1741 self.update_cache(line_out)
1807 self.update_cache(line_out)
1742 return line_out
1808 return line_out
1743
1809
1744 def handle_shell_escape(self, line, continue_prompt=None,
1810 def handle_shell_escape(self, line, continue_prompt=None,
1745 pre=None,iFun=None,theRest=None):
1811 pre=None,iFun=None,theRest=None):
1746 """Execute the line in a shell, empty return value"""
1812 """Execute the line in a shell, empty return value"""
1747
1813
1748 #print 'line in :', `line` # dbg
1814 #print 'line in :', `line` # dbg
1749 # Example of a special handler. Others follow a similar pattern.
1815 # Example of a special handler. Others follow a similar pattern.
1750 if continue_prompt: # multi-line statements
1816 if continue_prompt: # multi-line statements
1751 if iFun.startswith('!!'):
1817 if iFun.startswith('!!'):
1752 print 'SyntaxError: !! is not allowed in multiline statements'
1818 print 'SyntaxError: !! is not allowed in multiline statements'
1753 return pre
1819 return pre
1754 else:
1820 else:
1755 cmd = ("%s %s" % (iFun[1:],theRest)) #.replace('"','\\"')
1821 cmd = ("%s %s" % (iFun[1:],theRest)) #.replace('"','\\"')
1756 #line_out = '%s%s.system("%s")' % (pre,self.name,cmd)
1822 #line_out = '%s%s.system("%s")' % (pre,self.name,cmd)
1757 line_out = '%s%s.system(r"""%s"""[:-1])' % (pre,self.name,cmd + "_")
1823 line_out = '%s%s.system(r"""%s"""[:-1])' % (pre,self.name,cmd + "_")
1758 #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')'
1824 #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')'
1759 else: # single-line input
1825 else: # single-line input
1760 if line.startswith('!!'):
1826 if line.startswith('!!'):
1761 # rewrite iFun/theRest to properly hold the call to %sx and
1827 # rewrite iFun/theRest to properly hold the call to %sx and
1762 # the actual command to be executed, so handle_magic can work
1828 # the actual command to be executed, so handle_magic can work
1763 # correctly
1829 # correctly
1764 theRest = '%s %s' % (iFun[2:],theRest)
1830 theRest = '%s %s' % (iFun[2:],theRest)
1765 iFun = 'sx'
1831 iFun = 'sx'
1766 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1832 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1767 continue_prompt,pre,iFun,theRest)
1833 continue_prompt,pre,iFun,theRest)
1768 else:
1834 else:
1769 #cmd = esc_quotes(line[1:])
1835 #cmd = esc_quotes(line[1:])
1770 cmd=line[1:]
1836 cmd=line[1:]
1771 #line_out = '%s.system("%s")' % (self.name,cmd)
1837 #line_out = '%s.system("%s")' % (self.name,cmd)
1772 line_out = '%s.system(r"""%s"""[:-1])' % (self.name,cmd +"_")
1838 line_out = '%s.system(r"""%s"""[:-1])' % (self.name,cmd +"_")
1773 #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')'
1839 #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')'
1774 # update cache/log and return
1840 # update cache/log and return
1775 self.log(line_out,continue_prompt)
1841 self.log(line_out,continue_prompt)
1776 self.update_cache(line_out) # readline cache gets normal line
1842 self.update_cache(line_out) # readline cache gets normal line
1777 #print 'line out r:', `line_out` # dbg
1843 #print 'line out r:', `line_out` # dbg
1778 #print 'line out s:', line_out # dbg
1844 #print 'line out s:', line_out # dbg
1779 return line_out
1845 return line_out
1780
1846
1781 def handle_magic(self, line, continue_prompt=None,
1847 def handle_magic(self, line, continue_prompt=None,
1782 pre=None,iFun=None,theRest=None):
1848 pre=None,iFun=None,theRest=None):
1783 """Execute magic functions.
1849 """Execute magic functions.
1784
1850
1785 Also log them with a prepended # so the log is clean Python."""
1851 Also log them with a prepended # so the log is clean Python."""
1786
1852
1787 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1853 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1788 self.log(cmd,continue_prompt)
1854 self.log(cmd,continue_prompt)
1789 self.update_cache(line)
1855 self.update_cache(line)
1790 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1856 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1791 return cmd
1857 return cmd
1792
1858
1793 def handle_auto(self, line, continue_prompt=None,
1859 def handle_auto(self, line, continue_prompt=None,
1794 pre=None,iFun=None,theRest=None):
1860 pre=None,iFun=None,theRest=None):
1795 """Hande lines which can be auto-executed, quoting if requested."""
1861 """Hande lines which can be auto-executed, quoting if requested."""
1796
1862
1797 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1863 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1798
1864
1799 # This should only be active for single-line input!
1865 # This should only be active for single-line input!
1800 if continue_prompt:
1866 if continue_prompt:
1801 return line
1867 return line
1802
1868
1803 if pre == self.ESC_QUOTE:
1869 if pre == self.ESC_QUOTE:
1804 # Auto-quote splitting on whitespace
1870 # Auto-quote splitting on whitespace
1805 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1871 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1806 elif pre == self.ESC_QUOTE2:
1872 elif pre == self.ESC_QUOTE2:
1807 # Auto-quote whole string
1873 # Auto-quote whole string
1808 newcmd = '%s("%s")' % (iFun,theRest)
1874 newcmd = '%s("%s")' % (iFun,theRest)
1809 else:
1875 else:
1810 # Auto-paren
1876 # Auto-paren
1811 if theRest[0:1] in ('=','['):
1877 if theRest[0:1] in ('=','['):
1812 # Don't autocall in these cases. They can be either
1878 # Don't autocall in these cases. They can be either
1813 # rebindings of an existing callable's name, or item access
1879 # rebindings of an existing callable's name, or item access
1814 # for an object which is BOTH callable and implements
1880 # for an object which is BOTH callable and implements
1815 # __getitem__.
1881 # __getitem__.
1816 return '%s %s' % (iFun,theRest)
1882 return '%s %s' % (iFun,theRest)
1817 if theRest.endswith(';'):
1883 if theRest.endswith(';'):
1818 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1884 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1819 else:
1885 else:
1820 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1886 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1821
1887
1822 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1888 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1823 # log what is now valid Python, not the actual user input (without the
1889 # log what is now valid Python, not the actual user input (without the
1824 # final newline)
1890 # final newline)
1825 self.log(newcmd,continue_prompt)
1891 self.log(newcmd,continue_prompt)
1826 return newcmd
1892 return newcmd
1827
1893
1828 def handle_help(self, line, continue_prompt=None,
1894 def handle_help(self, line, continue_prompt=None,
1829 pre=None,iFun=None,theRest=None):
1895 pre=None,iFun=None,theRest=None):
1830 """Try to get some help for the object.
1896 """Try to get some help for the object.
1831
1897
1832 obj? or ?obj -> basic information.
1898 obj? or ?obj -> basic information.
1833 obj?? or ??obj -> more details.
1899 obj?? or ??obj -> more details.
1834 """
1900 """
1835
1901
1836 # We need to make sure that we don't process lines which would be
1902 # We need to make sure that we don't process lines which would be
1837 # otherwise valid python, such as "x=1 # what?"
1903 # otherwise valid python, such as "x=1 # what?"
1838 try:
1904 try:
1839 codeop.compile_command(line)
1905 codeop.compile_command(line)
1840 except SyntaxError:
1906 except SyntaxError:
1841 # We should only handle as help stuff which is NOT valid syntax
1907 # We should only handle as help stuff which is NOT valid syntax
1842 if line[0]==self.ESC_HELP:
1908 if line[0]==self.ESC_HELP:
1843 line = line[1:]
1909 line = line[1:]
1844 elif line[-1]==self.ESC_HELP:
1910 elif line[-1]==self.ESC_HELP:
1845 line = line[:-1]
1911 line = line[:-1]
1846 self.log('#?'+line)
1912 self.log('#?'+line)
1847 self.update_cache(line)
1913 self.update_cache(line)
1848 if line:
1914 if line:
1849 self.magic_pinfo(line)
1915 self.magic_pinfo(line)
1850 else:
1916 else:
1851 page(self.usage,screen_lines=self.rc.screen_length)
1917 page(self.usage,screen_lines=self.rc.screen_length)
1852 return '' # Empty string is needed here!
1918 return '' # Empty string is needed here!
1853 except:
1919 except:
1854 # Pass any other exceptions through to the normal handler
1920 # Pass any other exceptions through to the normal handler
1855 return self.handle_normal(line,continue_prompt)
1921 return self.handle_normal(line,continue_prompt)
1856 else:
1922 else:
1857 # If the code compiles ok, we should handle it normally
1923 # If the code compiles ok, we should handle it normally
1858 return self.handle_normal(line,continue_prompt)
1924 return self.handle_normal(line,continue_prompt)
1859
1925
1860 def handle_emacs(self,line,continue_prompt=None,
1926 def handle_emacs(self,line,continue_prompt=None,
1861 pre=None,iFun=None,theRest=None):
1927 pre=None,iFun=None,theRest=None):
1862 """Handle input lines marked by python-mode."""
1928 """Handle input lines marked by python-mode."""
1863
1929
1864 # Currently, nothing is done. Later more functionality can be added
1930 # Currently, nothing is done. Later more functionality can be added
1865 # here if needed.
1931 # here if needed.
1866
1932
1867 # The input cache shouldn't be updated
1933 # The input cache shouldn't be updated
1868
1934
1869 return line
1935 return line
1870
1936
1871 def write(self,data):
1937 def write(self,data):
1872 """Write a string to the default output"""
1938 """Write a string to the default output"""
1873 Term.cout.write(data)
1939 Term.cout.write(data)
1874
1940
1875 def write_err(self,data):
1941 def write_err(self,data):
1876 """Write a string to the default error output"""
1942 """Write a string to the default error output"""
1877 Term.cerr.write(data)
1943 Term.cerr.write(data)
1878
1944
1879 def exit(self):
1945 def exit(self):
1880 """Handle interactive exit.
1946 """Handle interactive exit.
1881
1947
1882 This method sets the exit_now attribute."""
1948 This method sets the exit_now attribute."""
1883
1949
1884 if self.rc.confirm_exit:
1950 if self.rc.confirm_exit:
1885 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
1951 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
1886 self.exit_now = True
1952 self.exit_now = True
1887 else:
1953 else:
1888 self.exit_now = True
1954 self.exit_now = True
1889 return self.exit_now
1955 return self.exit_now
1890
1956
1891 def safe_execfile(self,fname,*where,**kw):
1957 def safe_execfile(self,fname,*where,**kw):
1892 fname = os.path.expanduser(fname)
1958 fname = os.path.expanduser(fname)
1893
1959
1894 # find things also in current directory
1960 # find things also in current directory
1895 dname = os.path.dirname(fname)
1961 dname = os.path.dirname(fname)
1896 if not sys.path.count(dname):
1962 if not sys.path.count(dname):
1897 sys.path.append(dname)
1963 sys.path.append(dname)
1898
1964
1899 try:
1965 try:
1900 xfile = open(fname)
1966 xfile = open(fname)
1901 except:
1967 except:
1902 print >> Term.cerr, \
1968 print >> Term.cerr, \
1903 'Could not open file <%s> for safe execution.' % fname
1969 'Could not open file <%s> for safe execution.' % fname
1904 return None
1970 return None
1905
1971
1906 kw.setdefault('islog',0)
1972 kw.setdefault('islog',0)
1907 kw.setdefault('quiet',1)
1973 kw.setdefault('quiet',1)
1908 kw.setdefault('exit_ignore',0)
1974 kw.setdefault('exit_ignore',0)
1909 first = xfile.readline()
1975 first = xfile.readline()
1910 _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip()
1976 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
1911 xfile.close()
1977 xfile.close()
1912 # line by line execution
1978 # line by line execution
1913 if first.startswith(_LOGHEAD) or kw['islog']:
1979 if first.startswith(loghead) or kw['islog']:
1914 print 'Loading log file <%s> one line at a time...' % fname
1980 print 'Loading log file <%s> one line at a time...' % fname
1915 if kw['quiet']:
1981 if kw['quiet']:
1916 stdout_save = sys.stdout
1982 stdout_save = sys.stdout
1917 sys.stdout = StringIO.StringIO()
1983 sys.stdout = StringIO.StringIO()
1918 try:
1984 try:
1919 globs,locs = where[0:2]
1985 globs,locs = where[0:2]
1920 except:
1986 except:
1921 try:
1987 try:
1922 globs = locs = where[0]
1988 globs = locs = where[0]
1923 except:
1989 except:
1924 globs = locs = globals()
1990 globs = locs = globals()
1925 badblocks = []
1991 badblocks = []
1926
1992
1927 # we also need to identify indented blocks of code when replaying
1993 # we also need to identify indented blocks of code when replaying
1928 # logs and put them together before passing them to an exec
1994 # logs and put them together before passing them to an exec
1929 # statement. This takes a bit of regexp and look-ahead work in the
1995 # statement. This takes a bit of regexp and look-ahead work in the
1930 # file. It's easiest if we swallow the whole thing in memory
1996 # file. It's easiest if we swallow the whole thing in memory
1931 # first, and manually walk through the lines list moving the
1997 # first, and manually walk through the lines list moving the
1932 # counter ourselves.
1998 # counter ourselves.
1933 indent_re = re.compile('\s+\S')
1999 indent_re = re.compile('\s+\S')
1934 xfile = open(fname)
2000 xfile = open(fname)
1935 filelines = xfile.readlines()
2001 filelines = xfile.readlines()
1936 xfile.close()
2002 xfile.close()
1937 nlines = len(filelines)
2003 nlines = len(filelines)
1938 lnum = 0
2004 lnum = 0
1939 while lnum < nlines:
2005 while lnum < nlines:
1940 line = filelines[lnum]
2006 line = filelines[lnum]
1941 lnum += 1
2007 lnum += 1
1942 # don't re-insert logger status info into cache
2008 # don't re-insert logger status info into cache
1943 if line.startswith('#log#'):
2009 if line.startswith('#log#'):
1944 continue
2010 continue
1945 elif line.startswith('#%s'% self.ESC_MAGIC):
1946 self.update_cache(line[1:])
1947 line = magic2python(line)
1948 elif line.startswith('#!'):
2011 elif line.startswith('#!'):
1949 self.update_cache(line[1:])
2012 self.update_cache(line[1:])
1950 else:
2013 else:
1951 # build a block of code (maybe a single line) for execution
2014 # build a block of code (maybe a single line) for execution
1952 block = line
2015 block = line
1953 try:
2016 try:
1954 next = filelines[lnum] # lnum has already incremented
2017 next = filelines[lnum] # lnum has already incremented
1955 except:
2018 except:
1956 next = None
2019 next = None
1957 while next and indent_re.match(next):
2020 while next and indent_re.match(next):
1958 block += next
2021 block += next
1959 lnum += 1
2022 lnum += 1
1960 try:
2023 try:
1961 next = filelines[lnum]
2024 next = filelines[lnum]
1962 except:
2025 except:
1963 next = None
2026 next = None
1964 # now execute the block of one or more lines
2027 # now execute the block of one or more lines
1965 try:
2028 try:
1966 exec block in globs,locs
2029 exec block in globs,locs
1967 self.update_cache(block.rstrip())
2030 self.update_cache(block.rstrip())
1968 except SystemExit:
2031 except SystemExit:
1969 pass
2032 pass
1970 except:
2033 except:
1971 badblocks.append(block.rstrip())
2034 badblocks.append(block.rstrip())
1972 if kw['quiet']: # restore stdout
2035 if kw['quiet']: # restore stdout
1973 sys.stdout.close()
2036 sys.stdout.close()
1974 sys.stdout = stdout_save
2037 sys.stdout = stdout_save
1975 print 'Finished replaying log file <%s>' % fname
2038 print 'Finished replaying log file <%s>' % fname
1976 if badblocks:
2039 if badblocks:
1977 print >> sys.stderr, ('\nThe following lines/blocks in file '
2040 print >> sys.stderr, ('\nThe following lines/blocks in file '
1978 '<%s> reported errors:' % fname)
2041 '<%s> reported errors:' % fname)
1979
2042
1980 for badline in badblocks:
2043 for badline in badblocks:
1981 print >> sys.stderr, badline
2044 print >> sys.stderr, badline
1982 else: # regular file execution
2045 else: # regular file execution
1983 try:
2046 try:
1984 execfile(fname,*where)
2047 execfile(fname,*where)
1985 except SyntaxError:
2048 except SyntaxError:
1986 etype,evalue = sys.exc_info()[:2]
2049 etype,evalue = sys.exc_info()[:2]
1987 self.SyntaxTB(etype,evalue,[])
2050 self.SyntaxTB(etype,evalue,[])
1988 warn('Failure executing file: <%s>' % fname)
2051 warn('Failure executing file: <%s>' % fname)
1989 except SystemExit,status:
2052 except SystemExit,status:
1990 if not kw['exit_ignore']:
2053 if not kw['exit_ignore']:
1991 self.InteractiveTB()
2054 self.InteractiveTB()
1992 warn('Failure executing file: <%s>' % fname)
2055 warn('Failure executing file: <%s>' % fname)
1993 except:
2056 except:
1994 self.InteractiveTB()
2057 self.InteractiveTB()
1995 warn('Failure executing file: <%s>' % fname)
2058 warn('Failure executing file: <%s>' % fname)
1996
2059
1997 #************************* end of file <iplib.py> *****************************
2060 #************************* end of file <iplib.py> *****************************
@@ -1,735 +1,701 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.1 or better.
5 Requires Python 2.1 or better.
6
6
7 This file contains the main make_IPython() starter function.
7 This file contains the main make_IPython() starter function.
8
8
9 $Id: ipmaker.py 965 2005-12-28 23:23:09Z fperez $"""
9 $Id: ipmaker.py 966 2005-12-29 08:34:07Z fperez $"""
10
10
11 #*****************************************************************************
11 #*****************************************************************************
12 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
12 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
13 #
13 #
14 # Distributed under the terms of the BSD License. The full license is in
14 # Distributed under the terms of the BSD License. The full license is in
15 # the file COPYING, distributed as part of this software.
15 # the file COPYING, distributed as part of this software.
16 #*****************************************************************************
16 #*****************************************************************************
17
17
18 from IPython import Release
18 from IPython import Release
19 __author__ = '%s <%s>' % Release.authors['Fernando']
19 __author__ = '%s <%s>' % Release.authors['Fernando']
20 __license__ = Release.license
20 __license__ = Release.license
21 __version__ = Release.version
21 __version__ = Release.version
22
22
23 credits._Printer__data = """
23 credits._Printer__data = """
24 Python: %s
24 Python: %s
25
25
26 IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users.
26 IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users.
27 See http://ipython.scipy.org for more information.""" \
27 See http://ipython.scipy.org for more information.""" \
28 % credits._Printer__data
28 % credits._Printer__data
29
29
30 copyright._Printer__data += """
30 copyright._Printer__data += """
31
31
32 Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray.
32 Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray.
33 All Rights Reserved."""
33 All Rights Reserved."""
34
34
35 #****************************************************************************
35 #****************************************************************************
36 # Required modules
36 # Required modules
37
37
38 # From the standard library
38 # From the standard library
39 import __main__
39 import __main__
40 import __builtin__
40 import __builtin__
41 import os
41 import os
42 import re
42 import re
43 import sys
43 import sys
44 import types
44 import types
45 from pprint import pprint,pformat
45 from pprint import pprint,pformat
46
46
47 # Our own
47 # Our own
48 from IPython import DPyGetOpt
48 from IPython import DPyGetOpt
49 from IPython.Struct import Struct
49 from IPython.Struct import Struct
50 from IPython.OutputTrap import OutputTrap
50 from IPython.OutputTrap import OutputTrap
51 from IPython.ConfigLoader import ConfigLoader
51 from IPython.ConfigLoader import ConfigLoader
52 from IPython.iplib import InteractiveShell,qw_lol,import_fail_info
52 from IPython.iplib import InteractiveShell,qw_lol,import_fail_info
53 from IPython.usage import cmd_line_usage,interactive_usage
53 from IPython.usage import cmd_line_usage,interactive_usage
54 from IPython.Prompts import CachedOutput
55 from IPython.genutils import *
54 from IPython.genutils import *
56
55
57 #-----------------------------------------------------------------------------
56 #-----------------------------------------------------------------------------
58 def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1,
57 def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1,
59 rc_override=None,shell_class=InteractiveShell,
58 rc_override=None,shell_class=InteractiveShell,
60 embedded=False,**kw):
59 embedded=False,**kw):
61 """This is a dump of IPython into a single function.
60 """This is a dump of IPython into a single function.
62
61
63 Later it will have to be broken up in a sensible manner.
62 Later it will have to be broken up in a sensible manner.
64
63
65 Arguments:
64 Arguments:
66
65
67 - argv: a list similar to sys.argv[1:]. It should NOT contain the desired
66 - argv: a list similar to sys.argv[1:]. It should NOT contain the desired
68 script name, b/c DPyGetOpt strips the first argument only for the real
67 script name, b/c DPyGetOpt strips the first argument only for the real
69 sys.argv.
68 sys.argv.
70
69
71 - user_ns: a dict to be used as the user's namespace."""
70 - user_ns: a dict to be used as the user's namespace."""
72
71
73 #----------------------------------------------------------------------
72 #----------------------------------------------------------------------
74 # Defaults and initialization
73 # Defaults and initialization
75
74
76 # For developer debugging, deactivates crash handler and uses pdb.
75 # For developer debugging, deactivates crash handler and uses pdb.
77 DEVDEBUG = False
76 DEVDEBUG = False
78
77
79 if argv is None:
78 if argv is None:
80 argv = sys.argv
79 argv = sys.argv
81
80
82 # __IP is the main global that lives throughout and represents the whole
81 # __IP is the main global that lives throughout and represents the whole
83 # application. If the user redefines it, all bets are off as to what
82 # application. If the user redefines it, all bets are off as to what
84 # happens.
83 # happens.
85
84
86 # __IP is the name of he global which the caller will have accessible as
85 # __IP is the name of he global which the caller will have accessible as
87 # __IP.name. We set its name via the first parameter passed to
86 # __IP.name. We set its name via the first parameter passed to
88 # InteractiveShell:
87 # InteractiveShell:
89
88
90 IP = shell_class('__IP',user_ns=user_ns,user_global_ns=user_global_ns,
89 IP = shell_class('__IP',user_ns=user_ns,user_global_ns=user_global_ns,
91 embedded=embedded,**kw)
90 embedded=embedded,**kw)
92
91
93 # Put 'help' in the user namespace
92 # Put 'help' in the user namespace
94 from site import _Helper
93 from site import _Helper
95 IP.user_ns['help'] = _Helper()
94 IP.user_ns['help'] = _Helper()
96
95
97
96
98 if DEVDEBUG:
97 if DEVDEBUG:
99 # For developer debugging only (global flag)
98 # For developer debugging only (global flag)
100 from IPython import ultraTB
99 from IPython import ultraTB
101 sys.excepthook = ultraTB.VerboseTB(call_pdb=1)
100 sys.excepthook = ultraTB.VerboseTB(call_pdb=1)
102
101
103 IP.BANNER_PARTS = ['Python %s\n'
102 IP.BANNER_PARTS = ['Python %s\n'
104 'Type "copyright", "credits" or "license" '
103 'Type "copyright", "credits" or "license" '
105 'for more information.\n'
104 'for more information.\n'
106 % (sys.version.split('\n')[0],),
105 % (sys.version.split('\n')[0],),
107 "IPython %s -- An enhanced Interactive Python."
106 "IPython %s -- An enhanced Interactive Python."
108 % (__version__,),
107 % (__version__,),
109 """? -> Introduction to IPython's features.
108 """? -> Introduction to IPython's features.
110 %magic -> Information about IPython's 'magic' % functions.
109 %magic -> Information about IPython's 'magic' % functions.
111 help -> Python's own help system.
110 help -> Python's own help system.
112 object? -> Details about 'object'. ?object also works, ?? prints more.
111 object? -> Details about 'object'. ?object also works, ?? prints more.
113 """ ]
112 """ ]
114
113
115 IP.usage = interactive_usage
114 IP.usage = interactive_usage
116
115
117 # Platform-dependent suffix and directory names. We use _ipython instead
116 # Platform-dependent suffix and directory names. We use _ipython instead
118 # of .ipython under win32 b/c there's software that breaks with .named
117 # of .ipython under win32 b/c there's software that breaks with .named
119 # directories on that platform.
118 # directories on that platform.
120 if os.name == 'posix':
119 if os.name == 'posix':
121 rc_suffix = ''
120 rc_suffix = ''
122 ipdir_def = '.ipython'
121 ipdir_def = '.ipython'
123 else:
122 else:
124 rc_suffix = '.ini'
123 rc_suffix = '.ini'
125 ipdir_def = '_ipython'
124 ipdir_def = '_ipython'
126
125
127 # default directory for configuration
126 # default directory for configuration
128 ipythondir = os.path.abspath(os.environ.get('IPYTHONDIR',
127 ipythondir = os.path.abspath(os.environ.get('IPYTHONDIR',
129 os.path.join(IP.home_dir,ipdir_def)))
128 os.path.join(IP.home_dir,ipdir_def)))
130
129
131 # we need the directory where IPython itself is installed
130 # we need the directory where IPython itself is installed
132 import IPython
131 import IPython
133 IPython_dir = os.path.dirname(IPython.__file__)
132 IPython_dir = os.path.dirname(IPython.__file__)
134 del IPython
133 del IPython
135
134
136 #-------------------------------------------------------------------------
135 #-------------------------------------------------------------------------
137 # Command line handling
136 # Command line handling
138
137
139 # Valid command line options (uses DPyGetOpt syntax, like Perl's
138 # Valid command line options (uses DPyGetOpt syntax, like Perl's
140 # GetOpt::Long)
139 # GetOpt::Long)
141
140
142 # Any key not listed here gets deleted even if in the file (like session
141 # Any key not listed here gets deleted even if in the file (like session
143 # or profile). That's deliberate, to maintain the rc namespace clean.
142 # or profile). That's deliberate, to maintain the rc namespace clean.
144
143
145 # Each set of options appears twice: under _conv only the names are
144 # Each set of options appears twice: under _conv only the names are
146 # listed, indicating which type they must be converted to when reading the
145 # listed, indicating which type they must be converted to when reading the
147 # ipythonrc file. And under DPyGetOpt they are listed with the regular
146 # ipythonrc file. And under DPyGetOpt they are listed with the regular
148 # DPyGetOpt syntax (=s,=i,:f,etc).
147 # DPyGetOpt syntax (=s,=i,:f,etc).
149
148
150 # Make sure there's a space before each end of line (they get auto-joined!)
149 # Make sure there's a space before each end of line (they get auto-joined!)
151 cmdline_opts = ('autocall! autoindent! automagic! banner! cache_size|cs=i '
150 cmdline_opts = ('autocall! autoindent! automagic! banner! cache_size|cs=i '
152 'c=s classic|cl color_info! colors=s confirm_exit! '
151 'c=s classic|cl color_info! colors=s confirm_exit! '
153 'debug! deep_reload! editor=s log|l messages! nosep pdb! '
152 'debug! deep_reload! editor=s log|l messages! nosep pdb! '
154 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
153 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
155 'quick screen_length|sl=i prompts_pad_left=i '
154 'quick screen_length|sl=i prompts_pad_left=i '
156 'logfile|lf=s logplay|lp=s profile|p=s '
155 'logfile|lf=s logplay|lp=s profile|p=s '
157 'readline! readline_merge_completions! '
156 'readline! readline_merge_completions! '
158 'readline_omit__names! '
157 'readline_omit__names! '
159 'rcfile=s separate_in|si=s separate_out|so=s '
158 'rcfile=s separate_in|si=s separate_out|so=s '
160 'separate_out2|so2=s xmode=s wildcards_case_sensitive! '
159 'separate_out2|so2=s xmode=s wildcards_case_sensitive! '
161 'magic_docstrings system_verbose! '
160 'magic_docstrings system_verbose! '
162 'multi_line_specials! '
161 'multi_line_specials! '
163 'autoedit_syntax!')
162 'autoedit_syntax!')
164
163
165 # Options that can *only* appear at the cmd line (not in rcfiles).
164 # Options that can *only* appear at the cmd line (not in rcfiles).
166
165
167 # The "ignore" option is a kludge so that Emacs buffers don't crash, since
166 # The "ignore" option is a kludge so that Emacs buffers don't crash, since
168 # the 'C-c !' command in emacs automatically appends a -i option at the end.
167 # the 'C-c !' command in emacs automatically appends a -i option at the end.
169 cmdline_only = ('help ignore|i ipythondir=s Version upgrade '
168 cmdline_only = ('help ignore|i ipythondir=s Version upgrade '
170 'gthread! qthread! wthread! pylab! tk!')
169 'gthread! qthread! wthread! pylab! tk!')
171
170
172 # Build the actual name list to be used by DPyGetOpt
171 # Build the actual name list to be used by DPyGetOpt
173 opts_names = qw(cmdline_opts) + qw(cmdline_only)
172 opts_names = qw(cmdline_opts) + qw(cmdline_only)
174
173
175 # Set sensible command line defaults.
174 # Set sensible command line defaults.
176 # This should have everything from cmdline_opts and cmdline_only
175 # This should have everything from cmdline_opts and cmdline_only
177 opts_def = Struct(autocall = 1,
176 opts_def = Struct(autocall = 1,
178 autoedit_syntax = 1,
177 autoedit_syntax = 1,
179 autoindent=0,
178 autoindent=0,
180 automagic = 1,
179 automagic = 1,
181 banner = 1,
180 banner = 1,
182 cache_size = 1000,
181 cache_size = 1000,
183 c = '',
182 c = '',
184 classic = 0,
183 classic = 0,
185 colors = 'NoColor',
184 colors = 'NoColor',
186 color_info = 0,
185 color_info = 0,
187 confirm_exit = 1,
186 confirm_exit = 1,
188 debug = 0,
187 debug = 0,
189 deep_reload = 0,
188 deep_reload = 0,
190 editor = '0',
189 editor = '0',
191 help = 0,
190 help = 0,
192 ignore = 0,
191 ignore = 0,
193 ipythondir = ipythondir,
192 ipythondir = ipythondir,
194 log = 0,
193 log = 0,
195 logfile = '',
194 logfile = '',
196 logplay = '',
195 logplay = '',
197 multi_line_specials = 1,
196 multi_line_specials = 1,
198 messages = 1,
197 messages = 1,
199 nosep = 0,
198 nosep = 0,
200 pdb = 0,
199 pdb = 0,
201 pprint = 0,
200 pprint = 0,
202 profile = '',
201 profile = '',
203 prompt_in1 = 'In [\\#]: ',
202 prompt_in1 = 'In [\\#]: ',
204 prompt_in2 = ' .\\D.: ',
203 prompt_in2 = ' .\\D.: ',
205 prompt_out = 'Out[\\#]: ',
204 prompt_out = 'Out[\\#]: ',
206 prompts_pad_left = 1,
205 prompts_pad_left = 1,
207 quick = 0,
206 quick = 0,
208 readline = 1,
207 readline = 1,
209 readline_merge_completions = 1,
208 readline_merge_completions = 1,
210 readline_omit__names = 0,
209 readline_omit__names = 0,
211 rcfile = 'ipythonrc' + rc_suffix,
210 rcfile = 'ipythonrc' + rc_suffix,
212 screen_length = 0,
211 screen_length = 0,
213 separate_in = '\n',
212 separate_in = '\n',
214 separate_out = '\n',
213 separate_out = '\n',
215 separate_out2 = '',
214 separate_out2 = '',
216 system_verbose = 0,
215 system_verbose = 0,
217 gthread = 0,
216 gthread = 0,
218 qthread = 0,
217 qthread = 0,
219 wthread = 0,
218 wthread = 0,
220 pylab = 0,
219 pylab = 0,
221 tk = 0,
220 tk = 0,
222 upgrade = 0,
221 upgrade = 0,
223 Version = 0,
222 Version = 0,
224 xmode = 'Verbose',
223 xmode = 'Verbose',
225 wildcards_case_sensitive = 1,
224 wildcards_case_sensitive = 1,
226 magic_docstrings = 0, # undocumented, for doc generation
225 magic_docstrings = 0, # undocumented, for doc generation
227 )
226 )
228
227
229 # Things that will *only* appear in rcfiles (not at the command line).
228 # Things that will *only* appear in rcfiles (not at the command line).
230 # Make sure there's a space before each end of line (they get auto-joined!)
229 # Make sure there's a space before each end of line (they get auto-joined!)
231 rcfile_opts = { qwflat: 'include import_mod import_all execfile ',
230 rcfile_opts = { qwflat: 'include import_mod import_all execfile ',
232 qw_lol: 'import_some ',
231 qw_lol: 'import_some ',
233 # for things with embedded whitespace:
232 # for things with embedded whitespace:
234 list_strings:'execute alias readline_parse_and_bind ',
233 list_strings:'execute alias readline_parse_and_bind ',
235 # Regular strings need no conversion:
234 # Regular strings need no conversion:
236 None:'readline_remove_delims ',
235 None:'readline_remove_delims ',
237 }
236 }
238 # Default values for these
237 # Default values for these
239 rc_def = Struct(include = [],
238 rc_def = Struct(include = [],
240 import_mod = [],
239 import_mod = [],
241 import_all = [],
240 import_all = [],
242 import_some = [[]],
241 import_some = [[]],
243 execute = [],
242 execute = [],
244 execfile = [],
243 execfile = [],
245 alias = [],
244 alias = [],
246 readline_parse_and_bind = [],
245 readline_parse_and_bind = [],
247 readline_remove_delims = '',
246 readline_remove_delims = '',
248 )
247 )
249
248
250 # Build the type conversion dictionary from the above tables:
249 # Build the type conversion dictionary from the above tables:
251 typeconv = rcfile_opts.copy()
250 typeconv = rcfile_opts.copy()
252 typeconv.update(optstr2types(cmdline_opts))
251 typeconv.update(optstr2types(cmdline_opts))
253
252
254 # FIXME: the None key appears in both, put that back together by hand. Ugly!
253 # FIXME: the None key appears in both, put that back together by hand. Ugly!
255 typeconv[None] += ' ' + rcfile_opts[None]
254 typeconv[None] += ' ' + rcfile_opts[None]
256
255
257 # Remove quotes at ends of all strings (used to protect spaces)
256 # Remove quotes at ends of all strings (used to protect spaces)
258 typeconv[unquote_ends] = typeconv[None]
257 typeconv[unquote_ends] = typeconv[None]
259 del typeconv[None]
258 del typeconv[None]
260
259
261 # Build the list we'll use to make all config decisions with defaults:
260 # Build the list we'll use to make all config decisions with defaults:
262 opts_all = opts_def.copy()
261 opts_all = opts_def.copy()
263 opts_all.update(rc_def)
262 opts_all.update(rc_def)
264
263
265 # Build conflict resolver for recursive loading of config files:
264 # Build conflict resolver for recursive loading of config files:
266 # - preserve means the outermost file maintains the value, it is not
265 # - preserve means the outermost file maintains the value, it is not
267 # overwritten if an included file has the same key.
266 # overwritten if an included file has the same key.
268 # - add_flip applies + to the two values, so it better make sense to add
267 # - add_flip applies + to the two values, so it better make sense to add
269 # those types of keys. But it flips them first so that things loaded
268 # those types of keys. But it flips them first so that things loaded
270 # deeper in the inclusion chain have lower precedence.
269 # deeper in the inclusion chain have lower precedence.
271 conflict = {'preserve': ' '.join([ typeconv[int],
270 conflict = {'preserve': ' '.join([ typeconv[int],
272 typeconv[unquote_ends] ]),
271 typeconv[unquote_ends] ]),
273 'add_flip': ' '.join([ typeconv[qwflat],
272 'add_flip': ' '.join([ typeconv[qwflat],
274 typeconv[qw_lol],
273 typeconv[qw_lol],
275 typeconv[list_strings] ])
274 typeconv[list_strings] ])
276 }
275 }
277
276
278 # Now actually process the command line
277 # Now actually process the command line
279 getopt = DPyGetOpt.DPyGetOpt()
278 getopt = DPyGetOpt.DPyGetOpt()
280 getopt.setIgnoreCase(0)
279 getopt.setIgnoreCase(0)
281
280
282 getopt.parseConfiguration(opts_names)
281 getopt.parseConfiguration(opts_names)
283
282
284 try:
283 try:
285 getopt.processArguments(argv)
284 getopt.processArguments(argv)
286 except:
285 except:
287 print cmd_line_usage
286 print cmd_line_usage
288 warn('\nError in Arguments: ' + `sys.exc_value`)
287 warn('\nError in Arguments: ' + `sys.exc_value`)
289 sys.exit(1)
288 sys.exit(1)
290
289
291 # convert the options dict to a struct for much lighter syntax later
290 # convert the options dict to a struct for much lighter syntax later
292 opts = Struct(getopt.optionValues)
291 opts = Struct(getopt.optionValues)
293 args = getopt.freeValues
292 args = getopt.freeValues
294
293
295 # this is the struct (which has default values at this point) with which
294 # this is the struct (which has default values at this point) with which
296 # we make all decisions:
295 # we make all decisions:
297 opts_all.update(opts)
296 opts_all.update(opts)
298
297
299 # Options that force an immediate exit
298 # Options that force an immediate exit
300 if opts_all.help:
299 if opts_all.help:
301 page(cmd_line_usage)
300 page(cmd_line_usage)
302 sys.exit()
301 sys.exit()
303
302
304 if opts_all.Version:
303 if opts_all.Version:
305 print __version__
304 print __version__
306 sys.exit()
305 sys.exit()
307
306
308 if opts_all.magic_docstrings:
307 if opts_all.magic_docstrings:
309 IP.magic_magic('-latex')
308 IP.magic_magic('-latex')
310 sys.exit()
309 sys.exit()
311
310
312 # Create user config directory if it doesn't exist. This must be done
311 # Create user config directory if it doesn't exist. This must be done
313 # *after* getting the cmd line options.
312 # *after* getting the cmd line options.
314 if not os.path.isdir(opts_all.ipythondir):
313 if not os.path.isdir(opts_all.ipythondir):
315 IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
314 IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
316
315
317 # upgrade user config files while preserving a copy of the originals
316 # upgrade user config files while preserving a copy of the originals
318 if opts_all.upgrade:
317 if opts_all.upgrade:
319 IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade')
318 IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade')
320
319
321 # check mutually exclusive options in the *original* command line
320 # check mutually exclusive options in the *original* command line
322 mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'),
321 mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'),
323 qw('classic profile'),qw('classic rcfile')])
322 qw('classic profile'),qw('classic rcfile')])
324
323
325 # default logfilename used when -log is called.
326 IP.LOGDEF = 'ipython.log'
327
328 #---------------------------------------------------------------------------
324 #---------------------------------------------------------------------------
329 # Log replay
325 # Log replay
330
326
331 # if -logplay, we need to 'become' the other session. That basically means
327 # if -logplay, we need to 'become' the other session. That basically means
332 # replacing the current command line environment with that of the old
328 # replacing the current command line environment with that of the old
333 # session and moving on.
329 # session and moving on.
334
330
335 # this is needed so that later we know we're in session reload mode, as
331 # this is needed so that later we know we're in session reload mode, as
336 # opts_all will get overwritten:
332 # opts_all will get overwritten:
337 load_logplay = 0
333 load_logplay = 0
338
334
339 if opts_all.logplay:
335 if opts_all.logplay:
340 load_logplay = opts_all.logplay
336 load_logplay = opts_all.logplay
341 opts_debug_save = opts_all.debug
337 opts_debug_save = opts_all.debug
342 try:
338 try:
343 logplay = open(opts_all.logplay)
339 logplay = open(opts_all.logplay)
344 except IOError:
340 except IOError:
345 if opts_all.debug: IP.InteractiveTB()
341 if opts_all.debug: IP.InteractiveTB()
346 warn('Could not open logplay file '+`opts_all.logplay`)
342 warn('Could not open logplay file '+`opts_all.logplay`)
347 # restore state as if nothing had happened and move on, but make
343 # restore state as if nothing had happened and move on, but make
348 # sure that later we don't try to actually load the session file
344 # sure that later we don't try to actually load the session file
349 logplay = None
345 logplay = None
350 load_logplay = 0
346 load_logplay = 0
351 del opts_all.logplay
347 del opts_all.logplay
352 else:
348 else:
353 try:
349 try:
354 logplay.readline()
350 logplay.readline()
355 logplay.readline();
351 logplay.readline();
356 # this reloads that session's command line
352 # this reloads that session's command line
357 cmd = logplay.readline()[6:]
353 cmd = logplay.readline()[6:]
358 exec cmd
354 exec cmd
359 # restore the true debug flag given so that the process of
355 # restore the true debug flag given so that the process of
360 # session loading itself can be monitored.
356 # session loading itself can be monitored.
361 opts.debug = opts_debug_save
357 opts.debug = opts_debug_save
362 # save the logplay flag so later we don't overwrite the log
358 # save the logplay flag so later we don't overwrite the log
363 opts.logplay = load_logplay
359 opts.logplay = load_logplay
364 # now we must update our own structure with defaults
360 # now we must update our own structure with defaults
365 opts_all.update(opts)
361 opts_all.update(opts)
366 # now load args
362 # now load args
367 cmd = logplay.readline()[6:]
363 cmd = logplay.readline()[6:]
368 exec cmd
364 exec cmd
369 logplay.close()
365 logplay.close()
370 except:
366 except:
371 logplay.close()
367 logplay.close()
372 if opts_all.debug: IP.InteractiveTB()
368 if opts_all.debug: IP.InteractiveTB()
373 warn("Logplay file lacking full configuration information.\n"
369 warn("Logplay file lacking full configuration information.\n"
374 "I'll try to read it, but some things may not work.")
370 "I'll try to read it, but some things may not work.")
375
371
376 #-------------------------------------------------------------------------
372 #-------------------------------------------------------------------------
377 # set up output traps: catch all output from files, being run, modules
373 # set up output traps: catch all output from files, being run, modules
378 # loaded, etc. Then give it to the user in a clean form at the end.
374 # loaded, etc. Then give it to the user in a clean form at the end.
379
375
380 msg_out = 'Output messages. '
376 msg_out = 'Output messages. '
381 msg_err = 'Error messages. '
377 msg_err = 'Error messages. '
382 msg_sep = '\n'
378 msg_sep = '\n'
383 msg = Struct(config = OutputTrap('Configuration Loader',msg_out,
379 msg = Struct(config = OutputTrap('Configuration Loader',msg_out,
384 msg_err,msg_sep,debug,
380 msg_err,msg_sep,debug,
385 quiet_out=1),
381 quiet_out=1),
386 user_exec = OutputTrap('User File Execution',msg_out,
382 user_exec = OutputTrap('User File Execution',msg_out,
387 msg_err,msg_sep,debug),
383 msg_err,msg_sep,debug),
388 logplay = OutputTrap('Log Loader',msg_out,
384 logplay = OutputTrap('Log Loader',msg_out,
389 msg_err,msg_sep,debug),
385 msg_err,msg_sep,debug),
390 summary = ''
386 summary = ''
391 )
387 )
392
388
393 #-------------------------------------------------------------------------
389 #-------------------------------------------------------------------------
394 # Process user ipythonrc-type configuration files
390 # Process user ipythonrc-type configuration files
395
391
396 # turn on output trapping and log to msg.config
392 # turn on output trapping and log to msg.config
397 # remember that with debug on, trapping is actually disabled
393 # remember that with debug on, trapping is actually disabled
398 msg.config.trap_all()
394 msg.config.trap_all()
399
395
400 # look for rcfile in current or default directory
396 # look for rcfile in current or default directory
401 try:
397 try:
402 opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir)
398 opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir)
403 except IOError:
399 except IOError:
404 if opts_all.debug: IP.InteractiveTB()
400 if opts_all.debug: IP.InteractiveTB()
405 warn('Configuration file %s not found. Ignoring request.'
401 warn('Configuration file %s not found. Ignoring request.'
406 % (opts_all.rcfile) )
402 % (opts_all.rcfile) )
407
403
408 # 'profiles' are a shorthand notation for config filenames
404 # 'profiles' are a shorthand notation for config filenames
409 if opts_all.profile:
405 if opts_all.profile:
410 try:
406 try:
411 opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile
407 opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile
412 + rc_suffix,
408 + rc_suffix,
413 opts_all.ipythondir)
409 opts_all.ipythondir)
414 except IOError:
410 except IOError:
415 if opts_all.debug: IP.InteractiveTB()
411 if opts_all.debug: IP.InteractiveTB()
416 opts.profile = '' # remove profile from options if invalid
412 opts.profile = '' # remove profile from options if invalid
417 warn('Profile configuration file %s not found. Ignoring request.'
413 warn('Profile configuration file %s not found. Ignoring request.'
418 % (opts_all.profile) )
414 % (opts_all.profile) )
419
415
420 # load the config file
416 # load the config file
421 rcfiledata = None
417 rcfiledata = None
422 if opts_all.quick:
418 if opts_all.quick:
423 print 'Launching IPython in quick mode. No config file read.'
419 print 'Launching IPython in quick mode. No config file read.'
424 elif opts_all.classic:
420 elif opts_all.classic:
425 print 'Launching IPython in classic mode. No config file read.'
421 print 'Launching IPython in classic mode. No config file read.'
426 elif opts_all.rcfile:
422 elif opts_all.rcfile:
427 try:
423 try:
428 cfg_loader = ConfigLoader(conflict)
424 cfg_loader = ConfigLoader(conflict)
429 rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv,
425 rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv,
430 'include',opts_all.ipythondir,
426 'include',opts_all.ipythondir,
431 purge = 1,
427 purge = 1,
432 unique = conflict['preserve'])
428 unique = conflict['preserve'])
433 except:
429 except:
434 IP.InteractiveTB()
430 IP.InteractiveTB()
435 warn('Problems loading configuration file '+
431 warn('Problems loading configuration file '+
436 `opts_all.rcfile`+
432 `opts_all.rcfile`+
437 '\nStarting with default -bare bones- configuration.')
433 '\nStarting with default -bare bones- configuration.')
438 else:
434 else:
439 warn('No valid configuration file found in either currrent directory\n'+
435 warn('No valid configuration file found in either currrent directory\n'+
440 'or in the IPython config. directory: '+`opts_all.ipythondir`+
436 'or in the IPython config. directory: '+`opts_all.ipythondir`+
441 '\nProceeding with internal defaults.')
437 '\nProceeding with internal defaults.')
442
438
443 #------------------------------------------------------------------------
439 #------------------------------------------------------------------------
444 # Set exception handlers in mode requested by user.
440 # Set exception handlers in mode requested by user.
445 otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode
441 otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode
446 IP.magic_xmode(opts_all.xmode)
442 IP.magic_xmode(opts_all.xmode)
447 otrap.release_out()
443 otrap.release_out()
448
444
449 #------------------------------------------------------------------------
445 #------------------------------------------------------------------------
450 # Execute user config
446 # Execute user config
451
447
452 # Create a valid config structure with the right precedence order:
448 # Create a valid config structure with the right precedence order:
453 # defaults < rcfile < command line. This needs to be in the instance, so
449 # defaults < rcfile < command line. This needs to be in the instance, so
454 # that method calls below that rely on it find it.
450 # that method calls below that rely on it find it.
455 IP.rc = rc_def.copy()
451 IP.rc = rc_def.copy()
456
452
457 # Work with a local alias inside this routine to avoid unnecessary
453 # Work with a local alias inside this routine to avoid unnecessary
458 # attribute lookups.
454 # attribute lookups.
459 IP_rc = IP.rc
455 IP_rc = IP.rc
460
456
461 IP_rc.update(opts_def)
457 IP_rc.update(opts_def)
462 if rcfiledata:
458 if rcfiledata:
463 # now we can update
459 # now we can update
464 IP_rc.update(rcfiledata)
460 IP_rc.update(rcfiledata)
465 IP_rc.update(opts)
461 IP_rc.update(opts)
466 IP_rc.update(rc_override)
462 IP_rc.update(rc_override)
467
463
468 # Store the original cmd line for reference:
464 # Store the original cmd line for reference:
469 IP_rc.opts = opts
465 IP_rc.opts = opts
470 IP_rc.args = args
466 IP_rc.args = args
471
467
472 # create a *runtime* Struct like rc for holding parameters which may be
468 # create a *runtime* Struct like rc for holding parameters which may be
473 # created and/or modified by runtime user extensions.
469 # created and/or modified by runtime user extensions.
474 IP.runtime_rc = Struct()
470 IP.runtime_rc = Struct()
475
471
476 # from this point on, all config should be handled through IP_rc,
472 # from this point on, all config should be handled through IP_rc,
477 # opts* shouldn't be used anymore.
473 # opts* shouldn't be used anymore.
478
474
479 # add personal .ipython dir to sys.path so that users can put things in
475 # add personal .ipython dir to sys.path so that users can put things in
480 # there for customization
476 # there for customization
481 sys.path.append(IP_rc.ipythondir)
477 sys.path.append(IP_rc.ipythondir)
482 sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran
478 sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran
483
479
484 # update IP_rc with some special things that need manual
480 # update IP_rc with some special things that need manual
485 # tweaks. Basically options which affect other options. I guess this
481 # tweaks. Basically options which affect other options. I guess this
486 # should just be written so that options are fully orthogonal and we
482 # should just be written so that options are fully orthogonal and we
487 # wouldn't worry about this stuff!
483 # wouldn't worry about this stuff!
488
484
489 if IP_rc.classic:
485 if IP_rc.classic:
490 IP_rc.quick = 1
486 IP_rc.quick = 1
491 IP_rc.cache_size = 0
487 IP_rc.cache_size = 0
492 IP_rc.pprint = 0
488 IP_rc.pprint = 0
493 IP_rc.prompt_in1 = '>>> '
489 IP_rc.prompt_in1 = '>>> '
494 IP_rc.prompt_in2 = '... '
490 IP_rc.prompt_in2 = '... '
495 IP_rc.prompt_out = ''
491 IP_rc.prompt_out = ''
496 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
492 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
497 IP_rc.colors = 'NoColor'
493 IP_rc.colors = 'NoColor'
498 IP_rc.xmode = 'Plain'
494 IP_rc.xmode = 'Plain'
499
495
500 # configure readline
496 # configure readline
501 # Define the history file for saving commands in between sessions
497 # Define the history file for saving commands in between sessions
502 if IP_rc.profile:
498 if IP_rc.profile:
503 histfname = 'history-%s' % IP_rc.profile
499 histfname = 'history-%s' % IP_rc.profile
504 else:
500 else:
505 histfname = 'history'
501 histfname = 'history'
506 IP.histfile = os.path.join(opts_all.ipythondir,histfname)
502 IP.histfile = os.path.join(opts_all.ipythondir,histfname)
507
503
508 # update exception handlers with rc file status
504 # update exception handlers with rc file status
509 otrap.trap_out() # I don't want these messages ever.
505 otrap.trap_out() # I don't want these messages ever.
510 IP.magic_xmode(IP_rc.xmode)
506 IP.magic_xmode(IP_rc.xmode)
511 otrap.release_out()
507 otrap.release_out()
512
508
513 # activate logging if requested and not reloading a log
509 # activate logging if requested and not reloading a log
514 if IP_rc.logplay:
510 if IP_rc.logplay:
515 IP.magic_logstart(IP_rc.logplay + ' append')
511 IP.magic_logstart(IP_rc.logplay + ' append')
516 elif IP_rc.logfile:
512 elif IP_rc.logfile:
517 IP.magic_logstart(IP_rc.logfile)
513 IP.magic_logstart(IP_rc.logfile)
518 elif IP_rc.log:
514 elif IP_rc.log:
519 IP.magic_logstart()
515 IP.magic_logstart()
520
516
521 # find user editor so that it we don't have to look it up constantly
517 # find user editor so that it we don't have to look it up constantly
522 if IP_rc.editor.strip()=='0':
518 if IP_rc.editor.strip()=='0':
523 try:
519 try:
524 ed = os.environ['EDITOR']
520 ed = os.environ['EDITOR']
525 except KeyError:
521 except KeyError:
526 if os.name == 'posix':
522 if os.name == 'posix':
527 ed = 'vi' # the only one guaranteed to be there!
523 ed = 'vi' # the only one guaranteed to be there!
528 else:
524 else:
529 ed = 'notepad' # same in Windows!
525 ed = 'notepad' # same in Windows!
530 IP_rc.editor = ed
526 IP_rc.editor = ed
531
527
532 # Keep track of whether this is an embedded instance or not (useful for
528 # Keep track of whether this is an embedded instance or not (useful for
533 # post-mortems).
529 # post-mortems).
534 IP_rc.embedded = IP.embedded
530 IP_rc.embedded = IP.embedded
535
531
536 # Recursive reload
532 # Recursive reload
537 try:
533 try:
538 from IPython import deep_reload
534 from IPython import deep_reload
539 if IP_rc.deep_reload:
535 if IP_rc.deep_reload:
540 __builtin__.reload = deep_reload.reload
536 __builtin__.reload = deep_reload.reload
541 else:
537 else:
542 __builtin__.dreload = deep_reload.reload
538 __builtin__.dreload = deep_reload.reload
543 del deep_reload
539 del deep_reload
544 except ImportError:
540 except ImportError:
545 pass
541 pass
546
542
547 # Save the current state of our namespace so that the interactive shell
543 # Save the current state of our namespace so that the interactive shell
548 # can later know which variables have been created by us from config files
544 # can later know which variables have been created by us from config files
549 # and loading. This way, loading a file (in any way) is treated just like
545 # and loading. This way, loading a file (in any way) is treated just like
550 # defining things on the command line, and %who works as expected.
546 # defining things on the command line, and %who works as expected.
551
547
552 # DON'T do anything that affects the namespace beyond this point!
548 # DON'T do anything that affects the namespace beyond this point!
553 IP.internal_ns.update(__main__.__dict__)
549 IP.internal_ns.update(__main__.__dict__)
554
550
555 #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who
551 #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who
556
552
557 # Now run through the different sections of the users's config
553 # Now run through the different sections of the users's config
558 if IP_rc.debug:
554 if IP_rc.debug:
559 print 'Trying to execute the following configuration structure:'
555 print 'Trying to execute the following configuration structure:'
560 print '(Things listed first are deeper in the inclusion tree and get'
556 print '(Things listed first are deeper in the inclusion tree and get'
561 print 'loaded first).\n'
557 print 'loaded first).\n'
562 pprint(IP_rc.__dict__)
558 pprint(IP_rc.__dict__)
563
559
564 for mod in IP_rc.import_mod:
560 for mod in IP_rc.import_mod:
565 try:
561 try:
566 exec 'import '+mod in IP.user_ns
562 exec 'import '+mod in IP.user_ns
567 except :
563 except :
568 IP.InteractiveTB()
564 IP.InteractiveTB()
569 import_fail_info(mod)
565 import_fail_info(mod)
570
566
571 for mod_fn in IP_rc.import_some:
567 for mod_fn in IP_rc.import_some:
572 if mod_fn == []: break
568 if mod_fn == []: break
573 mod,fn = mod_fn[0],','.join(mod_fn[1:])
569 mod,fn = mod_fn[0],','.join(mod_fn[1:])
574 try:
570 try:
575 exec 'from '+mod+' import '+fn in IP.user_ns
571 exec 'from '+mod+' import '+fn in IP.user_ns
576 except :
572 except :
577 IP.InteractiveTB()
573 IP.InteractiveTB()
578 import_fail_info(mod,fn)
574 import_fail_info(mod,fn)
579
575
580 for mod in IP_rc.import_all:
576 for mod in IP_rc.import_all:
581 try:
577 try:
582 exec 'from '+mod+' import *' in IP.user_ns
578 exec 'from '+mod+' import *' in IP.user_ns
583 except :
579 except :
584 IP.InteractiveTB()
580 IP.InteractiveTB()
585 import_fail_info(mod)
581 import_fail_info(mod)
586
582
587 for code in IP_rc.execute:
583 for code in IP_rc.execute:
588 try:
584 try:
589 exec code in IP.user_ns
585 exec code in IP.user_ns
590 except:
586 except:
591 IP.InteractiveTB()
587 IP.InteractiveTB()
592 warn('Failure executing code: ' + `code`)
588 warn('Failure executing code: ' + `code`)
593
589
594 # Execute the files the user wants in ipythonrc
590 # Execute the files the user wants in ipythonrc
595 for file in IP_rc.execfile:
591 for file in IP_rc.execfile:
596 try:
592 try:
597 file = filefind(file,sys.path+[IPython_dir])
593 file = filefind(file,sys.path+[IPython_dir])
598 except IOError:
594 except IOError:
599 warn(itpl('File $file not found. Skipping it.'))
595 warn(itpl('File $file not found. Skipping it.'))
600 else:
596 else:
601 IP.safe_execfile(os.path.expanduser(file),IP.user_ns)
597 IP.safe_execfile(os.path.expanduser(file),IP.user_ns)
602
598
603 # release stdout and stderr and save config log into a global summary
599 # release stdout and stderr and save config log into a global summary
604 msg.config.release_all()
600 msg.config.release_all()
605 if IP_rc.messages:
601 if IP_rc.messages:
606 msg.summary += msg.config.summary_all()
602 msg.summary += msg.config.summary_all()
607
603
608 #------------------------------------------------------------------------
604 #------------------------------------------------------------------------
609 # Setup interactive session
605 # Setup interactive session
610
606
611 # Now we should be fully configured. We can then execute files or load
607 # Now we should be fully configured. We can then execute files or load
612 # things only needed for interactive use. Then we'll open the shell.
608 # things only needed for interactive use. Then we'll open the shell.
613
609
614 # Take a snapshot of the user namespace before opening the shell. That way
610 # Take a snapshot of the user namespace before opening the shell. That way
615 # we'll be able to identify which things were interactively defined and
611 # we'll be able to identify which things were interactively defined and
616 # which were defined through config files.
612 # which were defined through config files.
617 IP.user_config_ns = IP.user_ns.copy()
613 IP.user_config_ns = IP.user_ns.copy()
618
614
619 # Force reading a file as if it were a session log. Slower but safer.
615 # Force reading a file as if it were a session log. Slower but safer.
620 if load_logplay:
616 if load_logplay:
621 print 'Replaying log...'
617 print 'Replaying log...'
622 try:
618 try:
623 if IP_rc.debug:
619 if IP_rc.debug:
624 logplay_quiet = 0
620 logplay_quiet = 0
625 else:
621 else:
626 logplay_quiet = 1
622 logplay_quiet = 1
627
623
628 msg.logplay.trap_all()
624 msg.logplay.trap_all()
629 IP.safe_execfile(load_logplay,IP.user_ns,
625 IP.safe_execfile(load_logplay,IP.user_ns,
630 islog = 1, quiet = logplay_quiet)
626 islog = 1, quiet = logplay_quiet)
631 msg.logplay.release_all()
627 msg.logplay.release_all()
632 if IP_rc.messages:
628 if IP_rc.messages:
633 msg.summary += msg.logplay.summary_all()
629 msg.summary += msg.logplay.summary_all()
634 except:
630 except:
635 warn('Problems replaying logfile %s.' % load_logplay)
631 warn('Problems replaying logfile %s.' % load_logplay)
636 IP.InteractiveTB()
632 IP.InteractiveTB()
637
633
638 # Load remaining files in command line
634 # Load remaining files in command line
639 msg.user_exec.trap_all()
635 msg.user_exec.trap_all()
640
636
641 # Do NOT execute files named in the command line as scripts to be loaded
637 # Do NOT execute files named in the command line as scripts to be loaded
642 # by embedded instances. Doing so has the potential for an infinite
638 # by embedded instances. Doing so has the potential for an infinite
643 # recursion if there are exceptions thrown in the process.
639 # recursion if there are exceptions thrown in the process.
644
640
645 # XXX FIXME: the execution of user files should be moved out to after
641 # XXX FIXME: the execution of user files should be moved out to after
646 # ipython is fully initialized, just as if they were run via %run at the
642 # ipython is fully initialized, just as if they were run via %run at the
647 # ipython prompt. This would also give them the benefit of ipython's
643 # ipython prompt. This would also give them the benefit of ipython's
648 # nice tracebacks.
644 # nice tracebacks.
649
645
650 if not embedded and IP_rc.args:
646 if not embedded and IP_rc.args:
651 name_save = IP.user_ns['__name__']
647 name_save = IP.user_ns['__name__']
652 IP.user_ns['__name__'] = '__main__'
648 IP.user_ns['__name__'] = '__main__'
653 try:
649 try:
654 # Set our own excepthook in case the user code tries to call it
650 # Set our own excepthook in case the user code tries to call it
655 # directly. This prevents triggering the IPython crash handler.
651 # directly. This prevents triggering the IPython crash handler.
656 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
652 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
657 for run in args:
653 for run in args:
658 IP.safe_execfile(run,IP.user_ns)
654 IP.safe_execfile(run,IP.user_ns)
659 finally:
655 finally:
660 # Reset our crash handler in place
656 # Reset our crash handler in place
661 sys.excepthook = old_excepthook
657 sys.excepthook = old_excepthook
662
658
663 IP.user_ns['__name__'] = name_save
659 IP.user_ns['__name__'] = name_save
664
660
665 msg.user_exec.release_all()
661 msg.user_exec.release_all()
666 if IP_rc.messages:
662 if IP_rc.messages:
667 msg.summary += msg.user_exec.summary_all()
663 msg.summary += msg.user_exec.summary_all()
668
664
669 # since we can't specify a null string on the cmd line, 0 is the equivalent:
665 # since we can't specify a null string on the cmd line, 0 is the equivalent:
670 if IP_rc.nosep:
666 if IP_rc.nosep:
671 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
667 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
672 if IP_rc.separate_in == '0': IP_rc.separate_in = ''
668 if IP_rc.separate_in == '0': IP_rc.separate_in = ''
673 if IP_rc.separate_out == '0': IP_rc.separate_out = ''
669 if IP_rc.separate_out == '0': IP_rc.separate_out = ''
674 if IP_rc.separate_out2 == '0': IP_rc.separate_out2 = ''
670 if IP_rc.separate_out2 == '0': IP_rc.separate_out2 = ''
675 IP_rc.separate_in = IP_rc.separate_in.replace('\\n','\n')
671 IP_rc.separate_in = IP_rc.separate_in.replace('\\n','\n')
676 IP_rc.separate_out = IP_rc.separate_out.replace('\\n','\n')
672 IP_rc.separate_out = IP_rc.separate_out.replace('\\n','\n')
677 IP_rc.separate_out2 = IP_rc.separate_out2.replace('\\n','\n')
673 IP_rc.separate_out2 = IP_rc.separate_out2.replace('\\n','\n')
678
674
679 # Determine how many lines at the bottom of the screen are needed for
675 # Determine how many lines at the bottom of the screen are needed for
680 # showing prompts, so we can know wheter long strings are to be printed or
676 # showing prompts, so we can know wheter long strings are to be printed or
681 # paged:
677 # paged:
682 num_lines_bot = IP_rc.separate_in.count('\n')+1
678 num_lines_bot = IP_rc.separate_in.count('\n')+1
683 IP_rc.screen_length = IP_rc.screen_length - num_lines_bot
679 IP_rc.screen_length = IP_rc.screen_length - num_lines_bot
684 # Initialize cache, set in/out prompts and printing system
685 IP.outputcache = CachedOutput(IP_rc.cache_size,
686 IP_rc.pprint,
687 input_sep = IP_rc.separate_in,
688 output_sep = IP_rc.separate_out,
689 output_sep2 = IP_rc.separate_out2,
690 ps1 = IP_rc.prompt_in1,
691 ps2 = IP_rc.prompt_in2,
692 ps_out = IP_rc.prompt_out,
693 user_ns = IP.user_ns,
694 input_hist = IP.input_hist,
695 pad_left = IP_rc.prompts_pad_left)
696
697 # user may have over-ridden the default print hook:
698 try:
699 IP.outputcache.__class__.display = IP.hooks.display
700 except AttributeError:
701 pass
702
680
703 # Set calling of pdb on exceptions
704 IP.InteractiveTB.call_pdb = IP_rc.pdb
705
706 # I don't like assigning globally to sys, because it means when embedding
707 # instances, each embedded instance overrides the previous choice. But
708 # sys.displayhook seems to be called internally by exec, so I don't see a
709 # way around it.
710 sys.displayhook = IP.outputcache
711
712 # we need to know globally if we're caching i/o or not
713 IP.do_full_cache = IP.outputcache.do_full_cache
714
715 # configure startup banner
681 # configure startup banner
716 if IP_rc.c: # regular python doesn't print the banner with -c
682 if IP_rc.c: # regular python doesn't print the banner with -c
717 IP_rc.banner = 0
683 IP_rc.banner = 0
718 if IP_rc.banner:
684 if IP_rc.banner:
719 BANN_P = IP.BANNER_PARTS
685 BANN_P = IP.BANNER_PARTS
720 else:
686 else:
721 BANN_P = []
687 BANN_P = []
722
688
723 if IP_rc.profile: BANN_P.append('IPython profile: %s\n' % IP_rc.profile)
689 if IP_rc.profile: BANN_P.append('IPython profile: %s\n' % IP_rc.profile)
724
690
725 # add message log (possibly empty)
691 # add message log (possibly empty)
726 if msg.summary: BANN_P.append(msg.summary)
692 if msg.summary: BANN_P.append(msg.summary)
727 # Final banner is a string
693 # Final banner is a string
728 IP.BANNER = '\n'.join(BANN_P)
694 IP.BANNER = '\n'.join(BANN_P)
729
695
730 # Finalize the IPython instance. This assumes the rc structure is fully
696 # Finalize the IPython instance. This assumes the rc structure is fully
731 # in place.
697 # in place.
732 IP.post_config_initialization()
698 IP.post_config_initialization()
733
699
734 return IP
700 return IP
735 #************************ end of file <ipmaker.py> **************************
701 #************************ end of file <ipmaker.py> **************************
@@ -1,585 +1,585 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 #*****************************************************************************
2 #*****************************************************************************
3 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
3 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
4 #
4 #
5 # Distributed under the terms of the BSD License. The full license is in
5 # Distributed under the terms of the BSD License. The full license is in
6 # the file COPYING, distributed as part of this software.
6 # the file COPYING, distributed as part of this software.
7 #*****************************************************************************
7 #*****************************************************************************
8
8
9 # $Id: usage.py 960 2005-12-28 06:51:01Z fperez $
9 # $Id: usage.py 966 2005-12-29 08:34:07Z fperez $
10
10
11 from IPython import Release
11 from IPython import Release
12 __author__ = '%s <%s>' % Release.authors['Fernando']
12 __author__ = '%s <%s>' % Release.authors['Fernando']
13 __license__ = Release.license
13 __license__ = Release.license
14 __version__ = Release.version
14 __version__ = Release.version
15
15
16 __doc__ = """
16 __doc__ = """
17 IPython -- An enhanced Interactive Python
17 IPython -- An enhanced Interactive Python
18 =========================================
18 =========================================
19
19
20 A Python shell with automatic history (input and output), dynamic object
20 A Python shell with automatic history (input and output), dynamic object
21 introspection, easier configuration, command completion, access to the system
21 introspection, easier configuration, command completion, access to the system
22 shell and more.
22 shell and more.
23
23
24 IPython can also be embedded in running programs. See EMBEDDING below.
24 IPython can also be embedded in running programs. See EMBEDDING below.
25
25
26
26
27 USAGE
27 USAGE
28 ipython [options] files
28 ipython [options] files
29
29
30 If invoked with no options, it executes all the files listed in
30 If invoked with no options, it executes all the files listed in
31 sequence and drops you into the interpreter while still acknowledging
31 sequence and drops you into the interpreter while still acknowledging
32 any options you may have set in your ipythonrc file. This behavior is
32 any options you may have set in your ipythonrc file. This behavior is
33 different from standard Python, which when called as python -i will
33 different from standard Python, which when called as python -i will
34 only execute one file and will ignore your configuration setup.
34 only execute one file and will ignore your configuration setup.
35
35
36 Please note that some of the configuration options are not available at
36 Please note that some of the configuration options are not available at
37 the command line, simply because they are not practical here. Look into
37 the command line, simply because they are not practical here. Look into
38 your ipythonrc configuration file for details on those. This file
38 your ipythonrc configuration file for details on those. This file
39 typically installed in the $HOME/.ipython directory.
39 typically installed in the $HOME/.ipython directory.
40
40
41 For Windows users, $HOME resolves to C:\\Documents and
41 For Windows users, $HOME resolves to C:\\Documents and
42 Settings\\YourUserName in most instances, and _ipython is used instead
42 Settings\\YourUserName in most instances, and _ipython is used instead
43 of .ipython, since some Win32 programs have problems with dotted names
43 of .ipython, since some Win32 programs have problems with dotted names
44 in directories.
44 in directories.
45
45
46 In the rest of this text, we will refer to this directory as
46 In the rest of this text, we will refer to this directory as
47 IPYTHONDIR.
47 IPYTHONDIR.
48
48
49
49
50 SPECIAL THREADING OPTIONS
50 SPECIAL THREADING OPTIONS
51 The following special options are ONLY valid at the beginning of the
51 The following special options are ONLY valid at the beginning of the
52 command line, and not later. This is because they control the initial-
52 command line, and not later. This is because they control the initial-
53 ization of ipython itself, before the normal option-handling mechanism
53 ization of ipython itself, before the normal option-handling mechanism
54 is active.
54 is active.
55
55
56 -gthread, -qthread, -wthread, -pylab
56 -gthread, -qthread, -wthread, -pylab
57
57
58 Only ONE of these can be given, and it can only be given as the
58 Only ONE of these can be given, and it can only be given as the
59 first option passed to IPython (it will have no effect in any
59 first option passed to IPython (it will have no effect in any
60 other position). They provide threading support for the GTK, QT
60 other position). They provide threading support for the GTK, QT
61 and WXWidgets toolkits, and for the matplotlib library.
61 and WXWidgets toolkits, and for the matplotlib library.
62
62
63 With any of the first three options, IPython starts running a
63 With any of the first three options, IPython starts running a
64 separate thread for the graphical toolkit's operation, so that
64 separate thread for the graphical toolkit's operation, so that
65 you can open and control graphical elements from within an
65 you can open and control graphical elements from within an
66 IPython command line, without blocking. All three provide
66 IPython command line, without blocking. All three provide
67 essentially the same functionality, respectively for GTK, QT and
67 essentially the same functionality, respectively for GTK, QT and
68 WXWidgets (via their Python interfaces).
68 WXWidgets (via their Python interfaces).
69
69
70 If -pylab is given, IPython loads special support for the mat-
70 If -pylab is given, IPython loads special support for the mat-
71 plotlib library (http://matplotlib.sourceforge.net), allowing
71 plotlib library (http://matplotlib.sourceforge.net), allowing
72 interactive usage of any of its backends as defined in the
72 interactive usage of any of its backends as defined in the
73 user's .matplotlibrc file. It automatically activates GTK, QT
73 user's .matplotlibrc file. It automatically activates GTK, QT
74 or WX threading for IPyhton if the choice of matplotlib backend
74 or WX threading for IPyhton if the choice of matplotlib backend
75 requires it. It also modifies the %run command to correctly
75 requires it. It also modifies the %run command to correctly
76 execute (without blocking) any matplotlib-based script which
76 execute (without blocking) any matplotlib-based script which
77 calls show() at the end.
77 calls show() at the end.
78
78
79 -tk The -g/q/wthread options, and -pylab (if matplotlib is
79 -tk The -g/q/wthread options, and -pylab (if matplotlib is
80 configured to use GTK, QT or WX), will normally block Tk
80 configured to use GTK, QT or WX), will normally block Tk
81 graphical interfaces. This means that when GTK, QT or WX
81 graphical interfaces. This means that when GTK, QT or WX
82 threading is active, any attempt to open a Tk GUI will result in
82 threading is active, any attempt to open a Tk GUI will result in
83 a dead window, and possibly cause the Python interpreter to
83 a dead window, and possibly cause the Python interpreter to
84 crash. An extra option, -tk, is available to address this
84 crash. An extra option, -tk, is available to address this
85 issue. It can ONLY be given as a SECOND option after any of the
85 issue. It can ONLY be given as a SECOND option after any of the
86 above (-gthread, -qthread, -wthread or -pylab).
86 above (-gthread, -qthread, -wthread or -pylab).
87
87
88 If -tk is given, IPython will try to coordinate Tk threading
88 If -tk is given, IPython will try to coordinate Tk threading
89 with GTK, QT or WX. This is however potentially unreliable, and
89 with GTK, QT or WX. This is however potentially unreliable, and
90 you will have to test on your platform and Python configuration
90 you will have to test on your platform and Python configuration
91 to determine whether it works for you. Debian users have
91 to determine whether it works for you. Debian users have
92 reported success, apparently due to the fact that Debian builds
92 reported success, apparently due to the fact that Debian builds
93 all of Tcl, Tk, Tkinter and Python with pthreads support. Under
93 all of Tcl, Tk, Tkinter and Python with pthreads support. Under
94 other Linux environments (such as Fedora Core 2/3), this option
94 other Linux environments (such as Fedora Core 2/3), this option
95 has caused random crashes and lockups of the Python interpreter.
95 has caused random crashes and lockups of the Python interpreter.
96 Under other operating systems (Mac OSX and Windows), you'll need
96 Under other operating systems (Mac OSX and Windows), you'll need
97 to try it to find out, since currently no user reports are
97 to try it to find out, since currently no user reports are
98 available.
98 available.
99
99
100 There is unfortunately no way for IPython to determine at run-
100 There is unfortunately no way for IPython to determine at run-
101 time whether -tk will work reliably or not, so you will need to
101 time whether -tk will work reliably or not, so you will need to
102 do some experiments before relying on it for regular work.
102 do some experiments before relying on it for regular work.
103
103
104 A WARNING ABOUT SIGNALS AND THREADS
104 A WARNING ABOUT SIGNALS AND THREADS
105
105
106 When any of the thread systems (GTK, QT or WX) are active, either
106 When any of the thread systems (GTK, QT or WX) are active, either
107 directly or via -pylab with a threaded backend, it is impossible to
107 directly or via -pylab with a threaded backend, it is impossible to
108 interrupt long-running Python code via Ctrl-C. IPython can not pass
108 interrupt long-running Python code via Ctrl-C. IPython can not pass
109 the KeyboardInterrupt exception (or the underlying SIGINT) across
109 the KeyboardInterrupt exception (or the underlying SIGINT) across
110 threads, so any long-running process started from IPython will run to
110 threads, so any long-running process started from IPython will run to
111 completion, or will have to be killed via an external (OS-based)
111 completion, or will have to be killed via an external (OS-based)
112 mechanism.
112 mechanism.
113
113
114 To the best of my knowledge, this limitation is imposed by the Python
114 To the best of my knowledge, this limitation is imposed by the Python
115 interpreter itself, and it comes from the difficulty of writing
115 interpreter itself, and it comes from the difficulty of writing
116 portable signal/threaded code. If any user is an expert on this topic
116 portable signal/threaded code. If any user is an expert on this topic
117 and can suggest a better solution, I would love to hear about it. In
117 and can suggest a better solution, I would love to hear about it. In
118 the IPython sources, look at the Shell.py module, and in particular at
118 the IPython sources, look at the Shell.py module, and in particular at
119 the runcode() method.
119 the runcode() method.
120
120
121 REGULAR OPTIONS
121 REGULAR OPTIONS
122 After the above threading options have been given, regular options can
122 After the above threading options have been given, regular options can
123 follow in any order. All options can be abbreviated to their shortest
123 follow in any order. All options can be abbreviated to their shortest
124 non-ambiguous form and are case-sensitive. One or two dashes can be
124 non-ambiguous form and are case-sensitive. One or two dashes can be
125 used. Some options have an alternate short form, indicated after a |.
125 used. Some options have an alternate short form, indicated after a |.
126
126
127 Most options can also be set from your ipythonrc configuration file.
127 Most options can also be set from your ipythonrc configuration file.
128 See the provided examples for assistance. Options given on the comman-
128 See the provided examples for assistance. Options given on the comman-
129 dline override the values set in the ipythonrc file.
129 dline override the values set in the ipythonrc file.
130
130
131 All options with a [no] prepended can be specified in negated form
131 All options with a [no] prepended can be specified in negated form
132 (using -nooption instead of -option) to turn the feature off.
132 (using -nooption instead of -option) to turn the feature off.
133
133
134 -h, --help
134 -h, --help
135 Show summary of options.
135 Show summary of options.
136
136
137 -pylab This can only be given as the first option passed to IPython (it
137 -pylab This can only be given as the first option passed to IPython (it
138 will have no effect in any other position). It adds special sup-
138 will have no effect in any other position). It adds special sup-
139 port for the matplotlib library (http://matplotlib.source-
139 port for the matplotlib library (http://matplotlib.source-
140 forge.net), allowing interactive usage of any of its backends as
140 forge.net), allowing interactive usage of any of its backends as
141 defined in the user’s .matplotlibrc file. It automatically
141 defined in the user’s .matplotlibrc file. It automatically
142 activates GTK or WX threading for IPyhton if the choice of mat-
142 activates GTK or WX threading for IPyhton if the choice of mat-
143 plotlib backend requires it. It also modifies the @run command
143 plotlib backend requires it. It also modifies the @run command
144 to correctly execute (without blocking) any matplotlib-based
144 to correctly execute (without blocking) any matplotlib-based
145 script which calls show() at the end.
145 script which calls show() at the end.
146
146
147 -[no]autocall
147 -[no]autocall
148 Make IPython automatically call any callable object even if you
148 Make IPython automatically call any callable object even if you
149 didn’t type explicit parentheses. For example, ’str 43’ becomes
149 didn’t type explicit parentheses. For example, ’str 43’ becomes
150 ’str(43)’ automatically.
150 ’str(43)’ automatically.
151
151
152 -[no]autoindent
152 -[no]autoindent
153 Turn automatic indentation on/off.
153 Turn automatic indentation on/off.
154
154
155 -[no]automagic
155 -[no]automagic
156 Make magic commands automatic (without needing their first char-
156 Make magic commands automatic (without needing their first char-
157 acter to be %). Type %magic at the IPython prompt for more
157 acter to be %). Type %magic at the IPython prompt for more
158 information.
158 information.
159
159
160 -[no]autoedit_syntax
160 -[no]autoedit_syntax
161 When a syntax error occurs after editing a file, automatically
161 When a syntax error occurs after editing a file, automatically
162 open the file to the trouble causing line for convenient fixing.
162 open the file to the trouble causing line for convenient fixing.
163
163
164 -[no]banner
164 -[no]banner
165 Print the intial information banner (default on).
165 Print the intial information banner (default on).
166
166
167 -c <command>
167 -c <command>
168 Execute the given command string, and set sys.argv to [’c’].
168 Execute the given command string, and set sys.argv to [’c’].
169 This is similar to the -c option in the normal Python inter-
169 This is similar to the -c option in the normal Python inter-
170 preter.
170 preter.
171
171
172 -cache_size|cs <n>
172 -cache_size|cs <n>
173 Size of the output cache (maximum number of entries to hold in
173 Size of the output cache (maximum number of entries to hold in
174 memory). The default is 1000, you can change it permanently in
174 memory). The default is 1000, you can change it permanently in
175 your config file. Setting it to 0 completely disables the
175 your config file. Setting it to 0 completely disables the
176 caching system, and the minimum value accepted is 20 (if you
176 caching system, and the minimum value accepted is 20 (if you
177 provide a value less than 20, it is reset to 0 and a warning is
177 provide a value less than 20, it is reset to 0 and a warning is
178 issued). This limit is defined because otherwise you’ll spend
178 issued). This limit is defined because otherwise you’ll spend
179 more time re-flushing a too small cache than working.
179 more time re-flushing a too small cache than working.
180
180
181 -classic|cl
181 -classic|cl
182 Gives IPython a similar feel to the classic Python prompt.
182 Gives IPython a similar feel to the classic Python prompt.
183
183
184 -colors <scheme>
184 -colors <scheme>
185 Color scheme for prompts and exception reporting. Currently
185 Color scheme for prompts and exception reporting. Currently
186 implemented: NoColor, Linux, and LightBG.
186 implemented: NoColor, Linux, and LightBG.
187
187
188 -[no]color_info
188 -[no]color_info
189 IPython can display information about objects via a set of func-
189 IPython can display information about objects via a set of func-
190 tions, and optionally can use colors for this, syntax highlight-
190 tions, and optionally can use colors for this, syntax highlight-
191 ing source code and various other elements. However, because
191 ing source code and various other elements. However, because
192 this information is passed through a pager (like ’less’) and
192 this information is passed through a pager (like ’less’) and
193 many pagers get confused with color codes, this option is off by
193 many pagers get confused with color codes, this option is off by
194 default. You can test it and turn it on permanently in your
194 default. You can test it and turn it on permanently in your
195 ipythonrc file if it works for you. As a reference, the ’less’
195 ipythonrc file if it works for you. As a reference, the ’less’
196 pager supplied with Mandrake 8.2 works ok, but that in RedHat
196 pager supplied with Mandrake 8.2 works ok, but that in RedHat
197 7.2 doesn’t.
197 7.2 doesn’t.
198
198
199 Test it and turn it on permanently if it works with your system.
199 Test it and turn it on permanently if it works with your system.
200 The magic function @color_info allows you to toggle this inter-
200 The magic function @color_info allows you to toggle this inter-
201 actively for testing.
201 actively for testing.
202
202
203 -[no]confirm_exit
203 -[no]confirm_exit
204 Set to confirm when you try to exit IPython with an EOF (Con-
204 Set to confirm when you try to exit IPython with an EOF (Con-
205 trol-D in Unix, Control-Z/Enter in Windows). Note that using the
205 trol-D in Unix, Control-Z/Enter in Windows). Note that using the
206 magic functions @Exit or @Quit you can force a direct exit,
206 magic functions @Exit or @Quit you can force a direct exit,
207 bypassing any confirmation.
207 bypassing any confirmation.
208
208
209 -[no]debug
209 -[no]debug
210 Show information about the loading process. Very useful to pin
210 Show information about the loading process. Very useful to pin
211 down problems with your configuration files or to get details
211 down problems with your configuration files or to get details
212 about session restores.
212 about session restores.
213
213
214 -[no]deep_reload
214 -[no]deep_reload
215 IPython can use the deep_reload module which reloads changes in
215 IPython can use the deep_reload module which reloads changes in
216 modules recursively (it replaces the reload() function, so you
216 modules recursively (it replaces the reload() function, so you
217 don’t need to change anything to use it). deep_reload() forces a
217 don’t need to change anything to use it). deep_reload() forces a
218 full reload of modules whose code may have changed, which the
218 full reload of modules whose code may have changed, which the
219 default reload() function does not.
219 default reload() function does not.
220
220
221 When deep_reload is off, IPython will use the normal reload(),
221 When deep_reload is off, IPython will use the normal reload(),
222 but deep_reload will still be available as dreload(). This fea-
222 but deep_reload will still be available as dreload(). This fea-
223 ture is off by default [which means that you have both normal
223 ture is off by default [which means that you have both normal
224 reload() and dreload()].
224 reload() and dreload()].
225
225
226 -editor <name>
226 -editor <name>
227 Which editor to use with the @edit command. By default, IPython
227 Which editor to use with the @edit command. By default, IPython
228 will honor your EDITOR environment variable (if not set, vi is
228 will honor your EDITOR environment variable (if not set, vi is
229 the Unix default and notepad the Windows one). Since this editor
229 the Unix default and notepad the Windows one). Since this editor
230 is invoked on the fly by IPython and is meant for editing small
230 is invoked on the fly by IPython and is meant for editing small
231 code snippets, you may want to use a small, lightweight editor
231 code snippets, you may want to use a small, lightweight editor
232 here (in case your default EDITOR is something like Emacs).
232 here (in case your default EDITOR is something like Emacs).
233
233
234 -ipythondir <name>
234 -ipythondir <name>
235 The name of your IPython configuration directory IPYTHONDIR.
235 The name of your IPython configuration directory IPYTHONDIR.
236 This can also be specified through the environment variable
236 This can also be specified through the environment variable
237 IPYTHONDIR.
237 IPYTHONDIR.
238
238
239 -log|l Generate a log file of all input. The file is named ipython.log
239 -log|l Generate a log file of all input. The file is named
240 in your current directory (which prevents logs from multiple
240 ipython_log.py in your current directory (which prevents logs
241 IPython sessions from trampling each other). You can use this to
241 from multiple IPython sessions from trampling each other). You
242 later restore a session by loading your logfile as a file to be
242 can use this to later restore a session by loading your logfile
243 executed with option -logplay (see below).
243 as a file to be executed with option -logplay (see below).
244
244
245 -logfile|lf
245 -logfile|lf
246 Specifu the name of your logfile.
246 Specify the name of your logfile.
247
247
248 -logplay|lp
248 -logplay|lp
249 Replay a previous log. For restoring a session as close as pos-
249 Replay a previous log. For restoring a session as close as pos-
250 sible to the state you left it in, use this option (don’t just
250 sible to the state you left it in, use this option (don’t just
251 run the logfile). With -logplay, IPython will try to reconstruct
251 run the logfile). With -logplay, IPython will try to reconstruct
252 the previous working environment in full, not just execute the
252 the previous working environment in full, not just execute the
253 commands in the logfile.
253 commands in the logfile.
254 When a session is restored, logging is automatically turned on
254 When a session is restored, logging is automatically turned on
255 again with the name of the logfile it was invoked with (it is
255 again with the name of the logfile it was invoked with (it is
256 read from the log header). So once you’ve turned logging on for
256 read from the log header). So once you’ve turned logging on for
257 a session, you can quit IPython and reload it as many times as
257 a session, you can quit IPython and reload it as many times as
258 you want and it will continue to log its history and restore
258 you want and it will continue to log its history and restore
259 from the beginning every time.
259 from the beginning every time.
260
260
261 Caveats: there are limitations in this option. The history vari-
261 Caveats: there are limitations in this option. The history vari-
262 ables _i*,_* and _dh don’t get restored properly. In the future
262 ables _i*,_* and _dh don’t get restored properly. In the future
263 we will try to implement full session saving by writing and
263 we will try to implement full session saving by writing and
264 retrieving a failed because of inherent limitations of Python’s
264 retrieving a failed because of inherent limitations of Python’s
265 Pickle module, so this may have to wait.
265 Pickle module, so this may have to wait.
266
266
267 -[no]messages
267 -[no]messages
268 Print messages which IPython collects about its startup process
268 Print messages which IPython collects about its startup process
269 (default on).
269 (default on).
270
270
271 -[no]pdb
271 -[no]pdb
272 Automatically call the pdb debugger after every uncaught excep-
272 Automatically call the pdb debugger after every uncaught excep-
273 tion. If you are used to debugging using pdb, this puts you
273 tion. If you are used to debugging using pdb, this puts you
274 automatically inside of it after any call (either in IPython or
274 automatically inside of it after any call (either in IPython or
275 in code called by it) which triggers an exception which goes
275 in code called by it) which triggers an exception which goes
276 uncaught.
276 uncaught.
277
277
278 -[no]pprint
278 -[no]pprint
279 IPython can optionally use the pprint (pretty printer) module
279 IPython can optionally use the pprint (pretty printer) module
280 for displaying results. pprint tends to give a nicer display of
280 for displaying results. pprint tends to give a nicer display of
281 nested data structures. If you like it, you can turn it on per-
281 nested data structures. If you like it, you can turn it on per-
282 manently in your config file (default off).
282 manently in your config file (default off).
283
283
284 -profile|p <name>
284 -profile|p <name>
285 Assume that your config file is ipythonrc-<name> (looks in cur-
285 Assume that your config file is ipythonrc-<name> (looks in cur-
286 rent dir first, then in IPYTHONDIR). This is a quick way to keep
286 rent dir first, then in IPYTHONDIR). This is a quick way to keep
287 and load multiple config files for different tasks, especially
287 and load multiple config files for different tasks, especially
288 if you use the include option of config files. You can keep a
288 if you use the include option of config files. You can keep a
289 basic IPYTHONDIR/ipythonrc file and then have other ’profiles’
289 basic IPYTHONDIR/ipythonrc file and then have other ’profiles’
290 which include this one and load extra things for particular
290 which include this one and load extra things for particular
291 tasks. For example:
291 tasks. For example:
292
292
293 1) $HOME/.ipython/ipythonrc : load basic things you always want.
293 1) $HOME/.ipython/ipythonrc : load basic things you always want.
294 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math-
294 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math-
295 related modules.
295 related modules.
296 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
296 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
297 plotting modules.
297 plotting modules.
298
298
299 Since it is possible to create an endless loop by having circu-
299 Since it is possible to create an endless loop by having circu-
300 lar file inclusions, IPython will stop if it reaches 15 recur-
300 lar file inclusions, IPython will stop if it reaches 15 recur-
301 sive inclusions.
301 sive inclusions.
302
302
303 -prompt_in1|pi1 <string>
303 -prompt_in1|pi1 <string>
304 Specify the string used for input prompts. Note that if you are
304 Specify the string used for input prompts. Note that if you are
305 using numbered prompts, the number is represented with a ’\#’ in
305 using numbered prompts, the number is represented with a ’\#’ in
306 the string. Don’t forget to quote strings with spaces embedded
306 the string. Don’t forget to quote strings with spaces embedded
307 in them. Default: ’In [\#]:’.
307 in them. Default: ’In [\#]:’.
308
308
309 Most bash-like escapes can be used to customize IPython’s
309 Most bash-like escapes can be used to customize IPython’s
310 prompts, as well as a few additional ones which are IPython-spe-
310 prompts, as well as a few additional ones which are IPython-spe-
311 cific. All valid prompt escapes are described in detail in the
311 cific. All valid prompt escapes are described in detail in the
312 Customization section of the IPython HTML/PDF manual.
312 Customization section of the IPython HTML/PDF manual.
313
313
314 -prompt_in2|pi2 <string>
314 -prompt_in2|pi2 <string>
315 Similar to the previous option, but used for the continuation
315 Similar to the previous option, but used for the continuation
316 prompts. The special sequence ’\D’ is similar to ’\#’, but with
316 prompts. The special sequence ’\D’ is similar to ’\#’, but with
317 all digits replaced dots (so you can have your continuation
317 all digits replaced dots (so you can have your continuation
318 prompt aligned with your input prompt). Default: ’ .\D.:’
318 prompt aligned with your input prompt). Default: ’ .\D.:’
319 (note three spaces at the start for alignment with ’In [\#]’).
319 (note three spaces at the start for alignment with ’In [\#]’).
320
320
321 -prompt_out|po <string>
321 -prompt_out|po <string>
322 String used for output prompts, also uses numbers like
322 String used for output prompts, also uses numbers like
323 prompt_in1. Default: ’Out[\#]:’.
323 prompt_in1. Default: ’Out[\#]:’.
324
324
325 -quick Start in bare bones mode (no config file loaded).
325 -quick Start in bare bones mode (no config file loaded).
326
326
327 -rcfile <name>
327 -rcfile <name>
328 Name of your IPython resource configuration file. normally
328 Name of your IPython resource configuration file. normally
329 IPython loads ipythonrc (from current directory) or
329 IPython loads ipythonrc (from current directory) or
330 IPYTHONDIR/ipythonrc. If the loading of your config file fails,
330 IPYTHONDIR/ipythonrc. If the loading of your config file fails,
331 IPython starts with a bare bones configuration (no modules
331 IPython starts with a bare bones configuration (no modules
332 loaded at all).
332 loaded at all).
333
333
334 -[no]readline
334 -[no]readline
335 Use the readline library, which is needed to support name com-
335 Use the readline library, which is needed to support name com-
336 pletion and command history, among other things. It is enabled
336 pletion and command history, among other things. It is enabled
337 by default, but may cause problems for users of X/Emacs in
337 by default, but may cause problems for users of X/Emacs in
338 Python comint or shell buffers.
338 Python comint or shell buffers.
339
339
340 Note that emacs ’eterm’ buffers (opened with M-x term) support
340 Note that emacs ’eterm’ buffers (opened with M-x term) support
341 IPython’s readline and syntax coloring fine, only ’emacs’ (M-x
341 IPython’s readline and syntax coloring fine, only ’emacs’ (M-x
342 shell and C-c !) buffers do not.
342 shell and C-c !) buffers do not.
343
343
344 -screen_length|sl <n>
344 -screen_length|sl <n>
345 Number of lines of your screen. This is used to control print-
345 Number of lines of your screen. This is used to control print-
346 ing of very long strings. Strings longer than this number of
346 ing of very long strings. Strings longer than this number of
347 lines will be sent through a pager instead of directly printed.
347 lines will be sent through a pager instead of directly printed.
348
348
349 The default value for this is 0, which means IPython will auto-
349 The default value for this is 0, which means IPython will auto-
350 detect your screen size every time it needs to print certain
350 detect your screen size every time it needs to print certain
351 potentially long strings (this doesn’t change the behavior of
351 potentially long strings (this doesn’t change the behavior of
352 the ’print’ keyword, it’s only triggered internally). If for
352 the ’print’ keyword, it’s only triggered internally). If for
353 some reason this isn’t working well (it needs curses support),
353 some reason this isn’t working well (it needs curses support),
354 specify it yourself. Otherwise don’t change the default.
354 specify it yourself. Otherwise don’t change the default.
355
355
356 -separate_in|si <string>
356 -separate_in|si <string>
357 Separator before input prompts. Default ’0.
357 Separator before input prompts. Default ’0.
358
358
359 -separate_out|so <string>
359 -separate_out|so <string>
360 Separator before output prompts. Default: 0 (nothing).
360 Separator before output prompts. Default: 0 (nothing).
361
361
362 -separate_out2|so2 <string>
362 -separate_out2|so2 <string>
363 Separator after output prompts. Default: 0 (nothing).
363 Separator after output prompts. Default: 0 (nothing).
364
364
365 -nosep Shorthand for ’-separate_in 0 -separate_out 0 -separate_out2 0’.
365 -nosep Shorthand for ’-separate_in 0 -separate_out 0 -separate_out2 0’.
366 Simply removes all input/output separators.
366 Simply removes all input/output separators.
367
367
368 -upgrade
368 -upgrade
369 Allows you to upgrade your IPYTHONDIR configuration when you
369 Allows you to upgrade your IPYTHONDIR configuration when you
370 install a new version of IPython. Since new versions may
370 install a new version of IPython. Since new versions may
371 include new command lines options or example files, this copies
371 include new command lines options or example files, this copies
372 updated ipythonrc-type files. However, it backs up (with a .old
372 updated ipythonrc-type files. However, it backs up (with a .old
373 extension) all files which it overwrites so that you can merge
373 extension) all files which it overwrites so that you can merge
374 back any custimizations you might have in your personal files.
374 back any custimizations you might have in your personal files.
375
375
376 -Version
376 -Version
377 Print version information and exit.
377 Print version information and exit.
378
378
379 -xmode <modename>
379 -xmode <modename>
380 Mode for exception reporting. The valid modes are Plain, Con-
380 Mode for exception reporting. The valid modes are Plain, Con-
381 text, and Verbose.
381 text, and Verbose.
382
382
383 - Plain: similar to python’s normal traceback printing.
383 - Plain: similar to python’s normal traceback printing.
384
384
385 - Context: prints 5 lines of context source code around each
385 - Context: prints 5 lines of context source code around each
386 line in the traceback.
386 line in the traceback.
387
387
388 - Verbose: similar to Context, but additionally prints the vari-
388 - Verbose: similar to Context, but additionally prints the vari-
389 ables currently visible where the exception happened (shortening
389 ables currently visible where the exception happened (shortening
390 their strings if too long). This can potentially be very slow,
390 their strings if too long). This can potentially be very slow,
391 if you happen to have a huge data structure whose string repre-
391 if you happen to have a huge data structure whose string repre-
392 sentation is complex to compute. Your computer may appear to
392 sentation is complex to compute. Your computer may appear to
393 freeze for a while with cpu usage at 100%. If this occurs, you
393 freeze for a while with cpu usage at 100%. If this occurs, you
394 can cancel the traceback with Ctrl-C (maybe hitting it more than
394 can cancel the traceback with Ctrl-C (maybe hitting it more than
395 once).
395 once).
396
396
397
397
398 EMBEDDING
398 EMBEDDING
399 It is possible to start an IPython instance inside your own Python pro-
399 It is possible to start an IPython instance inside your own Python pro-
400 grams. In the documentation example files there are some illustrations
400 grams. In the documentation example files there are some illustrations
401 on how to do this.
401 on how to do this.
402
402
403 This feature allows you to evalutate dynamically the state of your
403 This feature allows you to evalutate dynamically the state of your
404 code, operate with your variables, analyze them, etc. Note however
404 code, operate with your variables, analyze them, etc. Note however
405 that any changes you make to values while in the shell do NOT propagate
405 that any changes you make to values while in the shell do NOT propagate
406 back to the running code, so it is safe to modify your values because
406 back to the running code, so it is safe to modify your values because
407 you won’t break your code in bizarre ways by doing so.
407 you won’t break your code in bizarre ways by doing so.
408 """
408 """
409
409
410 cmd_line_usage = __doc__
410 cmd_line_usage = __doc__
411
411
412 #---------------------------------------------------------------------------
412 #---------------------------------------------------------------------------
413 interactive_usage = """
413 interactive_usage = """
414 IPython -- An enhanced Interactive Python
414 IPython -- An enhanced Interactive Python
415 =========================================
415 =========================================
416
416
417 IPython offers a combination of convenient shell features, special commands
417 IPython offers a combination of convenient shell features, special commands
418 and a history mechanism for both input (command history) and output (results
418 and a history mechanism for both input (command history) and output (results
419 caching, similar to Mathematica). It is intended to be a fully compatible
419 caching, similar to Mathematica). It is intended to be a fully compatible
420 replacement for the standard Python interpreter, while offering vastly
420 replacement for the standard Python interpreter, while offering vastly
421 improved functionality and flexibility.
421 improved functionality and flexibility.
422
422
423 At your system command line, type 'ipython -help' to see the command line
423 At your system command line, type 'ipython -help' to see the command line
424 options available. This document only describes interactive features.
424 options available. This document only describes interactive features.
425
425
426 Warning: IPython relies on the existence of a global variable called __IP which
426 Warning: IPython relies on the existence of a global variable called __IP which
427 controls the shell itself. If you redefine __IP to anything, bizarre behavior
427 controls the shell itself. If you redefine __IP to anything, bizarre behavior
428 will quickly occur.
428 will quickly occur.
429
429
430 MAIN FEATURES
430 MAIN FEATURES
431
431
432 * Access to the standard Python help. As of Python 2.1, a help system is
432 * Access to the standard Python help. As of Python 2.1, a help system is
433 available with access to object docstrings and the Python manuals. Simply
433 available with access to object docstrings and the Python manuals. Simply
434 type 'help' (no quotes) to access it.
434 type 'help' (no quotes) to access it.
435
435
436 * Magic commands: type %magic for information on the magic subsystem.
436 * Magic commands: type %magic for information on the magic subsystem.
437
437
438 * System command aliases, via the %alias command or the ipythonrc config file.
438 * System command aliases, via the %alias command or the ipythonrc config file.
439
439
440 * Dynamic object information:
440 * Dynamic object information:
441
441
442 Typing ?word or word? prints detailed information about an object. If
442 Typing ?word or word? prints detailed information about an object. If
443 certain strings in the object are too long (docstrings, code, etc.) they get
443 certain strings in the object are too long (docstrings, code, etc.) they get
444 snipped in the center for brevity.
444 snipped in the center for brevity.
445
445
446 Typing ??word or word?? gives access to the full information without
446 Typing ??word or word?? gives access to the full information without
447 snipping long strings. Long strings are sent to the screen through the less
447 snipping long strings. Long strings are sent to the screen through the less
448 pager if longer than the screen, printed otherwise.
448 pager if longer than the screen, printed otherwise.
449
449
450 The ?/?? system gives access to the full source code for any object (if
450 The ?/?? system gives access to the full source code for any object (if
451 available), shows function prototypes and other useful information.
451 available), shows function prototypes and other useful information.
452
452
453 If you just want to see an object's docstring, type '%pdoc object' (without
453 If you just want to see an object's docstring, type '%pdoc object' (without
454 quotes, and without % if you have automagic on).
454 quotes, and without % if you have automagic on).
455
455
456 Both %pdoc and ?/?? give you access to documentation even on things which are
456 Both %pdoc and ?/?? give you access to documentation even on things which are
457 not explicitely defined. Try for example typing {}.get? or after import os,
457 not explicitely defined. Try for example typing {}.get? or after import os,
458 type os.path.abspath??. The magic functions %pdef, %source and %file operate
458 type os.path.abspath??. The magic functions %pdef, %source and %file operate
459 similarly.
459 similarly.
460
460
461 * Completion in the local namespace, by typing TAB at the prompt.
461 * Completion in the local namespace, by typing TAB at the prompt.
462
462
463 At any time, hitting tab will complete any available python commands or
463 At any time, hitting tab will complete any available python commands or
464 variable names, and show you a list of the possible completions if there's
464 variable names, and show you a list of the possible completions if there's
465 no unambiguous one. It will also complete filenames in the current directory.
465 no unambiguous one. It will also complete filenames in the current directory.
466
466
467 This feature requires the readline and rlcomplete modules, so it won't work
467 This feature requires the readline and rlcomplete modules, so it won't work
468 if your Python lacks readline support (such as under Windows).
468 if your Python lacks readline support (such as under Windows).
469
469
470 * Search previous command history in two ways (also requires readline):
470 * Search previous command history in two ways (also requires readline):
471
471
472 - Start typing, and then use Ctrl-p (previous,up) and Ctrl-n (next,down) to
472 - Start typing, and then use Ctrl-p (previous,up) and Ctrl-n (next,down) to
473 search through only the history items that match what you've typed so
473 search through only the history items that match what you've typed so
474 far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like
474 far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like
475 normal arrow keys.
475 normal arrow keys.
476
476
477 - Hit Ctrl-r: opens a search prompt. Begin typing and the system searches
477 - Hit Ctrl-r: opens a search prompt. Begin typing and the system searches
478 your history for lines that match what you've typed so far, completing as
478 your history for lines that match what you've typed so far, completing as
479 much as it can.
479 much as it can.
480
480
481 * Persistent command history across sessions (readline required).
481 * Persistent command history across sessions (readline required).
482
482
483 * Logging of input with the ability to save and restore a working session.
483 * Logging of input with the ability to save and restore a working session.
484
484
485 * System escape with !. Typing !ls will run 'ls' in the current directory.
485 * System escape with !. Typing !ls will run 'ls' in the current directory.
486
486
487 * The reload command does a 'deep' reload of a module: changes made to the
487 * The reload command does a 'deep' reload of a module: changes made to the
488 module since you imported will actually be available without having to exit.
488 module since you imported will actually be available without having to exit.
489
489
490 * Verbose and colored exception traceback printouts. See the magic xmode and
490 * Verbose and colored exception traceback printouts. See the magic xmode and
491 xcolor functions for details (just type %magic).
491 xcolor functions for details (just type %magic).
492
492
493 * Input caching system:
493 * Input caching system:
494
494
495 IPython offers numbered prompts (In/Out) with input and output caching. All
495 IPython offers numbered prompts (In/Out) with input and output caching. All
496 input is saved and can be retrieved as variables (besides the usual arrow
496 input is saved and can be retrieved as variables (besides the usual arrow
497 key recall).
497 key recall).
498
498
499 The following GLOBAL variables always exist (so don't overwrite them!):
499 The following GLOBAL variables always exist (so don't overwrite them!):
500 _i: stores previous input.
500 _i: stores previous input.
501 _ii: next previous.
501 _ii: next previous.
502 _iii: next-next previous.
502 _iii: next-next previous.
503 _ih : a list of all input _ih[n] is the input from line n.
503 _ih : a list of all input _ih[n] is the input from line n.
504
504
505 Additionally, global variables named _i<n> are dynamically created (<n>
505 Additionally, global variables named _i<n> are dynamically created (<n>
506 being the prompt counter), such that _i<n> == _ih[<n>]
506 being the prompt counter), such that _i<n> == _ih[<n>]
507
507
508 For example, what you typed at prompt 14 is available as _i14 and _ih[14].
508 For example, what you typed at prompt 14 is available as _i14 and _ih[14].
509
509
510 You can create macros which contain multiple input lines from this history,
510 You can create macros which contain multiple input lines from this history,
511 for later re-execution, with the %macro function.
511 for later re-execution, with the %macro function.
512
512
513 The history function %hist allows you to see any part of your input history
513 The history function %hist allows you to see any part of your input history
514 by printing a range of the _i variables. Note that inputs which contain
514 by printing a range of the _i variables. Note that inputs which contain
515 magic functions (%) appear in the history with a prepended comment. This is
515 magic functions (%) appear in the history with a prepended comment. This is
516 because they aren't really valid Python code, so you can't exec them.
516 because they aren't really valid Python code, so you can't exec them.
517
517
518 * Output caching system:
518 * Output caching system:
519
519
520 For output that is returned from actions, a system similar to the input
520 For output that is returned from actions, a system similar to the input
521 cache exists but using _ instead of _i. Only actions that produce a result
521 cache exists but using _ instead of _i. Only actions that produce a result
522 (NOT assignments, for example) are cached. If you are familiar with
522 (NOT assignments, for example) are cached. If you are familiar with
523 Mathematica, IPython's _ variables behave exactly like Mathematica's %
523 Mathematica, IPython's _ variables behave exactly like Mathematica's %
524 variables.
524 variables.
525
525
526 The following GLOBAL variables always exist (so don't overwrite them!):
526 The following GLOBAL variables always exist (so don't overwrite them!):
527 _ (one underscore): previous output.
527 _ (one underscore): previous output.
528 __ (two underscores): next previous.
528 __ (two underscores): next previous.
529 ___ (three underscores): next-next previous.
529 ___ (three underscores): next-next previous.
530
530
531 Global variables named _<n> are dynamically created (<n> being the prompt
531 Global variables named _<n> are dynamically created (<n> being the prompt
532 counter), such that the result of output <n> is always available as _<n>.
532 counter), such that the result of output <n> is always available as _<n>.
533
533
534 Finally, a global dictionary named _oh exists with entries for all lines
534 Finally, a global dictionary named _oh exists with entries for all lines
535 which generated output.
535 which generated output.
536
536
537 * Directory history:
537 * Directory history:
538
538
539 Your history of visited directories is kept in the global list _dh, and the
539 Your history of visited directories is kept in the global list _dh, and the
540 magic %cd command can be used to go to any entry in that list.
540 magic %cd command can be used to go to any entry in that list.
541
541
542 * Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython)
542 * Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython)
543
543
544 1. Auto-parentheses
544 1. Auto-parentheses
545 Callable objects (i.e. functions, methods, etc) can be invoked like
545 Callable objects (i.e. functions, methods, etc) can be invoked like
546 this (notice the commas between the arguments):
546 this (notice the commas between the arguments):
547 >>> callable_ob arg1, arg2, arg3
547 >>> callable_ob arg1, arg2, arg3
548 and the input will be translated to this:
548 and the input will be translated to this:
549 --> callable_ob(arg1, arg2, arg3)
549 --> callable_ob(arg1, arg2, arg3)
550 You can force auto-parentheses by using '/' as the first character
550 You can force auto-parentheses by using '/' as the first character
551 of a line. For example:
551 of a line. For example:
552 >>> /globals # becomes 'globals()'
552 >>> /globals # becomes 'globals()'
553 Note that the '/' MUST be the first character on the line! This
553 Note that the '/' MUST be the first character on the line! This
554 won't work:
554 won't work:
555 >>> print /globals # syntax error
555 >>> print /globals # syntax error
556
556
557 In most cases the automatic algorithm should work, so you should
557 In most cases the automatic algorithm should work, so you should
558 rarely need to explicitly invoke /. One notable exception is if you
558 rarely need to explicitly invoke /. One notable exception is if you
559 are trying to call a function with a list of tuples as arguments (the
559 are trying to call a function with a list of tuples as arguments (the
560 parenthesis will confuse IPython):
560 parenthesis will confuse IPython):
561 In [1]: zip (1,2,3),(4,5,6) # won't work
561 In [1]: zip (1,2,3),(4,5,6) # won't work
562 but this will work:
562 but this will work:
563 In [2]: /zip (1,2,3),(4,5,6)
563 In [2]: /zip (1,2,3),(4,5,6)
564 ------> zip ((1,2,3),(4,5,6))
564 ------> zip ((1,2,3),(4,5,6))
565 Out[2]= [(1, 4), (2, 5), (3, 6)]
565 Out[2]= [(1, 4), (2, 5), (3, 6)]
566
566
567 IPython tells you that it has altered your command line by
567 IPython tells you that it has altered your command line by
568 displaying the new command line preceded by -->. e.g.:
568 displaying the new command line preceded by -->. e.g.:
569 In [18]: callable list
569 In [18]: callable list
570 -------> callable (list)
570 -------> callable (list)
571
571
572 2. Auto-Quoting
572 2. Auto-Quoting
573 You can force auto-quoting of a function's arguments by using ',' as
573 You can force auto-quoting of a function's arguments by using ',' as
574 the first character of a line. For example:
574 the first character of a line. For example:
575 >>> ,my_function /home/me # becomes my_function("/home/me")
575 >>> ,my_function /home/me # becomes my_function("/home/me")
576
576
577 If you use ';' instead, the whole argument is quoted as a single
577 If you use ';' instead, the whole argument is quoted as a single
578 string (while ',' splits on whitespace):
578 string (while ',' splits on whitespace):
579 >>> ,my_function a b c # becomes my_function("a","b","c")
579 >>> ,my_function a b c # becomes my_function("a","b","c")
580 >>> ;my_function a b c # becomes my_function("a b c")
580 >>> ;my_function a b c # becomes my_function("a b c")
581
581
582 Note that the ',' MUST be the first character on the line! This
582 Note that the ',' MUST be the first character on the line! This
583 won't work:
583 won't work:
584 >>> x = ,my_function /home/me # syntax error
584 >>> x = ,my_function /home/me # syntax error
585 """
585 """
@@ -1,4599 +1,4627 b''
1 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Magic.py (Macro): simplified Macro class to just
4 subclass list. We've had only 2.2 compatibility for a very long
5 time, yet I was still avoiding subclassing the builtin types. No
6 more (I'm also starting to use properties, though I won't shift to
7 2.3-specific features quite yet).
8
9 * IPython/iplib.py (InteractiveShell.post_config_initialization):
10 changed the default logfile name from 'ipython.log' to
11 'ipython_log.py'. These logs are real python files, and now that
12 we have much better multiline support, people are more likely to
13 want to use them as such. Might as well name them correctly.
14
15 * IPython/Magic.py: substantial cleanup. While we can't stop
16 using magics as mixins, due to the existing customizations 'out
17 there' which rely on the mixin naming conventions, at least I
18 cleaned out all cross-class name usage. So once we are OK with
19 breaking compatibility, the two systems can be separated.
20
21 * IPython/Logger.py: major cleanup. This one is NOT a mixin
22 anymore, and the class is a fair bit less hideous as well. New
23 features were also introduced: timestamping of input, and logging
24 of output results. These are user-visible with the -t and -o
25 options to %logstart. Closes
26 http://www.scipy.net/roundup/ipython/issue11 and a request by
27 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
28
1 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
29 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
2
30
3 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
31 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
4 better hadnle backslashes in paths. See the thread 'More Windows
32 better hadnle backslashes in paths. See the thread 'More Windows
5 questions part 2 - \/ characters revisited' on the iypthon user
33 questions part 2 - \/ characters revisited' on the iypthon user
6 list:
34 list:
7 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
35 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
8
36
9 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
37 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
10
38
11 (InteractiveShell.__init__): change threaded shells to not use the
39 (InteractiveShell.__init__): change threaded shells to not use the
12 ipython crash handler. This was causing more problems than not,
40 ipython crash handler. This was causing more problems than not,
13 as exceptions in the main thread (GUI code, typically) would
41 as exceptions in the main thread (GUI code, typically) would
14 always show up as a 'crash', when they really weren't.
42 always show up as a 'crash', when they really weren't.
15
43
16 The colors and exception mode commands (%colors/%xmode) have been
44 The colors and exception mode commands (%colors/%xmode) have been
17 synchronized to also take this into account, so users can get
45 synchronized to also take this into account, so users can get
18 verbose exceptions for their threaded code as well. I also added
46 verbose exceptions for their threaded code as well. I also added
19 support for activating pdb inside this exception handler as well,
47 support for activating pdb inside this exception handler as well,
20 so now GUI authors can use IPython's enhanced pdb at runtime.
48 so now GUI authors can use IPython's enhanced pdb at runtime.
21
49
22 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
50 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
23 true by default, and add it to the shipped ipythonrc file. Since
51 true by default, and add it to the shipped ipythonrc file. Since
24 this asks the user before proceeding, I think it's OK to make it
52 this asks the user before proceeding, I think it's OK to make it
25 true by default.
53 true by default.
26
54
27 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
55 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
28 of the previous special-casing of input in the eval loop. I think
56 of the previous special-casing of input in the eval loop. I think
29 this is cleaner, as they really are commands and shouldn't have
57 this is cleaner, as they really are commands and shouldn't have
30 a special role in the middle of the core code.
58 a special role in the middle of the core code.
31
59
32 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
60 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
33
61
34 * IPython/iplib.py (edit_syntax_error): added support for
62 * IPython/iplib.py (edit_syntax_error): added support for
35 automatically reopening the editor if the file had a syntax error
63 automatically reopening the editor if the file had a syntax error
36 in it. Thanks to scottt who provided the patch at:
64 in it. Thanks to scottt who provided the patch at:
37 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
65 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
38 version committed).
66 version committed).
39
67
40 * IPython/iplib.py (handle_normal): add suport for multi-line
68 * IPython/iplib.py (handle_normal): add suport for multi-line
41 input with emtpy lines. This fixes
69 input with emtpy lines. This fixes
42 http://www.scipy.net/roundup/ipython/issue43 and a similar
70 http://www.scipy.net/roundup/ipython/issue43 and a similar
43 discussion on the user list.
71 discussion on the user list.
44
72
45 WARNING: a behavior change is necessarily introduced to support
73 WARNING: a behavior change is necessarily introduced to support
46 blank lines: now a single blank line with whitespace does NOT
74 blank lines: now a single blank line with whitespace does NOT
47 break the input loop, which means that when autoindent is on, by
75 break the input loop, which means that when autoindent is on, by
48 default hitting return on the next (indented) line does NOT exit.
76 default hitting return on the next (indented) line does NOT exit.
49
77
50 Instead, to exit a multiline input you can either have:
78 Instead, to exit a multiline input you can either have:
51
79
52 - TWO whitespace lines (just hit return again), or
80 - TWO whitespace lines (just hit return again), or
53 - a single whitespace line of a different length than provided
81 - a single whitespace line of a different length than provided
54 by the autoindent (add or remove a space).
82 by the autoindent (add or remove a space).
55
83
56 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
84 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
57 module to better organize all readline-related functionality.
85 module to better organize all readline-related functionality.
58 I've deleted FlexCompleter and put all completion clases here.
86 I've deleted FlexCompleter and put all completion clases here.
59
87
60 * IPython/iplib.py (raw_input): improve indentation management.
88 * IPython/iplib.py (raw_input): improve indentation management.
61 It is now possible to paste indented code with autoindent on, and
89 It is now possible to paste indented code with autoindent on, and
62 the code is interpreted correctly (though it still looks bad on
90 the code is interpreted correctly (though it still looks bad on
63 screen, due to the line-oriented nature of ipython).
91 screen, due to the line-oriented nature of ipython).
64 (MagicCompleter.complete): change behavior so that a TAB key on an
92 (MagicCompleter.complete): change behavior so that a TAB key on an
65 otherwise empty line actually inserts a tab, instead of completing
93 otherwise empty line actually inserts a tab, instead of completing
66 on the entire global namespace. This makes it easier to use the
94 on the entire global namespace. This makes it easier to use the
67 TAB key for indentation. After a request by Hans Meine
95 TAB key for indentation. After a request by Hans Meine
68 <hans_meine-AT-gmx.net>
96 <hans_meine-AT-gmx.net>
69 (_prefilter): add support so that typing plain 'exit' or 'quit'
97 (_prefilter): add support so that typing plain 'exit' or 'quit'
70 does a sensible thing. Originally I tried to deviate as little as
98 does a sensible thing. Originally I tried to deviate as little as
71 possible from the default python behavior, but even that one may
99 possible from the default python behavior, but even that one may
72 change in this direction (thread on python-dev to that effect).
100 change in this direction (thread on python-dev to that effect).
73 Regardless, ipython should do the right thing even if CPython's
101 Regardless, ipython should do the right thing even if CPython's
74 '>>>' prompt doesn't.
102 '>>>' prompt doesn't.
75 (InteractiveShell): removed subclassing code.InteractiveConsole
103 (InteractiveShell): removed subclassing code.InteractiveConsole
76 class. By now we'd overridden just about all of its methods: I've
104 class. By now we'd overridden just about all of its methods: I've
77 copied the remaining two over, and now ipython is a standalone
105 copied the remaining two over, and now ipython is a standalone
78 class. This will provide a clearer picture for the chainsaw
106 class. This will provide a clearer picture for the chainsaw
79 branch refactoring.
107 branch refactoring.
80
108
81 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
109 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
82
110
83 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
111 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
84 failures for objects which break when dir() is called on them.
112 failures for objects which break when dir() is called on them.
85
113
86 * IPython/FlexCompleter.py (Completer.__init__): Added support for
114 * IPython/FlexCompleter.py (Completer.__init__): Added support for
87 distinct local and global namespaces in the completer API. This
115 distinct local and global namespaces in the completer API. This
88 change allows us top properly handle completion with distinct
116 change allows us top properly handle completion with distinct
89 scopes, including in embedded instances (this had never really
117 scopes, including in embedded instances (this had never really
90 worked correctly).
118 worked correctly).
91
119
92 Note: this introduces a change in the constructor for
120 Note: this introduces a change in the constructor for
93 MagicCompleter, as a new global_namespace parameter is now the
121 MagicCompleter, as a new global_namespace parameter is now the
94 second argument (the others were bumped one position).
122 second argument (the others were bumped one position).
95
123
96 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
124 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
97
125
98 * IPython/iplib.py (embed_mainloop): fix tab-completion in
126 * IPython/iplib.py (embed_mainloop): fix tab-completion in
99 embedded instances (which can be done now thanks to Vivian's
127 embedded instances (which can be done now thanks to Vivian's
100 frame-handling fixes for pdb).
128 frame-handling fixes for pdb).
101 (InteractiveShell.__init__): Fix namespace handling problem in
129 (InteractiveShell.__init__): Fix namespace handling problem in
102 embedded instances. We were overwriting __main__ unconditionally,
130 embedded instances. We were overwriting __main__ unconditionally,
103 and this should only be done for 'full' (non-embedded) IPython;
131 and this should only be done for 'full' (non-embedded) IPython;
104 embedded instances must respect the caller's __main__. Thanks to
132 embedded instances must respect the caller's __main__. Thanks to
105 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
133 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
106
134
107 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
135 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
108
136
109 * setup.py: added download_url to setup(). This registers the
137 * setup.py: added download_url to setup(). This registers the
110 download address at PyPI, which is not only useful to humans
138 download address at PyPI, which is not only useful to humans
111 browsing the site, but is also picked up by setuptools (the Eggs
139 browsing the site, but is also picked up by setuptools (the Eggs
112 machinery). Thanks to Ville and R. Kern for the info/discussion
140 machinery). Thanks to Ville and R. Kern for the info/discussion
113 on this.
141 on this.
114
142
115 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
143 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
116
144
117 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
145 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
118 This brings a lot of nice functionality to the pdb mode, which now
146 This brings a lot of nice functionality to the pdb mode, which now
119 has tab-completion, syntax highlighting, and better stack handling
147 has tab-completion, syntax highlighting, and better stack handling
120 than before. Many thanks to Vivian De Smedt
148 than before. Many thanks to Vivian De Smedt
121 <vivian-AT-vdesmedt.com> for the original patches.
149 <vivian-AT-vdesmedt.com> for the original patches.
122
150
123 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
151 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
124
152
125 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
153 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
126 sequence to consistently accept the banner argument. The
154 sequence to consistently accept the banner argument. The
127 inconsistency was tripping SAGE, thanks to Gary Zablackis
155 inconsistency was tripping SAGE, thanks to Gary Zablackis
128 <gzabl-AT-yahoo.com> for the report.
156 <gzabl-AT-yahoo.com> for the report.
129
157
130 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
158 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
131
159
132 * IPython/iplib.py (InteractiveShell.post_config_initialization):
160 * IPython/iplib.py (InteractiveShell.post_config_initialization):
133 Fix bug where a naked 'alias' call in the ipythonrc file would
161 Fix bug where a naked 'alias' call in the ipythonrc file would
134 cause a crash. Bug reported by Jorgen Stenarson.
162 cause a crash. Bug reported by Jorgen Stenarson.
135
163
136 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
164 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
137
165
138 * IPython/ipmaker.py (make_IPython): cleanups which should improve
166 * IPython/ipmaker.py (make_IPython): cleanups which should improve
139 startup time.
167 startup time.
140
168
141 * IPython/iplib.py (runcode): my globals 'fix' for embedded
169 * IPython/iplib.py (runcode): my globals 'fix' for embedded
142 instances had introduced a bug with globals in normal code. Now
170 instances had introduced a bug with globals in normal code. Now
143 it's working in all cases.
171 it's working in all cases.
144
172
145 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
173 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
146 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
174 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
147 has been introduced to set the default case sensitivity of the
175 has been introduced to set the default case sensitivity of the
148 searches. Users can still select either mode at runtime on a
176 searches. Users can still select either mode at runtime on a
149 per-search basis.
177 per-search basis.
150
178
151 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
179 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
152
180
153 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
181 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
154 attributes in wildcard searches for subclasses. Modified version
182 attributes in wildcard searches for subclasses. Modified version
155 of a patch by Jorgen.
183 of a patch by Jorgen.
156
184
157 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
185 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
158
186
159 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
187 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
160 embedded instances. I added a user_global_ns attribute to the
188 embedded instances. I added a user_global_ns attribute to the
161 InteractiveShell class to handle this.
189 InteractiveShell class to handle this.
162
190
163 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
191 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
164
192
165 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
193 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
166 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
194 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
167 (reported under win32, but may happen also in other platforms).
195 (reported under win32, but may happen also in other platforms).
168 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
196 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
169
197
170 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
198 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
171
199
172 * IPython/Magic.py (magic_psearch): new support for wildcard
200 * IPython/Magic.py (magic_psearch): new support for wildcard
173 patterns. Now, typing ?a*b will list all names which begin with a
201 patterns. Now, typing ?a*b will list all names which begin with a
174 and end in b, for example. The %psearch magic has full
202 and end in b, for example. The %psearch magic has full
175 docstrings. Many thanks to Jörgen Stenarson
203 docstrings. Many thanks to Jörgen Stenarson
176 <jorgen.stenarson-AT-bostream.nu>, author of the patches
204 <jorgen.stenarson-AT-bostream.nu>, author of the patches
177 implementing this functionality.
205 implementing this functionality.
178
206
179 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
207 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
180
208
181 * Manual: fixed long-standing annoyance of double-dashes (as in
209 * Manual: fixed long-standing annoyance of double-dashes (as in
182 --prefix=~, for example) being stripped in the HTML version. This
210 --prefix=~, for example) being stripped in the HTML version. This
183 is a latex2html bug, but a workaround was provided. Many thanks
211 is a latex2html bug, but a workaround was provided. Many thanks
184 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
212 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
185 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
213 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
186 rolling. This seemingly small issue had tripped a number of users
214 rolling. This seemingly small issue had tripped a number of users
187 when first installing, so I'm glad to see it gone.
215 when first installing, so I'm glad to see it gone.
188
216
189 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
217 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
190
218
191 * IPython/Extensions/numeric_formats.py: fix missing import,
219 * IPython/Extensions/numeric_formats.py: fix missing import,
192 reported by Stephen Walton.
220 reported by Stephen Walton.
193
221
194 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
222 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
195
223
196 * IPython/demo.py: finish demo module, fully documented now.
224 * IPython/demo.py: finish demo module, fully documented now.
197
225
198 * IPython/genutils.py (file_read): simple little utility to read a
226 * IPython/genutils.py (file_read): simple little utility to read a
199 file and ensure it's closed afterwards.
227 file and ensure it's closed afterwards.
200
228
201 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
229 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
202
230
203 * IPython/demo.py (Demo.__init__): added support for individually
231 * IPython/demo.py (Demo.__init__): added support for individually
204 tagging blocks for automatic execution.
232 tagging blocks for automatic execution.
205
233
206 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
234 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
207 syntax-highlighted python sources, requested by John.
235 syntax-highlighted python sources, requested by John.
208
236
209 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
237 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
210
238
211 * IPython/demo.py (Demo.again): fix bug where again() blocks after
239 * IPython/demo.py (Demo.again): fix bug where again() blocks after
212 finishing.
240 finishing.
213
241
214 * IPython/genutils.py (shlex_split): moved from Magic to here,
242 * IPython/genutils.py (shlex_split): moved from Magic to here,
215 where all 2.2 compatibility stuff lives. I needed it for demo.py.
243 where all 2.2 compatibility stuff lives. I needed it for demo.py.
216
244
217 * IPython/demo.py (Demo.__init__): added support for silent
245 * IPython/demo.py (Demo.__init__): added support for silent
218 blocks, improved marks as regexps, docstrings written.
246 blocks, improved marks as regexps, docstrings written.
219 (Demo.__init__): better docstring, added support for sys.argv.
247 (Demo.__init__): better docstring, added support for sys.argv.
220
248
221 * IPython/genutils.py (marquee): little utility used by the demo
249 * IPython/genutils.py (marquee): little utility used by the demo
222 code, handy in general.
250 code, handy in general.
223
251
224 * IPython/demo.py (Demo.__init__): new class for interactive
252 * IPython/demo.py (Demo.__init__): new class for interactive
225 demos. Not documented yet, I just wrote it in a hurry for
253 demos. Not documented yet, I just wrote it in a hurry for
226 scipy'05. Will docstring later.
254 scipy'05. Will docstring later.
227
255
228 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
256 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
229
257
230 * IPython/Shell.py (sigint_handler): Drastic simplification which
258 * IPython/Shell.py (sigint_handler): Drastic simplification which
231 also seems to make Ctrl-C work correctly across threads! This is
259 also seems to make Ctrl-C work correctly across threads! This is
232 so simple, that I can't beleive I'd missed it before. Needs more
260 so simple, that I can't beleive I'd missed it before. Needs more
233 testing, though.
261 testing, though.
234 (KBINT): Never mind, revert changes. I'm sure I'd tried something
262 (KBINT): Never mind, revert changes. I'm sure I'd tried something
235 like this before...
263 like this before...
236
264
237 * IPython/genutils.py (get_home_dir): add protection against
265 * IPython/genutils.py (get_home_dir): add protection against
238 non-dirs in win32 registry.
266 non-dirs in win32 registry.
239
267
240 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
268 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
241 bug where dict was mutated while iterating (pysh crash).
269 bug where dict was mutated while iterating (pysh crash).
242
270
243 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
271 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
244
272
245 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
273 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
246 spurious newlines added by this routine. After a report by
274 spurious newlines added by this routine. After a report by
247 F. Mantegazza.
275 F. Mantegazza.
248
276
249 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
277 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
250
278
251 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
279 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
252 calls. These were a leftover from the GTK 1.x days, and can cause
280 calls. These were a leftover from the GTK 1.x days, and can cause
253 problems in certain cases (after a report by John Hunter).
281 problems in certain cases (after a report by John Hunter).
254
282
255 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
283 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
256 os.getcwd() fails at init time. Thanks to patch from David Remahl
284 os.getcwd() fails at init time. Thanks to patch from David Remahl
257 <chmod007-AT-mac.com>.
285 <chmod007-AT-mac.com>.
258 (InteractiveShell.__init__): prevent certain special magics from
286 (InteractiveShell.__init__): prevent certain special magics from
259 being shadowed by aliases. Closes
287 being shadowed by aliases. Closes
260 http://www.scipy.net/roundup/ipython/issue41.
288 http://www.scipy.net/roundup/ipython/issue41.
261
289
262 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
290 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
263
291
264 * IPython/iplib.py (InteractiveShell.complete): Added new
292 * IPython/iplib.py (InteractiveShell.complete): Added new
265 top-level completion method to expose the completion mechanism
293 top-level completion method to expose the completion mechanism
266 beyond readline-based environments.
294 beyond readline-based environments.
267
295
268 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
296 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
269
297
270 * tools/ipsvnc (svnversion): fix svnversion capture.
298 * tools/ipsvnc (svnversion): fix svnversion capture.
271
299
272 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
300 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
273 attribute to self, which was missing. Before, it was set by a
301 attribute to self, which was missing. Before, it was set by a
274 routine which in certain cases wasn't being called, so the
302 routine which in certain cases wasn't being called, so the
275 instance could end up missing the attribute. This caused a crash.
303 instance could end up missing the attribute. This caused a crash.
276 Closes http://www.scipy.net/roundup/ipython/issue40.
304 Closes http://www.scipy.net/roundup/ipython/issue40.
277
305
278 2005-08-16 Fernando Perez <fperez@colorado.edu>
306 2005-08-16 Fernando Perez <fperez@colorado.edu>
279
307
280 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
308 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
281 contains non-string attribute. Closes
309 contains non-string attribute. Closes
282 http://www.scipy.net/roundup/ipython/issue38.
310 http://www.scipy.net/roundup/ipython/issue38.
283
311
284 2005-08-14 Fernando Perez <fperez@colorado.edu>
312 2005-08-14 Fernando Perez <fperez@colorado.edu>
285
313
286 * tools/ipsvnc: Minor improvements, to add changeset info.
314 * tools/ipsvnc: Minor improvements, to add changeset info.
287
315
288 2005-08-12 Fernando Perez <fperez@colorado.edu>
316 2005-08-12 Fernando Perez <fperez@colorado.edu>
289
317
290 * IPython/iplib.py (runsource): remove self.code_to_run_src
318 * IPython/iplib.py (runsource): remove self.code_to_run_src
291 attribute. I realized this is nothing more than
319 attribute. I realized this is nothing more than
292 '\n'.join(self.buffer), and having the same data in two different
320 '\n'.join(self.buffer), and having the same data in two different
293 places is just asking for synchronization bugs. This may impact
321 places is just asking for synchronization bugs. This may impact
294 people who have custom exception handlers, so I need to warn
322 people who have custom exception handlers, so I need to warn
295 ipython-dev about it (F. Mantegazza may use them).
323 ipython-dev about it (F. Mantegazza may use them).
296
324
297 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
325 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
298
326
299 * IPython/genutils.py: fix 2.2 compatibility (generators)
327 * IPython/genutils.py: fix 2.2 compatibility (generators)
300
328
301 2005-07-18 Fernando Perez <fperez@colorado.edu>
329 2005-07-18 Fernando Perez <fperez@colorado.edu>
302
330
303 * IPython/genutils.py (get_home_dir): fix to help users with
331 * IPython/genutils.py (get_home_dir): fix to help users with
304 invalid $HOME under win32.
332 invalid $HOME under win32.
305
333
306 2005-07-17 Fernando Perez <fperez@colorado.edu>
334 2005-07-17 Fernando Perez <fperez@colorado.edu>
307
335
308 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
336 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
309 some old hacks and clean up a bit other routines; code should be
337 some old hacks and clean up a bit other routines; code should be
310 simpler and a bit faster.
338 simpler and a bit faster.
311
339
312 * IPython/iplib.py (interact): removed some last-resort attempts
340 * IPython/iplib.py (interact): removed some last-resort attempts
313 to survive broken stdout/stderr. That code was only making it
341 to survive broken stdout/stderr. That code was only making it
314 harder to abstract out the i/o (necessary for gui integration),
342 harder to abstract out the i/o (necessary for gui integration),
315 and the crashes it could prevent were extremely rare in practice
343 and the crashes it could prevent were extremely rare in practice
316 (besides being fully user-induced in a pretty violent manner).
344 (besides being fully user-induced in a pretty violent manner).
317
345
318 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
346 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
319 Nothing major yet, but the code is simpler to read; this should
347 Nothing major yet, but the code is simpler to read; this should
320 make it easier to do more serious modifications in the future.
348 make it easier to do more serious modifications in the future.
321
349
322 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
350 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
323 which broke in .15 (thanks to a report by Ville).
351 which broke in .15 (thanks to a report by Ville).
324
352
325 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
353 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
326 be quite correct, I know next to nothing about unicode). This
354 be quite correct, I know next to nothing about unicode). This
327 will allow unicode strings to be used in prompts, amongst other
355 will allow unicode strings to be used in prompts, amongst other
328 cases. It also will prevent ipython from crashing when unicode
356 cases. It also will prevent ipython from crashing when unicode
329 shows up unexpectedly in many places. If ascii encoding fails, we
357 shows up unexpectedly in many places. If ascii encoding fails, we
330 assume utf_8. Currently the encoding is not a user-visible
358 assume utf_8. Currently the encoding is not a user-visible
331 setting, though it could be made so if there is demand for it.
359 setting, though it could be made so if there is demand for it.
332
360
333 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
361 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
334
362
335 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
363 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
336
364
337 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
365 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
338
366
339 * IPython/genutils.py: Add 2.2 compatibility here, so all other
367 * IPython/genutils.py: Add 2.2 compatibility here, so all other
340 code can work transparently for 2.2/2.3.
368 code can work transparently for 2.2/2.3.
341
369
342 2005-07-16 Fernando Perez <fperez@colorado.edu>
370 2005-07-16 Fernando Perez <fperez@colorado.edu>
343
371
344 * IPython/ultraTB.py (ExceptionColors): Make a global variable
372 * IPython/ultraTB.py (ExceptionColors): Make a global variable
345 out of the color scheme table used for coloring exception
373 out of the color scheme table used for coloring exception
346 tracebacks. This allows user code to add new schemes at runtime.
374 tracebacks. This allows user code to add new schemes at runtime.
347 This is a minimally modified version of the patch at
375 This is a minimally modified version of the patch at
348 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
376 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
349 for the contribution.
377 for the contribution.
350
378
351 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
379 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
352 slightly modified version of the patch in
380 slightly modified version of the patch in
353 http://www.scipy.net/roundup/ipython/issue34, which also allows me
381 http://www.scipy.net/roundup/ipython/issue34, which also allows me
354 to remove the previous try/except solution (which was costlier).
382 to remove the previous try/except solution (which was costlier).
355 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
383 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
356
384
357 2005-06-08 Fernando Perez <fperez@colorado.edu>
385 2005-06-08 Fernando Perez <fperez@colorado.edu>
358
386
359 * IPython/iplib.py (write/write_err): Add methods to abstract all
387 * IPython/iplib.py (write/write_err): Add methods to abstract all
360 I/O a bit more.
388 I/O a bit more.
361
389
362 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
390 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
363 warning, reported by Aric Hagberg, fix by JD Hunter.
391 warning, reported by Aric Hagberg, fix by JD Hunter.
364
392
365 2005-06-02 *** Released version 0.6.15
393 2005-06-02 *** Released version 0.6.15
366
394
367 2005-06-01 Fernando Perez <fperez@colorado.edu>
395 2005-06-01 Fernando Perez <fperez@colorado.edu>
368
396
369 * IPython/iplib.py (MagicCompleter.file_matches): Fix
397 * IPython/iplib.py (MagicCompleter.file_matches): Fix
370 tab-completion of filenames within open-quoted strings. Note that
398 tab-completion of filenames within open-quoted strings. Note that
371 this requires that in ~/.ipython/ipythonrc, users change the
399 this requires that in ~/.ipython/ipythonrc, users change the
372 readline delimiters configuration to read:
400 readline delimiters configuration to read:
373
401
374 readline_remove_delims -/~
402 readline_remove_delims -/~
375
403
376
404
377 2005-05-31 *** Released version 0.6.14
405 2005-05-31 *** Released version 0.6.14
378
406
379 2005-05-29 Fernando Perez <fperez@colorado.edu>
407 2005-05-29 Fernando Perez <fperez@colorado.edu>
380
408
381 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
409 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
382 with files not on the filesystem. Reported by Eliyahu Sandler
410 with files not on the filesystem. Reported by Eliyahu Sandler
383 <eli@gondolin.net>
411 <eli@gondolin.net>
384
412
385 2005-05-22 Fernando Perez <fperez@colorado.edu>
413 2005-05-22 Fernando Perez <fperez@colorado.edu>
386
414
387 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
415 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
388 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
416 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
389
417
390 2005-05-19 Fernando Perez <fperez@colorado.edu>
418 2005-05-19 Fernando Perez <fperez@colorado.edu>
391
419
392 * IPython/iplib.py (safe_execfile): close a file which could be
420 * IPython/iplib.py (safe_execfile): close a file which could be
393 left open (causing problems in win32, which locks open files).
421 left open (causing problems in win32, which locks open files).
394 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
422 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
395
423
396 2005-05-18 Fernando Perez <fperez@colorado.edu>
424 2005-05-18 Fernando Perez <fperez@colorado.edu>
397
425
398 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
426 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
399 keyword arguments correctly to safe_execfile().
427 keyword arguments correctly to safe_execfile().
400
428
401 2005-05-13 Fernando Perez <fperez@colorado.edu>
429 2005-05-13 Fernando Perez <fperez@colorado.edu>
402
430
403 * ipython.1: Added info about Qt to manpage, and threads warning
431 * ipython.1: Added info about Qt to manpage, and threads warning
404 to usage page (invoked with --help).
432 to usage page (invoked with --help).
405
433
406 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
434 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
407 new matcher (it goes at the end of the priority list) to do
435 new matcher (it goes at the end of the priority list) to do
408 tab-completion on named function arguments. Submitted by George
436 tab-completion on named function arguments. Submitted by George
409 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
437 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
410 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
438 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
411 for more details.
439 for more details.
412
440
413 * IPython/Magic.py (magic_run): Added new -e flag to ignore
441 * IPython/Magic.py (magic_run): Added new -e flag to ignore
414 SystemExit exceptions in the script being run. Thanks to a report
442 SystemExit exceptions in the script being run. Thanks to a report
415 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
443 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
416 producing very annoying behavior when running unit tests.
444 producing very annoying behavior when running unit tests.
417
445
418 2005-05-12 Fernando Perez <fperez@colorado.edu>
446 2005-05-12 Fernando Perez <fperez@colorado.edu>
419
447
420 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
448 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
421 which I'd broken (again) due to a changed regexp. In the process,
449 which I'd broken (again) due to a changed regexp. In the process,
422 added ';' as an escape to auto-quote the whole line without
450 added ';' as an escape to auto-quote the whole line without
423 splitting its arguments. Thanks to a report by Jerry McRae
451 splitting its arguments. Thanks to a report by Jerry McRae
424 <qrs0xyc02-AT-sneakemail.com>.
452 <qrs0xyc02-AT-sneakemail.com>.
425
453
426 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
454 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
427 possible crashes caused by a TokenError. Reported by Ed Schofield
455 possible crashes caused by a TokenError. Reported by Ed Schofield
428 <schofield-AT-ftw.at>.
456 <schofield-AT-ftw.at>.
429
457
430 2005-05-06 Fernando Perez <fperez@colorado.edu>
458 2005-05-06 Fernando Perez <fperez@colorado.edu>
431
459
432 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
460 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
433
461
434 2005-04-29 Fernando Perez <fperez@colorado.edu>
462 2005-04-29 Fernando Perez <fperez@colorado.edu>
435
463
436 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
464 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
437 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
465 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
438 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
466 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
439 which provides support for Qt interactive usage (similar to the
467 which provides support for Qt interactive usage (similar to the
440 existing one for WX and GTK). This had been often requested.
468 existing one for WX and GTK). This had been often requested.
441
469
442 2005-04-14 *** Released version 0.6.13
470 2005-04-14 *** Released version 0.6.13
443
471
444 2005-04-08 Fernando Perez <fperez@colorado.edu>
472 2005-04-08 Fernando Perez <fperez@colorado.edu>
445
473
446 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
474 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
447 from _ofind, which gets called on almost every input line. Now,
475 from _ofind, which gets called on almost every input line. Now,
448 we only try to get docstrings if they are actually going to be
476 we only try to get docstrings if they are actually going to be
449 used (the overhead of fetching unnecessary docstrings can be
477 used (the overhead of fetching unnecessary docstrings can be
450 noticeable for certain objects, such as Pyro proxies).
478 noticeable for certain objects, such as Pyro proxies).
451
479
452 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
480 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
453 for completers. For some reason I had been passing them the state
481 for completers. For some reason I had been passing them the state
454 variable, which completers never actually need, and was in
482 variable, which completers never actually need, and was in
455 conflict with the rlcompleter API. Custom completers ONLY need to
483 conflict with the rlcompleter API. Custom completers ONLY need to
456 take the text parameter.
484 take the text parameter.
457
485
458 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
486 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
459 work correctly in pysh. I've also moved all the logic which used
487 work correctly in pysh. I've also moved all the logic which used
460 to be in pysh.py here, which will prevent problems with future
488 to be in pysh.py here, which will prevent problems with future
461 upgrades. However, this time I must warn users to update their
489 upgrades. However, this time I must warn users to update their
462 pysh profile to include the line
490 pysh profile to include the line
463
491
464 import_all IPython.Extensions.InterpreterExec
492 import_all IPython.Extensions.InterpreterExec
465
493
466 because otherwise things won't work for them. They MUST also
494 because otherwise things won't work for them. They MUST also
467 delete pysh.py and the line
495 delete pysh.py and the line
468
496
469 execfile pysh.py
497 execfile pysh.py
470
498
471 from their ipythonrc-pysh.
499 from their ipythonrc-pysh.
472
500
473 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
501 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
474 robust in the face of objects whose dir() returns non-strings
502 robust in the face of objects whose dir() returns non-strings
475 (which it shouldn't, but some broken libs like ITK do). Thanks to
503 (which it shouldn't, but some broken libs like ITK do). Thanks to
476 a patch by John Hunter (implemented differently, though). Also
504 a patch by John Hunter (implemented differently, though). Also
477 minor improvements by using .extend instead of + on lists.
505 minor improvements by using .extend instead of + on lists.
478
506
479 * pysh.py:
507 * pysh.py:
480
508
481 2005-04-06 Fernando Perez <fperez@colorado.edu>
509 2005-04-06 Fernando Perez <fperez@colorado.edu>
482
510
483 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
511 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
484 by default, so that all users benefit from it. Those who don't
512 by default, so that all users benefit from it. Those who don't
485 want it can still turn it off.
513 want it can still turn it off.
486
514
487 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
515 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
488 config file, I'd forgotten about this, so users were getting it
516 config file, I'd forgotten about this, so users were getting it
489 off by default.
517 off by default.
490
518
491 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
519 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
492 consistency. Now magics can be called in multiline statements,
520 consistency. Now magics can be called in multiline statements,
493 and python variables can be expanded in magic calls via $var.
521 and python variables can be expanded in magic calls via $var.
494 This makes the magic system behave just like aliases or !system
522 This makes the magic system behave just like aliases or !system
495 calls.
523 calls.
496
524
497 2005-03-28 Fernando Perez <fperez@colorado.edu>
525 2005-03-28 Fernando Perez <fperez@colorado.edu>
498
526
499 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
527 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
500 expensive string additions for building command. Add support for
528 expensive string additions for building command. Add support for
501 trailing ';' when autocall is used.
529 trailing ';' when autocall is used.
502
530
503 2005-03-26 Fernando Perez <fperez@colorado.edu>
531 2005-03-26 Fernando Perez <fperez@colorado.edu>
504
532
505 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
533 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
506 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
534 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
507 ipython.el robust against prompts with any number of spaces
535 ipython.el robust against prompts with any number of spaces
508 (including 0) after the ':' character.
536 (including 0) after the ':' character.
509
537
510 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
538 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
511 continuation prompt, which misled users to think the line was
539 continuation prompt, which misled users to think the line was
512 already indented. Closes debian Bug#300847, reported to me by
540 already indented. Closes debian Bug#300847, reported to me by
513 Norbert Tretkowski <tretkowski-AT-inittab.de>.
541 Norbert Tretkowski <tretkowski-AT-inittab.de>.
514
542
515 2005-03-23 Fernando Perez <fperez@colorado.edu>
543 2005-03-23 Fernando Perez <fperez@colorado.edu>
516
544
517 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
545 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
518 properly aligned if they have embedded newlines.
546 properly aligned if they have embedded newlines.
519
547
520 * IPython/iplib.py (runlines): Add a public method to expose
548 * IPython/iplib.py (runlines): Add a public method to expose
521 IPython's code execution machinery, so that users can run strings
549 IPython's code execution machinery, so that users can run strings
522 as if they had been typed at the prompt interactively.
550 as if they had been typed at the prompt interactively.
523 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
551 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
524 methods which can call the system shell, but with python variable
552 methods which can call the system shell, but with python variable
525 expansion. The three such methods are: __IPYTHON__.system,
553 expansion. The three such methods are: __IPYTHON__.system,
526 .getoutput and .getoutputerror. These need to be documented in a
554 .getoutput and .getoutputerror. These need to be documented in a
527 'public API' section (to be written) of the manual.
555 'public API' section (to be written) of the manual.
528
556
529 2005-03-20 Fernando Perez <fperez@colorado.edu>
557 2005-03-20 Fernando Perez <fperez@colorado.edu>
530
558
531 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
559 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
532 for custom exception handling. This is quite powerful, and it
560 for custom exception handling. This is quite powerful, and it
533 allows for user-installable exception handlers which can trap
561 allows for user-installable exception handlers which can trap
534 custom exceptions at runtime and treat them separately from
562 custom exceptions at runtime and treat them separately from
535 IPython's default mechanisms. At the request of Frédéric
563 IPython's default mechanisms. At the request of Frédéric
536 Mantegazza <mantegazza-AT-ill.fr>.
564 Mantegazza <mantegazza-AT-ill.fr>.
537 (InteractiveShell.set_custom_completer): public API function to
565 (InteractiveShell.set_custom_completer): public API function to
538 add new completers at runtime.
566 add new completers at runtime.
539
567
540 2005-03-19 Fernando Perez <fperez@colorado.edu>
568 2005-03-19 Fernando Perez <fperez@colorado.edu>
541
569
542 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
570 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
543 allow objects which provide their docstrings via non-standard
571 allow objects which provide their docstrings via non-standard
544 mechanisms (like Pyro proxies) to still be inspected by ipython's
572 mechanisms (like Pyro proxies) to still be inspected by ipython's
545 ? system.
573 ? system.
546
574
547 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
575 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
548 automatic capture system. I tried quite hard to make it work
576 automatic capture system. I tried quite hard to make it work
549 reliably, and simply failed. I tried many combinations with the
577 reliably, and simply failed. I tried many combinations with the
550 subprocess module, but eventually nothing worked in all needed
578 subprocess module, but eventually nothing worked in all needed
551 cases (not blocking stdin for the child, duplicating stdout
579 cases (not blocking stdin for the child, duplicating stdout
552 without blocking, etc). The new %sc/%sx still do capture to these
580 without blocking, etc). The new %sc/%sx still do capture to these
553 magical list/string objects which make shell use much more
581 magical list/string objects which make shell use much more
554 conveninent, so not all is lost.
582 conveninent, so not all is lost.
555
583
556 XXX - FIX MANUAL for the change above!
584 XXX - FIX MANUAL for the change above!
557
585
558 (runsource): I copied code.py's runsource() into ipython to modify
586 (runsource): I copied code.py's runsource() into ipython to modify
559 it a bit. Now the code object and source to be executed are
587 it a bit. Now the code object and source to be executed are
560 stored in ipython. This makes this info accessible to third-party
588 stored in ipython. This makes this info accessible to third-party
561 tools, like custom exception handlers. After a request by Frédéric
589 tools, like custom exception handlers. After a request by Frédéric
562 Mantegazza <mantegazza-AT-ill.fr>.
590 Mantegazza <mantegazza-AT-ill.fr>.
563
591
564 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
592 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
565 history-search via readline (like C-p/C-n). I'd wanted this for a
593 history-search via readline (like C-p/C-n). I'd wanted this for a
566 long time, but only recently found out how to do it. For users
594 long time, but only recently found out how to do it. For users
567 who already have their ipythonrc files made and want this, just
595 who already have their ipythonrc files made and want this, just
568 add:
596 add:
569
597
570 readline_parse_and_bind "\e[A": history-search-backward
598 readline_parse_and_bind "\e[A": history-search-backward
571 readline_parse_and_bind "\e[B": history-search-forward
599 readline_parse_and_bind "\e[B": history-search-forward
572
600
573 2005-03-18 Fernando Perez <fperez@colorado.edu>
601 2005-03-18 Fernando Perez <fperez@colorado.edu>
574
602
575 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
603 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
576 LSString and SList classes which allow transparent conversions
604 LSString and SList classes which allow transparent conversions
577 between list mode and whitespace-separated string.
605 between list mode and whitespace-separated string.
578 (magic_r): Fix recursion problem in %r.
606 (magic_r): Fix recursion problem in %r.
579
607
580 * IPython/genutils.py (LSString): New class to be used for
608 * IPython/genutils.py (LSString): New class to be used for
581 automatic storage of the results of all alias/system calls in _o
609 automatic storage of the results of all alias/system calls in _o
582 and _e (stdout/err). These provide a .l/.list attribute which
610 and _e (stdout/err). These provide a .l/.list attribute which
583 does automatic splitting on newlines. This means that for most
611 does automatic splitting on newlines. This means that for most
584 uses, you'll never need to do capturing of output with %sc/%sx
612 uses, you'll never need to do capturing of output with %sc/%sx
585 anymore, since ipython keeps this always done for you. Note that
613 anymore, since ipython keeps this always done for you. Note that
586 only the LAST results are stored, the _o/e variables are
614 only the LAST results are stored, the _o/e variables are
587 overwritten on each call. If you need to save their contents
615 overwritten on each call. If you need to save their contents
588 further, simply bind them to any other name.
616 further, simply bind them to any other name.
589
617
590 2005-03-17 Fernando Perez <fperez@colorado.edu>
618 2005-03-17 Fernando Perez <fperez@colorado.edu>
591
619
592 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
620 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
593 prompt namespace handling.
621 prompt namespace handling.
594
622
595 2005-03-16 Fernando Perez <fperez@colorado.edu>
623 2005-03-16 Fernando Perez <fperez@colorado.edu>
596
624
597 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
625 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
598 classic prompts to be '>>> ' (final space was missing, and it
626 classic prompts to be '>>> ' (final space was missing, and it
599 trips the emacs python mode).
627 trips the emacs python mode).
600 (BasePrompt.__str__): Added safe support for dynamic prompt
628 (BasePrompt.__str__): Added safe support for dynamic prompt
601 strings. Now you can set your prompt string to be '$x', and the
629 strings. Now you can set your prompt string to be '$x', and the
602 value of x will be printed from your interactive namespace. The
630 value of x will be printed from your interactive namespace. The
603 interpolation syntax includes the full Itpl support, so
631 interpolation syntax includes the full Itpl support, so
604 ${foo()+x+bar()} is a valid prompt string now, and the function
632 ${foo()+x+bar()} is a valid prompt string now, and the function
605 calls will be made at runtime.
633 calls will be made at runtime.
606
634
607 2005-03-15 Fernando Perez <fperez@colorado.edu>
635 2005-03-15 Fernando Perez <fperez@colorado.edu>
608
636
609 * IPython/Magic.py (magic_history): renamed %hist to %history, to
637 * IPython/Magic.py (magic_history): renamed %hist to %history, to
610 avoid name clashes in pylab. %hist still works, it just forwards
638 avoid name clashes in pylab. %hist still works, it just forwards
611 the call to %history.
639 the call to %history.
612
640
613 2005-03-02 *** Released version 0.6.12
641 2005-03-02 *** Released version 0.6.12
614
642
615 2005-03-02 Fernando Perez <fperez@colorado.edu>
643 2005-03-02 Fernando Perez <fperez@colorado.edu>
616
644
617 * IPython/iplib.py (handle_magic): log magic calls properly as
645 * IPython/iplib.py (handle_magic): log magic calls properly as
618 ipmagic() function calls.
646 ipmagic() function calls.
619
647
620 * IPython/Magic.py (magic_time): Improved %time to support
648 * IPython/Magic.py (magic_time): Improved %time to support
621 statements and provide wall-clock as well as CPU time.
649 statements and provide wall-clock as well as CPU time.
622
650
623 2005-02-27 Fernando Perez <fperez@colorado.edu>
651 2005-02-27 Fernando Perez <fperez@colorado.edu>
624
652
625 * IPython/hooks.py: New hooks module, to expose user-modifiable
653 * IPython/hooks.py: New hooks module, to expose user-modifiable
626 IPython functionality in a clean manner. For now only the editor
654 IPython functionality in a clean manner. For now only the editor
627 hook is actually written, and other thigns which I intend to turn
655 hook is actually written, and other thigns which I intend to turn
628 into proper hooks aren't yet there. The display and prefilter
656 into proper hooks aren't yet there. The display and prefilter
629 stuff, for example, should be hooks. But at least now the
657 stuff, for example, should be hooks. But at least now the
630 framework is in place, and the rest can be moved here with more
658 framework is in place, and the rest can be moved here with more
631 time later. IPython had had a .hooks variable for a long time for
659 time later. IPython had had a .hooks variable for a long time for
632 this purpose, but I'd never actually used it for anything.
660 this purpose, but I'd never actually used it for anything.
633
661
634 2005-02-26 Fernando Perez <fperez@colorado.edu>
662 2005-02-26 Fernando Perez <fperez@colorado.edu>
635
663
636 * IPython/ipmaker.py (make_IPython): make the default ipython
664 * IPython/ipmaker.py (make_IPython): make the default ipython
637 directory be called _ipython under win32, to follow more the
665 directory be called _ipython under win32, to follow more the
638 naming peculiarities of that platform (where buggy software like
666 naming peculiarities of that platform (where buggy software like
639 Visual Sourcesafe breaks with .named directories). Reported by
667 Visual Sourcesafe breaks with .named directories). Reported by
640 Ville Vainio.
668 Ville Vainio.
641
669
642 2005-02-23 Fernando Perez <fperez@colorado.edu>
670 2005-02-23 Fernando Perez <fperez@colorado.edu>
643
671
644 * IPython/iplib.py (InteractiveShell.__init__): removed a few
672 * IPython/iplib.py (InteractiveShell.__init__): removed a few
645 auto_aliases for win32 which were causing problems. Users can
673 auto_aliases for win32 which were causing problems. Users can
646 define the ones they personally like.
674 define the ones they personally like.
647
675
648 2005-02-21 Fernando Perez <fperez@colorado.edu>
676 2005-02-21 Fernando Perez <fperez@colorado.edu>
649
677
650 * IPython/Magic.py (magic_time): new magic to time execution of
678 * IPython/Magic.py (magic_time): new magic to time execution of
651 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
679 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
652
680
653 2005-02-19 Fernando Perez <fperez@colorado.edu>
681 2005-02-19 Fernando Perez <fperez@colorado.edu>
654
682
655 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
683 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
656 into keys (for prompts, for example).
684 into keys (for prompts, for example).
657
685
658 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
686 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
659 prompts in case users want them. This introduces a small behavior
687 prompts in case users want them. This introduces a small behavior
660 change: ipython does not automatically add a space to all prompts
688 change: ipython does not automatically add a space to all prompts
661 anymore. To get the old prompts with a space, users should add it
689 anymore. To get the old prompts with a space, users should add it
662 manually to their ipythonrc file, so for example prompt_in1 should
690 manually to their ipythonrc file, so for example prompt_in1 should
663 now read 'In [\#]: ' instead of 'In [\#]:'.
691 now read 'In [\#]: ' instead of 'In [\#]:'.
664 (BasePrompt.__init__): New option prompts_pad_left (only in rc
692 (BasePrompt.__init__): New option prompts_pad_left (only in rc
665 file) to control left-padding of secondary prompts.
693 file) to control left-padding of secondary prompts.
666
694
667 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
695 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
668 the profiler can't be imported. Fix for Debian, which removed
696 the profiler can't be imported. Fix for Debian, which removed
669 profile.py because of License issues. I applied a slightly
697 profile.py because of License issues. I applied a slightly
670 modified version of the original Debian patch at
698 modified version of the original Debian patch at
671 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
699 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
672
700
673 2005-02-17 Fernando Perez <fperez@colorado.edu>
701 2005-02-17 Fernando Perez <fperez@colorado.edu>
674
702
675 * IPython/genutils.py (native_line_ends): Fix bug which would
703 * IPython/genutils.py (native_line_ends): Fix bug which would
676 cause improper line-ends under win32 b/c I was not opening files
704 cause improper line-ends under win32 b/c I was not opening files
677 in binary mode. Bug report and fix thanks to Ville.
705 in binary mode. Bug report and fix thanks to Ville.
678
706
679 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
707 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
680 trying to catch spurious foo[1] autocalls. My fix actually broke
708 trying to catch spurious foo[1] autocalls. My fix actually broke
681 ',/' autoquote/call with explicit escape (bad regexp).
709 ',/' autoquote/call with explicit escape (bad regexp).
682
710
683 2005-02-15 *** Released version 0.6.11
711 2005-02-15 *** Released version 0.6.11
684
712
685 2005-02-14 Fernando Perez <fperez@colorado.edu>
713 2005-02-14 Fernando Perez <fperez@colorado.edu>
686
714
687 * IPython/background_jobs.py: New background job management
715 * IPython/background_jobs.py: New background job management
688 subsystem. This is implemented via a new set of classes, and
716 subsystem. This is implemented via a new set of classes, and
689 IPython now provides a builtin 'jobs' object for background job
717 IPython now provides a builtin 'jobs' object for background job
690 execution. A convenience %bg magic serves as a lightweight
718 execution. A convenience %bg magic serves as a lightweight
691 frontend for starting the more common type of calls. This was
719 frontend for starting the more common type of calls. This was
692 inspired by discussions with B. Granger and the BackgroundCommand
720 inspired by discussions with B. Granger and the BackgroundCommand
693 class described in the book Python Scripting for Computational
721 class described in the book Python Scripting for Computational
694 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
722 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
695 (although ultimately no code from this text was used, as IPython's
723 (although ultimately no code from this text was used, as IPython's
696 system is a separate implementation).
724 system is a separate implementation).
697
725
698 * IPython/iplib.py (MagicCompleter.python_matches): add new option
726 * IPython/iplib.py (MagicCompleter.python_matches): add new option
699 to control the completion of single/double underscore names
727 to control the completion of single/double underscore names
700 separately. As documented in the example ipytonrc file, the
728 separately. As documented in the example ipytonrc file, the
701 readline_omit__names variable can now be set to 2, to omit even
729 readline_omit__names variable can now be set to 2, to omit even
702 single underscore names. Thanks to a patch by Brian Wong
730 single underscore names. Thanks to a patch by Brian Wong
703 <BrianWong-AT-AirgoNetworks.Com>.
731 <BrianWong-AT-AirgoNetworks.Com>.
704 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
732 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
705 be autocalled as foo([1]) if foo were callable. A problem for
733 be autocalled as foo([1]) if foo were callable. A problem for
706 things which are both callable and implement __getitem__.
734 things which are both callable and implement __getitem__.
707 (init_readline): Fix autoindentation for win32. Thanks to a patch
735 (init_readline): Fix autoindentation for win32. Thanks to a patch
708 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
736 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
709
737
710 2005-02-12 Fernando Perez <fperez@colorado.edu>
738 2005-02-12 Fernando Perez <fperez@colorado.edu>
711
739
712 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
740 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
713 which I had written long ago to sort out user error messages which
741 which I had written long ago to sort out user error messages which
714 may occur during startup. This seemed like a good idea initially,
742 may occur during startup. This seemed like a good idea initially,
715 but it has proven a disaster in retrospect. I don't want to
743 but it has proven a disaster in retrospect. I don't want to
716 change much code for now, so my fix is to set the internal 'debug'
744 change much code for now, so my fix is to set the internal 'debug'
717 flag to true everywhere, whose only job was precisely to control
745 flag to true everywhere, whose only job was precisely to control
718 this subsystem. This closes issue 28 (as well as avoiding all
746 this subsystem. This closes issue 28 (as well as avoiding all
719 sorts of strange hangups which occur from time to time).
747 sorts of strange hangups which occur from time to time).
720
748
721 2005-02-07 Fernando Perez <fperez@colorado.edu>
749 2005-02-07 Fernando Perez <fperez@colorado.edu>
722
750
723 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
751 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
724 previous call produced a syntax error.
752 previous call produced a syntax error.
725
753
726 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
754 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
727 classes without constructor.
755 classes without constructor.
728
756
729 2005-02-06 Fernando Perez <fperez@colorado.edu>
757 2005-02-06 Fernando Perez <fperez@colorado.edu>
730
758
731 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
759 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
732 completions with the results of each matcher, so we return results
760 completions with the results of each matcher, so we return results
733 to the user from all namespaces. This breaks with ipython
761 to the user from all namespaces. This breaks with ipython
734 tradition, but I think it's a nicer behavior. Now you get all
762 tradition, but I think it's a nicer behavior. Now you get all
735 possible completions listed, from all possible namespaces (python,
763 possible completions listed, from all possible namespaces (python,
736 filesystem, magics...) After a request by John Hunter
764 filesystem, magics...) After a request by John Hunter
737 <jdhunter-AT-nitace.bsd.uchicago.edu>.
765 <jdhunter-AT-nitace.bsd.uchicago.edu>.
738
766
739 2005-02-05 Fernando Perez <fperez@colorado.edu>
767 2005-02-05 Fernando Perez <fperez@colorado.edu>
740
768
741 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
769 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
742 the call had quote characters in it (the quotes were stripped).
770 the call had quote characters in it (the quotes were stripped).
743
771
744 2005-01-31 Fernando Perez <fperez@colorado.edu>
772 2005-01-31 Fernando Perez <fperez@colorado.edu>
745
773
746 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
774 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
747 Itpl.itpl() to make the code more robust against psyco
775 Itpl.itpl() to make the code more robust against psyco
748 optimizations.
776 optimizations.
749
777
750 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
778 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
751 of causing an exception. Quicker, cleaner.
779 of causing an exception. Quicker, cleaner.
752
780
753 2005-01-28 Fernando Perez <fperez@colorado.edu>
781 2005-01-28 Fernando Perez <fperez@colorado.edu>
754
782
755 * scripts/ipython_win_post_install.py (install): hardcode
783 * scripts/ipython_win_post_install.py (install): hardcode
756 sys.prefix+'python.exe' as the executable path. It turns out that
784 sys.prefix+'python.exe' as the executable path. It turns out that
757 during the post-installation run, sys.executable resolves to the
785 during the post-installation run, sys.executable resolves to the
758 name of the binary installer! I should report this as a distutils
786 name of the binary installer! I should report this as a distutils
759 bug, I think. I updated the .10 release with this tiny fix, to
787 bug, I think. I updated the .10 release with this tiny fix, to
760 avoid annoying the lists further.
788 avoid annoying the lists further.
761
789
762 2005-01-27 *** Released version 0.6.10
790 2005-01-27 *** Released version 0.6.10
763
791
764 2005-01-27 Fernando Perez <fperez@colorado.edu>
792 2005-01-27 Fernando Perez <fperez@colorado.edu>
765
793
766 * IPython/numutils.py (norm): Added 'inf' as optional name for
794 * IPython/numutils.py (norm): Added 'inf' as optional name for
767 L-infinity norm, included references to mathworld.com for vector
795 L-infinity norm, included references to mathworld.com for vector
768 norm definitions.
796 norm definitions.
769 (amin/amax): added amin/amax for array min/max. Similar to what
797 (amin/amax): added amin/amax for array min/max. Similar to what
770 pylab ships with after the recent reorganization of names.
798 pylab ships with after the recent reorganization of names.
771 (spike/spike_odd): removed deprecated spike/spike_odd functions.
799 (spike/spike_odd): removed deprecated spike/spike_odd functions.
772
800
773 * ipython.el: committed Alex's recent fixes and improvements.
801 * ipython.el: committed Alex's recent fixes and improvements.
774 Tested with python-mode from CVS, and it looks excellent. Since
802 Tested with python-mode from CVS, and it looks excellent. Since
775 python-mode hasn't released anything in a while, I'm temporarily
803 python-mode hasn't released anything in a while, I'm temporarily
776 putting a copy of today's CVS (v 4.70) of python-mode in:
804 putting a copy of today's CVS (v 4.70) of python-mode in:
777 http://ipython.scipy.org/tmp/python-mode.el
805 http://ipython.scipy.org/tmp/python-mode.el
778
806
779 * scripts/ipython_win_post_install.py (install): Win32 fix to use
807 * scripts/ipython_win_post_install.py (install): Win32 fix to use
780 sys.executable for the executable name, instead of assuming it's
808 sys.executable for the executable name, instead of assuming it's
781 called 'python.exe' (the post-installer would have produced broken
809 called 'python.exe' (the post-installer would have produced broken
782 setups on systems with a differently named python binary).
810 setups on systems with a differently named python binary).
783
811
784 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
812 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
785 references to os.linesep, to make the code more
813 references to os.linesep, to make the code more
786 platform-independent. This is also part of the win32 coloring
814 platform-independent. This is also part of the win32 coloring
787 fixes.
815 fixes.
788
816
789 * IPython/genutils.py (page_dumb): Remove attempts to chop long
817 * IPython/genutils.py (page_dumb): Remove attempts to chop long
790 lines, which actually cause coloring bugs because the length of
818 lines, which actually cause coloring bugs because the length of
791 the line is very difficult to correctly compute with embedded
819 the line is very difficult to correctly compute with embedded
792 escapes. This was the source of all the coloring problems under
820 escapes. This was the source of all the coloring problems under
793 Win32. I think that _finally_, Win32 users have a properly
821 Win32. I think that _finally_, Win32 users have a properly
794 working ipython in all respects. This would never have happened
822 working ipython in all respects. This would never have happened
795 if not for Gary Bishop and Viktor Ransmayr's great help and work.
823 if not for Gary Bishop and Viktor Ransmayr's great help and work.
796
824
797 2005-01-26 *** Released version 0.6.9
825 2005-01-26 *** Released version 0.6.9
798
826
799 2005-01-25 Fernando Perez <fperez@colorado.edu>
827 2005-01-25 Fernando Perez <fperez@colorado.edu>
800
828
801 * setup.py: finally, we have a true Windows installer, thanks to
829 * setup.py: finally, we have a true Windows installer, thanks to
802 the excellent work of Viktor Ransmayr
830 the excellent work of Viktor Ransmayr
803 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
831 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
804 Windows users. The setup routine is quite a bit cleaner thanks to
832 Windows users. The setup routine is quite a bit cleaner thanks to
805 this, and the post-install script uses the proper functions to
833 this, and the post-install script uses the proper functions to
806 allow a clean de-installation using the standard Windows Control
834 allow a clean de-installation using the standard Windows Control
807 Panel.
835 Panel.
808
836
809 * IPython/genutils.py (get_home_dir): changed to use the $HOME
837 * IPython/genutils.py (get_home_dir): changed to use the $HOME
810 environment variable under all OSes (including win32) if
838 environment variable under all OSes (including win32) if
811 available. This will give consistency to win32 users who have set
839 available. This will give consistency to win32 users who have set
812 this variable for any reason. If os.environ['HOME'] fails, the
840 this variable for any reason. If os.environ['HOME'] fails, the
813 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
841 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
814
842
815 2005-01-24 Fernando Perez <fperez@colorado.edu>
843 2005-01-24 Fernando Perez <fperez@colorado.edu>
816
844
817 * IPython/numutils.py (empty_like): add empty_like(), similar to
845 * IPython/numutils.py (empty_like): add empty_like(), similar to
818 zeros_like() but taking advantage of the new empty() Numeric routine.
846 zeros_like() but taking advantage of the new empty() Numeric routine.
819
847
820 2005-01-23 *** Released version 0.6.8
848 2005-01-23 *** Released version 0.6.8
821
849
822 2005-01-22 Fernando Perez <fperez@colorado.edu>
850 2005-01-22 Fernando Perez <fperez@colorado.edu>
823
851
824 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
852 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
825 automatic show() calls. After discussing things with JDH, it
853 automatic show() calls. After discussing things with JDH, it
826 turns out there are too many corner cases where this can go wrong.
854 turns out there are too many corner cases where this can go wrong.
827 It's best not to try to be 'too smart', and simply have ipython
855 It's best not to try to be 'too smart', and simply have ipython
828 reproduce as much as possible the default behavior of a normal
856 reproduce as much as possible the default behavior of a normal
829 python shell.
857 python shell.
830
858
831 * IPython/iplib.py (InteractiveShell.__init__): Modified the
859 * IPython/iplib.py (InteractiveShell.__init__): Modified the
832 line-splitting regexp and _prefilter() to avoid calling getattr()
860 line-splitting regexp and _prefilter() to avoid calling getattr()
833 on assignments. This closes
861 on assignments. This closes
834 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
862 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
835 readline uses getattr(), so a simple <TAB> keypress is still
863 readline uses getattr(), so a simple <TAB> keypress is still
836 enough to trigger getattr() calls on an object.
864 enough to trigger getattr() calls on an object.
837
865
838 2005-01-21 Fernando Perez <fperez@colorado.edu>
866 2005-01-21 Fernando Perez <fperez@colorado.edu>
839
867
840 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
868 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
841 docstring under pylab so it doesn't mask the original.
869 docstring under pylab so it doesn't mask the original.
842
870
843 2005-01-21 *** Released version 0.6.7
871 2005-01-21 *** Released version 0.6.7
844
872
845 2005-01-21 Fernando Perez <fperez@colorado.edu>
873 2005-01-21 Fernando Perez <fperez@colorado.edu>
846
874
847 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
875 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
848 signal handling for win32 users in multithreaded mode.
876 signal handling for win32 users in multithreaded mode.
849
877
850 2005-01-17 Fernando Perez <fperez@colorado.edu>
878 2005-01-17 Fernando Perez <fperez@colorado.edu>
851
879
852 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
880 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
853 instances with no __init__. After a crash report by Norbert Nemec
881 instances with no __init__. After a crash report by Norbert Nemec
854 <Norbert-AT-nemec-online.de>.
882 <Norbert-AT-nemec-online.de>.
855
883
856 2005-01-14 Fernando Perez <fperez@colorado.edu>
884 2005-01-14 Fernando Perez <fperez@colorado.edu>
857
885
858 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
886 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
859 names for verbose exceptions, when multiple dotted names and the
887 names for verbose exceptions, when multiple dotted names and the
860 'parent' object were present on the same line.
888 'parent' object were present on the same line.
861
889
862 2005-01-11 Fernando Perez <fperez@colorado.edu>
890 2005-01-11 Fernando Perez <fperez@colorado.edu>
863
891
864 * IPython/genutils.py (flag_calls): new utility to trap and flag
892 * IPython/genutils.py (flag_calls): new utility to trap and flag
865 calls in functions. I need it to clean up matplotlib support.
893 calls in functions. I need it to clean up matplotlib support.
866 Also removed some deprecated code in genutils.
894 Also removed some deprecated code in genutils.
867
895
868 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
896 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
869 that matplotlib scripts called with %run, which don't call show()
897 that matplotlib scripts called with %run, which don't call show()
870 themselves, still have their plotting windows open.
898 themselves, still have their plotting windows open.
871
899
872 2005-01-05 Fernando Perez <fperez@colorado.edu>
900 2005-01-05 Fernando Perez <fperez@colorado.edu>
873
901
874 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
902 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
875 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
903 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
876
904
877 2004-12-19 Fernando Perez <fperez@colorado.edu>
905 2004-12-19 Fernando Perez <fperez@colorado.edu>
878
906
879 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
907 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
880 parent_runcode, which was an eyesore. The same result can be
908 parent_runcode, which was an eyesore. The same result can be
881 obtained with Python's regular superclass mechanisms.
909 obtained with Python's regular superclass mechanisms.
882
910
883 2004-12-17 Fernando Perez <fperez@colorado.edu>
911 2004-12-17 Fernando Perez <fperez@colorado.edu>
884
912
885 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
913 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
886 reported by Prabhu.
914 reported by Prabhu.
887 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
915 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
888 sys.stderr) instead of explicitly calling sys.stderr. This helps
916 sys.stderr) instead of explicitly calling sys.stderr. This helps
889 maintain our I/O abstractions clean, for future GUI embeddings.
917 maintain our I/O abstractions clean, for future GUI embeddings.
890
918
891 * IPython/genutils.py (info): added new utility for sys.stderr
919 * IPython/genutils.py (info): added new utility for sys.stderr
892 unified info message handling (thin wrapper around warn()).
920 unified info message handling (thin wrapper around warn()).
893
921
894 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
922 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
895 composite (dotted) names on verbose exceptions.
923 composite (dotted) names on verbose exceptions.
896 (VerboseTB.nullrepr): harden against another kind of errors which
924 (VerboseTB.nullrepr): harden against another kind of errors which
897 Python's inspect module can trigger, and which were crashing
925 Python's inspect module can trigger, and which were crashing
898 IPython. Thanks to a report by Marco Lombardi
926 IPython. Thanks to a report by Marco Lombardi
899 <mlombard-AT-ma010192.hq.eso.org>.
927 <mlombard-AT-ma010192.hq.eso.org>.
900
928
901 2004-12-13 *** Released version 0.6.6
929 2004-12-13 *** Released version 0.6.6
902
930
903 2004-12-12 Fernando Perez <fperez@colorado.edu>
931 2004-12-12 Fernando Perez <fperez@colorado.edu>
904
932
905 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
933 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
906 generated by pygtk upon initialization if it was built without
934 generated by pygtk upon initialization if it was built without
907 threads (for matplotlib users). After a crash reported by
935 threads (for matplotlib users). After a crash reported by
908 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
936 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
909
937
910 * IPython/ipmaker.py (make_IPython): fix small bug in the
938 * IPython/ipmaker.py (make_IPython): fix small bug in the
911 import_some parameter for multiple imports.
939 import_some parameter for multiple imports.
912
940
913 * IPython/iplib.py (ipmagic): simplified the interface of
941 * IPython/iplib.py (ipmagic): simplified the interface of
914 ipmagic() to take a single string argument, just as it would be
942 ipmagic() to take a single string argument, just as it would be
915 typed at the IPython cmd line.
943 typed at the IPython cmd line.
916 (ipalias): Added new ipalias() with an interface identical to
944 (ipalias): Added new ipalias() with an interface identical to
917 ipmagic(). This completes exposing a pure python interface to the
945 ipmagic(). This completes exposing a pure python interface to the
918 alias and magic system, which can be used in loops or more complex
946 alias and magic system, which can be used in loops or more complex
919 code where IPython's automatic line mangling is not active.
947 code where IPython's automatic line mangling is not active.
920
948
921 * IPython/genutils.py (timing): changed interface of timing to
949 * IPython/genutils.py (timing): changed interface of timing to
922 simply run code once, which is the most common case. timings()
950 simply run code once, which is the most common case. timings()
923 remains unchanged, for the cases where you want multiple runs.
951 remains unchanged, for the cases where you want multiple runs.
924
952
925 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
953 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
926 bug where Python2.2 crashes with exec'ing code which does not end
954 bug where Python2.2 crashes with exec'ing code which does not end
927 in a single newline. Python 2.3 is OK, so I hadn't noticed this
955 in a single newline. Python 2.3 is OK, so I hadn't noticed this
928 before.
956 before.
929
957
930 2004-12-10 Fernando Perez <fperez@colorado.edu>
958 2004-12-10 Fernando Perez <fperez@colorado.edu>
931
959
932 * IPython/Magic.py (Magic.magic_prun): changed name of option from
960 * IPython/Magic.py (Magic.magic_prun): changed name of option from
933 -t to -T, to accomodate the new -t flag in %run (the %run and
961 -t to -T, to accomodate the new -t flag in %run (the %run and
934 %prun options are kind of intermixed, and it's not easy to change
962 %prun options are kind of intermixed, and it's not easy to change
935 this with the limitations of python's getopt).
963 this with the limitations of python's getopt).
936
964
937 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
965 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
938 the execution of scripts. It's not as fine-tuned as timeit.py,
966 the execution of scripts. It's not as fine-tuned as timeit.py,
939 but it works from inside ipython (and under 2.2, which lacks
967 but it works from inside ipython (and under 2.2, which lacks
940 timeit.py). Optionally a number of runs > 1 can be given for
968 timeit.py). Optionally a number of runs > 1 can be given for
941 timing very short-running code.
969 timing very short-running code.
942
970
943 * IPython/genutils.py (uniq_stable): new routine which returns a
971 * IPython/genutils.py (uniq_stable): new routine which returns a
944 list of unique elements in any iterable, but in stable order of
972 list of unique elements in any iterable, but in stable order of
945 appearance. I needed this for the ultraTB fixes, and it's a handy
973 appearance. I needed this for the ultraTB fixes, and it's a handy
946 utility.
974 utility.
947
975
948 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
976 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
949 dotted names in Verbose exceptions. This had been broken since
977 dotted names in Verbose exceptions. This had been broken since
950 the very start, now x.y will properly be printed in a Verbose
978 the very start, now x.y will properly be printed in a Verbose
951 traceback, instead of x being shown and y appearing always as an
979 traceback, instead of x being shown and y appearing always as an
952 'undefined global'. Getting this to work was a bit tricky,
980 'undefined global'. Getting this to work was a bit tricky,
953 because by default python tokenizers are stateless. Saved by
981 because by default python tokenizers are stateless. Saved by
954 python's ability to easily add a bit of state to an arbitrary
982 python's ability to easily add a bit of state to an arbitrary
955 function (without needing to build a full-blown callable object).
983 function (without needing to build a full-blown callable object).
956
984
957 Also big cleanup of this code, which had horrendous runtime
985 Also big cleanup of this code, which had horrendous runtime
958 lookups of zillions of attributes for colorization. Moved all
986 lookups of zillions of attributes for colorization. Moved all
959 this code into a few templates, which make it cleaner and quicker.
987 this code into a few templates, which make it cleaner and quicker.
960
988
961 Printout quality was also improved for Verbose exceptions: one
989 Printout quality was also improved for Verbose exceptions: one
962 variable per line, and memory addresses are printed (this can be
990 variable per line, and memory addresses are printed (this can be
963 quite handy in nasty debugging situations, which is what Verbose
991 quite handy in nasty debugging situations, which is what Verbose
964 is for).
992 is for).
965
993
966 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
994 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
967 the command line as scripts to be loaded by embedded instances.
995 the command line as scripts to be loaded by embedded instances.
968 Doing so has the potential for an infinite recursion if there are
996 Doing so has the potential for an infinite recursion if there are
969 exceptions thrown in the process. This fixes a strange crash
997 exceptions thrown in the process. This fixes a strange crash
970 reported by Philippe MULLER <muller-AT-irit.fr>.
998 reported by Philippe MULLER <muller-AT-irit.fr>.
971
999
972 2004-12-09 Fernando Perez <fperez@colorado.edu>
1000 2004-12-09 Fernando Perez <fperez@colorado.edu>
973
1001
974 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1002 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
975 to reflect new names in matplotlib, which now expose the
1003 to reflect new names in matplotlib, which now expose the
976 matlab-compatible interface via a pylab module instead of the
1004 matlab-compatible interface via a pylab module instead of the
977 'matlab' name. The new code is backwards compatible, so users of
1005 'matlab' name. The new code is backwards compatible, so users of
978 all matplotlib versions are OK. Patch by J. Hunter.
1006 all matplotlib versions are OK. Patch by J. Hunter.
979
1007
980 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1008 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
981 of __init__ docstrings for instances (class docstrings are already
1009 of __init__ docstrings for instances (class docstrings are already
982 automatically printed). Instances with customized docstrings
1010 automatically printed). Instances with customized docstrings
983 (indep. of the class) are also recognized and all 3 separate
1011 (indep. of the class) are also recognized and all 3 separate
984 docstrings are printed (instance, class, constructor). After some
1012 docstrings are printed (instance, class, constructor). After some
985 comments/suggestions by J. Hunter.
1013 comments/suggestions by J. Hunter.
986
1014
987 2004-12-05 Fernando Perez <fperez@colorado.edu>
1015 2004-12-05 Fernando Perez <fperez@colorado.edu>
988
1016
989 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1017 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
990 warnings when tab-completion fails and triggers an exception.
1018 warnings when tab-completion fails and triggers an exception.
991
1019
992 2004-12-03 Fernando Perez <fperez@colorado.edu>
1020 2004-12-03 Fernando Perez <fperez@colorado.edu>
993
1021
994 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1022 * IPython/Magic.py (magic_prun): Fix bug where an exception would
995 be triggered when using 'run -p'. An incorrect option flag was
1023 be triggered when using 'run -p'. An incorrect option flag was
996 being set ('d' instead of 'D').
1024 being set ('d' instead of 'D').
997 (manpage): fix missing escaped \- sign.
1025 (manpage): fix missing escaped \- sign.
998
1026
999 2004-11-30 *** Released version 0.6.5
1027 2004-11-30 *** Released version 0.6.5
1000
1028
1001 2004-11-30 Fernando Perez <fperez@colorado.edu>
1029 2004-11-30 Fernando Perez <fperez@colorado.edu>
1002
1030
1003 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1031 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1004 setting with -d option.
1032 setting with -d option.
1005
1033
1006 * setup.py (docfiles): Fix problem where the doc glob I was using
1034 * setup.py (docfiles): Fix problem where the doc glob I was using
1007 was COMPLETELY BROKEN. It was giving the right files by pure
1035 was COMPLETELY BROKEN. It was giving the right files by pure
1008 accident, but failed once I tried to include ipython.el. Note:
1036 accident, but failed once I tried to include ipython.el. Note:
1009 glob() does NOT allow you to do exclusion on multiple endings!
1037 glob() does NOT allow you to do exclusion on multiple endings!
1010
1038
1011 2004-11-29 Fernando Perez <fperez@colorado.edu>
1039 2004-11-29 Fernando Perez <fperez@colorado.edu>
1012
1040
1013 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1041 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1014 the manpage as the source. Better formatting & consistency.
1042 the manpage as the source. Better formatting & consistency.
1015
1043
1016 * IPython/Magic.py (magic_run): Added new -d option, to run
1044 * IPython/Magic.py (magic_run): Added new -d option, to run
1017 scripts under the control of the python pdb debugger. Note that
1045 scripts under the control of the python pdb debugger. Note that
1018 this required changing the %prun option -d to -D, to avoid a clash
1046 this required changing the %prun option -d to -D, to avoid a clash
1019 (since %run must pass options to %prun, and getopt is too dumb to
1047 (since %run must pass options to %prun, and getopt is too dumb to
1020 handle options with string values with embedded spaces). Thanks
1048 handle options with string values with embedded spaces). Thanks
1021 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1049 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1022 (magic_who_ls): added type matching to %who and %whos, so that one
1050 (magic_who_ls): added type matching to %who and %whos, so that one
1023 can filter their output to only include variables of certain
1051 can filter their output to only include variables of certain
1024 types. Another suggestion by Matthew.
1052 types. Another suggestion by Matthew.
1025 (magic_whos): Added memory summaries in kb and Mb for arrays.
1053 (magic_whos): Added memory summaries in kb and Mb for arrays.
1026 (magic_who): Improve formatting (break lines every 9 vars).
1054 (magic_who): Improve formatting (break lines every 9 vars).
1027
1055
1028 2004-11-28 Fernando Perez <fperez@colorado.edu>
1056 2004-11-28 Fernando Perez <fperez@colorado.edu>
1029
1057
1030 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1058 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1031 cache when empty lines were present.
1059 cache when empty lines were present.
1032
1060
1033 2004-11-24 Fernando Perez <fperez@colorado.edu>
1061 2004-11-24 Fernando Perez <fperez@colorado.edu>
1034
1062
1035 * IPython/usage.py (__doc__): document the re-activated threading
1063 * IPython/usage.py (__doc__): document the re-activated threading
1036 options for WX and GTK.
1064 options for WX and GTK.
1037
1065
1038 2004-11-23 Fernando Perez <fperez@colorado.edu>
1066 2004-11-23 Fernando Perez <fperez@colorado.edu>
1039
1067
1040 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1068 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1041 the -wthread and -gthread options, along with a new -tk one to try
1069 the -wthread and -gthread options, along with a new -tk one to try
1042 and coordinate Tk threading with wx/gtk. The tk support is very
1070 and coordinate Tk threading with wx/gtk. The tk support is very
1043 platform dependent, since it seems to require Tcl and Tk to be
1071 platform dependent, since it seems to require Tcl and Tk to be
1044 built with threads (Fedora1/2 appears NOT to have it, but in
1072 built with threads (Fedora1/2 appears NOT to have it, but in
1045 Prabhu's Debian boxes it works OK). But even with some Tk
1073 Prabhu's Debian boxes it works OK). But even with some Tk
1046 limitations, this is a great improvement.
1074 limitations, this is a great improvement.
1047
1075
1048 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1076 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1049 info in user prompts. Patch by Prabhu.
1077 info in user prompts. Patch by Prabhu.
1050
1078
1051 2004-11-18 Fernando Perez <fperez@colorado.edu>
1079 2004-11-18 Fernando Perez <fperez@colorado.edu>
1052
1080
1053 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1081 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1054 EOFErrors and bail, to avoid infinite loops if a non-terminating
1082 EOFErrors and bail, to avoid infinite loops if a non-terminating
1055 file is fed into ipython. Patch submitted in issue 19 by user,
1083 file is fed into ipython. Patch submitted in issue 19 by user,
1056 many thanks.
1084 many thanks.
1057
1085
1058 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1086 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1059 autoquote/parens in continuation prompts, which can cause lots of
1087 autoquote/parens in continuation prompts, which can cause lots of
1060 problems. Closes roundup issue 20.
1088 problems. Closes roundup issue 20.
1061
1089
1062 2004-11-17 Fernando Perez <fperez@colorado.edu>
1090 2004-11-17 Fernando Perez <fperez@colorado.edu>
1063
1091
1064 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1092 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1065 reported as debian bug #280505. I'm not sure my local changelog
1093 reported as debian bug #280505. I'm not sure my local changelog
1066 entry has the proper debian format (Jack?).
1094 entry has the proper debian format (Jack?).
1067
1095
1068 2004-11-08 *** Released version 0.6.4
1096 2004-11-08 *** Released version 0.6.4
1069
1097
1070 2004-11-08 Fernando Perez <fperez@colorado.edu>
1098 2004-11-08 Fernando Perez <fperez@colorado.edu>
1071
1099
1072 * IPython/iplib.py (init_readline): Fix exit message for Windows
1100 * IPython/iplib.py (init_readline): Fix exit message for Windows
1073 when readline is active. Thanks to a report by Eric Jones
1101 when readline is active. Thanks to a report by Eric Jones
1074 <eric-AT-enthought.com>.
1102 <eric-AT-enthought.com>.
1075
1103
1076 2004-11-07 Fernando Perez <fperez@colorado.edu>
1104 2004-11-07 Fernando Perez <fperez@colorado.edu>
1077
1105
1078 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1106 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1079 sometimes seen by win2k/cygwin users.
1107 sometimes seen by win2k/cygwin users.
1080
1108
1081 2004-11-06 Fernando Perez <fperez@colorado.edu>
1109 2004-11-06 Fernando Perez <fperez@colorado.edu>
1082
1110
1083 * IPython/iplib.py (interact): Change the handling of %Exit from
1111 * IPython/iplib.py (interact): Change the handling of %Exit from
1084 trying to propagate a SystemExit to an internal ipython flag.
1112 trying to propagate a SystemExit to an internal ipython flag.
1085 This is less elegant than using Python's exception mechanism, but
1113 This is less elegant than using Python's exception mechanism, but
1086 I can't get that to work reliably with threads, so under -pylab
1114 I can't get that to work reliably with threads, so under -pylab
1087 %Exit was hanging IPython. Cross-thread exception handling is
1115 %Exit was hanging IPython. Cross-thread exception handling is
1088 really a bitch. Thaks to a bug report by Stephen Walton
1116 really a bitch. Thaks to a bug report by Stephen Walton
1089 <stephen.walton-AT-csun.edu>.
1117 <stephen.walton-AT-csun.edu>.
1090
1118
1091 2004-11-04 Fernando Perez <fperez@colorado.edu>
1119 2004-11-04 Fernando Perez <fperez@colorado.edu>
1092
1120
1093 * IPython/iplib.py (raw_input_original): store a pointer to the
1121 * IPython/iplib.py (raw_input_original): store a pointer to the
1094 true raw_input to harden against code which can modify it
1122 true raw_input to harden against code which can modify it
1095 (wx.py.PyShell does this and would otherwise crash ipython).
1123 (wx.py.PyShell does this and would otherwise crash ipython).
1096 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1124 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1097
1125
1098 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1126 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1099 Ctrl-C problem, which does not mess up the input line.
1127 Ctrl-C problem, which does not mess up the input line.
1100
1128
1101 2004-11-03 Fernando Perez <fperez@colorado.edu>
1129 2004-11-03 Fernando Perez <fperez@colorado.edu>
1102
1130
1103 * IPython/Release.py: Changed licensing to BSD, in all files.
1131 * IPython/Release.py: Changed licensing to BSD, in all files.
1104 (name): lowercase name for tarball/RPM release.
1132 (name): lowercase name for tarball/RPM release.
1105
1133
1106 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1134 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1107 use throughout ipython.
1135 use throughout ipython.
1108
1136
1109 * IPython/Magic.py (Magic._ofind): Switch to using the new
1137 * IPython/Magic.py (Magic._ofind): Switch to using the new
1110 OInspect.getdoc() function.
1138 OInspect.getdoc() function.
1111
1139
1112 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1140 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1113 of the line currently being canceled via Ctrl-C. It's extremely
1141 of the line currently being canceled via Ctrl-C. It's extremely
1114 ugly, but I don't know how to do it better (the problem is one of
1142 ugly, but I don't know how to do it better (the problem is one of
1115 handling cross-thread exceptions).
1143 handling cross-thread exceptions).
1116
1144
1117 2004-10-28 Fernando Perez <fperez@colorado.edu>
1145 2004-10-28 Fernando Perez <fperez@colorado.edu>
1118
1146
1119 * IPython/Shell.py (signal_handler): add signal handlers to trap
1147 * IPython/Shell.py (signal_handler): add signal handlers to trap
1120 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1148 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1121 report by Francesc Alted.
1149 report by Francesc Alted.
1122
1150
1123 2004-10-21 Fernando Perez <fperez@colorado.edu>
1151 2004-10-21 Fernando Perez <fperez@colorado.edu>
1124
1152
1125 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1153 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1126 to % for pysh syntax extensions.
1154 to % for pysh syntax extensions.
1127
1155
1128 2004-10-09 Fernando Perez <fperez@colorado.edu>
1156 2004-10-09 Fernando Perez <fperez@colorado.edu>
1129
1157
1130 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1158 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1131 arrays to print a more useful summary, without calling str(arr).
1159 arrays to print a more useful summary, without calling str(arr).
1132 This avoids the problem of extremely lengthy computations which
1160 This avoids the problem of extremely lengthy computations which
1133 occur if arr is large, and appear to the user as a system lockup
1161 occur if arr is large, and appear to the user as a system lockup
1134 with 100% cpu activity. After a suggestion by Kristian Sandberg
1162 with 100% cpu activity. After a suggestion by Kristian Sandberg
1135 <Kristian.Sandberg@colorado.edu>.
1163 <Kristian.Sandberg@colorado.edu>.
1136 (Magic.__init__): fix bug in global magic escapes not being
1164 (Magic.__init__): fix bug in global magic escapes not being
1137 correctly set.
1165 correctly set.
1138
1166
1139 2004-10-08 Fernando Perez <fperez@colorado.edu>
1167 2004-10-08 Fernando Perez <fperez@colorado.edu>
1140
1168
1141 * IPython/Magic.py (__license__): change to absolute imports of
1169 * IPython/Magic.py (__license__): change to absolute imports of
1142 ipython's own internal packages, to start adapting to the absolute
1170 ipython's own internal packages, to start adapting to the absolute
1143 import requirement of PEP-328.
1171 import requirement of PEP-328.
1144
1172
1145 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1173 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1146 files, and standardize author/license marks through the Release
1174 files, and standardize author/license marks through the Release
1147 module instead of having per/file stuff (except for files with
1175 module instead of having per/file stuff (except for files with
1148 particular licenses, like the MIT/PSF-licensed codes).
1176 particular licenses, like the MIT/PSF-licensed codes).
1149
1177
1150 * IPython/Debugger.py: remove dead code for python 2.1
1178 * IPython/Debugger.py: remove dead code for python 2.1
1151
1179
1152 2004-10-04 Fernando Perez <fperez@colorado.edu>
1180 2004-10-04 Fernando Perez <fperez@colorado.edu>
1153
1181
1154 * IPython/iplib.py (ipmagic): New function for accessing magics
1182 * IPython/iplib.py (ipmagic): New function for accessing magics
1155 via a normal python function call.
1183 via a normal python function call.
1156
1184
1157 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1185 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1158 from '@' to '%', to accomodate the new @decorator syntax of python
1186 from '@' to '%', to accomodate the new @decorator syntax of python
1159 2.4.
1187 2.4.
1160
1188
1161 2004-09-29 Fernando Perez <fperez@colorado.edu>
1189 2004-09-29 Fernando Perez <fperez@colorado.edu>
1162
1190
1163 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1191 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1164 matplotlib.use to prevent running scripts which try to switch
1192 matplotlib.use to prevent running scripts which try to switch
1165 interactive backends from within ipython. This will just crash
1193 interactive backends from within ipython. This will just crash
1166 the python interpreter, so we can't allow it (but a detailed error
1194 the python interpreter, so we can't allow it (but a detailed error
1167 is given to the user).
1195 is given to the user).
1168
1196
1169 2004-09-28 Fernando Perez <fperez@colorado.edu>
1197 2004-09-28 Fernando Perez <fperez@colorado.edu>
1170
1198
1171 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1199 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1172 matplotlib-related fixes so that using @run with non-matplotlib
1200 matplotlib-related fixes so that using @run with non-matplotlib
1173 scripts doesn't pop up spurious plot windows. This requires
1201 scripts doesn't pop up spurious plot windows. This requires
1174 matplotlib >= 0.63, where I had to make some changes as well.
1202 matplotlib >= 0.63, where I had to make some changes as well.
1175
1203
1176 * IPython/ipmaker.py (make_IPython): update version requirement to
1204 * IPython/ipmaker.py (make_IPython): update version requirement to
1177 python 2.2.
1205 python 2.2.
1178
1206
1179 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1207 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1180 banner arg for embedded customization.
1208 banner arg for embedded customization.
1181
1209
1182 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1210 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1183 explicit uses of __IP as the IPython's instance name. Now things
1211 explicit uses of __IP as the IPython's instance name. Now things
1184 are properly handled via the shell.name value. The actual code
1212 are properly handled via the shell.name value. The actual code
1185 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1213 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1186 is much better than before. I'll clean things completely when the
1214 is much better than before. I'll clean things completely when the
1187 magic stuff gets a real overhaul.
1215 magic stuff gets a real overhaul.
1188
1216
1189 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1217 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1190 minor changes to debian dir.
1218 minor changes to debian dir.
1191
1219
1192 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1220 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1193 pointer to the shell itself in the interactive namespace even when
1221 pointer to the shell itself in the interactive namespace even when
1194 a user-supplied dict is provided. This is needed for embedding
1222 a user-supplied dict is provided. This is needed for embedding
1195 purposes (found by tests with Michel Sanner).
1223 purposes (found by tests with Michel Sanner).
1196
1224
1197 2004-09-27 Fernando Perez <fperez@colorado.edu>
1225 2004-09-27 Fernando Perez <fperez@colorado.edu>
1198
1226
1199 * IPython/UserConfig/ipythonrc: remove []{} from
1227 * IPython/UserConfig/ipythonrc: remove []{} from
1200 readline_remove_delims, so that things like [modname.<TAB> do
1228 readline_remove_delims, so that things like [modname.<TAB> do
1201 proper completion. This disables [].TAB, but that's a less common
1229 proper completion. This disables [].TAB, but that's a less common
1202 case than module names in list comprehensions, for example.
1230 case than module names in list comprehensions, for example.
1203 Thanks to a report by Andrea Riciputi.
1231 Thanks to a report by Andrea Riciputi.
1204
1232
1205 2004-09-09 Fernando Perez <fperez@colorado.edu>
1233 2004-09-09 Fernando Perez <fperez@colorado.edu>
1206
1234
1207 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1235 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1208 blocking problems in win32 and osx. Fix by John.
1236 blocking problems in win32 and osx. Fix by John.
1209
1237
1210 2004-09-08 Fernando Perez <fperez@colorado.edu>
1238 2004-09-08 Fernando Perez <fperez@colorado.edu>
1211
1239
1212 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1240 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1213 for Win32 and OSX. Fix by John Hunter.
1241 for Win32 and OSX. Fix by John Hunter.
1214
1242
1215 2004-08-30 *** Released version 0.6.3
1243 2004-08-30 *** Released version 0.6.3
1216
1244
1217 2004-08-30 Fernando Perez <fperez@colorado.edu>
1245 2004-08-30 Fernando Perez <fperez@colorado.edu>
1218
1246
1219 * setup.py (isfile): Add manpages to list of dependent files to be
1247 * setup.py (isfile): Add manpages to list of dependent files to be
1220 updated.
1248 updated.
1221
1249
1222 2004-08-27 Fernando Perez <fperez@colorado.edu>
1250 2004-08-27 Fernando Perez <fperez@colorado.edu>
1223
1251
1224 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1252 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1225 for now. They don't really work with standalone WX/GTK code
1253 for now. They don't really work with standalone WX/GTK code
1226 (though matplotlib IS working fine with both of those backends).
1254 (though matplotlib IS working fine with both of those backends).
1227 This will neeed much more testing. I disabled most things with
1255 This will neeed much more testing. I disabled most things with
1228 comments, so turning it back on later should be pretty easy.
1256 comments, so turning it back on later should be pretty easy.
1229
1257
1230 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1258 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1231 autocalling of expressions like r'foo', by modifying the line
1259 autocalling of expressions like r'foo', by modifying the line
1232 split regexp. Closes
1260 split regexp. Closes
1233 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1261 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1234 Riley <ipythonbugs-AT-sabi.net>.
1262 Riley <ipythonbugs-AT-sabi.net>.
1235 (InteractiveShell.mainloop): honor --nobanner with banner
1263 (InteractiveShell.mainloop): honor --nobanner with banner
1236 extensions.
1264 extensions.
1237
1265
1238 * IPython/Shell.py: Significant refactoring of all classes, so
1266 * IPython/Shell.py: Significant refactoring of all classes, so
1239 that we can really support ALL matplotlib backends and threading
1267 that we can really support ALL matplotlib backends and threading
1240 models (John spotted a bug with Tk which required this). Now we
1268 models (John spotted a bug with Tk which required this). Now we
1241 should support single-threaded, WX-threads and GTK-threads, both
1269 should support single-threaded, WX-threads and GTK-threads, both
1242 for generic code and for matplotlib.
1270 for generic code and for matplotlib.
1243
1271
1244 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1272 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1245 -pylab, to simplify things for users. Will also remove the pylab
1273 -pylab, to simplify things for users. Will also remove the pylab
1246 profile, since now all of matplotlib configuration is directly
1274 profile, since now all of matplotlib configuration is directly
1247 handled here. This also reduces startup time.
1275 handled here. This also reduces startup time.
1248
1276
1249 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1277 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1250 shell wasn't being correctly called. Also in IPShellWX.
1278 shell wasn't being correctly called. Also in IPShellWX.
1251
1279
1252 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1280 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1253 fine-tune banner.
1281 fine-tune banner.
1254
1282
1255 * IPython/numutils.py (spike): Deprecate these spike functions,
1283 * IPython/numutils.py (spike): Deprecate these spike functions,
1256 delete (long deprecated) gnuplot_exec handler.
1284 delete (long deprecated) gnuplot_exec handler.
1257
1285
1258 2004-08-26 Fernando Perez <fperez@colorado.edu>
1286 2004-08-26 Fernando Perez <fperez@colorado.edu>
1259
1287
1260 * ipython.1: Update for threading options, plus some others which
1288 * ipython.1: Update for threading options, plus some others which
1261 were missing.
1289 were missing.
1262
1290
1263 * IPython/ipmaker.py (__call__): Added -wthread option for
1291 * IPython/ipmaker.py (__call__): Added -wthread option for
1264 wxpython thread handling. Make sure threading options are only
1292 wxpython thread handling. Make sure threading options are only
1265 valid at the command line.
1293 valid at the command line.
1266
1294
1267 * scripts/ipython: moved shell selection into a factory function
1295 * scripts/ipython: moved shell selection into a factory function
1268 in Shell.py, to keep the starter script to a minimum.
1296 in Shell.py, to keep the starter script to a minimum.
1269
1297
1270 2004-08-25 Fernando Perez <fperez@colorado.edu>
1298 2004-08-25 Fernando Perez <fperez@colorado.edu>
1271
1299
1272 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1300 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1273 John. Along with some recent changes he made to matplotlib, the
1301 John. Along with some recent changes he made to matplotlib, the
1274 next versions of both systems should work very well together.
1302 next versions of both systems should work very well together.
1275
1303
1276 2004-08-24 Fernando Perez <fperez@colorado.edu>
1304 2004-08-24 Fernando Perez <fperez@colorado.edu>
1277
1305
1278 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1306 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1279 tried to switch the profiling to using hotshot, but I'm getting
1307 tried to switch the profiling to using hotshot, but I'm getting
1280 strange errors from prof.runctx() there. I may be misreading the
1308 strange errors from prof.runctx() there. I may be misreading the
1281 docs, but it looks weird. For now the profiling code will
1309 docs, but it looks weird. For now the profiling code will
1282 continue to use the standard profiler.
1310 continue to use the standard profiler.
1283
1311
1284 2004-08-23 Fernando Perez <fperez@colorado.edu>
1312 2004-08-23 Fernando Perez <fperez@colorado.edu>
1285
1313
1286 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1314 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1287 threaded shell, by John Hunter. It's not quite ready yet, but
1315 threaded shell, by John Hunter. It's not quite ready yet, but
1288 close.
1316 close.
1289
1317
1290 2004-08-22 Fernando Perez <fperez@colorado.edu>
1318 2004-08-22 Fernando Perez <fperez@colorado.edu>
1291
1319
1292 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1320 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1293 in Magic and ultraTB.
1321 in Magic and ultraTB.
1294
1322
1295 * ipython.1: document threading options in manpage.
1323 * ipython.1: document threading options in manpage.
1296
1324
1297 * scripts/ipython: Changed name of -thread option to -gthread,
1325 * scripts/ipython: Changed name of -thread option to -gthread,
1298 since this is GTK specific. I want to leave the door open for a
1326 since this is GTK specific. I want to leave the door open for a
1299 -wthread option for WX, which will most likely be necessary. This
1327 -wthread option for WX, which will most likely be necessary. This
1300 change affects usage and ipmaker as well.
1328 change affects usage and ipmaker as well.
1301
1329
1302 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1330 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1303 handle the matplotlib shell issues. Code by John Hunter
1331 handle the matplotlib shell issues. Code by John Hunter
1304 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1332 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1305 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1333 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1306 broken (and disabled for end users) for now, but it puts the
1334 broken (and disabled for end users) for now, but it puts the
1307 infrastructure in place.
1335 infrastructure in place.
1308
1336
1309 2004-08-21 Fernando Perez <fperez@colorado.edu>
1337 2004-08-21 Fernando Perez <fperez@colorado.edu>
1310
1338
1311 * ipythonrc-pylab: Add matplotlib support.
1339 * ipythonrc-pylab: Add matplotlib support.
1312
1340
1313 * matplotlib_config.py: new files for matplotlib support, part of
1341 * matplotlib_config.py: new files for matplotlib support, part of
1314 the pylab profile.
1342 the pylab profile.
1315
1343
1316 * IPython/usage.py (__doc__): documented the threading options.
1344 * IPython/usage.py (__doc__): documented the threading options.
1317
1345
1318 2004-08-20 Fernando Perez <fperez@colorado.edu>
1346 2004-08-20 Fernando Perez <fperez@colorado.edu>
1319
1347
1320 * ipython: Modified the main calling routine to handle the -thread
1348 * ipython: Modified the main calling routine to handle the -thread
1321 and -mpthread options. This needs to be done as a top-level hack,
1349 and -mpthread options. This needs to be done as a top-level hack,
1322 because it determines which class to instantiate for IPython
1350 because it determines which class to instantiate for IPython
1323 itself.
1351 itself.
1324
1352
1325 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1353 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1326 classes to support multithreaded GTK operation without blocking,
1354 classes to support multithreaded GTK operation without blocking,
1327 and matplotlib with all backends. This is a lot of still very
1355 and matplotlib with all backends. This is a lot of still very
1328 experimental code, and threads are tricky. So it may still have a
1356 experimental code, and threads are tricky. So it may still have a
1329 few rough edges... This code owes a lot to
1357 few rough edges... This code owes a lot to
1330 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1358 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1331 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1359 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1332 to John Hunter for all the matplotlib work.
1360 to John Hunter for all the matplotlib work.
1333
1361
1334 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1362 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1335 options for gtk thread and matplotlib support.
1363 options for gtk thread and matplotlib support.
1336
1364
1337 2004-08-16 Fernando Perez <fperez@colorado.edu>
1365 2004-08-16 Fernando Perez <fperez@colorado.edu>
1338
1366
1339 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1367 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1340 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1368 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1341 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1369 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1342
1370
1343 2004-08-11 Fernando Perez <fperez@colorado.edu>
1371 2004-08-11 Fernando Perez <fperez@colorado.edu>
1344
1372
1345 * setup.py (isfile): Fix build so documentation gets updated for
1373 * setup.py (isfile): Fix build so documentation gets updated for
1346 rpms (it was only done for .tgz builds).
1374 rpms (it was only done for .tgz builds).
1347
1375
1348 2004-08-10 Fernando Perez <fperez@colorado.edu>
1376 2004-08-10 Fernando Perez <fperez@colorado.edu>
1349
1377
1350 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1378 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1351
1379
1352 * iplib.py : Silence syntax error exceptions in tab-completion.
1380 * iplib.py : Silence syntax error exceptions in tab-completion.
1353
1381
1354 2004-08-05 Fernando Perez <fperez@colorado.edu>
1382 2004-08-05 Fernando Perez <fperez@colorado.edu>
1355
1383
1356 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1384 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1357 'color off' mark for continuation prompts. This was causing long
1385 'color off' mark for continuation prompts. This was causing long
1358 continuation lines to mis-wrap.
1386 continuation lines to mis-wrap.
1359
1387
1360 2004-08-01 Fernando Perez <fperez@colorado.edu>
1388 2004-08-01 Fernando Perez <fperez@colorado.edu>
1361
1389
1362 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1390 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1363 for building ipython to be a parameter. All this is necessary
1391 for building ipython to be a parameter. All this is necessary
1364 right now to have a multithreaded version, but this insane
1392 right now to have a multithreaded version, but this insane
1365 non-design will be cleaned up soon. For now, it's a hack that
1393 non-design will be cleaned up soon. For now, it's a hack that
1366 works.
1394 works.
1367
1395
1368 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1396 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1369 args in various places. No bugs so far, but it's a dangerous
1397 args in various places. No bugs so far, but it's a dangerous
1370 practice.
1398 practice.
1371
1399
1372 2004-07-31 Fernando Perez <fperez@colorado.edu>
1400 2004-07-31 Fernando Perez <fperez@colorado.edu>
1373
1401
1374 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1402 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1375 fix completion of files with dots in their names under most
1403 fix completion of files with dots in their names under most
1376 profiles (pysh was OK because the completion order is different).
1404 profiles (pysh was OK because the completion order is different).
1377
1405
1378 2004-07-27 Fernando Perez <fperez@colorado.edu>
1406 2004-07-27 Fernando Perez <fperez@colorado.edu>
1379
1407
1380 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1408 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1381 keywords manually, b/c the one in keyword.py was removed in python
1409 keywords manually, b/c the one in keyword.py was removed in python
1382 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1410 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1383 This is NOT a bug under python 2.3 and earlier.
1411 This is NOT a bug under python 2.3 and earlier.
1384
1412
1385 2004-07-26 Fernando Perez <fperez@colorado.edu>
1413 2004-07-26 Fernando Perez <fperez@colorado.edu>
1386
1414
1387 * IPython/ultraTB.py (VerboseTB.text): Add another
1415 * IPython/ultraTB.py (VerboseTB.text): Add another
1388 linecache.checkcache() call to try to prevent inspect.py from
1416 linecache.checkcache() call to try to prevent inspect.py from
1389 crashing under python 2.3. I think this fixes
1417 crashing under python 2.3. I think this fixes
1390 http://www.scipy.net/roundup/ipython/issue17.
1418 http://www.scipy.net/roundup/ipython/issue17.
1391
1419
1392 2004-07-26 *** Released version 0.6.2
1420 2004-07-26 *** Released version 0.6.2
1393
1421
1394 2004-07-26 Fernando Perez <fperez@colorado.edu>
1422 2004-07-26 Fernando Perez <fperez@colorado.edu>
1395
1423
1396 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1424 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1397 fail for any number.
1425 fail for any number.
1398 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1426 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1399 empty bookmarks.
1427 empty bookmarks.
1400
1428
1401 2004-07-26 *** Released version 0.6.1
1429 2004-07-26 *** Released version 0.6.1
1402
1430
1403 2004-07-26 Fernando Perez <fperez@colorado.edu>
1431 2004-07-26 Fernando Perez <fperez@colorado.edu>
1404
1432
1405 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1433 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1406
1434
1407 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1435 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1408 escaping '()[]{}' in filenames.
1436 escaping '()[]{}' in filenames.
1409
1437
1410 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1438 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1411 Python 2.2 users who lack a proper shlex.split.
1439 Python 2.2 users who lack a proper shlex.split.
1412
1440
1413 2004-07-19 Fernando Perez <fperez@colorado.edu>
1441 2004-07-19 Fernando Perez <fperez@colorado.edu>
1414
1442
1415 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1443 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1416 for reading readline's init file. I follow the normal chain:
1444 for reading readline's init file. I follow the normal chain:
1417 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1445 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1418 report by Mike Heeter. This closes
1446 report by Mike Heeter. This closes
1419 http://www.scipy.net/roundup/ipython/issue16.
1447 http://www.scipy.net/roundup/ipython/issue16.
1420
1448
1421 2004-07-18 Fernando Perez <fperez@colorado.edu>
1449 2004-07-18 Fernando Perez <fperez@colorado.edu>
1422
1450
1423 * IPython/iplib.py (__init__): Add better handling of '\' under
1451 * IPython/iplib.py (__init__): Add better handling of '\' under
1424 Win32 for filenames. After a patch by Ville.
1452 Win32 for filenames. After a patch by Ville.
1425
1453
1426 2004-07-17 Fernando Perez <fperez@colorado.edu>
1454 2004-07-17 Fernando Perez <fperez@colorado.edu>
1427
1455
1428 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1456 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1429 autocalling would be triggered for 'foo is bar' if foo is
1457 autocalling would be triggered for 'foo is bar' if foo is
1430 callable. I also cleaned up the autocall detection code to use a
1458 callable. I also cleaned up the autocall detection code to use a
1431 regexp, which is faster. Bug reported by Alexander Schmolck.
1459 regexp, which is faster. Bug reported by Alexander Schmolck.
1432
1460
1433 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1461 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1434 '?' in them would confuse the help system. Reported by Alex
1462 '?' in them would confuse the help system. Reported by Alex
1435 Schmolck.
1463 Schmolck.
1436
1464
1437 2004-07-16 Fernando Perez <fperez@colorado.edu>
1465 2004-07-16 Fernando Perez <fperez@colorado.edu>
1438
1466
1439 * IPython/GnuplotInteractive.py (__all__): added plot2.
1467 * IPython/GnuplotInteractive.py (__all__): added plot2.
1440
1468
1441 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1469 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1442 plotting dictionaries, lists or tuples of 1d arrays.
1470 plotting dictionaries, lists or tuples of 1d arrays.
1443
1471
1444 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1472 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1445 optimizations.
1473 optimizations.
1446
1474
1447 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1475 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1448 the information which was there from Janko's original IPP code:
1476 the information which was there from Janko's original IPP code:
1449
1477
1450 03.05.99 20:53 porto.ifm.uni-kiel.de
1478 03.05.99 20:53 porto.ifm.uni-kiel.de
1451 --Started changelog.
1479 --Started changelog.
1452 --make clear do what it say it does
1480 --make clear do what it say it does
1453 --added pretty output of lines from inputcache
1481 --added pretty output of lines from inputcache
1454 --Made Logger a mixin class, simplifies handling of switches
1482 --Made Logger a mixin class, simplifies handling of switches
1455 --Added own completer class. .string<TAB> expands to last history
1483 --Added own completer class. .string<TAB> expands to last history
1456 line which starts with string. The new expansion is also present
1484 line which starts with string. The new expansion is also present
1457 with Ctrl-r from the readline library. But this shows, who this
1485 with Ctrl-r from the readline library. But this shows, who this
1458 can be done for other cases.
1486 can be done for other cases.
1459 --Added convention that all shell functions should accept a
1487 --Added convention that all shell functions should accept a
1460 parameter_string This opens the door for different behaviour for
1488 parameter_string This opens the door for different behaviour for
1461 each function. @cd is a good example of this.
1489 each function. @cd is a good example of this.
1462
1490
1463 04.05.99 12:12 porto.ifm.uni-kiel.de
1491 04.05.99 12:12 porto.ifm.uni-kiel.de
1464 --added logfile rotation
1492 --added logfile rotation
1465 --added new mainloop method which freezes first the namespace
1493 --added new mainloop method which freezes first the namespace
1466
1494
1467 07.05.99 21:24 porto.ifm.uni-kiel.de
1495 07.05.99 21:24 porto.ifm.uni-kiel.de
1468 --added the docreader classes. Now there is a help system.
1496 --added the docreader classes. Now there is a help system.
1469 -This is only a first try. Currently it's not easy to put new
1497 -This is only a first try. Currently it's not easy to put new
1470 stuff in the indices. But this is the way to go. Info would be
1498 stuff in the indices. But this is the way to go. Info would be
1471 better, but HTML is every where and not everybody has an info
1499 better, but HTML is every where and not everybody has an info
1472 system installed and it's not so easy to change html-docs to info.
1500 system installed and it's not so easy to change html-docs to info.
1473 --added global logfile option
1501 --added global logfile option
1474 --there is now a hook for object inspection method pinfo needs to
1502 --there is now a hook for object inspection method pinfo needs to
1475 be provided for this. Can be reached by two '??'.
1503 be provided for this. Can be reached by two '??'.
1476
1504
1477 08.05.99 20:51 porto.ifm.uni-kiel.de
1505 08.05.99 20:51 porto.ifm.uni-kiel.de
1478 --added a README
1506 --added a README
1479 --bug in rc file. Something has changed so functions in the rc
1507 --bug in rc file. Something has changed so functions in the rc
1480 file need to reference the shell and not self. Not clear if it's a
1508 file need to reference the shell and not self. Not clear if it's a
1481 bug or feature.
1509 bug or feature.
1482 --changed rc file for new behavior
1510 --changed rc file for new behavior
1483
1511
1484 2004-07-15 Fernando Perez <fperez@colorado.edu>
1512 2004-07-15 Fernando Perez <fperez@colorado.edu>
1485
1513
1486 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1514 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1487 cache was falling out of sync in bizarre manners when multi-line
1515 cache was falling out of sync in bizarre manners when multi-line
1488 input was present. Minor optimizations and cleanup.
1516 input was present. Minor optimizations and cleanup.
1489
1517
1490 (Logger): Remove old Changelog info for cleanup. This is the
1518 (Logger): Remove old Changelog info for cleanup. This is the
1491 information which was there from Janko's original code:
1519 information which was there from Janko's original code:
1492
1520
1493 Changes to Logger: - made the default log filename a parameter
1521 Changes to Logger: - made the default log filename a parameter
1494
1522
1495 - put a check for lines beginning with !@? in log(). Needed
1523 - put a check for lines beginning with !@? in log(). Needed
1496 (even if the handlers properly log their lines) for mid-session
1524 (even if the handlers properly log their lines) for mid-session
1497 logging activation to work properly. Without this, lines logged
1525 logging activation to work properly. Without this, lines logged
1498 in mid session, which get read from the cache, would end up
1526 in mid session, which get read from the cache, would end up
1499 'bare' (with !@? in the open) in the log. Now they are caught
1527 'bare' (with !@? in the open) in the log. Now they are caught
1500 and prepended with a #.
1528 and prepended with a #.
1501
1529
1502 * IPython/iplib.py (InteractiveShell.init_readline): added check
1530 * IPython/iplib.py (InteractiveShell.init_readline): added check
1503 in case MagicCompleter fails to be defined, so we don't crash.
1531 in case MagicCompleter fails to be defined, so we don't crash.
1504
1532
1505 2004-07-13 Fernando Perez <fperez@colorado.edu>
1533 2004-07-13 Fernando Perez <fperez@colorado.edu>
1506
1534
1507 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1535 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1508 of EPS if the requested filename ends in '.eps'.
1536 of EPS if the requested filename ends in '.eps'.
1509
1537
1510 2004-07-04 Fernando Perez <fperez@colorado.edu>
1538 2004-07-04 Fernando Perez <fperez@colorado.edu>
1511
1539
1512 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1540 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1513 escaping of quotes when calling the shell.
1541 escaping of quotes when calling the shell.
1514
1542
1515 2004-07-02 Fernando Perez <fperez@colorado.edu>
1543 2004-07-02 Fernando Perez <fperez@colorado.edu>
1516
1544
1517 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1545 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1518 gettext not working because we were clobbering '_'. Fixes
1546 gettext not working because we were clobbering '_'. Fixes
1519 http://www.scipy.net/roundup/ipython/issue6.
1547 http://www.scipy.net/roundup/ipython/issue6.
1520
1548
1521 2004-07-01 Fernando Perez <fperez@colorado.edu>
1549 2004-07-01 Fernando Perez <fperez@colorado.edu>
1522
1550
1523 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1551 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1524 into @cd. Patch by Ville.
1552 into @cd. Patch by Ville.
1525
1553
1526 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1554 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1527 new function to store things after ipmaker runs. Patch by Ville.
1555 new function to store things after ipmaker runs. Patch by Ville.
1528 Eventually this will go away once ipmaker is removed and the class
1556 Eventually this will go away once ipmaker is removed and the class
1529 gets cleaned up, but for now it's ok. Key functionality here is
1557 gets cleaned up, but for now it's ok. Key functionality here is
1530 the addition of the persistent storage mechanism, a dict for
1558 the addition of the persistent storage mechanism, a dict for
1531 keeping data across sessions (for now just bookmarks, but more can
1559 keeping data across sessions (for now just bookmarks, but more can
1532 be implemented later).
1560 be implemented later).
1533
1561
1534 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1562 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1535 persistent across sections. Patch by Ville, I modified it
1563 persistent across sections. Patch by Ville, I modified it
1536 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1564 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1537 added a '-l' option to list all bookmarks.
1565 added a '-l' option to list all bookmarks.
1538
1566
1539 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1567 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1540 center for cleanup. Registered with atexit.register(). I moved
1568 center for cleanup. Registered with atexit.register(). I moved
1541 here the old exit_cleanup(). After a patch by Ville.
1569 here the old exit_cleanup(). After a patch by Ville.
1542
1570
1543 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1571 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1544 characters in the hacked shlex_split for python 2.2.
1572 characters in the hacked shlex_split for python 2.2.
1545
1573
1546 * IPython/iplib.py (file_matches): more fixes to filenames with
1574 * IPython/iplib.py (file_matches): more fixes to filenames with
1547 whitespace in them. It's not perfect, but limitations in python's
1575 whitespace in them. It's not perfect, but limitations in python's
1548 readline make it impossible to go further.
1576 readline make it impossible to go further.
1549
1577
1550 2004-06-29 Fernando Perez <fperez@colorado.edu>
1578 2004-06-29 Fernando Perez <fperez@colorado.edu>
1551
1579
1552 * IPython/iplib.py (file_matches): escape whitespace correctly in
1580 * IPython/iplib.py (file_matches): escape whitespace correctly in
1553 filename completions. Bug reported by Ville.
1581 filename completions. Bug reported by Ville.
1554
1582
1555 2004-06-28 Fernando Perez <fperez@colorado.edu>
1583 2004-06-28 Fernando Perez <fperez@colorado.edu>
1556
1584
1557 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1585 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1558 the history file will be called 'history-PROFNAME' (or just
1586 the history file will be called 'history-PROFNAME' (or just
1559 'history' if no profile is loaded). I was getting annoyed at
1587 'history' if no profile is loaded). I was getting annoyed at
1560 getting my Numerical work history clobbered by pysh sessions.
1588 getting my Numerical work history clobbered by pysh sessions.
1561
1589
1562 * IPython/iplib.py (InteractiveShell.__init__): Internal
1590 * IPython/iplib.py (InteractiveShell.__init__): Internal
1563 getoutputerror() function so that we can honor the system_verbose
1591 getoutputerror() function so that we can honor the system_verbose
1564 flag for _all_ system calls. I also added escaping of #
1592 flag for _all_ system calls. I also added escaping of #
1565 characters here to avoid confusing Itpl.
1593 characters here to avoid confusing Itpl.
1566
1594
1567 * IPython/Magic.py (shlex_split): removed call to shell in
1595 * IPython/Magic.py (shlex_split): removed call to shell in
1568 parse_options and replaced it with shlex.split(). The annoying
1596 parse_options and replaced it with shlex.split(). The annoying
1569 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1597 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1570 to backport it from 2.3, with several frail hacks (the shlex
1598 to backport it from 2.3, with several frail hacks (the shlex
1571 module is rather limited in 2.2). Thanks to a suggestion by Ville
1599 module is rather limited in 2.2). Thanks to a suggestion by Ville
1572 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1600 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1573 problem.
1601 problem.
1574
1602
1575 (Magic.magic_system_verbose): new toggle to print the actual
1603 (Magic.magic_system_verbose): new toggle to print the actual
1576 system calls made by ipython. Mainly for debugging purposes.
1604 system calls made by ipython. Mainly for debugging purposes.
1577
1605
1578 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1606 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1579 doesn't support persistence. Reported (and fix suggested) by
1607 doesn't support persistence. Reported (and fix suggested) by
1580 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1608 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1581
1609
1582 2004-06-26 Fernando Perez <fperez@colorado.edu>
1610 2004-06-26 Fernando Perez <fperez@colorado.edu>
1583
1611
1584 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1612 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1585 continue prompts.
1613 continue prompts.
1586
1614
1587 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1615 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1588 function (basically a big docstring) and a few more things here to
1616 function (basically a big docstring) and a few more things here to
1589 speedup startup. pysh.py is now very lightweight. We want because
1617 speedup startup. pysh.py is now very lightweight. We want because
1590 it gets execfile'd, while InterpreterExec gets imported, so
1618 it gets execfile'd, while InterpreterExec gets imported, so
1591 byte-compilation saves time.
1619 byte-compilation saves time.
1592
1620
1593 2004-06-25 Fernando Perez <fperez@colorado.edu>
1621 2004-06-25 Fernando Perez <fperez@colorado.edu>
1594
1622
1595 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1623 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1596 -NUM', which was recently broken.
1624 -NUM', which was recently broken.
1597
1625
1598 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1626 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1599 in multi-line input (but not !!, which doesn't make sense there).
1627 in multi-line input (but not !!, which doesn't make sense there).
1600
1628
1601 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1629 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1602 It's just too useful, and people can turn it off in the less
1630 It's just too useful, and people can turn it off in the less
1603 common cases where it's a problem.
1631 common cases where it's a problem.
1604
1632
1605 2004-06-24 Fernando Perez <fperez@colorado.edu>
1633 2004-06-24 Fernando Perez <fperez@colorado.edu>
1606
1634
1607 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1635 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1608 special syntaxes (like alias calling) is now allied in multi-line
1636 special syntaxes (like alias calling) is now allied in multi-line
1609 input. This is still _very_ experimental, but it's necessary for
1637 input. This is still _very_ experimental, but it's necessary for
1610 efficient shell usage combining python looping syntax with system
1638 efficient shell usage combining python looping syntax with system
1611 calls. For now it's restricted to aliases, I don't think it
1639 calls. For now it's restricted to aliases, I don't think it
1612 really even makes sense to have this for magics.
1640 really even makes sense to have this for magics.
1613
1641
1614 2004-06-23 Fernando Perez <fperez@colorado.edu>
1642 2004-06-23 Fernando Perez <fperez@colorado.edu>
1615
1643
1616 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1644 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1617 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1645 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1618
1646
1619 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1647 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1620 extensions under Windows (after code sent by Gary Bishop). The
1648 extensions under Windows (after code sent by Gary Bishop). The
1621 extensions considered 'executable' are stored in IPython's rc
1649 extensions considered 'executable' are stored in IPython's rc
1622 structure as win_exec_ext.
1650 structure as win_exec_ext.
1623
1651
1624 * IPython/genutils.py (shell): new function, like system() but
1652 * IPython/genutils.py (shell): new function, like system() but
1625 without return value. Very useful for interactive shell work.
1653 without return value. Very useful for interactive shell work.
1626
1654
1627 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1655 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1628 delete aliases.
1656 delete aliases.
1629
1657
1630 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1658 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1631 sure that the alias table doesn't contain python keywords.
1659 sure that the alias table doesn't contain python keywords.
1632
1660
1633 2004-06-21 Fernando Perez <fperez@colorado.edu>
1661 2004-06-21 Fernando Perez <fperez@colorado.edu>
1634
1662
1635 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1663 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1636 non-existent items are found in $PATH. Reported by Thorsten.
1664 non-existent items are found in $PATH. Reported by Thorsten.
1637
1665
1638 2004-06-20 Fernando Perez <fperez@colorado.edu>
1666 2004-06-20 Fernando Perez <fperez@colorado.edu>
1639
1667
1640 * IPython/iplib.py (complete): modified the completer so that the
1668 * IPython/iplib.py (complete): modified the completer so that the
1641 order of priorities can be easily changed at runtime.
1669 order of priorities can be easily changed at runtime.
1642
1670
1643 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1671 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1644 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1672 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1645
1673
1646 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1674 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1647 expand Python variables prepended with $ in all system calls. The
1675 expand Python variables prepended with $ in all system calls. The
1648 same was done to InteractiveShell.handle_shell_escape. Now all
1676 same was done to InteractiveShell.handle_shell_escape. Now all
1649 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1677 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1650 expansion of python variables and expressions according to the
1678 expansion of python variables and expressions according to the
1651 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1679 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1652
1680
1653 Though PEP-215 has been rejected, a similar (but simpler) one
1681 Though PEP-215 has been rejected, a similar (but simpler) one
1654 seems like it will go into Python 2.4, PEP-292 -
1682 seems like it will go into Python 2.4, PEP-292 -
1655 http://www.python.org/peps/pep-0292.html.
1683 http://www.python.org/peps/pep-0292.html.
1656
1684
1657 I'll keep the full syntax of PEP-215, since IPython has since the
1685 I'll keep the full syntax of PEP-215, since IPython has since the
1658 start used Ka-Ping Yee's reference implementation discussed there
1686 start used Ka-Ping Yee's reference implementation discussed there
1659 (Itpl), and I actually like the powerful semantics it offers.
1687 (Itpl), and I actually like the powerful semantics it offers.
1660
1688
1661 In order to access normal shell variables, the $ has to be escaped
1689 In order to access normal shell variables, the $ has to be escaped
1662 via an extra $. For example:
1690 via an extra $. For example:
1663
1691
1664 In [7]: PATH='a python variable'
1692 In [7]: PATH='a python variable'
1665
1693
1666 In [8]: !echo $PATH
1694 In [8]: !echo $PATH
1667 a python variable
1695 a python variable
1668
1696
1669 In [9]: !echo $$PATH
1697 In [9]: !echo $$PATH
1670 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1698 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1671
1699
1672 (Magic.parse_options): escape $ so the shell doesn't evaluate
1700 (Magic.parse_options): escape $ so the shell doesn't evaluate
1673 things prematurely.
1701 things prematurely.
1674
1702
1675 * IPython/iplib.py (InteractiveShell.call_alias): added the
1703 * IPython/iplib.py (InteractiveShell.call_alias): added the
1676 ability for aliases to expand python variables via $.
1704 ability for aliases to expand python variables via $.
1677
1705
1678 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1706 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1679 system, now there's a @rehash/@rehashx pair of magics. These work
1707 system, now there's a @rehash/@rehashx pair of magics. These work
1680 like the csh rehash command, and can be invoked at any time. They
1708 like the csh rehash command, and can be invoked at any time. They
1681 build a table of aliases to everything in the user's $PATH
1709 build a table of aliases to everything in the user's $PATH
1682 (@rehash uses everything, @rehashx is slower but only adds
1710 (@rehash uses everything, @rehashx is slower but only adds
1683 executable files). With this, the pysh.py-based shell profile can
1711 executable files). With this, the pysh.py-based shell profile can
1684 now simply call rehash upon startup, and full access to all
1712 now simply call rehash upon startup, and full access to all
1685 programs in the user's path is obtained.
1713 programs in the user's path is obtained.
1686
1714
1687 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1715 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1688 functionality is now fully in place. I removed the old dynamic
1716 functionality is now fully in place. I removed the old dynamic
1689 code generation based approach, in favor of a much lighter one
1717 code generation based approach, in favor of a much lighter one
1690 based on a simple dict. The advantage is that this allows me to
1718 based on a simple dict. The advantage is that this allows me to
1691 now have thousands of aliases with negligible cost (unthinkable
1719 now have thousands of aliases with negligible cost (unthinkable
1692 with the old system).
1720 with the old system).
1693
1721
1694 2004-06-19 Fernando Perez <fperez@colorado.edu>
1722 2004-06-19 Fernando Perez <fperez@colorado.edu>
1695
1723
1696 * IPython/iplib.py (__init__): extended MagicCompleter class to
1724 * IPython/iplib.py (__init__): extended MagicCompleter class to
1697 also complete (last in priority) on user aliases.
1725 also complete (last in priority) on user aliases.
1698
1726
1699 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1727 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1700 call to eval.
1728 call to eval.
1701 (ItplNS.__init__): Added a new class which functions like Itpl,
1729 (ItplNS.__init__): Added a new class which functions like Itpl,
1702 but allows configuring the namespace for the evaluation to occur
1730 but allows configuring the namespace for the evaluation to occur
1703 in.
1731 in.
1704
1732
1705 2004-06-18 Fernando Perez <fperez@colorado.edu>
1733 2004-06-18 Fernando Perez <fperez@colorado.edu>
1706
1734
1707 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1735 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1708 better message when 'exit' or 'quit' are typed (a common newbie
1736 better message when 'exit' or 'quit' are typed (a common newbie
1709 confusion).
1737 confusion).
1710
1738
1711 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1739 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1712 check for Windows users.
1740 check for Windows users.
1713
1741
1714 * IPython/iplib.py (InteractiveShell.user_setup): removed
1742 * IPython/iplib.py (InteractiveShell.user_setup): removed
1715 disabling of colors for Windows. I'll test at runtime and issue a
1743 disabling of colors for Windows. I'll test at runtime and issue a
1716 warning if Gary's readline isn't found, as to nudge users to
1744 warning if Gary's readline isn't found, as to nudge users to
1717 download it.
1745 download it.
1718
1746
1719 2004-06-16 Fernando Perez <fperez@colorado.edu>
1747 2004-06-16 Fernando Perez <fperez@colorado.edu>
1720
1748
1721 * IPython/genutils.py (Stream.__init__): changed to print errors
1749 * IPython/genutils.py (Stream.__init__): changed to print errors
1722 to sys.stderr. I had a circular dependency here. Now it's
1750 to sys.stderr. I had a circular dependency here. Now it's
1723 possible to run ipython as IDLE's shell (consider this pre-alpha,
1751 possible to run ipython as IDLE's shell (consider this pre-alpha,
1724 since true stdout things end up in the starting terminal instead
1752 since true stdout things end up in the starting terminal instead
1725 of IDLE's out).
1753 of IDLE's out).
1726
1754
1727 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1755 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1728 users who haven't # updated their prompt_in2 definitions. Remove
1756 users who haven't # updated their prompt_in2 definitions. Remove
1729 eventually.
1757 eventually.
1730 (multiple_replace): added credit to original ASPN recipe.
1758 (multiple_replace): added credit to original ASPN recipe.
1731
1759
1732 2004-06-15 Fernando Perez <fperez@colorado.edu>
1760 2004-06-15 Fernando Perez <fperez@colorado.edu>
1733
1761
1734 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1762 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1735 list of auto-defined aliases.
1763 list of auto-defined aliases.
1736
1764
1737 2004-06-13 Fernando Perez <fperez@colorado.edu>
1765 2004-06-13 Fernando Perez <fperez@colorado.edu>
1738
1766
1739 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1767 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1740 install was really requested (so setup.py can be used for other
1768 install was really requested (so setup.py can be used for other
1741 things under Windows).
1769 things under Windows).
1742
1770
1743 2004-06-10 Fernando Perez <fperez@colorado.edu>
1771 2004-06-10 Fernando Perez <fperez@colorado.edu>
1744
1772
1745 * IPython/Logger.py (Logger.create_log): Manually remove any old
1773 * IPython/Logger.py (Logger.create_log): Manually remove any old
1746 backup, since os.remove may fail under Windows. Fixes bug
1774 backup, since os.remove may fail under Windows. Fixes bug
1747 reported by Thorsten.
1775 reported by Thorsten.
1748
1776
1749 2004-06-09 Fernando Perez <fperez@colorado.edu>
1777 2004-06-09 Fernando Perez <fperez@colorado.edu>
1750
1778
1751 * examples/example-embed.py: fixed all references to %n (replaced
1779 * examples/example-embed.py: fixed all references to %n (replaced
1752 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1780 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1753 for all examples and the manual as well.
1781 for all examples and the manual as well.
1754
1782
1755 2004-06-08 Fernando Perez <fperez@colorado.edu>
1783 2004-06-08 Fernando Perez <fperez@colorado.edu>
1756
1784
1757 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1785 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1758 alignment and color management. All 3 prompt subsystems now
1786 alignment and color management. All 3 prompt subsystems now
1759 inherit from BasePrompt.
1787 inherit from BasePrompt.
1760
1788
1761 * tools/release: updates for windows installer build and tag rpms
1789 * tools/release: updates for windows installer build and tag rpms
1762 with python version (since paths are fixed).
1790 with python version (since paths are fixed).
1763
1791
1764 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1792 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1765 which will become eventually obsolete. Also fixed the default
1793 which will become eventually obsolete. Also fixed the default
1766 prompt_in2 to use \D, so at least new users start with the correct
1794 prompt_in2 to use \D, so at least new users start with the correct
1767 defaults.
1795 defaults.
1768 WARNING: Users with existing ipythonrc files will need to apply
1796 WARNING: Users with existing ipythonrc files will need to apply
1769 this fix manually!
1797 this fix manually!
1770
1798
1771 * setup.py: make windows installer (.exe). This is finally the
1799 * setup.py: make windows installer (.exe). This is finally the
1772 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1800 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1773 which I hadn't included because it required Python 2.3 (or recent
1801 which I hadn't included because it required Python 2.3 (or recent
1774 distutils).
1802 distutils).
1775
1803
1776 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1804 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1777 usage of new '\D' escape.
1805 usage of new '\D' escape.
1778
1806
1779 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1807 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1780 lacks os.getuid())
1808 lacks os.getuid())
1781 (CachedOutput.set_colors): Added the ability to turn coloring
1809 (CachedOutput.set_colors): Added the ability to turn coloring
1782 on/off with @colors even for manually defined prompt colors. It
1810 on/off with @colors even for manually defined prompt colors. It
1783 uses a nasty global, but it works safely and via the generic color
1811 uses a nasty global, but it works safely and via the generic color
1784 handling mechanism.
1812 handling mechanism.
1785 (Prompt2.__init__): Introduced new escape '\D' for continuation
1813 (Prompt2.__init__): Introduced new escape '\D' for continuation
1786 prompts. It represents the counter ('\#') as dots.
1814 prompts. It represents the counter ('\#') as dots.
1787 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1815 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1788 need to update their ipythonrc files and replace '%n' with '\D' in
1816 need to update their ipythonrc files and replace '%n' with '\D' in
1789 their prompt_in2 settings everywhere. Sorry, but there's
1817 their prompt_in2 settings everywhere. Sorry, but there's
1790 otherwise no clean way to get all prompts to properly align. The
1818 otherwise no clean way to get all prompts to properly align. The
1791 ipythonrc shipped with IPython has been updated.
1819 ipythonrc shipped with IPython has been updated.
1792
1820
1793 2004-06-07 Fernando Perez <fperez@colorado.edu>
1821 2004-06-07 Fernando Perez <fperez@colorado.edu>
1794
1822
1795 * setup.py (isfile): Pass local_icons option to latex2html, so the
1823 * setup.py (isfile): Pass local_icons option to latex2html, so the
1796 resulting HTML file is self-contained. Thanks to
1824 resulting HTML file is self-contained. Thanks to
1797 dryice-AT-liu.com.cn for the tip.
1825 dryice-AT-liu.com.cn for the tip.
1798
1826
1799 * pysh.py: I created a new profile 'shell', which implements a
1827 * pysh.py: I created a new profile 'shell', which implements a
1800 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1828 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1801 system shell, nor will it become one anytime soon. It's mainly
1829 system shell, nor will it become one anytime soon. It's mainly
1802 meant to illustrate the use of the new flexible bash-like prompts.
1830 meant to illustrate the use of the new flexible bash-like prompts.
1803 I guess it could be used by hardy souls for true shell management,
1831 I guess it could be used by hardy souls for true shell management,
1804 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1832 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1805 profile. This uses the InterpreterExec extension provided by
1833 profile. This uses the InterpreterExec extension provided by
1806 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1834 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1807
1835
1808 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1836 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1809 auto-align itself with the length of the previous input prompt
1837 auto-align itself with the length of the previous input prompt
1810 (taking into account the invisible color escapes).
1838 (taking into account the invisible color escapes).
1811 (CachedOutput.__init__): Large restructuring of this class. Now
1839 (CachedOutput.__init__): Large restructuring of this class. Now
1812 all three prompts (primary1, primary2, output) are proper objects,
1840 all three prompts (primary1, primary2, output) are proper objects,
1813 managed by the 'parent' CachedOutput class. The code is still a
1841 managed by the 'parent' CachedOutput class. The code is still a
1814 bit hackish (all prompts share state via a pointer to the cache),
1842 bit hackish (all prompts share state via a pointer to the cache),
1815 but it's overall far cleaner than before.
1843 but it's overall far cleaner than before.
1816
1844
1817 * IPython/genutils.py (getoutputerror): modified to add verbose,
1845 * IPython/genutils.py (getoutputerror): modified to add verbose,
1818 debug and header options. This makes the interface of all getout*
1846 debug and header options. This makes the interface of all getout*
1819 functions uniform.
1847 functions uniform.
1820 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1848 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1821
1849
1822 * IPython/Magic.py (Magic.default_option): added a function to
1850 * IPython/Magic.py (Magic.default_option): added a function to
1823 allow registering default options for any magic command. This
1851 allow registering default options for any magic command. This
1824 makes it easy to have profiles which customize the magics globally
1852 makes it easy to have profiles which customize the magics globally
1825 for a certain use. The values set through this function are
1853 for a certain use. The values set through this function are
1826 picked up by the parse_options() method, which all magics should
1854 picked up by the parse_options() method, which all magics should
1827 use to parse their options.
1855 use to parse their options.
1828
1856
1829 * IPython/genutils.py (warn): modified the warnings framework to
1857 * IPython/genutils.py (warn): modified the warnings framework to
1830 use the Term I/O class. I'm trying to slowly unify all of
1858 use the Term I/O class. I'm trying to slowly unify all of
1831 IPython's I/O operations to pass through Term.
1859 IPython's I/O operations to pass through Term.
1832
1860
1833 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1861 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1834 the secondary prompt to correctly match the length of the primary
1862 the secondary prompt to correctly match the length of the primary
1835 one for any prompt. Now multi-line code will properly line up
1863 one for any prompt. Now multi-line code will properly line up
1836 even for path dependent prompts, such as the new ones available
1864 even for path dependent prompts, such as the new ones available
1837 via the prompt_specials.
1865 via the prompt_specials.
1838
1866
1839 2004-06-06 Fernando Perez <fperez@colorado.edu>
1867 2004-06-06 Fernando Perez <fperez@colorado.edu>
1840
1868
1841 * IPython/Prompts.py (prompt_specials): Added the ability to have
1869 * IPython/Prompts.py (prompt_specials): Added the ability to have
1842 bash-like special sequences in the prompts, which get
1870 bash-like special sequences in the prompts, which get
1843 automatically expanded. Things like hostname, current working
1871 automatically expanded. Things like hostname, current working
1844 directory and username are implemented already, but it's easy to
1872 directory and username are implemented already, but it's easy to
1845 add more in the future. Thanks to a patch by W.J. van der Laan
1873 add more in the future. Thanks to a patch by W.J. van der Laan
1846 <gnufnork-AT-hetdigitalegat.nl>
1874 <gnufnork-AT-hetdigitalegat.nl>
1847 (prompt_specials): Added color support for prompt strings, so
1875 (prompt_specials): Added color support for prompt strings, so
1848 users can define arbitrary color setups for their prompts.
1876 users can define arbitrary color setups for their prompts.
1849
1877
1850 2004-06-05 Fernando Perez <fperez@colorado.edu>
1878 2004-06-05 Fernando Perez <fperez@colorado.edu>
1851
1879
1852 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1880 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1853 code to load Gary Bishop's readline and configure it
1881 code to load Gary Bishop's readline and configure it
1854 automatically. Thanks to Gary for help on this.
1882 automatically. Thanks to Gary for help on this.
1855
1883
1856 2004-06-01 Fernando Perez <fperez@colorado.edu>
1884 2004-06-01 Fernando Perez <fperez@colorado.edu>
1857
1885
1858 * IPython/Logger.py (Logger.create_log): fix bug for logging
1886 * IPython/Logger.py (Logger.create_log): fix bug for logging
1859 with no filename (previous fix was incomplete).
1887 with no filename (previous fix was incomplete).
1860
1888
1861 2004-05-25 Fernando Perez <fperez@colorado.edu>
1889 2004-05-25 Fernando Perez <fperez@colorado.edu>
1862
1890
1863 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1891 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1864 parens would get passed to the shell.
1892 parens would get passed to the shell.
1865
1893
1866 2004-05-20 Fernando Perez <fperez@colorado.edu>
1894 2004-05-20 Fernando Perez <fperez@colorado.edu>
1867
1895
1868 * IPython/Magic.py (Magic.magic_prun): changed default profile
1896 * IPython/Magic.py (Magic.magic_prun): changed default profile
1869 sort order to 'time' (the more common profiling need).
1897 sort order to 'time' (the more common profiling need).
1870
1898
1871 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1899 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1872 so that source code shown is guaranteed in sync with the file on
1900 so that source code shown is guaranteed in sync with the file on
1873 disk (also changed in psource). Similar fix to the one for
1901 disk (also changed in psource). Similar fix to the one for
1874 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1902 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1875 <yann.ledu-AT-noos.fr>.
1903 <yann.ledu-AT-noos.fr>.
1876
1904
1877 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1905 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1878 with a single option would not be correctly parsed. Closes
1906 with a single option would not be correctly parsed. Closes
1879 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1907 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1880 introduced in 0.6.0 (on 2004-05-06).
1908 introduced in 0.6.0 (on 2004-05-06).
1881
1909
1882 2004-05-13 *** Released version 0.6.0
1910 2004-05-13 *** Released version 0.6.0
1883
1911
1884 2004-05-13 Fernando Perez <fperez@colorado.edu>
1912 2004-05-13 Fernando Perez <fperez@colorado.edu>
1885
1913
1886 * debian/: Added debian/ directory to CVS, so that debian support
1914 * debian/: Added debian/ directory to CVS, so that debian support
1887 is publicly accessible. The debian package is maintained by Jack
1915 is publicly accessible. The debian package is maintained by Jack
1888 Moffit <jack-AT-xiph.org>.
1916 Moffit <jack-AT-xiph.org>.
1889
1917
1890 * Documentation: included the notes about an ipython-based system
1918 * Documentation: included the notes about an ipython-based system
1891 shell (the hypothetical 'pysh') into the new_design.pdf document,
1919 shell (the hypothetical 'pysh') into the new_design.pdf document,
1892 so that these ideas get distributed to users along with the
1920 so that these ideas get distributed to users along with the
1893 official documentation.
1921 official documentation.
1894
1922
1895 2004-05-10 Fernando Perez <fperez@colorado.edu>
1923 2004-05-10 Fernando Perez <fperez@colorado.edu>
1896
1924
1897 * IPython/Logger.py (Logger.create_log): fix recently introduced
1925 * IPython/Logger.py (Logger.create_log): fix recently introduced
1898 bug (misindented line) where logstart would fail when not given an
1926 bug (misindented line) where logstart would fail when not given an
1899 explicit filename.
1927 explicit filename.
1900
1928
1901 2004-05-09 Fernando Perez <fperez@colorado.edu>
1929 2004-05-09 Fernando Perez <fperez@colorado.edu>
1902
1930
1903 * IPython/Magic.py (Magic.parse_options): skip system call when
1931 * IPython/Magic.py (Magic.parse_options): skip system call when
1904 there are no options to look for. Faster, cleaner for the common
1932 there are no options to look for. Faster, cleaner for the common
1905 case.
1933 case.
1906
1934
1907 * Documentation: many updates to the manual: describing Windows
1935 * Documentation: many updates to the manual: describing Windows
1908 support better, Gnuplot updates, credits, misc small stuff. Also
1936 support better, Gnuplot updates, credits, misc small stuff. Also
1909 updated the new_design doc a bit.
1937 updated the new_design doc a bit.
1910
1938
1911 2004-05-06 *** Released version 0.6.0.rc1
1939 2004-05-06 *** Released version 0.6.0.rc1
1912
1940
1913 2004-05-06 Fernando Perez <fperez@colorado.edu>
1941 2004-05-06 Fernando Perez <fperez@colorado.edu>
1914
1942
1915 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1943 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1916 operations to use the vastly more efficient list/''.join() method.
1944 operations to use the vastly more efficient list/''.join() method.
1917 (FormattedTB.text): Fix
1945 (FormattedTB.text): Fix
1918 http://www.scipy.net/roundup/ipython/issue12 - exception source
1946 http://www.scipy.net/roundup/ipython/issue12 - exception source
1919 extract not updated after reload. Thanks to Mike Salib
1947 extract not updated after reload. Thanks to Mike Salib
1920 <msalib-AT-mit.edu> for pinning the source of the problem.
1948 <msalib-AT-mit.edu> for pinning the source of the problem.
1921 Fortunately, the solution works inside ipython and doesn't require
1949 Fortunately, the solution works inside ipython and doesn't require
1922 any changes to python proper.
1950 any changes to python proper.
1923
1951
1924 * IPython/Magic.py (Magic.parse_options): Improved to process the
1952 * IPython/Magic.py (Magic.parse_options): Improved to process the
1925 argument list as a true shell would (by actually using the
1953 argument list as a true shell would (by actually using the
1926 underlying system shell). This way, all @magics automatically get
1954 underlying system shell). This way, all @magics automatically get
1927 shell expansion for variables. Thanks to a comment by Alex
1955 shell expansion for variables. Thanks to a comment by Alex
1928 Schmolck.
1956 Schmolck.
1929
1957
1930 2004-04-04 Fernando Perez <fperez@colorado.edu>
1958 2004-04-04 Fernando Perez <fperez@colorado.edu>
1931
1959
1932 * IPython/iplib.py (InteractiveShell.interact): Added a special
1960 * IPython/iplib.py (InteractiveShell.interact): Added a special
1933 trap for a debugger quit exception, which is basically impossible
1961 trap for a debugger quit exception, which is basically impossible
1934 to handle by normal mechanisms, given what pdb does to the stack.
1962 to handle by normal mechanisms, given what pdb does to the stack.
1935 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1963 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1936
1964
1937 2004-04-03 Fernando Perez <fperez@colorado.edu>
1965 2004-04-03 Fernando Perez <fperez@colorado.edu>
1938
1966
1939 * IPython/genutils.py (Term): Standardized the names of the Term
1967 * IPython/genutils.py (Term): Standardized the names of the Term
1940 class streams to cin/cout/cerr, following C++ naming conventions
1968 class streams to cin/cout/cerr, following C++ naming conventions
1941 (I can't use in/out/err because 'in' is not a valid attribute
1969 (I can't use in/out/err because 'in' is not a valid attribute
1942 name).
1970 name).
1943
1971
1944 * IPython/iplib.py (InteractiveShell.interact): don't increment
1972 * IPython/iplib.py (InteractiveShell.interact): don't increment
1945 the prompt if there's no user input. By Daniel 'Dang' Griffith
1973 the prompt if there's no user input. By Daniel 'Dang' Griffith
1946 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1974 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1947 Francois Pinard.
1975 Francois Pinard.
1948
1976
1949 2004-04-02 Fernando Perez <fperez@colorado.edu>
1977 2004-04-02 Fernando Perez <fperez@colorado.edu>
1950
1978
1951 * IPython/genutils.py (Stream.__init__): Modified to survive at
1979 * IPython/genutils.py (Stream.__init__): Modified to survive at
1952 least importing in contexts where stdin/out/err aren't true file
1980 least importing in contexts where stdin/out/err aren't true file
1953 objects, such as PyCrust (they lack fileno() and mode). However,
1981 objects, such as PyCrust (they lack fileno() and mode). However,
1954 the recovery facilities which rely on these things existing will
1982 the recovery facilities which rely on these things existing will
1955 not work.
1983 not work.
1956
1984
1957 2004-04-01 Fernando Perez <fperez@colorado.edu>
1985 2004-04-01 Fernando Perez <fperez@colorado.edu>
1958
1986
1959 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1987 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1960 use the new getoutputerror() function, so it properly
1988 use the new getoutputerror() function, so it properly
1961 distinguishes stdout/err.
1989 distinguishes stdout/err.
1962
1990
1963 * IPython/genutils.py (getoutputerror): added a function to
1991 * IPython/genutils.py (getoutputerror): added a function to
1964 capture separately the standard output and error of a command.
1992 capture separately the standard output and error of a command.
1965 After a comment from dang on the mailing lists. This code is
1993 After a comment from dang on the mailing lists. This code is
1966 basically a modified version of commands.getstatusoutput(), from
1994 basically a modified version of commands.getstatusoutput(), from
1967 the standard library.
1995 the standard library.
1968
1996
1969 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1997 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1970 '!!' as a special syntax (shorthand) to access @sx.
1998 '!!' as a special syntax (shorthand) to access @sx.
1971
1999
1972 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2000 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1973 command and return its output as a list split on '\n'.
2001 command and return its output as a list split on '\n'.
1974
2002
1975 2004-03-31 Fernando Perez <fperez@colorado.edu>
2003 2004-03-31 Fernando Perez <fperez@colorado.edu>
1976
2004
1977 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2005 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1978 method to dictionaries used as FakeModule instances if they lack
2006 method to dictionaries used as FakeModule instances if they lack
1979 it. At least pydoc in python2.3 breaks for runtime-defined
2007 it. At least pydoc in python2.3 breaks for runtime-defined
1980 functions without this hack. At some point I need to _really_
2008 functions without this hack. At some point I need to _really_
1981 understand what FakeModule is doing, because it's a gross hack.
2009 understand what FakeModule is doing, because it's a gross hack.
1982 But it solves Arnd's problem for now...
2010 But it solves Arnd's problem for now...
1983
2011
1984 2004-02-27 Fernando Perez <fperez@colorado.edu>
2012 2004-02-27 Fernando Perez <fperez@colorado.edu>
1985
2013
1986 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2014 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1987 mode would behave erratically. Also increased the number of
2015 mode would behave erratically. Also increased the number of
1988 possible logs in rotate mod to 999. Thanks to Rod Holland
2016 possible logs in rotate mod to 999. Thanks to Rod Holland
1989 <rhh@StructureLABS.com> for the report and fixes.
2017 <rhh@StructureLABS.com> for the report and fixes.
1990
2018
1991 2004-02-26 Fernando Perez <fperez@colorado.edu>
2019 2004-02-26 Fernando Perez <fperez@colorado.edu>
1992
2020
1993 * IPython/genutils.py (page): Check that the curses module really
2021 * IPython/genutils.py (page): Check that the curses module really
1994 has the initscr attribute before trying to use it. For some
2022 has the initscr attribute before trying to use it. For some
1995 reason, the Solaris curses module is missing this. I think this
2023 reason, the Solaris curses module is missing this. I think this
1996 should be considered a Solaris python bug, but I'm not sure.
2024 should be considered a Solaris python bug, but I'm not sure.
1997
2025
1998 2004-01-17 Fernando Perez <fperez@colorado.edu>
2026 2004-01-17 Fernando Perez <fperez@colorado.edu>
1999
2027
2000 * IPython/genutils.py (Stream.__init__): Changes to try to make
2028 * IPython/genutils.py (Stream.__init__): Changes to try to make
2001 ipython robust against stdin/out/err being closed by the user.
2029 ipython robust against stdin/out/err being closed by the user.
2002 This is 'user error' (and blocks a normal python session, at least
2030 This is 'user error' (and blocks a normal python session, at least
2003 the stdout case). However, Ipython should be able to survive such
2031 the stdout case). However, Ipython should be able to survive such
2004 instances of abuse as gracefully as possible. To simplify the
2032 instances of abuse as gracefully as possible. To simplify the
2005 coding and maintain compatibility with Gary Bishop's Term
2033 coding and maintain compatibility with Gary Bishop's Term
2006 contributions, I've made use of classmethods for this. I think
2034 contributions, I've made use of classmethods for this. I think
2007 this introduces a dependency on python 2.2.
2035 this introduces a dependency on python 2.2.
2008
2036
2009 2004-01-13 Fernando Perez <fperez@colorado.edu>
2037 2004-01-13 Fernando Perez <fperez@colorado.edu>
2010
2038
2011 * IPython/numutils.py (exp_safe): simplified the code a bit and
2039 * IPython/numutils.py (exp_safe): simplified the code a bit and
2012 removed the need for importing the kinds module altogether.
2040 removed the need for importing the kinds module altogether.
2013
2041
2014 2004-01-06 Fernando Perez <fperez@colorado.edu>
2042 2004-01-06 Fernando Perez <fperez@colorado.edu>
2015
2043
2016 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2044 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2017 a magic function instead, after some community feedback. No
2045 a magic function instead, after some community feedback. No
2018 special syntax will exist for it, but its name is deliberately
2046 special syntax will exist for it, but its name is deliberately
2019 very short.
2047 very short.
2020
2048
2021 2003-12-20 Fernando Perez <fperez@colorado.edu>
2049 2003-12-20 Fernando Perez <fperez@colorado.edu>
2022
2050
2023 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2051 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2024 new functionality, to automagically assign the result of a shell
2052 new functionality, to automagically assign the result of a shell
2025 command to a variable. I'll solicit some community feedback on
2053 command to a variable. I'll solicit some community feedback on
2026 this before making it permanent.
2054 this before making it permanent.
2027
2055
2028 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2056 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2029 requested about callables for which inspect couldn't obtain a
2057 requested about callables for which inspect couldn't obtain a
2030 proper argspec. Thanks to a crash report sent by Etienne
2058 proper argspec. Thanks to a crash report sent by Etienne
2031 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2059 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2032
2060
2033 2003-12-09 Fernando Perez <fperez@colorado.edu>
2061 2003-12-09 Fernando Perez <fperez@colorado.edu>
2034
2062
2035 * IPython/genutils.py (page): patch for the pager to work across
2063 * IPython/genutils.py (page): patch for the pager to work across
2036 various versions of Windows. By Gary Bishop.
2064 various versions of Windows. By Gary Bishop.
2037
2065
2038 2003-12-04 Fernando Perez <fperez@colorado.edu>
2066 2003-12-04 Fernando Perez <fperez@colorado.edu>
2039
2067
2040 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2068 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2041 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2069 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2042 While I tested this and it looks ok, there may still be corner
2070 While I tested this and it looks ok, there may still be corner
2043 cases I've missed.
2071 cases I've missed.
2044
2072
2045 2003-12-01 Fernando Perez <fperez@colorado.edu>
2073 2003-12-01 Fernando Perez <fperez@colorado.edu>
2046
2074
2047 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2075 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2048 where a line like 'p,q=1,2' would fail because the automagic
2076 where a line like 'p,q=1,2' would fail because the automagic
2049 system would be triggered for @p.
2077 system would be triggered for @p.
2050
2078
2051 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2079 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2052 cleanups, code unmodified.
2080 cleanups, code unmodified.
2053
2081
2054 * IPython/genutils.py (Term): added a class for IPython to handle
2082 * IPython/genutils.py (Term): added a class for IPython to handle
2055 output. In most cases it will just be a proxy for stdout/err, but
2083 output. In most cases it will just be a proxy for stdout/err, but
2056 having this allows modifications to be made for some platforms,
2084 having this allows modifications to be made for some platforms,
2057 such as handling color escapes under Windows. All of this code
2085 such as handling color escapes under Windows. All of this code
2058 was contributed by Gary Bishop, with minor modifications by me.
2086 was contributed by Gary Bishop, with minor modifications by me.
2059 The actual changes affect many files.
2087 The actual changes affect many files.
2060
2088
2061 2003-11-30 Fernando Perez <fperez@colorado.edu>
2089 2003-11-30 Fernando Perez <fperez@colorado.edu>
2062
2090
2063 * IPython/iplib.py (file_matches): new completion code, courtesy
2091 * IPython/iplib.py (file_matches): new completion code, courtesy
2064 of Jeff Collins. This enables filename completion again under
2092 of Jeff Collins. This enables filename completion again under
2065 python 2.3, which disabled it at the C level.
2093 python 2.3, which disabled it at the C level.
2066
2094
2067 2003-11-11 Fernando Perez <fperez@colorado.edu>
2095 2003-11-11 Fernando Perez <fperez@colorado.edu>
2068
2096
2069 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2097 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2070 for Numeric.array(map(...)), but often convenient.
2098 for Numeric.array(map(...)), but often convenient.
2071
2099
2072 2003-11-05 Fernando Perez <fperez@colorado.edu>
2100 2003-11-05 Fernando Perez <fperez@colorado.edu>
2073
2101
2074 * IPython/numutils.py (frange): Changed a call from int() to
2102 * IPython/numutils.py (frange): Changed a call from int() to
2075 int(round()) to prevent a problem reported with arange() in the
2103 int(round()) to prevent a problem reported with arange() in the
2076 numpy list.
2104 numpy list.
2077
2105
2078 2003-10-06 Fernando Perez <fperez@colorado.edu>
2106 2003-10-06 Fernando Perez <fperez@colorado.edu>
2079
2107
2080 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2108 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2081 prevent crashes if sys lacks an argv attribute (it happens with
2109 prevent crashes if sys lacks an argv attribute (it happens with
2082 embedded interpreters which build a bare-bones sys module).
2110 embedded interpreters which build a bare-bones sys module).
2083 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2111 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2084
2112
2085 2003-09-24 Fernando Perez <fperez@colorado.edu>
2113 2003-09-24 Fernando Perez <fperez@colorado.edu>
2086
2114
2087 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2115 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2088 to protect against poorly written user objects where __getattr__
2116 to protect against poorly written user objects where __getattr__
2089 raises exceptions other than AttributeError. Thanks to a bug
2117 raises exceptions other than AttributeError. Thanks to a bug
2090 report by Oliver Sander <osander-AT-gmx.de>.
2118 report by Oliver Sander <osander-AT-gmx.de>.
2091
2119
2092 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2120 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2093 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2121 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2094
2122
2095 2003-09-09 Fernando Perez <fperez@colorado.edu>
2123 2003-09-09 Fernando Perez <fperez@colorado.edu>
2096
2124
2097 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2125 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2098 unpacking a list whith a callable as first element would
2126 unpacking a list whith a callable as first element would
2099 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2127 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2100 Collins.
2128 Collins.
2101
2129
2102 2003-08-25 *** Released version 0.5.0
2130 2003-08-25 *** Released version 0.5.0
2103
2131
2104 2003-08-22 Fernando Perez <fperez@colorado.edu>
2132 2003-08-22 Fernando Perez <fperez@colorado.edu>
2105
2133
2106 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2134 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2107 improperly defined user exceptions. Thanks to feedback from Mark
2135 improperly defined user exceptions. Thanks to feedback from Mark
2108 Russell <mrussell-AT-verio.net>.
2136 Russell <mrussell-AT-verio.net>.
2109
2137
2110 2003-08-20 Fernando Perez <fperez@colorado.edu>
2138 2003-08-20 Fernando Perez <fperez@colorado.edu>
2111
2139
2112 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2140 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2113 printing so that it would print multi-line string forms starting
2141 printing so that it would print multi-line string forms starting
2114 with a new line. This way the formatting is better respected for
2142 with a new line. This way the formatting is better respected for
2115 objects which work hard to make nice string forms.
2143 objects which work hard to make nice string forms.
2116
2144
2117 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2145 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2118 autocall would overtake data access for objects with both
2146 autocall would overtake data access for objects with both
2119 __getitem__ and __call__.
2147 __getitem__ and __call__.
2120
2148
2121 2003-08-19 *** Released version 0.5.0-rc1
2149 2003-08-19 *** Released version 0.5.0-rc1
2122
2150
2123 2003-08-19 Fernando Perez <fperez@colorado.edu>
2151 2003-08-19 Fernando Perez <fperez@colorado.edu>
2124
2152
2125 * IPython/deep_reload.py (load_tail): single tiny change here
2153 * IPython/deep_reload.py (load_tail): single tiny change here
2126 seems to fix the long-standing bug of dreload() failing to work
2154 seems to fix the long-standing bug of dreload() failing to work
2127 for dotted names. But this module is pretty tricky, so I may have
2155 for dotted names. But this module is pretty tricky, so I may have
2128 missed some subtlety. Needs more testing!.
2156 missed some subtlety. Needs more testing!.
2129
2157
2130 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2158 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2131 exceptions which have badly implemented __str__ methods.
2159 exceptions which have badly implemented __str__ methods.
2132 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2160 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2133 which I've been getting reports about from Python 2.3 users. I
2161 which I've been getting reports about from Python 2.3 users. I
2134 wish I had a simple test case to reproduce the problem, so I could
2162 wish I had a simple test case to reproduce the problem, so I could
2135 either write a cleaner workaround or file a bug report if
2163 either write a cleaner workaround or file a bug report if
2136 necessary.
2164 necessary.
2137
2165
2138 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2166 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2139 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2167 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2140 a bug report by Tjabo Kloppenburg.
2168 a bug report by Tjabo Kloppenburg.
2141
2169
2142 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2170 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2143 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2171 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2144 seems rather unstable. Thanks to a bug report by Tjabo
2172 seems rather unstable. Thanks to a bug report by Tjabo
2145 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2173 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2146
2174
2147 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2175 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2148 this out soon because of the critical fixes in the inner loop for
2176 this out soon because of the critical fixes in the inner loop for
2149 generators.
2177 generators.
2150
2178
2151 * IPython/Magic.py (Magic.getargspec): removed. This (and
2179 * IPython/Magic.py (Magic.getargspec): removed. This (and
2152 _get_def) have been obsoleted by OInspect for a long time, I
2180 _get_def) have been obsoleted by OInspect for a long time, I
2153 hadn't noticed that they were dead code.
2181 hadn't noticed that they were dead code.
2154 (Magic._ofind): restored _ofind functionality for a few literals
2182 (Magic._ofind): restored _ofind functionality for a few literals
2155 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2183 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2156 for things like "hello".capitalize?, since that would require a
2184 for things like "hello".capitalize?, since that would require a
2157 potentially dangerous eval() again.
2185 potentially dangerous eval() again.
2158
2186
2159 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2187 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2160 logic a bit more to clean up the escapes handling and minimize the
2188 logic a bit more to clean up the escapes handling and minimize the
2161 use of _ofind to only necessary cases. The interactive 'feel' of
2189 use of _ofind to only necessary cases. The interactive 'feel' of
2162 IPython should have improved quite a bit with the changes in
2190 IPython should have improved quite a bit with the changes in
2163 _prefilter and _ofind (besides being far safer than before).
2191 _prefilter and _ofind (besides being far safer than before).
2164
2192
2165 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2193 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2166 obscure, never reported). Edit would fail to find the object to
2194 obscure, never reported). Edit would fail to find the object to
2167 edit under some circumstances.
2195 edit under some circumstances.
2168 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2196 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2169 which were causing double-calling of generators. Those eval calls
2197 which were causing double-calling of generators. Those eval calls
2170 were _very_ dangerous, since code with side effects could be
2198 were _very_ dangerous, since code with side effects could be
2171 triggered. As they say, 'eval is evil'... These were the
2199 triggered. As they say, 'eval is evil'... These were the
2172 nastiest evals in IPython. Besides, _ofind is now far simpler,
2200 nastiest evals in IPython. Besides, _ofind is now far simpler,
2173 and it should also be quite a bit faster. Its use of inspect is
2201 and it should also be quite a bit faster. Its use of inspect is
2174 also safer, so perhaps some of the inspect-related crashes I've
2202 also safer, so perhaps some of the inspect-related crashes I've
2175 seen lately with Python 2.3 might be taken care of. That will
2203 seen lately with Python 2.3 might be taken care of. That will
2176 need more testing.
2204 need more testing.
2177
2205
2178 2003-08-17 Fernando Perez <fperez@colorado.edu>
2206 2003-08-17 Fernando Perez <fperez@colorado.edu>
2179
2207
2180 * IPython/iplib.py (InteractiveShell._prefilter): significant
2208 * IPython/iplib.py (InteractiveShell._prefilter): significant
2181 simplifications to the logic for handling user escapes. Faster
2209 simplifications to the logic for handling user escapes. Faster
2182 and simpler code.
2210 and simpler code.
2183
2211
2184 2003-08-14 Fernando Perez <fperez@colorado.edu>
2212 2003-08-14 Fernando Perez <fperez@colorado.edu>
2185
2213
2186 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2214 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2187 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2215 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2188 but it should be quite a bit faster. And the recursive version
2216 but it should be quite a bit faster. And the recursive version
2189 generated O(log N) intermediate storage for all rank>1 arrays,
2217 generated O(log N) intermediate storage for all rank>1 arrays,
2190 even if they were contiguous.
2218 even if they were contiguous.
2191 (l1norm): Added this function.
2219 (l1norm): Added this function.
2192 (norm): Added this function for arbitrary norms (including
2220 (norm): Added this function for arbitrary norms (including
2193 l-infinity). l1 and l2 are still special cases for convenience
2221 l-infinity). l1 and l2 are still special cases for convenience
2194 and speed.
2222 and speed.
2195
2223
2196 2003-08-03 Fernando Perez <fperez@colorado.edu>
2224 2003-08-03 Fernando Perez <fperez@colorado.edu>
2197
2225
2198 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2226 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2199 exceptions, which now raise PendingDeprecationWarnings in Python
2227 exceptions, which now raise PendingDeprecationWarnings in Python
2200 2.3. There were some in Magic and some in Gnuplot2.
2228 2.3. There were some in Magic and some in Gnuplot2.
2201
2229
2202 2003-06-30 Fernando Perez <fperez@colorado.edu>
2230 2003-06-30 Fernando Perez <fperez@colorado.edu>
2203
2231
2204 * IPython/genutils.py (page): modified to call curses only for
2232 * IPython/genutils.py (page): modified to call curses only for
2205 terminals where TERM=='xterm'. After problems under many other
2233 terminals where TERM=='xterm'. After problems under many other
2206 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2234 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2207
2235
2208 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2236 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2209 would be triggered when readline was absent. This was just an old
2237 would be triggered when readline was absent. This was just an old
2210 debugging statement I'd forgotten to take out.
2238 debugging statement I'd forgotten to take out.
2211
2239
2212 2003-06-20 Fernando Perez <fperez@colorado.edu>
2240 2003-06-20 Fernando Perez <fperez@colorado.edu>
2213
2241
2214 * IPython/genutils.py (clock): modified to return only user time
2242 * IPython/genutils.py (clock): modified to return only user time
2215 (not counting system time), after a discussion on scipy. While
2243 (not counting system time), after a discussion on scipy. While
2216 system time may be a useful quantity occasionally, it may much
2244 system time may be a useful quantity occasionally, it may much
2217 more easily be skewed by occasional swapping or other similar
2245 more easily be skewed by occasional swapping or other similar
2218 activity.
2246 activity.
2219
2247
2220 2003-06-05 Fernando Perez <fperez@colorado.edu>
2248 2003-06-05 Fernando Perez <fperez@colorado.edu>
2221
2249
2222 * IPython/numutils.py (identity): new function, for building
2250 * IPython/numutils.py (identity): new function, for building
2223 arbitrary rank Kronecker deltas (mostly backwards compatible with
2251 arbitrary rank Kronecker deltas (mostly backwards compatible with
2224 Numeric.identity)
2252 Numeric.identity)
2225
2253
2226 2003-06-03 Fernando Perez <fperez@colorado.edu>
2254 2003-06-03 Fernando Perez <fperez@colorado.edu>
2227
2255
2228 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2256 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2229 arguments passed to magics with spaces, to allow trailing '\' to
2257 arguments passed to magics with spaces, to allow trailing '\' to
2230 work normally (mainly for Windows users).
2258 work normally (mainly for Windows users).
2231
2259
2232 2003-05-29 Fernando Perez <fperez@colorado.edu>
2260 2003-05-29 Fernando Perez <fperez@colorado.edu>
2233
2261
2234 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2262 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2235 instead of pydoc.help. This fixes a bizarre behavior where
2263 instead of pydoc.help. This fixes a bizarre behavior where
2236 printing '%s' % locals() would trigger the help system. Now
2264 printing '%s' % locals() would trigger the help system. Now
2237 ipython behaves like normal python does.
2265 ipython behaves like normal python does.
2238
2266
2239 Note that if one does 'from pydoc import help', the bizarre
2267 Note that if one does 'from pydoc import help', the bizarre
2240 behavior returns, but this will also happen in normal python, so
2268 behavior returns, but this will also happen in normal python, so
2241 it's not an ipython bug anymore (it has to do with how pydoc.help
2269 it's not an ipython bug anymore (it has to do with how pydoc.help
2242 is implemented).
2270 is implemented).
2243
2271
2244 2003-05-22 Fernando Perez <fperez@colorado.edu>
2272 2003-05-22 Fernando Perez <fperez@colorado.edu>
2245
2273
2246 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2274 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2247 return [] instead of None when nothing matches, also match to end
2275 return [] instead of None when nothing matches, also match to end
2248 of line. Patch by Gary Bishop.
2276 of line. Patch by Gary Bishop.
2249
2277
2250 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2278 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2251 protection as before, for files passed on the command line. This
2279 protection as before, for files passed on the command line. This
2252 prevents the CrashHandler from kicking in if user files call into
2280 prevents the CrashHandler from kicking in if user files call into
2253 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2281 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2254 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2282 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2255
2283
2256 2003-05-20 *** Released version 0.4.0
2284 2003-05-20 *** Released version 0.4.0
2257
2285
2258 2003-05-20 Fernando Perez <fperez@colorado.edu>
2286 2003-05-20 Fernando Perez <fperez@colorado.edu>
2259
2287
2260 * setup.py: added support for manpages. It's a bit hackish b/c of
2288 * setup.py: added support for manpages. It's a bit hackish b/c of
2261 a bug in the way the bdist_rpm distutils target handles gzipped
2289 a bug in the way the bdist_rpm distutils target handles gzipped
2262 manpages, but it works. After a patch by Jack.
2290 manpages, but it works. After a patch by Jack.
2263
2291
2264 2003-05-19 Fernando Perez <fperez@colorado.edu>
2292 2003-05-19 Fernando Perez <fperez@colorado.edu>
2265
2293
2266 * IPython/numutils.py: added a mockup of the kinds module, since
2294 * IPython/numutils.py: added a mockup of the kinds module, since
2267 it was recently removed from Numeric. This way, numutils will
2295 it was recently removed from Numeric. This way, numutils will
2268 work for all users even if they are missing kinds.
2296 work for all users even if they are missing kinds.
2269
2297
2270 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2298 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2271 failure, which can occur with SWIG-wrapped extensions. After a
2299 failure, which can occur with SWIG-wrapped extensions. After a
2272 crash report from Prabhu.
2300 crash report from Prabhu.
2273
2301
2274 2003-05-16 Fernando Perez <fperez@colorado.edu>
2302 2003-05-16 Fernando Perez <fperez@colorado.edu>
2275
2303
2276 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2304 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2277 protect ipython from user code which may call directly
2305 protect ipython from user code which may call directly
2278 sys.excepthook (this looks like an ipython crash to the user, even
2306 sys.excepthook (this looks like an ipython crash to the user, even
2279 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2307 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2280 This is especially important to help users of WxWindows, but may
2308 This is especially important to help users of WxWindows, but may
2281 also be useful in other cases.
2309 also be useful in other cases.
2282
2310
2283 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2311 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2284 an optional tb_offset to be specified, and to preserve exception
2312 an optional tb_offset to be specified, and to preserve exception
2285 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2313 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2286
2314
2287 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2315 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2288
2316
2289 2003-05-15 Fernando Perez <fperez@colorado.edu>
2317 2003-05-15 Fernando Perez <fperez@colorado.edu>
2290
2318
2291 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2319 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2292 installing for a new user under Windows.
2320 installing for a new user under Windows.
2293
2321
2294 2003-05-12 Fernando Perez <fperez@colorado.edu>
2322 2003-05-12 Fernando Perez <fperez@colorado.edu>
2295
2323
2296 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2324 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2297 handler for Emacs comint-based lines. Currently it doesn't do
2325 handler for Emacs comint-based lines. Currently it doesn't do
2298 much (but importantly, it doesn't update the history cache). In
2326 much (but importantly, it doesn't update the history cache). In
2299 the future it may be expanded if Alex needs more functionality
2327 the future it may be expanded if Alex needs more functionality
2300 there.
2328 there.
2301
2329
2302 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2330 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2303 info to crash reports.
2331 info to crash reports.
2304
2332
2305 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2333 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2306 just like Python's -c. Also fixed crash with invalid -color
2334 just like Python's -c. Also fixed crash with invalid -color
2307 option value at startup. Thanks to Will French
2335 option value at startup. Thanks to Will French
2308 <wfrench-AT-bestweb.net> for the bug report.
2336 <wfrench-AT-bestweb.net> for the bug report.
2309
2337
2310 2003-05-09 Fernando Perez <fperez@colorado.edu>
2338 2003-05-09 Fernando Perez <fperez@colorado.edu>
2311
2339
2312 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2340 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2313 to EvalDict (it's a mapping, after all) and simplified its code
2341 to EvalDict (it's a mapping, after all) and simplified its code
2314 quite a bit, after a nice discussion on c.l.py where Gustavo
2342 quite a bit, after a nice discussion on c.l.py where Gustavo
2315 Córdova <gcordova-AT-sismex.com> suggested the new version.
2343 Córdova <gcordova-AT-sismex.com> suggested the new version.
2316
2344
2317 2003-04-30 Fernando Perez <fperez@colorado.edu>
2345 2003-04-30 Fernando Perez <fperez@colorado.edu>
2318
2346
2319 * IPython/genutils.py (timings_out): modified it to reduce its
2347 * IPython/genutils.py (timings_out): modified it to reduce its
2320 overhead in the common reps==1 case.
2348 overhead in the common reps==1 case.
2321
2349
2322 2003-04-29 Fernando Perez <fperez@colorado.edu>
2350 2003-04-29 Fernando Perez <fperez@colorado.edu>
2323
2351
2324 * IPython/genutils.py (timings_out): Modified to use the resource
2352 * IPython/genutils.py (timings_out): Modified to use the resource
2325 module, which avoids the wraparound problems of time.clock().
2353 module, which avoids the wraparound problems of time.clock().
2326
2354
2327 2003-04-17 *** Released version 0.2.15pre4
2355 2003-04-17 *** Released version 0.2.15pre4
2328
2356
2329 2003-04-17 Fernando Perez <fperez@colorado.edu>
2357 2003-04-17 Fernando Perez <fperez@colorado.edu>
2330
2358
2331 * setup.py (scriptfiles): Split windows-specific stuff over to a
2359 * setup.py (scriptfiles): Split windows-specific stuff over to a
2332 separate file, in an attempt to have a Windows GUI installer.
2360 separate file, in an attempt to have a Windows GUI installer.
2333 That didn't work, but part of the groundwork is done.
2361 That didn't work, but part of the groundwork is done.
2334
2362
2335 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2363 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2336 indent/unindent with 4 spaces. Particularly useful in combination
2364 indent/unindent with 4 spaces. Particularly useful in combination
2337 with the new auto-indent option.
2365 with the new auto-indent option.
2338
2366
2339 2003-04-16 Fernando Perez <fperez@colorado.edu>
2367 2003-04-16 Fernando Perez <fperez@colorado.edu>
2340
2368
2341 * IPython/Magic.py: various replacements of self.rc for
2369 * IPython/Magic.py: various replacements of self.rc for
2342 self.shell.rc. A lot more remains to be done to fully disentangle
2370 self.shell.rc. A lot more remains to be done to fully disentangle
2343 this class from the main Shell class.
2371 this class from the main Shell class.
2344
2372
2345 * IPython/GnuplotRuntime.py: added checks for mouse support so
2373 * IPython/GnuplotRuntime.py: added checks for mouse support so
2346 that we don't try to enable it if the current gnuplot doesn't
2374 that we don't try to enable it if the current gnuplot doesn't
2347 really support it. Also added checks so that we don't try to
2375 really support it. Also added checks so that we don't try to
2348 enable persist under Windows (where Gnuplot doesn't recognize the
2376 enable persist under Windows (where Gnuplot doesn't recognize the
2349 option).
2377 option).
2350
2378
2351 * IPython/iplib.py (InteractiveShell.interact): Added optional
2379 * IPython/iplib.py (InteractiveShell.interact): Added optional
2352 auto-indenting code, after a patch by King C. Shu
2380 auto-indenting code, after a patch by King C. Shu
2353 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2381 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2354 get along well with pasting indented code. If I ever figure out
2382 get along well with pasting indented code. If I ever figure out
2355 how to make that part go well, it will become on by default.
2383 how to make that part go well, it will become on by default.
2356
2384
2357 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2385 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2358 crash ipython if there was an unmatched '%' in the user's prompt
2386 crash ipython if there was an unmatched '%' in the user's prompt
2359 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2387 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2360
2388
2361 * IPython/iplib.py (InteractiveShell.interact): removed the
2389 * IPython/iplib.py (InteractiveShell.interact): removed the
2362 ability to ask the user whether he wants to crash or not at the
2390 ability to ask the user whether he wants to crash or not at the
2363 'last line' exception handler. Calling functions at that point
2391 'last line' exception handler. Calling functions at that point
2364 changes the stack, and the error reports would have incorrect
2392 changes the stack, and the error reports would have incorrect
2365 tracebacks.
2393 tracebacks.
2366
2394
2367 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2395 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2368 pass through a peger a pretty-printed form of any object. After a
2396 pass through a peger a pretty-printed form of any object. After a
2369 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2397 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2370
2398
2371 2003-04-14 Fernando Perez <fperez@colorado.edu>
2399 2003-04-14 Fernando Perez <fperez@colorado.edu>
2372
2400
2373 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2401 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2374 all files in ~ would be modified at first install (instead of
2402 all files in ~ would be modified at first install (instead of
2375 ~/.ipython). This could be potentially disastrous, as the
2403 ~/.ipython). This could be potentially disastrous, as the
2376 modification (make line-endings native) could damage binary files.
2404 modification (make line-endings native) could damage binary files.
2377
2405
2378 2003-04-10 Fernando Perez <fperez@colorado.edu>
2406 2003-04-10 Fernando Perez <fperez@colorado.edu>
2379
2407
2380 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2408 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2381 handle only lines which are invalid python. This now means that
2409 handle only lines which are invalid python. This now means that
2382 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2410 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2383 for the bug report.
2411 for the bug report.
2384
2412
2385 2003-04-01 Fernando Perez <fperez@colorado.edu>
2413 2003-04-01 Fernando Perez <fperez@colorado.edu>
2386
2414
2387 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2415 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2388 where failing to set sys.last_traceback would crash pdb.pm().
2416 where failing to set sys.last_traceback would crash pdb.pm().
2389 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2417 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2390 report.
2418 report.
2391
2419
2392 2003-03-25 Fernando Perez <fperez@colorado.edu>
2420 2003-03-25 Fernando Perez <fperez@colorado.edu>
2393
2421
2394 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2422 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2395 before printing it (it had a lot of spurious blank lines at the
2423 before printing it (it had a lot of spurious blank lines at the
2396 end).
2424 end).
2397
2425
2398 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2426 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2399 output would be sent 21 times! Obviously people don't use this
2427 output would be sent 21 times! Obviously people don't use this
2400 too often, or I would have heard about it.
2428 too often, or I would have heard about it.
2401
2429
2402 2003-03-24 Fernando Perez <fperez@colorado.edu>
2430 2003-03-24 Fernando Perez <fperez@colorado.edu>
2403
2431
2404 * setup.py (scriptfiles): renamed the data_files parameter from
2432 * setup.py (scriptfiles): renamed the data_files parameter from
2405 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2433 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2406 for the patch.
2434 for the patch.
2407
2435
2408 2003-03-20 Fernando Perez <fperez@colorado.edu>
2436 2003-03-20 Fernando Perez <fperez@colorado.edu>
2409
2437
2410 * IPython/genutils.py (error): added error() and fatal()
2438 * IPython/genutils.py (error): added error() and fatal()
2411 functions.
2439 functions.
2412
2440
2413 2003-03-18 *** Released version 0.2.15pre3
2441 2003-03-18 *** Released version 0.2.15pre3
2414
2442
2415 2003-03-18 Fernando Perez <fperez@colorado.edu>
2443 2003-03-18 Fernando Perez <fperez@colorado.edu>
2416
2444
2417 * setupext/install_data_ext.py
2445 * setupext/install_data_ext.py
2418 (install_data_ext.initialize_options): Class contributed by Jack
2446 (install_data_ext.initialize_options): Class contributed by Jack
2419 Moffit for fixing the old distutils hack. He is sending this to
2447 Moffit for fixing the old distutils hack. He is sending this to
2420 the distutils folks so in the future we may not need it as a
2448 the distutils folks so in the future we may not need it as a
2421 private fix.
2449 private fix.
2422
2450
2423 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2451 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2424 changes for Debian packaging. See his patch for full details.
2452 changes for Debian packaging. See his patch for full details.
2425 The old distutils hack of making the ipythonrc* files carry a
2453 The old distutils hack of making the ipythonrc* files carry a
2426 bogus .py extension is gone, at last. Examples were moved to a
2454 bogus .py extension is gone, at last. Examples were moved to a
2427 separate subdir under doc/, and the separate executable scripts
2455 separate subdir under doc/, and the separate executable scripts
2428 now live in their own directory. Overall a great cleanup. The
2456 now live in their own directory. Overall a great cleanup. The
2429 manual was updated to use the new files, and setup.py has been
2457 manual was updated to use the new files, and setup.py has been
2430 fixed for this setup.
2458 fixed for this setup.
2431
2459
2432 * IPython/PyColorize.py (Parser.usage): made non-executable and
2460 * IPython/PyColorize.py (Parser.usage): made non-executable and
2433 created a pycolor wrapper around it to be included as a script.
2461 created a pycolor wrapper around it to be included as a script.
2434
2462
2435 2003-03-12 *** Released version 0.2.15pre2
2463 2003-03-12 *** Released version 0.2.15pre2
2436
2464
2437 2003-03-12 Fernando Perez <fperez@colorado.edu>
2465 2003-03-12 Fernando Perez <fperez@colorado.edu>
2438
2466
2439 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2467 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2440 long-standing problem with garbage characters in some terminals.
2468 long-standing problem with garbage characters in some terminals.
2441 The issue was really that the \001 and \002 escapes must _only_ be
2469 The issue was really that the \001 and \002 escapes must _only_ be
2442 passed to input prompts (which call readline), but _never_ to
2470 passed to input prompts (which call readline), but _never_ to
2443 normal text to be printed on screen. I changed ColorANSI to have
2471 normal text to be printed on screen. I changed ColorANSI to have
2444 two classes: TermColors and InputTermColors, each with the
2472 two classes: TermColors and InputTermColors, each with the
2445 appropriate escapes for input prompts or normal text. The code in
2473 appropriate escapes for input prompts or normal text. The code in
2446 Prompts.py got slightly more complicated, but this very old and
2474 Prompts.py got slightly more complicated, but this very old and
2447 annoying bug is finally fixed.
2475 annoying bug is finally fixed.
2448
2476
2449 All the credit for nailing down the real origin of this problem
2477 All the credit for nailing down the real origin of this problem
2450 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2478 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2451 *Many* thanks to him for spending quite a bit of effort on this.
2479 *Many* thanks to him for spending quite a bit of effort on this.
2452
2480
2453 2003-03-05 *** Released version 0.2.15pre1
2481 2003-03-05 *** Released version 0.2.15pre1
2454
2482
2455 2003-03-03 Fernando Perez <fperez@colorado.edu>
2483 2003-03-03 Fernando Perez <fperez@colorado.edu>
2456
2484
2457 * IPython/FakeModule.py: Moved the former _FakeModule to a
2485 * IPython/FakeModule.py: Moved the former _FakeModule to a
2458 separate file, because it's also needed by Magic (to fix a similar
2486 separate file, because it's also needed by Magic (to fix a similar
2459 pickle-related issue in @run).
2487 pickle-related issue in @run).
2460
2488
2461 2003-03-02 Fernando Perez <fperez@colorado.edu>
2489 2003-03-02 Fernando Perez <fperez@colorado.edu>
2462
2490
2463 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2491 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2464 the autocall option at runtime.
2492 the autocall option at runtime.
2465 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2493 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2466 across Magic.py to start separating Magic from InteractiveShell.
2494 across Magic.py to start separating Magic from InteractiveShell.
2467 (Magic._ofind): Fixed to return proper namespace for dotted
2495 (Magic._ofind): Fixed to return proper namespace for dotted
2468 names. Before, a dotted name would always return 'not currently
2496 names. Before, a dotted name would always return 'not currently
2469 defined', because it would find the 'parent'. s.x would be found,
2497 defined', because it would find the 'parent'. s.x would be found,
2470 but since 'x' isn't defined by itself, it would get confused.
2498 but since 'x' isn't defined by itself, it would get confused.
2471 (Magic.magic_run): Fixed pickling problems reported by Ralf
2499 (Magic.magic_run): Fixed pickling problems reported by Ralf
2472 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2500 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2473 that I'd used when Mike Heeter reported similar issues at the
2501 that I'd used when Mike Heeter reported similar issues at the
2474 top-level, but now for @run. It boils down to injecting the
2502 top-level, but now for @run. It boils down to injecting the
2475 namespace where code is being executed with something that looks
2503 namespace where code is being executed with something that looks
2476 enough like a module to fool pickle.dump(). Since a pickle stores
2504 enough like a module to fool pickle.dump(). Since a pickle stores
2477 a named reference to the importing module, we need this for
2505 a named reference to the importing module, we need this for
2478 pickles to save something sensible.
2506 pickles to save something sensible.
2479
2507
2480 * IPython/ipmaker.py (make_IPython): added an autocall option.
2508 * IPython/ipmaker.py (make_IPython): added an autocall option.
2481
2509
2482 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2510 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2483 the auto-eval code. Now autocalling is an option, and the code is
2511 the auto-eval code. Now autocalling is an option, and the code is
2484 also vastly safer. There is no more eval() involved at all.
2512 also vastly safer. There is no more eval() involved at all.
2485
2513
2486 2003-03-01 Fernando Perez <fperez@colorado.edu>
2514 2003-03-01 Fernando Perez <fperez@colorado.edu>
2487
2515
2488 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2516 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2489 dict with named keys instead of a tuple.
2517 dict with named keys instead of a tuple.
2490
2518
2491 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2519 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2492
2520
2493 * setup.py (make_shortcut): Fixed message about directories
2521 * setup.py (make_shortcut): Fixed message about directories
2494 created during Windows installation (the directories were ok, just
2522 created during Windows installation (the directories were ok, just
2495 the printed message was misleading). Thanks to Chris Liechti
2523 the printed message was misleading). Thanks to Chris Liechti
2496 <cliechti-AT-gmx.net> for the heads up.
2524 <cliechti-AT-gmx.net> for the heads up.
2497
2525
2498 2003-02-21 Fernando Perez <fperez@colorado.edu>
2526 2003-02-21 Fernando Perez <fperez@colorado.edu>
2499
2527
2500 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2528 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2501 of ValueError exception when checking for auto-execution. This
2529 of ValueError exception when checking for auto-execution. This
2502 one is raised by things like Numeric arrays arr.flat when the
2530 one is raised by things like Numeric arrays arr.flat when the
2503 array is non-contiguous.
2531 array is non-contiguous.
2504
2532
2505 2003-01-31 Fernando Perez <fperez@colorado.edu>
2533 2003-01-31 Fernando Perez <fperez@colorado.edu>
2506
2534
2507 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2535 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2508 not return any value at all (even though the command would get
2536 not return any value at all (even though the command would get
2509 executed).
2537 executed).
2510 (xsys): Flush stdout right after printing the command to ensure
2538 (xsys): Flush stdout right after printing the command to ensure
2511 proper ordering of commands and command output in the total
2539 proper ordering of commands and command output in the total
2512 output.
2540 output.
2513 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2541 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2514 system/getoutput as defaults. The old ones are kept for
2542 system/getoutput as defaults. The old ones are kept for
2515 compatibility reasons, so no code which uses this library needs
2543 compatibility reasons, so no code which uses this library needs
2516 changing.
2544 changing.
2517
2545
2518 2003-01-27 *** Released version 0.2.14
2546 2003-01-27 *** Released version 0.2.14
2519
2547
2520 2003-01-25 Fernando Perez <fperez@colorado.edu>
2548 2003-01-25 Fernando Perez <fperez@colorado.edu>
2521
2549
2522 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2550 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2523 functions defined in previous edit sessions could not be re-edited
2551 functions defined in previous edit sessions could not be re-edited
2524 (because the temp files were immediately removed). Now temp files
2552 (because the temp files were immediately removed). Now temp files
2525 are removed only at IPython's exit.
2553 are removed only at IPython's exit.
2526 (Magic.magic_run): Improved @run to perform shell-like expansions
2554 (Magic.magic_run): Improved @run to perform shell-like expansions
2527 on its arguments (~users and $VARS). With this, @run becomes more
2555 on its arguments (~users and $VARS). With this, @run becomes more
2528 like a normal command-line.
2556 like a normal command-line.
2529
2557
2530 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2558 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2531 bugs related to embedding and cleaned up that code. A fairly
2559 bugs related to embedding and cleaned up that code. A fairly
2532 important one was the impossibility to access the global namespace
2560 important one was the impossibility to access the global namespace
2533 through the embedded IPython (only local variables were visible).
2561 through the embedded IPython (only local variables were visible).
2534
2562
2535 2003-01-14 Fernando Perez <fperez@colorado.edu>
2563 2003-01-14 Fernando Perez <fperez@colorado.edu>
2536
2564
2537 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2565 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2538 auto-calling to be a bit more conservative. Now it doesn't get
2566 auto-calling to be a bit more conservative. Now it doesn't get
2539 triggered if any of '!=()<>' are in the rest of the input line, to
2567 triggered if any of '!=()<>' are in the rest of the input line, to
2540 allow comparing callables. Thanks to Alex for the heads up.
2568 allow comparing callables. Thanks to Alex for the heads up.
2541
2569
2542 2003-01-07 Fernando Perez <fperez@colorado.edu>
2570 2003-01-07 Fernando Perez <fperez@colorado.edu>
2543
2571
2544 * IPython/genutils.py (page): fixed estimation of the number of
2572 * IPython/genutils.py (page): fixed estimation of the number of
2545 lines in a string to be paged to simply count newlines. This
2573 lines in a string to be paged to simply count newlines. This
2546 prevents over-guessing due to embedded escape sequences. A better
2574 prevents over-guessing due to embedded escape sequences. A better
2547 long-term solution would involve stripping out the control chars
2575 long-term solution would involve stripping out the control chars
2548 for the count, but it's potentially so expensive I just don't
2576 for the count, but it's potentially so expensive I just don't
2549 think it's worth doing.
2577 think it's worth doing.
2550
2578
2551 2002-12-19 *** Released version 0.2.14pre50
2579 2002-12-19 *** Released version 0.2.14pre50
2552
2580
2553 2002-12-19 Fernando Perez <fperez@colorado.edu>
2581 2002-12-19 Fernando Perez <fperez@colorado.edu>
2554
2582
2555 * tools/release (version): Changed release scripts to inform
2583 * tools/release (version): Changed release scripts to inform
2556 Andrea and build a NEWS file with a list of recent changes.
2584 Andrea and build a NEWS file with a list of recent changes.
2557
2585
2558 * IPython/ColorANSI.py (__all__): changed terminal detection
2586 * IPython/ColorANSI.py (__all__): changed terminal detection
2559 code. Seems to work better for xterms without breaking
2587 code. Seems to work better for xterms without breaking
2560 konsole. Will need more testing to determine if WinXP and Mac OSX
2588 konsole. Will need more testing to determine if WinXP and Mac OSX
2561 also work ok.
2589 also work ok.
2562
2590
2563 2002-12-18 *** Released version 0.2.14pre49
2591 2002-12-18 *** Released version 0.2.14pre49
2564
2592
2565 2002-12-18 Fernando Perez <fperez@colorado.edu>
2593 2002-12-18 Fernando Perez <fperez@colorado.edu>
2566
2594
2567 * Docs: added new info about Mac OSX, from Andrea.
2595 * Docs: added new info about Mac OSX, from Andrea.
2568
2596
2569 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2597 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2570 allow direct plotting of python strings whose format is the same
2598 allow direct plotting of python strings whose format is the same
2571 of gnuplot data files.
2599 of gnuplot data files.
2572
2600
2573 2002-12-16 Fernando Perez <fperez@colorado.edu>
2601 2002-12-16 Fernando Perez <fperez@colorado.edu>
2574
2602
2575 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2603 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2576 value of exit question to be acknowledged.
2604 value of exit question to be acknowledged.
2577
2605
2578 2002-12-03 Fernando Perez <fperez@colorado.edu>
2606 2002-12-03 Fernando Perez <fperez@colorado.edu>
2579
2607
2580 * IPython/ipmaker.py: removed generators, which had been added
2608 * IPython/ipmaker.py: removed generators, which had been added
2581 by mistake in an earlier debugging run. This was causing trouble
2609 by mistake in an earlier debugging run. This was causing trouble
2582 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2610 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2583 for pointing this out.
2611 for pointing this out.
2584
2612
2585 2002-11-17 Fernando Perez <fperez@colorado.edu>
2613 2002-11-17 Fernando Perez <fperez@colorado.edu>
2586
2614
2587 * Manual: updated the Gnuplot section.
2615 * Manual: updated the Gnuplot section.
2588
2616
2589 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2617 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2590 a much better split of what goes in Runtime and what goes in
2618 a much better split of what goes in Runtime and what goes in
2591 Interactive.
2619 Interactive.
2592
2620
2593 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2621 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2594 being imported from iplib.
2622 being imported from iplib.
2595
2623
2596 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2624 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2597 for command-passing. Now the global Gnuplot instance is called
2625 for command-passing. Now the global Gnuplot instance is called
2598 'gp' instead of 'g', which was really a far too fragile and
2626 'gp' instead of 'g', which was really a far too fragile and
2599 common name.
2627 common name.
2600
2628
2601 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2629 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2602 bounding boxes generated by Gnuplot for square plots.
2630 bounding boxes generated by Gnuplot for square plots.
2603
2631
2604 * IPython/genutils.py (popkey): new function added. I should
2632 * IPython/genutils.py (popkey): new function added. I should
2605 suggest this on c.l.py as a dict method, it seems useful.
2633 suggest this on c.l.py as a dict method, it seems useful.
2606
2634
2607 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2635 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2608 to transparently handle PostScript generation. MUCH better than
2636 to transparently handle PostScript generation. MUCH better than
2609 the previous plot_eps/replot_eps (which I removed now). The code
2637 the previous plot_eps/replot_eps (which I removed now). The code
2610 is also fairly clean and well documented now (including
2638 is also fairly clean and well documented now (including
2611 docstrings).
2639 docstrings).
2612
2640
2613 2002-11-13 Fernando Perez <fperez@colorado.edu>
2641 2002-11-13 Fernando Perez <fperez@colorado.edu>
2614
2642
2615 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2643 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2616 (inconsistent with options).
2644 (inconsistent with options).
2617
2645
2618 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2646 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2619 manually disabled, I don't know why. Fixed it.
2647 manually disabled, I don't know why. Fixed it.
2620 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2648 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2621 eps output.
2649 eps output.
2622
2650
2623 2002-11-12 Fernando Perez <fperez@colorado.edu>
2651 2002-11-12 Fernando Perez <fperez@colorado.edu>
2624
2652
2625 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2653 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2626 don't propagate up to caller. Fixes crash reported by François
2654 don't propagate up to caller. Fixes crash reported by François
2627 Pinard.
2655 Pinard.
2628
2656
2629 2002-11-09 Fernando Perez <fperez@colorado.edu>
2657 2002-11-09 Fernando Perez <fperez@colorado.edu>
2630
2658
2631 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2659 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2632 history file for new users.
2660 history file for new users.
2633 (make_IPython): fixed bug where initial install would leave the
2661 (make_IPython): fixed bug where initial install would leave the
2634 user running in the .ipython dir.
2662 user running in the .ipython dir.
2635 (make_IPython): fixed bug where config dir .ipython would be
2663 (make_IPython): fixed bug where config dir .ipython would be
2636 created regardless of the given -ipythondir option. Thanks to Cory
2664 created regardless of the given -ipythondir option. Thanks to Cory
2637 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2665 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2638
2666
2639 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2667 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2640 type confirmations. Will need to use it in all of IPython's code
2668 type confirmations. Will need to use it in all of IPython's code
2641 consistently.
2669 consistently.
2642
2670
2643 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2671 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2644 context to print 31 lines instead of the default 5. This will make
2672 context to print 31 lines instead of the default 5. This will make
2645 the crash reports extremely detailed in case the problem is in
2673 the crash reports extremely detailed in case the problem is in
2646 libraries I don't have access to.
2674 libraries I don't have access to.
2647
2675
2648 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2676 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2649 line of defense' code to still crash, but giving users fair
2677 line of defense' code to still crash, but giving users fair
2650 warning. I don't want internal errors to go unreported: if there's
2678 warning. I don't want internal errors to go unreported: if there's
2651 an internal problem, IPython should crash and generate a full
2679 an internal problem, IPython should crash and generate a full
2652 report.
2680 report.
2653
2681
2654 2002-11-08 Fernando Perez <fperez@colorado.edu>
2682 2002-11-08 Fernando Perez <fperez@colorado.edu>
2655
2683
2656 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2684 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2657 otherwise uncaught exceptions which can appear if people set
2685 otherwise uncaught exceptions which can appear if people set
2658 sys.stdout to something badly broken. Thanks to a crash report
2686 sys.stdout to something badly broken. Thanks to a crash report
2659 from henni-AT-mail.brainbot.com.
2687 from henni-AT-mail.brainbot.com.
2660
2688
2661 2002-11-04 Fernando Perez <fperez@colorado.edu>
2689 2002-11-04 Fernando Perez <fperez@colorado.edu>
2662
2690
2663 * IPython/iplib.py (InteractiveShell.interact): added
2691 * IPython/iplib.py (InteractiveShell.interact): added
2664 __IPYTHON__active to the builtins. It's a flag which goes on when
2692 __IPYTHON__active to the builtins. It's a flag which goes on when
2665 the interaction starts and goes off again when it stops. This
2693 the interaction starts and goes off again when it stops. This
2666 allows embedding code to detect being inside IPython. Before this
2694 allows embedding code to detect being inside IPython. Before this
2667 was done via __IPYTHON__, but that only shows that an IPython
2695 was done via __IPYTHON__, but that only shows that an IPython
2668 instance has been created.
2696 instance has been created.
2669
2697
2670 * IPython/Magic.py (Magic.magic_env): I realized that in a
2698 * IPython/Magic.py (Magic.magic_env): I realized that in a
2671 UserDict, instance.data holds the data as a normal dict. So I
2699 UserDict, instance.data holds the data as a normal dict. So I
2672 modified @env to return os.environ.data instead of rebuilding a
2700 modified @env to return os.environ.data instead of rebuilding a
2673 dict by hand.
2701 dict by hand.
2674
2702
2675 2002-11-02 Fernando Perez <fperez@colorado.edu>
2703 2002-11-02 Fernando Perez <fperez@colorado.edu>
2676
2704
2677 * IPython/genutils.py (warn): changed so that level 1 prints no
2705 * IPython/genutils.py (warn): changed so that level 1 prints no
2678 header. Level 2 is now the default (with 'WARNING' header, as
2706 header. Level 2 is now the default (with 'WARNING' header, as
2679 before). I think I tracked all places where changes were needed in
2707 before). I think I tracked all places where changes were needed in
2680 IPython, but outside code using the old level numbering may have
2708 IPython, but outside code using the old level numbering may have
2681 broken.
2709 broken.
2682
2710
2683 * IPython/iplib.py (InteractiveShell.runcode): added this to
2711 * IPython/iplib.py (InteractiveShell.runcode): added this to
2684 handle the tracebacks in SystemExit traps correctly. The previous
2712 handle the tracebacks in SystemExit traps correctly. The previous
2685 code (through interact) was printing more of the stack than
2713 code (through interact) was printing more of the stack than
2686 necessary, showing IPython internal code to the user.
2714 necessary, showing IPython internal code to the user.
2687
2715
2688 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2716 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2689 default. Now that the default at the confirmation prompt is yes,
2717 default. Now that the default at the confirmation prompt is yes,
2690 it's not so intrusive. François' argument that ipython sessions
2718 it's not so intrusive. François' argument that ipython sessions
2691 tend to be complex enough not to lose them from an accidental C-d,
2719 tend to be complex enough not to lose them from an accidental C-d,
2692 is a valid one.
2720 is a valid one.
2693
2721
2694 * IPython/iplib.py (InteractiveShell.interact): added a
2722 * IPython/iplib.py (InteractiveShell.interact): added a
2695 showtraceback() call to the SystemExit trap, and modified the exit
2723 showtraceback() call to the SystemExit trap, and modified the exit
2696 confirmation to have yes as the default.
2724 confirmation to have yes as the default.
2697
2725
2698 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2726 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2699 this file. It's been gone from the code for a long time, this was
2727 this file. It's been gone from the code for a long time, this was
2700 simply leftover junk.
2728 simply leftover junk.
2701
2729
2702 2002-11-01 Fernando Perez <fperez@colorado.edu>
2730 2002-11-01 Fernando Perez <fperez@colorado.edu>
2703
2731
2704 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2732 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2705 added. If set, IPython now traps EOF and asks for
2733 added. If set, IPython now traps EOF and asks for
2706 confirmation. After a request by François Pinard.
2734 confirmation. After a request by François Pinard.
2707
2735
2708 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2736 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2709 of @abort, and with a new (better) mechanism for handling the
2737 of @abort, and with a new (better) mechanism for handling the
2710 exceptions.
2738 exceptions.
2711
2739
2712 2002-10-27 Fernando Perez <fperez@colorado.edu>
2740 2002-10-27 Fernando Perez <fperez@colorado.edu>
2713
2741
2714 * IPython/usage.py (__doc__): updated the --help information and
2742 * IPython/usage.py (__doc__): updated the --help information and
2715 the ipythonrc file to indicate that -log generates
2743 the ipythonrc file to indicate that -log generates
2716 ./ipython.log. Also fixed the corresponding info in @logstart.
2744 ./ipython.log. Also fixed the corresponding info in @logstart.
2717 This and several other fixes in the manuals thanks to reports by
2745 This and several other fixes in the manuals thanks to reports by
2718 François Pinard <pinard-AT-iro.umontreal.ca>.
2746 François Pinard <pinard-AT-iro.umontreal.ca>.
2719
2747
2720 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2748 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2721 refer to @logstart (instead of @log, which doesn't exist).
2749 refer to @logstart (instead of @log, which doesn't exist).
2722
2750
2723 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2751 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2724 AttributeError crash. Thanks to Christopher Armstrong
2752 AttributeError crash. Thanks to Christopher Armstrong
2725 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2753 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2726 introduced recently (in 0.2.14pre37) with the fix to the eval
2754 introduced recently (in 0.2.14pre37) with the fix to the eval
2727 problem mentioned below.
2755 problem mentioned below.
2728
2756
2729 2002-10-17 Fernando Perez <fperez@colorado.edu>
2757 2002-10-17 Fernando Perez <fperez@colorado.edu>
2730
2758
2731 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2759 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2732 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2760 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2733
2761
2734 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2762 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2735 this function to fix a problem reported by Alex Schmolck. He saw
2763 this function to fix a problem reported by Alex Schmolck. He saw
2736 it with list comprehensions and generators, which were getting
2764 it with list comprehensions and generators, which were getting
2737 called twice. The real problem was an 'eval' call in testing for
2765 called twice. The real problem was an 'eval' call in testing for
2738 automagic which was evaluating the input line silently.
2766 automagic which was evaluating the input line silently.
2739
2767
2740 This is a potentially very nasty bug, if the input has side
2768 This is a potentially very nasty bug, if the input has side
2741 effects which must not be repeated. The code is much cleaner now,
2769 effects which must not be repeated. The code is much cleaner now,
2742 without any blanket 'except' left and with a regexp test for
2770 without any blanket 'except' left and with a regexp test for
2743 actual function names.
2771 actual function names.
2744
2772
2745 But an eval remains, which I'm not fully comfortable with. I just
2773 But an eval remains, which I'm not fully comfortable with. I just
2746 don't know how to find out if an expression could be a callable in
2774 don't know how to find out if an expression could be a callable in
2747 the user's namespace without doing an eval on the string. However
2775 the user's namespace without doing an eval on the string. However
2748 that string is now much more strictly checked so that no code
2776 that string is now much more strictly checked so that no code
2749 slips by, so the eval should only happen for things that can
2777 slips by, so the eval should only happen for things that can
2750 really be only function/method names.
2778 really be only function/method names.
2751
2779
2752 2002-10-15 Fernando Perez <fperez@colorado.edu>
2780 2002-10-15 Fernando Perez <fperez@colorado.edu>
2753
2781
2754 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2782 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2755 OSX information to main manual, removed README_Mac_OSX file from
2783 OSX information to main manual, removed README_Mac_OSX file from
2756 distribution. Also updated credits for recent additions.
2784 distribution. Also updated credits for recent additions.
2757
2785
2758 2002-10-10 Fernando Perez <fperez@colorado.edu>
2786 2002-10-10 Fernando Perez <fperez@colorado.edu>
2759
2787
2760 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2788 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2761 terminal-related issues. Many thanks to Andrea Riciputi
2789 terminal-related issues. Many thanks to Andrea Riciputi
2762 <andrea.riciputi-AT-libero.it> for writing it.
2790 <andrea.riciputi-AT-libero.it> for writing it.
2763
2791
2764 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2792 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2765 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2793 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2766
2794
2767 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2795 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2768 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2796 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2769 <syver-en-AT-online.no> who both submitted patches for this problem.
2797 <syver-en-AT-online.no> who both submitted patches for this problem.
2770
2798
2771 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2799 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2772 global embedding to make sure that things don't overwrite user
2800 global embedding to make sure that things don't overwrite user
2773 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2801 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2774
2802
2775 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2803 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2776 compatibility. Thanks to Hayden Callow
2804 compatibility. Thanks to Hayden Callow
2777 <h.callow-AT-elec.canterbury.ac.nz>
2805 <h.callow-AT-elec.canterbury.ac.nz>
2778
2806
2779 2002-10-04 Fernando Perez <fperez@colorado.edu>
2807 2002-10-04 Fernando Perez <fperez@colorado.edu>
2780
2808
2781 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2809 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2782 Gnuplot.File objects.
2810 Gnuplot.File objects.
2783
2811
2784 2002-07-23 Fernando Perez <fperez@colorado.edu>
2812 2002-07-23 Fernando Perez <fperez@colorado.edu>
2785
2813
2786 * IPython/genutils.py (timing): Added timings() and timing() for
2814 * IPython/genutils.py (timing): Added timings() and timing() for
2787 quick access to the most commonly needed data, the execution
2815 quick access to the most commonly needed data, the execution
2788 times. Old timing() renamed to timings_out().
2816 times. Old timing() renamed to timings_out().
2789
2817
2790 2002-07-18 Fernando Perez <fperez@colorado.edu>
2818 2002-07-18 Fernando Perez <fperez@colorado.edu>
2791
2819
2792 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2820 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2793 bug with nested instances disrupting the parent's tab completion.
2821 bug with nested instances disrupting the parent's tab completion.
2794
2822
2795 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2823 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2796 all_completions code to begin the emacs integration.
2824 all_completions code to begin the emacs integration.
2797
2825
2798 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2826 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2799 argument to allow titling individual arrays when plotting.
2827 argument to allow titling individual arrays when plotting.
2800
2828
2801 2002-07-15 Fernando Perez <fperez@colorado.edu>
2829 2002-07-15 Fernando Perez <fperez@colorado.edu>
2802
2830
2803 * setup.py (make_shortcut): changed to retrieve the value of
2831 * setup.py (make_shortcut): changed to retrieve the value of
2804 'Program Files' directory from the registry (this value changes in
2832 'Program Files' directory from the registry (this value changes in
2805 non-english versions of Windows). Thanks to Thomas Fanslau
2833 non-english versions of Windows). Thanks to Thomas Fanslau
2806 <tfanslau-AT-gmx.de> for the report.
2834 <tfanslau-AT-gmx.de> for the report.
2807
2835
2808 2002-07-10 Fernando Perez <fperez@colorado.edu>
2836 2002-07-10 Fernando Perez <fperez@colorado.edu>
2809
2837
2810 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2838 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2811 a bug in pdb, which crashes if a line with only whitespace is
2839 a bug in pdb, which crashes if a line with only whitespace is
2812 entered. Bug report submitted to sourceforge.
2840 entered. Bug report submitted to sourceforge.
2813
2841
2814 2002-07-09 Fernando Perez <fperez@colorado.edu>
2842 2002-07-09 Fernando Perez <fperez@colorado.edu>
2815
2843
2816 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2844 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2817 reporting exceptions (it's a bug in inspect.py, I just set a
2845 reporting exceptions (it's a bug in inspect.py, I just set a
2818 workaround).
2846 workaround).
2819
2847
2820 2002-07-08 Fernando Perez <fperez@colorado.edu>
2848 2002-07-08 Fernando Perez <fperez@colorado.edu>
2821
2849
2822 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2850 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2823 __IPYTHON__ in __builtins__ to show up in user_ns.
2851 __IPYTHON__ in __builtins__ to show up in user_ns.
2824
2852
2825 2002-07-03 Fernando Perez <fperez@colorado.edu>
2853 2002-07-03 Fernando Perez <fperez@colorado.edu>
2826
2854
2827 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2855 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2828 name from @gp_set_instance to @gp_set_default.
2856 name from @gp_set_instance to @gp_set_default.
2829
2857
2830 * IPython/ipmaker.py (make_IPython): default editor value set to
2858 * IPython/ipmaker.py (make_IPython): default editor value set to
2831 '0' (a string), to match the rc file. Otherwise will crash when
2859 '0' (a string), to match the rc file. Otherwise will crash when
2832 .strip() is called on it.
2860 .strip() is called on it.
2833
2861
2834
2862
2835 2002-06-28 Fernando Perez <fperez@colorado.edu>
2863 2002-06-28 Fernando Perez <fperez@colorado.edu>
2836
2864
2837 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2865 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2838 of files in current directory when a file is executed via
2866 of files in current directory when a file is executed via
2839 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2867 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2840
2868
2841 * setup.py (manfiles): fix for rpm builds, submitted by RA
2869 * setup.py (manfiles): fix for rpm builds, submitted by RA
2842 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2870 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2843
2871
2844 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2872 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2845 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2873 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2846 string!). A. Schmolck caught this one.
2874 string!). A. Schmolck caught this one.
2847
2875
2848 2002-06-27 Fernando Perez <fperez@colorado.edu>
2876 2002-06-27 Fernando Perez <fperez@colorado.edu>
2849
2877
2850 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2878 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2851 defined files at the cmd line. __name__ wasn't being set to
2879 defined files at the cmd line. __name__ wasn't being set to
2852 __main__.
2880 __main__.
2853
2881
2854 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2882 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2855 regular lists and tuples besides Numeric arrays.
2883 regular lists and tuples besides Numeric arrays.
2856
2884
2857 * IPython/Prompts.py (CachedOutput.__call__): Added output
2885 * IPython/Prompts.py (CachedOutput.__call__): Added output
2858 supression for input ending with ';'. Similar to Mathematica and
2886 supression for input ending with ';'. Similar to Mathematica and
2859 Matlab. The _* vars and Out[] list are still updated, just like
2887 Matlab. The _* vars and Out[] list are still updated, just like
2860 Mathematica behaves.
2888 Mathematica behaves.
2861
2889
2862 2002-06-25 Fernando Perez <fperez@colorado.edu>
2890 2002-06-25 Fernando Perez <fperez@colorado.edu>
2863
2891
2864 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2892 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2865 .ini extensions for profiels under Windows.
2893 .ini extensions for profiels under Windows.
2866
2894
2867 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2895 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2868 string form. Fix contributed by Alexander Schmolck
2896 string form. Fix contributed by Alexander Schmolck
2869 <a.schmolck-AT-gmx.net>
2897 <a.schmolck-AT-gmx.net>
2870
2898
2871 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2899 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2872 pre-configured Gnuplot instance.
2900 pre-configured Gnuplot instance.
2873
2901
2874 2002-06-21 Fernando Perez <fperez@colorado.edu>
2902 2002-06-21 Fernando Perez <fperez@colorado.edu>
2875
2903
2876 * IPython/numutils.py (exp_safe): new function, works around the
2904 * IPython/numutils.py (exp_safe): new function, works around the
2877 underflow problems in Numeric.
2905 underflow problems in Numeric.
2878 (log2): New fn. Safe log in base 2: returns exact integer answer
2906 (log2): New fn. Safe log in base 2: returns exact integer answer
2879 for exact integer powers of 2.
2907 for exact integer powers of 2.
2880
2908
2881 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2909 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2882 properly.
2910 properly.
2883
2911
2884 2002-06-20 Fernando Perez <fperez@colorado.edu>
2912 2002-06-20 Fernando Perez <fperez@colorado.edu>
2885
2913
2886 * IPython/genutils.py (timing): new function like
2914 * IPython/genutils.py (timing): new function like
2887 Mathematica's. Similar to time_test, but returns more info.
2915 Mathematica's. Similar to time_test, but returns more info.
2888
2916
2889 2002-06-18 Fernando Perez <fperez@colorado.edu>
2917 2002-06-18 Fernando Perez <fperez@colorado.edu>
2890
2918
2891 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2919 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2892 according to Mike Heeter's suggestions.
2920 according to Mike Heeter's suggestions.
2893
2921
2894 2002-06-16 Fernando Perez <fperez@colorado.edu>
2922 2002-06-16 Fernando Perez <fperez@colorado.edu>
2895
2923
2896 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2924 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2897 system. GnuplotMagic is gone as a user-directory option. New files
2925 system. GnuplotMagic is gone as a user-directory option. New files
2898 make it easier to use all the gnuplot stuff both from external
2926 make it easier to use all the gnuplot stuff both from external
2899 programs as well as from IPython. Had to rewrite part of
2927 programs as well as from IPython. Had to rewrite part of
2900 hardcopy() b/c of a strange bug: often the ps files simply don't
2928 hardcopy() b/c of a strange bug: often the ps files simply don't
2901 get created, and require a repeat of the command (often several
2929 get created, and require a repeat of the command (often several
2902 times).
2930 times).
2903
2931
2904 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2932 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2905 resolve output channel at call time, so that if sys.stderr has
2933 resolve output channel at call time, so that if sys.stderr has
2906 been redirected by user this gets honored.
2934 been redirected by user this gets honored.
2907
2935
2908 2002-06-13 Fernando Perez <fperez@colorado.edu>
2936 2002-06-13 Fernando Perez <fperez@colorado.edu>
2909
2937
2910 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2938 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2911 IPShell. Kept a copy with the old names to avoid breaking people's
2939 IPShell. Kept a copy with the old names to avoid breaking people's
2912 embedded code.
2940 embedded code.
2913
2941
2914 * IPython/ipython: simplified it to the bare minimum after
2942 * IPython/ipython: simplified it to the bare minimum after
2915 Holger's suggestions. Added info about how to use it in
2943 Holger's suggestions. Added info about how to use it in
2916 PYTHONSTARTUP.
2944 PYTHONSTARTUP.
2917
2945
2918 * IPython/Shell.py (IPythonShell): changed the options passing
2946 * IPython/Shell.py (IPythonShell): changed the options passing
2919 from a string with funky %s replacements to a straight list. Maybe
2947 from a string with funky %s replacements to a straight list. Maybe
2920 a bit more typing, but it follows sys.argv conventions, so there's
2948 a bit more typing, but it follows sys.argv conventions, so there's
2921 less special-casing to remember.
2949 less special-casing to remember.
2922
2950
2923 2002-06-12 Fernando Perez <fperez@colorado.edu>
2951 2002-06-12 Fernando Perez <fperez@colorado.edu>
2924
2952
2925 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2953 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2926 command. Thanks to a suggestion by Mike Heeter.
2954 command. Thanks to a suggestion by Mike Heeter.
2927 (Magic.magic_pfile): added behavior to look at filenames if given
2955 (Magic.magic_pfile): added behavior to look at filenames if given
2928 arg is not a defined object.
2956 arg is not a defined object.
2929 (Magic.magic_save): New @save function to save code snippets. Also
2957 (Magic.magic_save): New @save function to save code snippets. Also
2930 a Mike Heeter idea.
2958 a Mike Heeter idea.
2931
2959
2932 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2960 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2933 plot() and replot(). Much more convenient now, especially for
2961 plot() and replot(). Much more convenient now, especially for
2934 interactive use.
2962 interactive use.
2935
2963
2936 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2964 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2937 filenames.
2965 filenames.
2938
2966
2939 2002-06-02 Fernando Perez <fperez@colorado.edu>
2967 2002-06-02 Fernando Perez <fperez@colorado.edu>
2940
2968
2941 * IPython/Struct.py (Struct.__init__): modified to admit
2969 * IPython/Struct.py (Struct.__init__): modified to admit
2942 initialization via another struct.
2970 initialization via another struct.
2943
2971
2944 * IPython/genutils.py (SystemExec.__init__): New stateful
2972 * IPython/genutils.py (SystemExec.__init__): New stateful
2945 interface to xsys and bq. Useful for writing system scripts.
2973 interface to xsys and bq. Useful for writing system scripts.
2946
2974
2947 2002-05-30 Fernando Perez <fperez@colorado.edu>
2975 2002-05-30 Fernando Perez <fperez@colorado.edu>
2948
2976
2949 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2977 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2950 documents. This will make the user download smaller (it's getting
2978 documents. This will make the user download smaller (it's getting
2951 too big).
2979 too big).
2952
2980
2953 2002-05-29 Fernando Perez <fperez@colorado.edu>
2981 2002-05-29 Fernando Perez <fperez@colorado.edu>
2954
2982
2955 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2983 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2956 fix problems with shelve and pickle. Seems to work, but I don't
2984 fix problems with shelve and pickle. Seems to work, but I don't
2957 know if corner cases break it. Thanks to Mike Heeter
2985 know if corner cases break it. Thanks to Mike Heeter
2958 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2986 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2959
2987
2960 2002-05-24 Fernando Perez <fperez@colorado.edu>
2988 2002-05-24 Fernando Perez <fperez@colorado.edu>
2961
2989
2962 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2990 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2963 macros having broken.
2991 macros having broken.
2964
2992
2965 2002-05-21 Fernando Perez <fperez@colorado.edu>
2993 2002-05-21 Fernando Perez <fperez@colorado.edu>
2966
2994
2967 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2995 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2968 introduced logging bug: all history before logging started was
2996 introduced logging bug: all history before logging started was
2969 being written one character per line! This came from the redesign
2997 being written one character per line! This came from the redesign
2970 of the input history as a special list which slices to strings,
2998 of the input history as a special list which slices to strings,
2971 not to lists.
2999 not to lists.
2972
3000
2973 2002-05-20 Fernando Perez <fperez@colorado.edu>
3001 2002-05-20 Fernando Perez <fperez@colorado.edu>
2974
3002
2975 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3003 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2976 be an attribute of all classes in this module. The design of these
3004 be an attribute of all classes in this module. The design of these
2977 classes needs some serious overhauling.
3005 classes needs some serious overhauling.
2978
3006
2979 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3007 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2980 which was ignoring '_' in option names.
3008 which was ignoring '_' in option names.
2981
3009
2982 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3010 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2983 'Verbose_novars' to 'Context' and made it the new default. It's a
3011 'Verbose_novars' to 'Context' and made it the new default. It's a
2984 bit more readable and also safer than verbose.
3012 bit more readable and also safer than verbose.
2985
3013
2986 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3014 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2987 triple-quoted strings.
3015 triple-quoted strings.
2988
3016
2989 * IPython/OInspect.py (__all__): new module exposing the object
3017 * IPython/OInspect.py (__all__): new module exposing the object
2990 introspection facilities. Now the corresponding magics are dummy
3018 introspection facilities. Now the corresponding magics are dummy
2991 wrappers around this. Having this module will make it much easier
3019 wrappers around this. Having this module will make it much easier
2992 to put these functions into our modified pdb.
3020 to put these functions into our modified pdb.
2993 This new object inspector system uses the new colorizing module,
3021 This new object inspector system uses the new colorizing module,
2994 so source code and other things are nicely syntax highlighted.
3022 so source code and other things are nicely syntax highlighted.
2995
3023
2996 2002-05-18 Fernando Perez <fperez@colorado.edu>
3024 2002-05-18 Fernando Perez <fperez@colorado.edu>
2997
3025
2998 * IPython/ColorANSI.py: Split the coloring tools into a separate
3026 * IPython/ColorANSI.py: Split the coloring tools into a separate
2999 module so I can use them in other code easier (they were part of
3027 module so I can use them in other code easier (they were part of
3000 ultraTB).
3028 ultraTB).
3001
3029
3002 2002-05-17 Fernando Perez <fperez@colorado.edu>
3030 2002-05-17 Fernando Perez <fperez@colorado.edu>
3003
3031
3004 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3032 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3005 fixed it to set the global 'g' also to the called instance, as
3033 fixed it to set the global 'g' also to the called instance, as
3006 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3034 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3007 user's 'g' variables).
3035 user's 'g' variables).
3008
3036
3009 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3037 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3010 global variables (aliases to _ih,_oh) so that users which expect
3038 global variables (aliases to _ih,_oh) so that users which expect
3011 In[5] or Out[7] to work aren't unpleasantly surprised.
3039 In[5] or Out[7] to work aren't unpleasantly surprised.
3012 (InputList.__getslice__): new class to allow executing slices of
3040 (InputList.__getslice__): new class to allow executing slices of
3013 input history directly. Very simple class, complements the use of
3041 input history directly. Very simple class, complements the use of
3014 macros.
3042 macros.
3015
3043
3016 2002-05-16 Fernando Perez <fperez@colorado.edu>
3044 2002-05-16 Fernando Perez <fperez@colorado.edu>
3017
3045
3018 * setup.py (docdirbase): make doc directory be just doc/IPython
3046 * setup.py (docdirbase): make doc directory be just doc/IPython
3019 without version numbers, it will reduce clutter for users.
3047 without version numbers, it will reduce clutter for users.
3020
3048
3021 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3049 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3022 execfile call to prevent possible memory leak. See for details:
3050 execfile call to prevent possible memory leak. See for details:
3023 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3051 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3024
3052
3025 2002-05-15 Fernando Perez <fperez@colorado.edu>
3053 2002-05-15 Fernando Perez <fperez@colorado.edu>
3026
3054
3027 * IPython/Magic.py (Magic.magic_psource): made the object
3055 * IPython/Magic.py (Magic.magic_psource): made the object
3028 introspection names be more standard: pdoc, pdef, pfile and
3056 introspection names be more standard: pdoc, pdef, pfile and
3029 psource. They all print/page their output, and it makes
3057 psource. They all print/page their output, and it makes
3030 remembering them easier. Kept old names for compatibility as
3058 remembering them easier. Kept old names for compatibility as
3031 aliases.
3059 aliases.
3032
3060
3033 2002-05-14 Fernando Perez <fperez@colorado.edu>
3061 2002-05-14 Fernando Perez <fperez@colorado.edu>
3034
3062
3035 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3063 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3036 what the mouse problem was. The trick is to use gnuplot with temp
3064 what the mouse problem was. The trick is to use gnuplot with temp
3037 files and NOT with pipes (for data communication), because having
3065 files and NOT with pipes (for data communication), because having
3038 both pipes and the mouse on is bad news.
3066 both pipes and the mouse on is bad news.
3039
3067
3040 2002-05-13 Fernando Perez <fperez@colorado.edu>
3068 2002-05-13 Fernando Perez <fperez@colorado.edu>
3041
3069
3042 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3070 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3043 bug. Information would be reported about builtins even when
3071 bug. Information would be reported about builtins even when
3044 user-defined functions overrode them.
3072 user-defined functions overrode them.
3045
3073
3046 2002-05-11 Fernando Perez <fperez@colorado.edu>
3074 2002-05-11 Fernando Perez <fperez@colorado.edu>
3047
3075
3048 * IPython/__init__.py (__all__): removed FlexCompleter from
3076 * IPython/__init__.py (__all__): removed FlexCompleter from
3049 __all__ so that things don't fail in platforms without readline.
3077 __all__ so that things don't fail in platforms without readline.
3050
3078
3051 2002-05-10 Fernando Perez <fperez@colorado.edu>
3079 2002-05-10 Fernando Perez <fperez@colorado.edu>
3052
3080
3053 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3081 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3054 it requires Numeric, effectively making Numeric a dependency for
3082 it requires Numeric, effectively making Numeric a dependency for
3055 IPython.
3083 IPython.
3056
3084
3057 * Released 0.2.13
3085 * Released 0.2.13
3058
3086
3059 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3087 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3060 profiler interface. Now all the major options from the profiler
3088 profiler interface. Now all the major options from the profiler
3061 module are directly supported in IPython, both for single
3089 module are directly supported in IPython, both for single
3062 expressions (@prun) and for full programs (@run -p).
3090 expressions (@prun) and for full programs (@run -p).
3063
3091
3064 2002-05-09 Fernando Perez <fperez@colorado.edu>
3092 2002-05-09 Fernando Perez <fperez@colorado.edu>
3065
3093
3066 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3094 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3067 magic properly formatted for screen.
3095 magic properly formatted for screen.
3068
3096
3069 * setup.py (make_shortcut): Changed things to put pdf version in
3097 * setup.py (make_shortcut): Changed things to put pdf version in
3070 doc/ instead of doc/manual (had to change lyxport a bit).
3098 doc/ instead of doc/manual (had to change lyxport a bit).
3071
3099
3072 * IPython/Magic.py (Profile.string_stats): made profile runs go
3100 * IPython/Magic.py (Profile.string_stats): made profile runs go
3073 through pager (they are long and a pager allows searching, saving,
3101 through pager (they are long and a pager allows searching, saving,
3074 etc.)
3102 etc.)
3075
3103
3076 2002-05-08 Fernando Perez <fperez@colorado.edu>
3104 2002-05-08 Fernando Perez <fperez@colorado.edu>
3077
3105
3078 * Released 0.2.12
3106 * Released 0.2.12
3079
3107
3080 2002-05-06 Fernando Perez <fperez@colorado.edu>
3108 2002-05-06 Fernando Perez <fperez@colorado.edu>
3081
3109
3082 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3110 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3083 introduced); 'hist n1 n2' was broken.
3111 introduced); 'hist n1 n2' was broken.
3084 (Magic.magic_pdb): added optional on/off arguments to @pdb
3112 (Magic.magic_pdb): added optional on/off arguments to @pdb
3085 (Magic.magic_run): added option -i to @run, which executes code in
3113 (Magic.magic_run): added option -i to @run, which executes code in
3086 the IPython namespace instead of a clean one. Also added @irun as
3114 the IPython namespace instead of a clean one. Also added @irun as
3087 an alias to @run -i.
3115 an alias to @run -i.
3088
3116
3089 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3117 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3090 fixed (it didn't really do anything, the namespaces were wrong).
3118 fixed (it didn't really do anything, the namespaces were wrong).
3091
3119
3092 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3120 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3093
3121
3094 * IPython/__init__.py (__all__): Fixed package namespace, now
3122 * IPython/__init__.py (__all__): Fixed package namespace, now
3095 'import IPython' does give access to IPython.<all> as
3123 'import IPython' does give access to IPython.<all> as
3096 expected. Also renamed __release__ to Release.
3124 expected. Also renamed __release__ to Release.
3097
3125
3098 * IPython/Debugger.py (__license__): created new Pdb class which
3126 * IPython/Debugger.py (__license__): created new Pdb class which
3099 functions like a drop-in for the normal pdb.Pdb but does NOT
3127 functions like a drop-in for the normal pdb.Pdb but does NOT
3100 import readline by default. This way it doesn't muck up IPython's
3128 import readline by default. This way it doesn't muck up IPython's
3101 readline handling, and now tab-completion finally works in the
3129 readline handling, and now tab-completion finally works in the
3102 debugger -- sort of. It completes things globally visible, but the
3130 debugger -- sort of. It completes things globally visible, but the
3103 completer doesn't track the stack as pdb walks it. That's a bit
3131 completer doesn't track the stack as pdb walks it. That's a bit
3104 tricky, and I'll have to implement it later.
3132 tricky, and I'll have to implement it later.
3105
3133
3106 2002-05-05 Fernando Perez <fperez@colorado.edu>
3134 2002-05-05 Fernando Perez <fperez@colorado.edu>
3107
3135
3108 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3136 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3109 magic docstrings when printed via ? (explicit \'s were being
3137 magic docstrings when printed via ? (explicit \'s were being
3110 printed).
3138 printed).
3111
3139
3112 * IPython/ipmaker.py (make_IPython): fixed namespace
3140 * IPython/ipmaker.py (make_IPython): fixed namespace
3113 identification bug. Now variables loaded via logs or command-line
3141 identification bug. Now variables loaded via logs or command-line
3114 files are recognized in the interactive namespace by @who.
3142 files are recognized in the interactive namespace by @who.
3115
3143
3116 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3144 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3117 log replay system stemming from the string form of Structs.
3145 log replay system stemming from the string form of Structs.
3118
3146
3119 * IPython/Magic.py (Macro.__init__): improved macros to properly
3147 * IPython/Magic.py (Macro.__init__): improved macros to properly
3120 handle magic commands in them.
3148 handle magic commands in them.
3121 (Magic.magic_logstart): usernames are now expanded so 'logstart
3149 (Magic.magic_logstart): usernames are now expanded so 'logstart
3122 ~/mylog' now works.
3150 ~/mylog' now works.
3123
3151
3124 * IPython/iplib.py (complete): fixed bug where paths starting with
3152 * IPython/iplib.py (complete): fixed bug where paths starting with
3125 '/' would be completed as magic names.
3153 '/' would be completed as magic names.
3126
3154
3127 2002-05-04 Fernando Perez <fperez@colorado.edu>
3155 2002-05-04 Fernando Perez <fperez@colorado.edu>
3128
3156
3129 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3157 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3130 allow running full programs under the profiler's control.
3158 allow running full programs under the profiler's control.
3131
3159
3132 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3160 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3133 mode to report exceptions verbosely but without formatting
3161 mode to report exceptions verbosely but without formatting
3134 variables. This addresses the issue of ipython 'freezing' (it's
3162 variables. This addresses the issue of ipython 'freezing' (it's
3135 not frozen, but caught in an expensive formatting loop) when huge
3163 not frozen, but caught in an expensive formatting loop) when huge
3136 variables are in the context of an exception.
3164 variables are in the context of an exception.
3137 (VerboseTB.text): Added '--->' markers at line where exception was
3165 (VerboseTB.text): Added '--->' markers at line where exception was
3138 triggered. Much clearer to read, especially in NoColor modes.
3166 triggered. Much clearer to read, especially in NoColor modes.
3139
3167
3140 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3168 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3141 implemented in reverse when changing to the new parse_options().
3169 implemented in reverse when changing to the new parse_options().
3142
3170
3143 2002-05-03 Fernando Perez <fperez@colorado.edu>
3171 2002-05-03 Fernando Perez <fperez@colorado.edu>
3144
3172
3145 * IPython/Magic.py (Magic.parse_options): new function so that
3173 * IPython/Magic.py (Magic.parse_options): new function so that
3146 magics can parse options easier.
3174 magics can parse options easier.
3147 (Magic.magic_prun): new function similar to profile.run(),
3175 (Magic.magic_prun): new function similar to profile.run(),
3148 suggested by Chris Hart.
3176 suggested by Chris Hart.
3149 (Magic.magic_cd): fixed behavior so that it only changes if
3177 (Magic.magic_cd): fixed behavior so that it only changes if
3150 directory actually is in history.
3178 directory actually is in history.
3151
3179
3152 * IPython/usage.py (__doc__): added information about potential
3180 * IPython/usage.py (__doc__): added information about potential
3153 slowness of Verbose exception mode when there are huge data
3181 slowness of Verbose exception mode when there are huge data
3154 structures to be formatted (thanks to Archie Paulson).
3182 structures to be formatted (thanks to Archie Paulson).
3155
3183
3156 * IPython/ipmaker.py (make_IPython): Changed default logging
3184 * IPython/ipmaker.py (make_IPython): Changed default logging
3157 (when simply called with -log) to use curr_dir/ipython.log in
3185 (when simply called with -log) to use curr_dir/ipython.log in
3158 rotate mode. Fixed crash which was occuring with -log before
3186 rotate mode. Fixed crash which was occuring with -log before
3159 (thanks to Jim Boyle).
3187 (thanks to Jim Boyle).
3160
3188
3161 2002-05-01 Fernando Perez <fperez@colorado.edu>
3189 2002-05-01 Fernando Perez <fperez@colorado.edu>
3162
3190
3163 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3191 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3164 was nasty -- though somewhat of a corner case).
3192 was nasty -- though somewhat of a corner case).
3165
3193
3166 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3194 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3167 text (was a bug).
3195 text (was a bug).
3168
3196
3169 2002-04-30 Fernando Perez <fperez@colorado.edu>
3197 2002-04-30 Fernando Perez <fperez@colorado.edu>
3170
3198
3171 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3199 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3172 a print after ^D or ^C from the user so that the In[] prompt
3200 a print after ^D or ^C from the user so that the In[] prompt
3173 doesn't over-run the gnuplot one.
3201 doesn't over-run the gnuplot one.
3174
3202
3175 2002-04-29 Fernando Perez <fperez@colorado.edu>
3203 2002-04-29 Fernando Perez <fperez@colorado.edu>
3176
3204
3177 * Released 0.2.10
3205 * Released 0.2.10
3178
3206
3179 * IPython/__release__.py (version): get date dynamically.
3207 * IPython/__release__.py (version): get date dynamically.
3180
3208
3181 * Misc. documentation updates thanks to Arnd's comments. Also ran
3209 * Misc. documentation updates thanks to Arnd's comments. Also ran
3182 a full spellcheck on the manual (hadn't been done in a while).
3210 a full spellcheck on the manual (hadn't been done in a while).
3183
3211
3184 2002-04-27 Fernando Perez <fperez@colorado.edu>
3212 2002-04-27 Fernando Perez <fperez@colorado.edu>
3185
3213
3186 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3214 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3187 starting a log in mid-session would reset the input history list.
3215 starting a log in mid-session would reset the input history list.
3188
3216
3189 2002-04-26 Fernando Perez <fperez@colorado.edu>
3217 2002-04-26 Fernando Perez <fperez@colorado.edu>
3190
3218
3191 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3219 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3192 all files were being included in an update. Now anything in
3220 all files were being included in an update. Now anything in
3193 UserConfig that matches [A-Za-z]*.py will go (this excludes
3221 UserConfig that matches [A-Za-z]*.py will go (this excludes
3194 __init__.py)
3222 __init__.py)
3195
3223
3196 2002-04-25 Fernando Perez <fperez@colorado.edu>
3224 2002-04-25 Fernando Perez <fperez@colorado.edu>
3197
3225
3198 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3226 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3199 to __builtins__ so that any form of embedded or imported code can
3227 to __builtins__ so that any form of embedded or imported code can
3200 test for being inside IPython.
3228 test for being inside IPython.
3201
3229
3202 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3230 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3203 changed to GnuplotMagic because it's now an importable module,
3231 changed to GnuplotMagic because it's now an importable module,
3204 this makes the name follow that of the standard Gnuplot module.
3232 this makes the name follow that of the standard Gnuplot module.
3205 GnuplotMagic can now be loaded at any time in mid-session.
3233 GnuplotMagic can now be loaded at any time in mid-session.
3206
3234
3207 2002-04-24 Fernando Perez <fperez@colorado.edu>
3235 2002-04-24 Fernando Perez <fperez@colorado.edu>
3208
3236
3209 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3237 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3210 the globals (IPython has its own namespace) and the
3238 the globals (IPython has its own namespace) and the
3211 PhysicalQuantity stuff is much better anyway.
3239 PhysicalQuantity stuff is much better anyway.
3212
3240
3213 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3241 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3214 embedding example to standard user directory for
3242 embedding example to standard user directory for
3215 distribution. Also put it in the manual.
3243 distribution. Also put it in the manual.
3216
3244
3217 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3245 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3218 instance as first argument (so it doesn't rely on some obscure
3246 instance as first argument (so it doesn't rely on some obscure
3219 hidden global).
3247 hidden global).
3220
3248
3221 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3249 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3222 delimiters. While it prevents ().TAB from working, it allows
3250 delimiters. While it prevents ().TAB from working, it allows
3223 completions in open (... expressions. This is by far a more common
3251 completions in open (... expressions. This is by far a more common
3224 case.
3252 case.
3225
3253
3226 2002-04-23 Fernando Perez <fperez@colorado.edu>
3254 2002-04-23 Fernando Perez <fperez@colorado.edu>
3227
3255
3228 * IPython/Extensions/InterpreterPasteInput.py: new
3256 * IPython/Extensions/InterpreterPasteInput.py: new
3229 syntax-processing module for pasting lines with >>> or ... at the
3257 syntax-processing module for pasting lines with >>> or ... at the
3230 start.
3258 start.
3231
3259
3232 * IPython/Extensions/PhysicalQ_Interactive.py
3260 * IPython/Extensions/PhysicalQ_Interactive.py
3233 (PhysicalQuantityInteractive.__int__): fixed to work with either
3261 (PhysicalQuantityInteractive.__int__): fixed to work with either
3234 Numeric or math.
3262 Numeric or math.
3235
3263
3236 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3264 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3237 provided profiles. Now we have:
3265 provided profiles. Now we have:
3238 -math -> math module as * and cmath with its own namespace.
3266 -math -> math module as * and cmath with its own namespace.
3239 -numeric -> Numeric as *, plus gnuplot & grace
3267 -numeric -> Numeric as *, plus gnuplot & grace
3240 -physics -> same as before
3268 -physics -> same as before
3241
3269
3242 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3270 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3243 user-defined magics wouldn't be found by @magic if they were
3271 user-defined magics wouldn't be found by @magic if they were
3244 defined as class methods. Also cleaned up the namespace search
3272 defined as class methods. Also cleaned up the namespace search
3245 logic and the string building (to use %s instead of many repeated
3273 logic and the string building (to use %s instead of many repeated
3246 string adds).
3274 string adds).
3247
3275
3248 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3276 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3249 of user-defined magics to operate with class methods (cleaner, in
3277 of user-defined magics to operate with class methods (cleaner, in
3250 line with the gnuplot code).
3278 line with the gnuplot code).
3251
3279
3252 2002-04-22 Fernando Perez <fperez@colorado.edu>
3280 2002-04-22 Fernando Perez <fperez@colorado.edu>
3253
3281
3254 * setup.py: updated dependency list so that manual is updated when
3282 * setup.py: updated dependency list so that manual is updated when
3255 all included files change.
3283 all included files change.
3256
3284
3257 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3285 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3258 the delimiter removal option (the fix is ugly right now).
3286 the delimiter removal option (the fix is ugly right now).
3259
3287
3260 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3288 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3261 all of the math profile (quicker loading, no conflict between
3289 all of the math profile (quicker loading, no conflict between
3262 g-9.8 and g-gnuplot).
3290 g-9.8 and g-gnuplot).
3263
3291
3264 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3292 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3265 name of post-mortem files to IPython_crash_report.txt.
3293 name of post-mortem files to IPython_crash_report.txt.
3266
3294
3267 * Cleanup/update of the docs. Added all the new readline info and
3295 * Cleanup/update of the docs. Added all the new readline info and
3268 formatted all lists as 'real lists'.
3296 formatted all lists as 'real lists'.
3269
3297
3270 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3298 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3271 tab-completion options, since the full readline parse_and_bind is
3299 tab-completion options, since the full readline parse_and_bind is
3272 now accessible.
3300 now accessible.
3273
3301
3274 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3302 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3275 handling of readline options. Now users can specify any string to
3303 handling of readline options. Now users can specify any string to
3276 be passed to parse_and_bind(), as well as the delimiters to be
3304 be passed to parse_and_bind(), as well as the delimiters to be
3277 removed.
3305 removed.
3278 (InteractiveShell.__init__): Added __name__ to the global
3306 (InteractiveShell.__init__): Added __name__ to the global
3279 namespace so that things like Itpl which rely on its existence
3307 namespace so that things like Itpl which rely on its existence
3280 don't crash.
3308 don't crash.
3281 (InteractiveShell._prefilter): Defined the default with a _ so
3309 (InteractiveShell._prefilter): Defined the default with a _ so
3282 that prefilter() is easier to override, while the default one
3310 that prefilter() is easier to override, while the default one
3283 remains available.
3311 remains available.
3284
3312
3285 2002-04-18 Fernando Perez <fperez@colorado.edu>
3313 2002-04-18 Fernando Perez <fperez@colorado.edu>
3286
3314
3287 * Added information about pdb in the docs.
3315 * Added information about pdb in the docs.
3288
3316
3289 2002-04-17 Fernando Perez <fperez@colorado.edu>
3317 2002-04-17 Fernando Perez <fperez@colorado.edu>
3290
3318
3291 * IPython/ipmaker.py (make_IPython): added rc_override option to
3319 * IPython/ipmaker.py (make_IPython): added rc_override option to
3292 allow passing config options at creation time which may override
3320 allow passing config options at creation time which may override
3293 anything set in the config files or command line. This is
3321 anything set in the config files or command line. This is
3294 particularly useful for configuring embedded instances.
3322 particularly useful for configuring embedded instances.
3295
3323
3296 2002-04-15 Fernando Perez <fperez@colorado.edu>
3324 2002-04-15 Fernando Perez <fperez@colorado.edu>
3297
3325
3298 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3326 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3299 crash embedded instances because of the input cache falling out of
3327 crash embedded instances because of the input cache falling out of
3300 sync with the output counter.
3328 sync with the output counter.
3301
3329
3302 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3330 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3303 mode which calls pdb after an uncaught exception in IPython itself.
3331 mode which calls pdb after an uncaught exception in IPython itself.
3304
3332
3305 2002-04-14 Fernando Perez <fperez@colorado.edu>
3333 2002-04-14 Fernando Perez <fperez@colorado.edu>
3306
3334
3307 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3335 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3308 readline, fix it back after each call.
3336 readline, fix it back after each call.
3309
3337
3310 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3338 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3311 method to force all access via __call__(), which guarantees that
3339 method to force all access via __call__(), which guarantees that
3312 traceback references are properly deleted.
3340 traceback references are properly deleted.
3313
3341
3314 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3342 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3315 improve printing when pprint is in use.
3343 improve printing when pprint is in use.
3316
3344
3317 2002-04-13 Fernando Perez <fperez@colorado.edu>
3345 2002-04-13 Fernando Perez <fperez@colorado.edu>
3318
3346
3319 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3347 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3320 exceptions aren't caught anymore. If the user triggers one, he
3348 exceptions aren't caught anymore. If the user triggers one, he
3321 should know why he's doing it and it should go all the way up,
3349 should know why he's doing it and it should go all the way up,
3322 just like any other exception. So now @abort will fully kill the
3350 just like any other exception. So now @abort will fully kill the
3323 embedded interpreter and the embedding code (unless that happens
3351 embedded interpreter and the embedding code (unless that happens
3324 to catch SystemExit).
3352 to catch SystemExit).
3325
3353
3326 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3354 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3327 and a debugger() method to invoke the interactive pdb debugger
3355 and a debugger() method to invoke the interactive pdb debugger
3328 after printing exception information. Also added the corresponding
3356 after printing exception information. Also added the corresponding
3329 -pdb option and @pdb magic to control this feature, and updated
3357 -pdb option and @pdb magic to control this feature, and updated
3330 the docs. After a suggestion from Christopher Hart
3358 the docs. After a suggestion from Christopher Hart
3331 (hart-AT-caltech.edu).
3359 (hart-AT-caltech.edu).
3332
3360
3333 2002-04-12 Fernando Perez <fperez@colorado.edu>
3361 2002-04-12 Fernando Perez <fperez@colorado.edu>
3334
3362
3335 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3363 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3336 the exception handlers defined by the user (not the CrashHandler)
3364 the exception handlers defined by the user (not the CrashHandler)
3337 so that user exceptions don't trigger an ipython bug report.
3365 so that user exceptions don't trigger an ipython bug report.
3338
3366
3339 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3367 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3340 configurable (it should have always been so).
3368 configurable (it should have always been so).
3341
3369
3342 2002-03-26 Fernando Perez <fperez@colorado.edu>
3370 2002-03-26 Fernando Perez <fperez@colorado.edu>
3343
3371
3344 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3372 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3345 and there to fix embedding namespace issues. This should all be
3373 and there to fix embedding namespace issues. This should all be
3346 done in a more elegant way.
3374 done in a more elegant way.
3347
3375
3348 2002-03-25 Fernando Perez <fperez@colorado.edu>
3376 2002-03-25 Fernando Perez <fperez@colorado.edu>
3349
3377
3350 * IPython/genutils.py (get_home_dir): Try to make it work under
3378 * IPython/genutils.py (get_home_dir): Try to make it work under
3351 win9x also.
3379 win9x also.
3352
3380
3353 2002-03-20 Fernando Perez <fperez@colorado.edu>
3381 2002-03-20 Fernando Perez <fperez@colorado.edu>
3354
3382
3355 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3383 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3356 sys.displayhook untouched upon __init__.
3384 sys.displayhook untouched upon __init__.
3357
3385
3358 2002-03-19 Fernando Perez <fperez@colorado.edu>
3386 2002-03-19 Fernando Perez <fperez@colorado.edu>
3359
3387
3360 * Released 0.2.9 (for embedding bug, basically).
3388 * Released 0.2.9 (for embedding bug, basically).
3361
3389
3362 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3390 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3363 exceptions so that enclosing shell's state can be restored.
3391 exceptions so that enclosing shell's state can be restored.
3364
3392
3365 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3393 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3366 naming conventions in the .ipython/ dir.
3394 naming conventions in the .ipython/ dir.
3367
3395
3368 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3396 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3369 from delimiters list so filenames with - in them get expanded.
3397 from delimiters list so filenames with - in them get expanded.
3370
3398
3371 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3399 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3372 sys.displayhook not being properly restored after an embedded call.
3400 sys.displayhook not being properly restored after an embedded call.
3373
3401
3374 2002-03-18 Fernando Perez <fperez@colorado.edu>
3402 2002-03-18 Fernando Perez <fperez@colorado.edu>
3375
3403
3376 * Released 0.2.8
3404 * Released 0.2.8
3377
3405
3378 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3406 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3379 some files weren't being included in a -upgrade.
3407 some files weren't being included in a -upgrade.
3380 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3408 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3381 on' so that the first tab completes.
3409 on' so that the first tab completes.
3382 (InteractiveShell.handle_magic): fixed bug with spaces around
3410 (InteractiveShell.handle_magic): fixed bug with spaces around
3383 quotes breaking many magic commands.
3411 quotes breaking many magic commands.
3384
3412
3385 * setup.py: added note about ignoring the syntax error messages at
3413 * setup.py: added note about ignoring the syntax error messages at
3386 installation.
3414 installation.
3387
3415
3388 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3416 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3389 streamlining the gnuplot interface, now there's only one magic @gp.
3417 streamlining the gnuplot interface, now there's only one magic @gp.
3390
3418
3391 2002-03-17 Fernando Perez <fperez@colorado.edu>
3419 2002-03-17 Fernando Perez <fperez@colorado.edu>
3392
3420
3393 * IPython/UserConfig/magic_gnuplot.py: new name for the
3421 * IPython/UserConfig/magic_gnuplot.py: new name for the
3394 example-magic_pm.py file. Much enhanced system, now with a shell
3422 example-magic_pm.py file. Much enhanced system, now with a shell
3395 for communicating directly with gnuplot, one command at a time.
3423 for communicating directly with gnuplot, one command at a time.
3396
3424
3397 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3425 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3398 setting __name__=='__main__'.
3426 setting __name__=='__main__'.
3399
3427
3400 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3428 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3401 mini-shell for accessing gnuplot from inside ipython. Should
3429 mini-shell for accessing gnuplot from inside ipython. Should
3402 extend it later for grace access too. Inspired by Arnd's
3430 extend it later for grace access too. Inspired by Arnd's
3403 suggestion.
3431 suggestion.
3404
3432
3405 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3433 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3406 calling magic functions with () in their arguments. Thanks to Arnd
3434 calling magic functions with () in their arguments. Thanks to Arnd
3407 Baecker for pointing this to me.
3435 Baecker for pointing this to me.
3408
3436
3409 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3437 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3410 infinitely for integer or complex arrays (only worked with floats).
3438 infinitely for integer or complex arrays (only worked with floats).
3411
3439
3412 2002-03-16 Fernando Perez <fperez@colorado.edu>
3440 2002-03-16 Fernando Perez <fperez@colorado.edu>
3413
3441
3414 * setup.py: Merged setup and setup_windows into a single script
3442 * setup.py: Merged setup and setup_windows into a single script
3415 which properly handles things for windows users.
3443 which properly handles things for windows users.
3416
3444
3417 2002-03-15 Fernando Perez <fperez@colorado.edu>
3445 2002-03-15 Fernando Perez <fperez@colorado.edu>
3418
3446
3419 * Big change to the manual: now the magics are all automatically
3447 * Big change to the manual: now the magics are all automatically
3420 documented. This information is generated from their docstrings
3448 documented. This information is generated from their docstrings
3421 and put in a latex file included by the manual lyx file. This way
3449 and put in a latex file included by the manual lyx file. This way
3422 we get always up to date information for the magics. The manual
3450 we get always up to date information for the magics. The manual
3423 now also has proper version information, also auto-synced.
3451 now also has proper version information, also auto-synced.
3424
3452
3425 For this to work, an undocumented --magic_docstrings option was added.
3453 For this to work, an undocumented --magic_docstrings option was added.
3426
3454
3427 2002-03-13 Fernando Perez <fperez@colorado.edu>
3455 2002-03-13 Fernando Perez <fperez@colorado.edu>
3428
3456
3429 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3457 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3430 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3458 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3431
3459
3432 2002-03-12 Fernando Perez <fperez@colorado.edu>
3460 2002-03-12 Fernando Perez <fperez@colorado.edu>
3433
3461
3434 * IPython/ultraTB.py (TermColors): changed color escapes again to
3462 * IPython/ultraTB.py (TermColors): changed color escapes again to
3435 fix the (old, reintroduced) line-wrapping bug. Basically, if
3463 fix the (old, reintroduced) line-wrapping bug. Basically, if
3436 \001..\002 aren't given in the color escapes, lines get wrapped
3464 \001..\002 aren't given in the color escapes, lines get wrapped
3437 weirdly. But giving those screws up old xterms and emacs terms. So
3465 weirdly. But giving those screws up old xterms and emacs terms. So
3438 I added some logic for emacs terms to be ok, but I can't identify old
3466 I added some logic for emacs terms to be ok, but I can't identify old
3439 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3467 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3440
3468
3441 2002-03-10 Fernando Perez <fperez@colorado.edu>
3469 2002-03-10 Fernando Perez <fperez@colorado.edu>
3442
3470
3443 * IPython/usage.py (__doc__): Various documentation cleanups and
3471 * IPython/usage.py (__doc__): Various documentation cleanups and
3444 updates, both in usage docstrings and in the manual.
3472 updates, both in usage docstrings and in the manual.
3445
3473
3446 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3474 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3447 handling of caching. Set minimum acceptabe value for having a
3475 handling of caching. Set minimum acceptabe value for having a
3448 cache at 20 values.
3476 cache at 20 values.
3449
3477
3450 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3478 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3451 install_first_time function to a method, renamed it and added an
3479 install_first_time function to a method, renamed it and added an
3452 'upgrade' mode. Now people can update their config directory with
3480 'upgrade' mode. Now people can update their config directory with
3453 a simple command line switch (-upgrade, also new).
3481 a simple command line switch (-upgrade, also new).
3454
3482
3455 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3483 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3456 @file (convenient for automagic users under Python >= 2.2).
3484 @file (convenient for automagic users under Python >= 2.2).
3457 Removed @files (it seemed more like a plural than an abbrev. of
3485 Removed @files (it seemed more like a plural than an abbrev. of
3458 'file show').
3486 'file show').
3459
3487
3460 * IPython/iplib.py (install_first_time): Fixed crash if there were
3488 * IPython/iplib.py (install_first_time): Fixed crash if there were
3461 backup files ('~') in .ipython/ install directory.
3489 backup files ('~') in .ipython/ install directory.
3462
3490
3463 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3491 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3464 system. Things look fine, but these changes are fairly
3492 system. Things look fine, but these changes are fairly
3465 intrusive. Test them for a few days.
3493 intrusive. Test them for a few days.
3466
3494
3467 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3495 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3468 the prompts system. Now all in/out prompt strings are user
3496 the prompts system. Now all in/out prompt strings are user
3469 controllable. This is particularly useful for embedding, as one
3497 controllable. This is particularly useful for embedding, as one
3470 can tag embedded instances with particular prompts.
3498 can tag embedded instances with particular prompts.
3471
3499
3472 Also removed global use of sys.ps1/2, which now allows nested
3500 Also removed global use of sys.ps1/2, which now allows nested
3473 embeddings without any problems. Added command-line options for
3501 embeddings without any problems. Added command-line options for
3474 the prompt strings.
3502 the prompt strings.
3475
3503
3476 2002-03-08 Fernando Perez <fperez@colorado.edu>
3504 2002-03-08 Fernando Perez <fperez@colorado.edu>
3477
3505
3478 * IPython/UserConfig/example-embed-short.py (ipshell): added
3506 * IPython/UserConfig/example-embed-short.py (ipshell): added
3479 example file with the bare minimum code for embedding.
3507 example file with the bare minimum code for embedding.
3480
3508
3481 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3509 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3482 functionality for the embeddable shell to be activated/deactivated
3510 functionality for the embeddable shell to be activated/deactivated
3483 either globally or at each call.
3511 either globally or at each call.
3484
3512
3485 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3513 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3486 rewriting the prompt with '--->' for auto-inputs with proper
3514 rewriting the prompt with '--->' for auto-inputs with proper
3487 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3515 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3488 this is handled by the prompts class itself, as it should.
3516 this is handled by the prompts class itself, as it should.
3489
3517
3490 2002-03-05 Fernando Perez <fperez@colorado.edu>
3518 2002-03-05 Fernando Perez <fperez@colorado.edu>
3491
3519
3492 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3520 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3493 @logstart to avoid name clashes with the math log function.
3521 @logstart to avoid name clashes with the math log function.
3494
3522
3495 * Big updates to X/Emacs section of the manual.
3523 * Big updates to X/Emacs section of the manual.
3496
3524
3497 * Removed ipython_emacs. Milan explained to me how to pass
3525 * Removed ipython_emacs. Milan explained to me how to pass
3498 arguments to ipython through Emacs. Some day I'm going to end up
3526 arguments to ipython through Emacs. Some day I'm going to end up
3499 learning some lisp...
3527 learning some lisp...
3500
3528
3501 2002-03-04 Fernando Perez <fperez@colorado.edu>
3529 2002-03-04 Fernando Perez <fperez@colorado.edu>
3502
3530
3503 * IPython/ipython_emacs: Created script to be used as the
3531 * IPython/ipython_emacs: Created script to be used as the
3504 py-python-command Emacs variable so we can pass IPython
3532 py-python-command Emacs variable so we can pass IPython
3505 parameters. I can't figure out how to tell Emacs directly to pass
3533 parameters. I can't figure out how to tell Emacs directly to pass
3506 parameters to IPython, so a dummy shell script will do it.
3534 parameters to IPython, so a dummy shell script will do it.
3507
3535
3508 Other enhancements made for things to work better under Emacs'
3536 Other enhancements made for things to work better under Emacs'
3509 various types of terminals. Many thanks to Milan Zamazal
3537 various types of terminals. Many thanks to Milan Zamazal
3510 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3538 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3511
3539
3512 2002-03-01 Fernando Perez <fperez@colorado.edu>
3540 2002-03-01 Fernando Perez <fperez@colorado.edu>
3513
3541
3514 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3542 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3515 that loading of readline is now optional. This gives better
3543 that loading of readline is now optional. This gives better
3516 control to emacs users.
3544 control to emacs users.
3517
3545
3518 * IPython/ultraTB.py (__date__): Modified color escape sequences
3546 * IPython/ultraTB.py (__date__): Modified color escape sequences
3519 and now things work fine under xterm and in Emacs' term buffers
3547 and now things work fine under xterm and in Emacs' term buffers
3520 (though not shell ones). Well, in emacs you get colors, but all
3548 (though not shell ones). Well, in emacs you get colors, but all
3521 seem to be 'light' colors (no difference between dark and light
3549 seem to be 'light' colors (no difference between dark and light
3522 ones). But the garbage chars are gone, and also in xterms. It
3550 ones). But the garbage chars are gone, and also in xterms. It
3523 seems that now I'm using 'cleaner' ansi sequences.
3551 seems that now I'm using 'cleaner' ansi sequences.
3524
3552
3525 2002-02-21 Fernando Perez <fperez@colorado.edu>
3553 2002-02-21 Fernando Perez <fperez@colorado.edu>
3526
3554
3527 * Released 0.2.7 (mainly to publish the scoping fix).
3555 * Released 0.2.7 (mainly to publish the scoping fix).
3528
3556
3529 * IPython/Logger.py (Logger.logstate): added. A corresponding
3557 * IPython/Logger.py (Logger.logstate): added. A corresponding
3530 @logstate magic was created.
3558 @logstate magic was created.
3531
3559
3532 * IPython/Magic.py: fixed nested scoping problem under Python
3560 * IPython/Magic.py: fixed nested scoping problem under Python
3533 2.1.x (automagic wasn't working).
3561 2.1.x (automagic wasn't working).
3534
3562
3535 2002-02-20 Fernando Perez <fperez@colorado.edu>
3563 2002-02-20 Fernando Perez <fperez@colorado.edu>
3536
3564
3537 * Released 0.2.6.
3565 * Released 0.2.6.
3538
3566
3539 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3567 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3540 option so that logs can come out without any headers at all.
3568 option so that logs can come out without any headers at all.
3541
3569
3542 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3570 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3543 SciPy.
3571 SciPy.
3544
3572
3545 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3573 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3546 that embedded IPython calls don't require vars() to be explicitly
3574 that embedded IPython calls don't require vars() to be explicitly
3547 passed. Now they are extracted from the caller's frame (code
3575 passed. Now they are extracted from the caller's frame (code
3548 snatched from Eric Jones' weave). Added better documentation to
3576 snatched from Eric Jones' weave). Added better documentation to
3549 the section on embedding and the example file.
3577 the section on embedding and the example file.
3550
3578
3551 * IPython/genutils.py (page): Changed so that under emacs, it just
3579 * IPython/genutils.py (page): Changed so that under emacs, it just
3552 prints the string. You can then page up and down in the emacs
3580 prints the string. You can then page up and down in the emacs
3553 buffer itself. This is how the builtin help() works.
3581 buffer itself. This is how the builtin help() works.
3554
3582
3555 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3583 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3556 macro scoping: macros need to be executed in the user's namespace
3584 macro scoping: macros need to be executed in the user's namespace
3557 to work as if they had been typed by the user.
3585 to work as if they had been typed by the user.
3558
3586
3559 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3587 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3560 execute automatically (no need to type 'exec...'). They then
3588 execute automatically (no need to type 'exec...'). They then
3561 behave like 'true macros'. The printing system was also modified
3589 behave like 'true macros'. The printing system was also modified
3562 for this to work.
3590 for this to work.
3563
3591
3564 2002-02-19 Fernando Perez <fperez@colorado.edu>
3592 2002-02-19 Fernando Perez <fperez@colorado.edu>
3565
3593
3566 * IPython/genutils.py (page_file): new function for paging files
3594 * IPython/genutils.py (page_file): new function for paging files
3567 in an OS-independent way. Also necessary for file viewing to work
3595 in an OS-independent way. Also necessary for file viewing to work
3568 well inside Emacs buffers.
3596 well inside Emacs buffers.
3569 (page): Added checks for being in an emacs buffer.
3597 (page): Added checks for being in an emacs buffer.
3570 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3598 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3571 same bug in iplib.
3599 same bug in iplib.
3572
3600
3573 2002-02-18 Fernando Perez <fperez@colorado.edu>
3601 2002-02-18 Fernando Perez <fperez@colorado.edu>
3574
3602
3575 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3603 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3576 of readline so that IPython can work inside an Emacs buffer.
3604 of readline so that IPython can work inside an Emacs buffer.
3577
3605
3578 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3606 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3579 method signatures (they weren't really bugs, but it looks cleaner
3607 method signatures (they weren't really bugs, but it looks cleaner
3580 and keeps PyChecker happy).
3608 and keeps PyChecker happy).
3581
3609
3582 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3610 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3583 for implementing various user-defined hooks. Currently only
3611 for implementing various user-defined hooks. Currently only
3584 display is done.
3612 display is done.
3585
3613
3586 * IPython/Prompts.py (CachedOutput._display): changed display
3614 * IPython/Prompts.py (CachedOutput._display): changed display
3587 functions so that they can be dynamically changed by users easily.
3615 functions so that they can be dynamically changed by users easily.
3588
3616
3589 * IPython/Extensions/numeric_formats.py (num_display): added an
3617 * IPython/Extensions/numeric_formats.py (num_display): added an
3590 extension for printing NumPy arrays in flexible manners. It
3618 extension for printing NumPy arrays in flexible manners. It
3591 doesn't do anything yet, but all the structure is in
3619 doesn't do anything yet, but all the structure is in
3592 place. Ultimately the plan is to implement output format control
3620 place. Ultimately the plan is to implement output format control
3593 like in Octave.
3621 like in Octave.
3594
3622
3595 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3623 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3596 methods are found at run-time by all the automatic machinery.
3624 methods are found at run-time by all the automatic machinery.
3597
3625
3598 2002-02-17 Fernando Perez <fperez@colorado.edu>
3626 2002-02-17 Fernando Perez <fperez@colorado.edu>
3599
3627
3600 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3628 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3601 whole file a little.
3629 whole file a little.
3602
3630
3603 * ToDo: closed this document. Now there's a new_design.lyx
3631 * ToDo: closed this document. Now there's a new_design.lyx
3604 document for all new ideas. Added making a pdf of it for the
3632 document for all new ideas. Added making a pdf of it for the
3605 end-user distro.
3633 end-user distro.
3606
3634
3607 * IPython/Logger.py (Logger.switch_log): Created this to replace
3635 * IPython/Logger.py (Logger.switch_log): Created this to replace
3608 logon() and logoff(). It also fixes a nasty crash reported by
3636 logon() and logoff(). It also fixes a nasty crash reported by
3609 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3637 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3610
3638
3611 * IPython/iplib.py (complete): got auto-completion to work with
3639 * IPython/iplib.py (complete): got auto-completion to work with
3612 automagic (I had wanted this for a long time).
3640 automagic (I had wanted this for a long time).
3613
3641
3614 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3642 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3615 to @file, since file() is now a builtin and clashes with automagic
3643 to @file, since file() is now a builtin and clashes with automagic
3616 for @file.
3644 for @file.
3617
3645
3618 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3646 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3619 of this was previously in iplib, which had grown to more than 2000
3647 of this was previously in iplib, which had grown to more than 2000
3620 lines, way too long. No new functionality, but it makes managing
3648 lines, way too long. No new functionality, but it makes managing
3621 the code a bit easier.
3649 the code a bit easier.
3622
3650
3623 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3651 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3624 information to crash reports.
3652 information to crash reports.
3625
3653
3626 2002-02-12 Fernando Perez <fperez@colorado.edu>
3654 2002-02-12 Fernando Perez <fperez@colorado.edu>
3627
3655
3628 * Released 0.2.5.
3656 * Released 0.2.5.
3629
3657
3630 2002-02-11 Fernando Perez <fperez@colorado.edu>
3658 2002-02-11 Fernando Perez <fperez@colorado.edu>
3631
3659
3632 * Wrote a relatively complete Windows installer. It puts
3660 * Wrote a relatively complete Windows installer. It puts
3633 everything in place, creates Start Menu entries and fixes the
3661 everything in place, creates Start Menu entries and fixes the
3634 color issues. Nothing fancy, but it works.
3662 color issues. Nothing fancy, but it works.
3635
3663
3636 2002-02-10 Fernando Perez <fperez@colorado.edu>
3664 2002-02-10 Fernando Perez <fperez@colorado.edu>
3637
3665
3638 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3666 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3639 os.path.expanduser() call so that we can type @run ~/myfile.py and
3667 os.path.expanduser() call so that we can type @run ~/myfile.py and
3640 have thigs work as expected.
3668 have thigs work as expected.
3641
3669
3642 * IPython/genutils.py (page): fixed exception handling so things
3670 * IPython/genutils.py (page): fixed exception handling so things
3643 work both in Unix and Windows correctly. Quitting a pager triggers
3671 work both in Unix and Windows correctly. Quitting a pager triggers
3644 an IOError/broken pipe in Unix, and in windows not finding a pager
3672 an IOError/broken pipe in Unix, and in windows not finding a pager
3645 is also an IOError, so I had to actually look at the return value
3673 is also an IOError, so I had to actually look at the return value
3646 of the exception, not just the exception itself. Should be ok now.
3674 of the exception, not just the exception itself. Should be ok now.
3647
3675
3648 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3676 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3649 modified to allow case-insensitive color scheme changes.
3677 modified to allow case-insensitive color scheme changes.
3650
3678
3651 2002-02-09 Fernando Perez <fperez@colorado.edu>
3679 2002-02-09 Fernando Perez <fperez@colorado.edu>
3652
3680
3653 * IPython/genutils.py (native_line_ends): new function to leave
3681 * IPython/genutils.py (native_line_ends): new function to leave
3654 user config files with os-native line-endings.
3682 user config files with os-native line-endings.
3655
3683
3656 * README and manual updates.
3684 * README and manual updates.
3657
3685
3658 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3686 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3659 instead of StringType to catch Unicode strings.
3687 instead of StringType to catch Unicode strings.
3660
3688
3661 * IPython/genutils.py (filefind): fixed bug for paths with
3689 * IPython/genutils.py (filefind): fixed bug for paths with
3662 embedded spaces (very common in Windows).
3690 embedded spaces (very common in Windows).
3663
3691
3664 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3692 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3665 files under Windows, so that they get automatically associated
3693 files under Windows, so that they get automatically associated
3666 with a text editor. Windows makes it a pain to handle
3694 with a text editor. Windows makes it a pain to handle
3667 extension-less files.
3695 extension-less files.
3668
3696
3669 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3697 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3670 warning about readline only occur for Posix. In Windows there's no
3698 warning about readline only occur for Posix. In Windows there's no
3671 way to get readline, so why bother with the warning.
3699 way to get readline, so why bother with the warning.
3672
3700
3673 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3701 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3674 for __str__ instead of dir(self), since dir() changed in 2.2.
3702 for __str__ instead of dir(self), since dir() changed in 2.2.
3675
3703
3676 * Ported to Windows! Tested on XP, I suspect it should work fine
3704 * Ported to Windows! Tested on XP, I suspect it should work fine
3677 on NT/2000, but I don't think it will work on 98 et al. That
3705 on NT/2000, but I don't think it will work on 98 et al. That
3678 series of Windows is such a piece of junk anyway that I won't try
3706 series of Windows is such a piece of junk anyway that I won't try
3679 porting it there. The XP port was straightforward, showed a few
3707 porting it there. The XP port was straightforward, showed a few
3680 bugs here and there (fixed all), in particular some string
3708 bugs here and there (fixed all), in particular some string
3681 handling stuff which required considering Unicode strings (which
3709 handling stuff which required considering Unicode strings (which
3682 Windows uses). This is good, but hasn't been too tested :) No
3710 Windows uses). This is good, but hasn't been too tested :) No
3683 fancy installer yet, I'll put a note in the manual so people at
3711 fancy installer yet, I'll put a note in the manual so people at
3684 least make manually a shortcut.
3712 least make manually a shortcut.
3685
3713
3686 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3714 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3687 into a single one, "colors". This now controls both prompt and
3715 into a single one, "colors". This now controls both prompt and
3688 exception color schemes, and can be changed both at startup
3716 exception color schemes, and can be changed both at startup
3689 (either via command-line switches or via ipythonrc files) and at
3717 (either via command-line switches or via ipythonrc files) and at
3690 runtime, with @colors.
3718 runtime, with @colors.
3691 (Magic.magic_run): renamed @prun to @run and removed the old
3719 (Magic.magic_run): renamed @prun to @run and removed the old
3692 @run. The two were too similar to warrant keeping both.
3720 @run. The two were too similar to warrant keeping both.
3693
3721
3694 2002-02-03 Fernando Perez <fperez@colorado.edu>
3722 2002-02-03 Fernando Perez <fperez@colorado.edu>
3695
3723
3696 * IPython/iplib.py (install_first_time): Added comment on how to
3724 * IPython/iplib.py (install_first_time): Added comment on how to
3697 configure the color options for first-time users. Put a <return>
3725 configure the color options for first-time users. Put a <return>
3698 request at the end so that small-terminal users get a chance to
3726 request at the end so that small-terminal users get a chance to
3699 read the startup info.
3727 read the startup info.
3700
3728
3701 2002-01-23 Fernando Perez <fperez@colorado.edu>
3729 2002-01-23 Fernando Perez <fperez@colorado.edu>
3702
3730
3703 * IPython/iplib.py (CachedOutput.update): Changed output memory
3731 * IPython/iplib.py (CachedOutput.update): Changed output memory
3704 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3732 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3705 input history we still use _i. Did this b/c these variable are
3733 input history we still use _i. Did this b/c these variable are
3706 very commonly used in interactive work, so the less we need to
3734 very commonly used in interactive work, so the less we need to
3707 type the better off we are.
3735 type the better off we are.
3708 (Magic.magic_prun): updated @prun to better handle the namespaces
3736 (Magic.magic_prun): updated @prun to better handle the namespaces
3709 the file will run in, including a fix for __name__ not being set
3737 the file will run in, including a fix for __name__ not being set
3710 before.
3738 before.
3711
3739
3712 2002-01-20 Fernando Perez <fperez@colorado.edu>
3740 2002-01-20 Fernando Perez <fperez@colorado.edu>
3713
3741
3714 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3742 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3715 extra garbage for Python 2.2. Need to look more carefully into
3743 extra garbage for Python 2.2. Need to look more carefully into
3716 this later.
3744 this later.
3717
3745
3718 2002-01-19 Fernando Perez <fperez@colorado.edu>
3746 2002-01-19 Fernando Perez <fperez@colorado.edu>
3719
3747
3720 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3748 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3721 display SyntaxError exceptions properly formatted when they occur
3749 display SyntaxError exceptions properly formatted when they occur
3722 (they can be triggered by imported code).
3750 (they can be triggered by imported code).
3723
3751
3724 2002-01-18 Fernando Perez <fperez@colorado.edu>
3752 2002-01-18 Fernando Perez <fperez@colorado.edu>
3725
3753
3726 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3754 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3727 SyntaxError exceptions are reported nicely formatted, instead of
3755 SyntaxError exceptions are reported nicely formatted, instead of
3728 spitting out only offset information as before.
3756 spitting out only offset information as before.
3729 (Magic.magic_prun): Added the @prun function for executing
3757 (Magic.magic_prun): Added the @prun function for executing
3730 programs with command line args inside IPython.
3758 programs with command line args inside IPython.
3731
3759
3732 2002-01-16 Fernando Perez <fperez@colorado.edu>
3760 2002-01-16 Fernando Perez <fperez@colorado.edu>
3733
3761
3734 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3762 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3735 to *not* include the last item given in a range. This brings their
3763 to *not* include the last item given in a range. This brings their
3736 behavior in line with Python's slicing:
3764 behavior in line with Python's slicing:
3737 a[n1:n2] -> a[n1]...a[n2-1]
3765 a[n1:n2] -> a[n1]...a[n2-1]
3738 It may be a bit less convenient, but I prefer to stick to Python's
3766 It may be a bit less convenient, but I prefer to stick to Python's
3739 conventions *everywhere*, so users never have to wonder.
3767 conventions *everywhere*, so users never have to wonder.
3740 (Magic.magic_macro): Added @macro function to ease the creation of
3768 (Magic.magic_macro): Added @macro function to ease the creation of
3741 macros.
3769 macros.
3742
3770
3743 2002-01-05 Fernando Perez <fperez@colorado.edu>
3771 2002-01-05 Fernando Perez <fperez@colorado.edu>
3744
3772
3745 * Released 0.2.4.
3773 * Released 0.2.4.
3746
3774
3747 * IPython/iplib.py (Magic.magic_pdef):
3775 * IPython/iplib.py (Magic.magic_pdef):
3748 (InteractiveShell.safe_execfile): report magic lines and error
3776 (InteractiveShell.safe_execfile): report magic lines and error
3749 lines without line numbers so one can easily copy/paste them for
3777 lines without line numbers so one can easily copy/paste them for
3750 re-execution.
3778 re-execution.
3751
3779
3752 * Updated manual with recent changes.
3780 * Updated manual with recent changes.
3753
3781
3754 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3782 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3755 docstring printing when class? is called. Very handy for knowing
3783 docstring printing when class? is called. Very handy for knowing
3756 how to create class instances (as long as __init__ is well
3784 how to create class instances (as long as __init__ is well
3757 documented, of course :)
3785 documented, of course :)
3758 (Magic.magic_doc): print both class and constructor docstrings.
3786 (Magic.magic_doc): print both class and constructor docstrings.
3759 (Magic.magic_pdef): give constructor info if passed a class and
3787 (Magic.magic_pdef): give constructor info if passed a class and
3760 __call__ info for callable object instances.
3788 __call__ info for callable object instances.
3761
3789
3762 2002-01-04 Fernando Perez <fperez@colorado.edu>
3790 2002-01-04 Fernando Perez <fperez@colorado.edu>
3763
3791
3764 * Made deep_reload() off by default. It doesn't always work
3792 * Made deep_reload() off by default. It doesn't always work
3765 exactly as intended, so it's probably safer to have it off. It's
3793 exactly as intended, so it's probably safer to have it off. It's
3766 still available as dreload() anyway, so nothing is lost.
3794 still available as dreload() anyway, so nothing is lost.
3767
3795
3768 2002-01-02 Fernando Perez <fperez@colorado.edu>
3796 2002-01-02 Fernando Perez <fperez@colorado.edu>
3769
3797
3770 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3798 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3771 so I wanted an updated release).
3799 so I wanted an updated release).
3772
3800
3773 2001-12-27 Fernando Perez <fperez@colorado.edu>
3801 2001-12-27 Fernando Perez <fperez@colorado.edu>
3774
3802
3775 * IPython/iplib.py (InteractiveShell.interact): Added the original
3803 * IPython/iplib.py (InteractiveShell.interact): Added the original
3776 code from 'code.py' for this module in order to change the
3804 code from 'code.py' for this module in order to change the
3777 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3805 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3778 the history cache would break when the user hit Ctrl-C, and
3806 the history cache would break when the user hit Ctrl-C, and
3779 interact() offers no way to add any hooks to it.
3807 interact() offers no way to add any hooks to it.
3780
3808
3781 2001-12-23 Fernando Perez <fperez@colorado.edu>
3809 2001-12-23 Fernando Perez <fperez@colorado.edu>
3782
3810
3783 * setup.py: added check for 'MANIFEST' before trying to remove
3811 * setup.py: added check for 'MANIFEST' before trying to remove
3784 it. Thanks to Sean Reifschneider.
3812 it. Thanks to Sean Reifschneider.
3785
3813
3786 2001-12-22 Fernando Perez <fperez@colorado.edu>
3814 2001-12-22 Fernando Perez <fperez@colorado.edu>
3787
3815
3788 * Released 0.2.2.
3816 * Released 0.2.2.
3789
3817
3790 * Finished (reasonably) writing the manual. Later will add the
3818 * Finished (reasonably) writing the manual. Later will add the
3791 python-standard navigation stylesheets, but for the time being
3819 python-standard navigation stylesheets, but for the time being
3792 it's fairly complete. Distribution will include html and pdf
3820 it's fairly complete. Distribution will include html and pdf
3793 versions.
3821 versions.
3794
3822
3795 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3823 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3796 (MayaVi author).
3824 (MayaVi author).
3797
3825
3798 2001-12-21 Fernando Perez <fperez@colorado.edu>
3826 2001-12-21 Fernando Perez <fperez@colorado.edu>
3799
3827
3800 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3828 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3801 good public release, I think (with the manual and the distutils
3829 good public release, I think (with the manual and the distutils
3802 installer). The manual can use some work, but that can go
3830 installer). The manual can use some work, but that can go
3803 slowly. Otherwise I think it's quite nice for end users. Next
3831 slowly. Otherwise I think it's quite nice for end users. Next
3804 summer, rewrite the guts of it...
3832 summer, rewrite the guts of it...
3805
3833
3806 * Changed format of ipythonrc files to use whitespace as the
3834 * Changed format of ipythonrc files to use whitespace as the
3807 separator instead of an explicit '='. Cleaner.
3835 separator instead of an explicit '='. Cleaner.
3808
3836
3809 2001-12-20 Fernando Perez <fperez@colorado.edu>
3837 2001-12-20 Fernando Perez <fperez@colorado.edu>
3810
3838
3811 * Started a manual in LyX. For now it's just a quick merge of the
3839 * Started a manual in LyX. For now it's just a quick merge of the
3812 various internal docstrings and READMEs. Later it may grow into a
3840 various internal docstrings and READMEs. Later it may grow into a
3813 nice, full-blown manual.
3841 nice, full-blown manual.
3814
3842
3815 * Set up a distutils based installer. Installation should now be
3843 * Set up a distutils based installer. Installation should now be
3816 trivially simple for end-users.
3844 trivially simple for end-users.
3817
3845
3818 2001-12-11 Fernando Perez <fperez@colorado.edu>
3846 2001-12-11 Fernando Perez <fperez@colorado.edu>
3819
3847
3820 * Released 0.2.0. First public release, announced it at
3848 * Released 0.2.0. First public release, announced it at
3821 comp.lang.python. From now on, just bugfixes...
3849 comp.lang.python. From now on, just bugfixes...
3822
3850
3823 * Went through all the files, set copyright/license notices and
3851 * Went through all the files, set copyright/license notices and
3824 cleaned up things. Ready for release.
3852 cleaned up things. Ready for release.
3825
3853
3826 2001-12-10 Fernando Perez <fperez@colorado.edu>
3854 2001-12-10 Fernando Perez <fperez@colorado.edu>
3827
3855
3828 * Changed the first-time installer not to use tarfiles. It's more
3856 * Changed the first-time installer not to use tarfiles. It's more
3829 robust now and less unix-dependent. Also makes it easier for
3857 robust now and less unix-dependent. Also makes it easier for
3830 people to later upgrade versions.
3858 people to later upgrade versions.
3831
3859
3832 * Changed @exit to @abort to reflect the fact that it's pretty
3860 * Changed @exit to @abort to reflect the fact that it's pretty
3833 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3861 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3834 becomes significant only when IPyhton is embedded: in that case,
3862 becomes significant only when IPyhton is embedded: in that case,
3835 C-D closes IPython only, but @abort kills the enclosing program
3863 C-D closes IPython only, but @abort kills the enclosing program
3836 too (unless it had called IPython inside a try catching
3864 too (unless it had called IPython inside a try catching
3837 SystemExit).
3865 SystemExit).
3838
3866
3839 * Created Shell module which exposes the actuall IPython Shell
3867 * Created Shell module which exposes the actuall IPython Shell
3840 classes, currently the normal and the embeddable one. This at
3868 classes, currently the normal and the embeddable one. This at
3841 least offers a stable interface we won't need to change when
3869 least offers a stable interface we won't need to change when
3842 (later) the internals are rewritten. That rewrite will be confined
3870 (later) the internals are rewritten. That rewrite will be confined
3843 to iplib and ipmaker, but the Shell interface should remain as is.
3871 to iplib and ipmaker, but the Shell interface should remain as is.
3844
3872
3845 * Added embed module which offers an embeddable IPShell object,
3873 * Added embed module which offers an embeddable IPShell object,
3846 useful to fire up IPython *inside* a running program. Great for
3874 useful to fire up IPython *inside* a running program. Great for
3847 debugging or dynamical data analysis.
3875 debugging or dynamical data analysis.
3848
3876
3849 2001-12-08 Fernando Perez <fperez@colorado.edu>
3877 2001-12-08 Fernando Perez <fperez@colorado.edu>
3850
3878
3851 * Fixed small bug preventing seeing info from methods of defined
3879 * Fixed small bug preventing seeing info from methods of defined
3852 objects (incorrect namespace in _ofind()).
3880 objects (incorrect namespace in _ofind()).
3853
3881
3854 * Documentation cleanup. Moved the main usage docstrings to a
3882 * Documentation cleanup. Moved the main usage docstrings to a
3855 separate file, usage.py (cleaner to maintain, and hopefully in the
3883 separate file, usage.py (cleaner to maintain, and hopefully in the
3856 future some perlpod-like way of producing interactive, man and
3884 future some perlpod-like way of producing interactive, man and
3857 html docs out of it will be found).
3885 html docs out of it will be found).
3858
3886
3859 * Added @profile to see your profile at any time.
3887 * Added @profile to see your profile at any time.
3860
3888
3861 * Added @p as an alias for 'print'. It's especially convenient if
3889 * Added @p as an alias for 'print'. It's especially convenient if
3862 using automagic ('p x' prints x).
3890 using automagic ('p x' prints x).
3863
3891
3864 * Small cleanups and fixes after a pychecker run.
3892 * Small cleanups and fixes after a pychecker run.
3865
3893
3866 * Changed the @cd command to handle @cd - and @cd -<n> for
3894 * Changed the @cd command to handle @cd - and @cd -<n> for
3867 visiting any directory in _dh.
3895 visiting any directory in _dh.
3868
3896
3869 * Introduced _dh, a history of visited directories. @dhist prints
3897 * Introduced _dh, a history of visited directories. @dhist prints
3870 it out with numbers.
3898 it out with numbers.
3871
3899
3872 2001-12-07 Fernando Perez <fperez@colorado.edu>
3900 2001-12-07 Fernando Perez <fperez@colorado.edu>
3873
3901
3874 * Released 0.1.22
3902 * Released 0.1.22
3875
3903
3876 * Made initialization a bit more robust against invalid color
3904 * Made initialization a bit more robust against invalid color
3877 options in user input (exit, not traceback-crash).
3905 options in user input (exit, not traceback-crash).
3878
3906
3879 * Changed the bug crash reporter to write the report only in the
3907 * Changed the bug crash reporter to write the report only in the
3880 user's .ipython directory. That way IPython won't litter people's
3908 user's .ipython directory. That way IPython won't litter people's
3881 hard disks with crash files all over the place. Also print on
3909 hard disks with crash files all over the place. Also print on
3882 screen the necessary mail command.
3910 screen the necessary mail command.
3883
3911
3884 * With the new ultraTB, implemented LightBG color scheme for light
3912 * With the new ultraTB, implemented LightBG color scheme for light
3885 background terminals. A lot of people like white backgrounds, so I
3913 background terminals. A lot of people like white backgrounds, so I
3886 guess we should at least give them something readable.
3914 guess we should at least give them something readable.
3887
3915
3888 2001-12-06 Fernando Perez <fperez@colorado.edu>
3916 2001-12-06 Fernando Perez <fperez@colorado.edu>
3889
3917
3890 * Modified the structure of ultraTB. Now there's a proper class
3918 * Modified the structure of ultraTB. Now there's a proper class
3891 for tables of color schemes which allow adding schemes easily and
3919 for tables of color schemes which allow adding schemes easily and
3892 switching the active scheme without creating a new instance every
3920 switching the active scheme without creating a new instance every
3893 time (which was ridiculous). The syntax for creating new schemes
3921 time (which was ridiculous). The syntax for creating new schemes
3894 is also cleaner. I think ultraTB is finally done, with a clean
3922 is also cleaner. I think ultraTB is finally done, with a clean
3895 class structure. Names are also much cleaner (now there's proper
3923 class structure. Names are also much cleaner (now there's proper
3896 color tables, no need for every variable to also have 'color' in
3924 color tables, no need for every variable to also have 'color' in
3897 its name).
3925 its name).
3898
3926
3899 * Broke down genutils into separate files. Now genutils only
3927 * Broke down genutils into separate files. Now genutils only
3900 contains utility functions, and classes have been moved to their
3928 contains utility functions, and classes have been moved to their
3901 own files (they had enough independent functionality to warrant
3929 own files (they had enough independent functionality to warrant
3902 it): ConfigLoader, OutputTrap, Struct.
3930 it): ConfigLoader, OutputTrap, Struct.
3903
3931
3904 2001-12-05 Fernando Perez <fperez@colorado.edu>
3932 2001-12-05 Fernando Perez <fperez@colorado.edu>
3905
3933
3906 * IPython turns 21! Released version 0.1.21, as a candidate for
3934 * IPython turns 21! Released version 0.1.21, as a candidate for
3907 public consumption. If all goes well, release in a few days.
3935 public consumption. If all goes well, release in a few days.
3908
3936
3909 * Fixed path bug (files in Extensions/ directory wouldn't be found
3937 * Fixed path bug (files in Extensions/ directory wouldn't be found
3910 unless IPython/ was explicitly in sys.path).
3938 unless IPython/ was explicitly in sys.path).
3911
3939
3912 * Extended the FlexCompleter class as MagicCompleter to allow
3940 * Extended the FlexCompleter class as MagicCompleter to allow
3913 completion of @-starting lines.
3941 completion of @-starting lines.
3914
3942
3915 * Created __release__.py file as a central repository for release
3943 * Created __release__.py file as a central repository for release
3916 info that other files can read from.
3944 info that other files can read from.
3917
3945
3918 * Fixed small bug in logging: when logging was turned on in
3946 * Fixed small bug in logging: when logging was turned on in
3919 mid-session, old lines with special meanings (!@?) were being
3947 mid-session, old lines with special meanings (!@?) were being
3920 logged without the prepended comment, which is necessary since
3948 logged without the prepended comment, which is necessary since
3921 they are not truly valid python syntax. This should make session
3949 they are not truly valid python syntax. This should make session
3922 restores produce less errors.
3950 restores produce less errors.
3923
3951
3924 * The namespace cleanup forced me to make a FlexCompleter class
3952 * The namespace cleanup forced me to make a FlexCompleter class
3925 which is nothing but a ripoff of rlcompleter, but with selectable
3953 which is nothing but a ripoff of rlcompleter, but with selectable
3926 namespace (rlcompleter only works in __main__.__dict__). I'll try
3954 namespace (rlcompleter only works in __main__.__dict__). I'll try
3927 to submit a note to the authors to see if this change can be
3955 to submit a note to the authors to see if this change can be
3928 incorporated in future rlcompleter releases (Dec.6: done)
3956 incorporated in future rlcompleter releases (Dec.6: done)
3929
3957
3930 * More fixes to namespace handling. It was a mess! Now all
3958 * More fixes to namespace handling. It was a mess! Now all
3931 explicit references to __main__.__dict__ are gone (except when
3959 explicit references to __main__.__dict__ are gone (except when
3932 really needed) and everything is handled through the namespace
3960 really needed) and everything is handled through the namespace
3933 dicts in the IPython instance. We seem to be getting somewhere
3961 dicts in the IPython instance. We seem to be getting somewhere
3934 with this, finally...
3962 with this, finally...
3935
3963
3936 * Small documentation updates.
3964 * Small documentation updates.
3937
3965
3938 * Created the Extensions directory under IPython (with an
3966 * Created the Extensions directory under IPython (with an
3939 __init__.py). Put the PhysicalQ stuff there. This directory should
3967 __init__.py). Put the PhysicalQ stuff there. This directory should
3940 be used for all special-purpose extensions.
3968 be used for all special-purpose extensions.
3941
3969
3942 * File renaming:
3970 * File renaming:
3943 ipythonlib --> ipmaker
3971 ipythonlib --> ipmaker
3944 ipplib --> iplib
3972 ipplib --> iplib
3945 This makes a bit more sense in terms of what these files actually do.
3973 This makes a bit more sense in terms of what these files actually do.
3946
3974
3947 * Moved all the classes and functions in ipythonlib to ipplib, so
3975 * Moved all the classes and functions in ipythonlib to ipplib, so
3948 now ipythonlib only has make_IPython(). This will ease up its
3976 now ipythonlib only has make_IPython(). This will ease up its
3949 splitting in smaller functional chunks later.
3977 splitting in smaller functional chunks later.
3950
3978
3951 * Cleaned up (done, I think) output of @whos. Better column
3979 * Cleaned up (done, I think) output of @whos. Better column
3952 formatting, and now shows str(var) for as much as it can, which is
3980 formatting, and now shows str(var) for as much as it can, which is
3953 typically what one gets with a 'print var'.
3981 typically what one gets with a 'print var'.
3954
3982
3955 2001-12-04 Fernando Perez <fperez@colorado.edu>
3983 2001-12-04 Fernando Perez <fperez@colorado.edu>
3956
3984
3957 * Fixed namespace problems. Now builtin/IPyhton/user names get
3985 * Fixed namespace problems. Now builtin/IPyhton/user names get
3958 properly reported in their namespace. Internal namespace handling
3986 properly reported in their namespace. Internal namespace handling
3959 is finally getting decent (not perfect yet, but much better than
3987 is finally getting decent (not perfect yet, but much better than
3960 the ad-hoc mess we had).
3988 the ad-hoc mess we had).
3961
3989
3962 * Removed -exit option. If people just want to run a python
3990 * Removed -exit option. If people just want to run a python
3963 script, that's what the normal interpreter is for. Less
3991 script, that's what the normal interpreter is for. Less
3964 unnecessary options, less chances for bugs.
3992 unnecessary options, less chances for bugs.
3965
3993
3966 * Added a crash handler which generates a complete post-mortem if
3994 * Added a crash handler which generates a complete post-mortem if
3967 IPython crashes. This will help a lot in tracking bugs down the
3995 IPython crashes. This will help a lot in tracking bugs down the
3968 road.
3996 road.
3969
3997
3970 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3998 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3971 which were boud to functions being reassigned would bypass the
3999 which were boud to functions being reassigned would bypass the
3972 logger, breaking the sync of _il with the prompt counter. This
4000 logger, breaking the sync of _il with the prompt counter. This
3973 would then crash IPython later when a new line was logged.
4001 would then crash IPython later when a new line was logged.
3974
4002
3975 2001-12-02 Fernando Perez <fperez@colorado.edu>
4003 2001-12-02 Fernando Perez <fperez@colorado.edu>
3976
4004
3977 * Made IPython a package. This means people don't have to clutter
4005 * Made IPython a package. This means people don't have to clutter
3978 their sys.path with yet another directory. Changed the INSTALL
4006 their sys.path with yet another directory. Changed the INSTALL
3979 file accordingly.
4007 file accordingly.
3980
4008
3981 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4009 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3982 sorts its output (so @who shows it sorted) and @whos formats the
4010 sorts its output (so @who shows it sorted) and @whos formats the
3983 table according to the width of the first column. Nicer, easier to
4011 table according to the width of the first column. Nicer, easier to
3984 read. Todo: write a generic table_format() which takes a list of
4012 read. Todo: write a generic table_format() which takes a list of
3985 lists and prints it nicely formatted, with optional row/column
4013 lists and prints it nicely formatted, with optional row/column
3986 separators and proper padding and justification.
4014 separators and proper padding and justification.
3987
4015
3988 * Released 0.1.20
4016 * Released 0.1.20
3989
4017
3990 * Fixed bug in @log which would reverse the inputcache list (a
4018 * Fixed bug in @log which would reverse the inputcache list (a
3991 copy operation was missing).
4019 copy operation was missing).
3992
4020
3993 * Code cleanup. @config was changed to use page(). Better, since
4021 * Code cleanup. @config was changed to use page(). Better, since
3994 its output is always quite long.
4022 its output is always quite long.
3995
4023
3996 * Itpl is back as a dependency. I was having too many problems
4024 * Itpl is back as a dependency. I was having too many problems
3997 getting the parametric aliases to work reliably, and it's just
4025 getting the parametric aliases to work reliably, and it's just
3998 easier to code weird string operations with it than playing %()s
4026 easier to code weird string operations with it than playing %()s
3999 games. It's only ~6k, so I don't think it's too big a deal.
4027 games. It's only ~6k, so I don't think it's too big a deal.
4000
4028
4001 * Found (and fixed) a very nasty bug with history. !lines weren't
4029 * Found (and fixed) a very nasty bug with history. !lines weren't
4002 getting cached, and the out of sync caches would crash
4030 getting cached, and the out of sync caches would crash
4003 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4031 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4004 division of labor a bit better. Bug fixed, cleaner structure.
4032 division of labor a bit better. Bug fixed, cleaner structure.
4005
4033
4006 2001-12-01 Fernando Perez <fperez@colorado.edu>
4034 2001-12-01 Fernando Perez <fperez@colorado.edu>
4007
4035
4008 * Released 0.1.19
4036 * Released 0.1.19
4009
4037
4010 * Added option -n to @hist to prevent line number printing. Much
4038 * Added option -n to @hist to prevent line number printing. Much
4011 easier to copy/paste code this way.
4039 easier to copy/paste code this way.
4012
4040
4013 * Created global _il to hold the input list. Allows easy
4041 * Created global _il to hold the input list. Allows easy
4014 re-execution of blocks of code by slicing it (inspired by Janko's
4042 re-execution of blocks of code by slicing it (inspired by Janko's
4015 comment on 'macros').
4043 comment on 'macros').
4016
4044
4017 * Small fixes and doc updates.
4045 * Small fixes and doc updates.
4018
4046
4019 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4047 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4020 much too fragile with automagic. Handles properly multi-line
4048 much too fragile with automagic. Handles properly multi-line
4021 statements and takes parameters.
4049 statements and takes parameters.
4022
4050
4023 2001-11-30 Fernando Perez <fperez@colorado.edu>
4051 2001-11-30 Fernando Perez <fperez@colorado.edu>
4024
4052
4025 * Version 0.1.18 released.
4053 * Version 0.1.18 released.
4026
4054
4027 * Fixed nasty namespace bug in initial module imports.
4055 * Fixed nasty namespace bug in initial module imports.
4028
4056
4029 * Added copyright/license notes to all code files (except
4057 * Added copyright/license notes to all code files (except
4030 DPyGetOpt). For the time being, LGPL. That could change.
4058 DPyGetOpt). For the time being, LGPL. That could change.
4031
4059
4032 * Rewrote a much nicer README, updated INSTALL, cleaned up
4060 * Rewrote a much nicer README, updated INSTALL, cleaned up
4033 ipythonrc-* samples.
4061 ipythonrc-* samples.
4034
4062
4035 * Overall code/documentation cleanup. Basically ready for
4063 * Overall code/documentation cleanup. Basically ready for
4036 release. Only remaining thing: licence decision (LGPL?).
4064 release. Only remaining thing: licence decision (LGPL?).
4037
4065
4038 * Converted load_config to a class, ConfigLoader. Now recursion
4066 * Converted load_config to a class, ConfigLoader. Now recursion
4039 control is better organized. Doesn't include the same file twice.
4067 control is better organized. Doesn't include the same file twice.
4040
4068
4041 2001-11-29 Fernando Perez <fperez@colorado.edu>
4069 2001-11-29 Fernando Perez <fperez@colorado.edu>
4042
4070
4043 * Got input history working. Changed output history variables from
4071 * Got input history working. Changed output history variables from
4044 _p to _o so that _i is for input and _o for output. Just cleaner
4072 _p to _o so that _i is for input and _o for output. Just cleaner
4045 convention.
4073 convention.
4046
4074
4047 * Implemented parametric aliases. This pretty much allows the
4075 * Implemented parametric aliases. This pretty much allows the
4048 alias system to offer full-blown shell convenience, I think.
4076 alias system to offer full-blown shell convenience, I think.
4049
4077
4050 * Version 0.1.17 released, 0.1.18 opened.
4078 * Version 0.1.17 released, 0.1.18 opened.
4051
4079
4052 * dot_ipython/ipythonrc (alias): added documentation.
4080 * dot_ipython/ipythonrc (alias): added documentation.
4053 (xcolor): Fixed small bug (xcolors -> xcolor)
4081 (xcolor): Fixed small bug (xcolors -> xcolor)
4054
4082
4055 * Changed the alias system. Now alias is a magic command to define
4083 * Changed the alias system. Now alias is a magic command to define
4056 aliases just like the shell. Rationale: the builtin magics should
4084 aliases just like the shell. Rationale: the builtin magics should
4057 be there for things deeply connected to IPython's
4085 be there for things deeply connected to IPython's
4058 architecture. And this is a much lighter system for what I think
4086 architecture. And this is a much lighter system for what I think
4059 is the really important feature: allowing users to define quickly
4087 is the really important feature: allowing users to define quickly
4060 magics that will do shell things for them, so they can customize
4088 magics that will do shell things for them, so they can customize
4061 IPython easily to match their work habits. If someone is really
4089 IPython easily to match their work habits. If someone is really
4062 desperate to have another name for a builtin alias, they can
4090 desperate to have another name for a builtin alias, they can
4063 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4091 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4064 works.
4092 works.
4065
4093
4066 2001-11-28 Fernando Perez <fperez@colorado.edu>
4094 2001-11-28 Fernando Perez <fperez@colorado.edu>
4067
4095
4068 * Changed @file so that it opens the source file at the proper
4096 * Changed @file so that it opens the source file at the proper
4069 line. Since it uses less, if your EDITOR environment is
4097 line. Since it uses less, if your EDITOR environment is
4070 configured, typing v will immediately open your editor of choice
4098 configured, typing v will immediately open your editor of choice
4071 right at the line where the object is defined. Not as quick as
4099 right at the line where the object is defined. Not as quick as
4072 having a direct @edit command, but for all intents and purposes it
4100 having a direct @edit command, but for all intents and purposes it
4073 works. And I don't have to worry about writing @edit to deal with
4101 works. And I don't have to worry about writing @edit to deal with
4074 all the editors, less does that.
4102 all the editors, less does that.
4075
4103
4076 * Version 0.1.16 released, 0.1.17 opened.
4104 * Version 0.1.16 released, 0.1.17 opened.
4077
4105
4078 * Fixed some nasty bugs in the page/page_dumb combo that could
4106 * Fixed some nasty bugs in the page/page_dumb combo that could
4079 crash IPython.
4107 crash IPython.
4080
4108
4081 2001-11-27 Fernando Perez <fperez@colorado.edu>
4109 2001-11-27 Fernando Perez <fperez@colorado.edu>
4082
4110
4083 * Version 0.1.15 released, 0.1.16 opened.
4111 * Version 0.1.15 released, 0.1.16 opened.
4084
4112
4085 * Finally got ? and ?? to work for undefined things: now it's
4113 * Finally got ? and ?? to work for undefined things: now it's
4086 possible to type {}.get? and get information about the get method
4114 possible to type {}.get? and get information about the get method
4087 of dicts, or os.path? even if only os is defined (so technically
4115 of dicts, or os.path? even if only os is defined (so technically
4088 os.path isn't). Works at any level. For example, after import os,
4116 os.path isn't). Works at any level. For example, after import os,
4089 os?, os.path?, os.path.abspath? all work. This is great, took some
4117 os?, os.path?, os.path.abspath? all work. This is great, took some
4090 work in _ofind.
4118 work in _ofind.
4091
4119
4092 * Fixed more bugs with logging. The sanest way to do it was to add
4120 * Fixed more bugs with logging. The sanest way to do it was to add
4093 to @log a 'mode' parameter. Killed two in one shot (this mode
4121 to @log a 'mode' parameter. Killed two in one shot (this mode
4094 option was a request of Janko's). I think it's finally clean
4122 option was a request of Janko's). I think it's finally clean
4095 (famous last words).
4123 (famous last words).
4096
4124
4097 * Added a page_dumb() pager which does a decent job of paging on
4125 * Added a page_dumb() pager which does a decent job of paging on
4098 screen, if better things (like less) aren't available. One less
4126 screen, if better things (like less) aren't available. One less
4099 unix dependency (someday maybe somebody will port this to
4127 unix dependency (someday maybe somebody will port this to
4100 windows).
4128 windows).
4101
4129
4102 * Fixed problem in magic_log: would lock of logging out if log
4130 * Fixed problem in magic_log: would lock of logging out if log
4103 creation failed (because it would still think it had succeeded).
4131 creation failed (because it would still think it had succeeded).
4104
4132
4105 * Improved the page() function using curses to auto-detect screen
4133 * Improved the page() function using curses to auto-detect screen
4106 size. Now it can make a much better decision on whether to print
4134 size. Now it can make a much better decision on whether to print
4107 or page a string. Option screen_length was modified: a value 0
4135 or page a string. Option screen_length was modified: a value 0
4108 means auto-detect, and that's the default now.
4136 means auto-detect, and that's the default now.
4109
4137
4110 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4138 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4111 go out. I'll test it for a few days, then talk to Janko about
4139 go out. I'll test it for a few days, then talk to Janko about
4112 licences and announce it.
4140 licences and announce it.
4113
4141
4114 * Fixed the length of the auto-generated ---> prompt which appears
4142 * Fixed the length of the auto-generated ---> prompt which appears
4115 for auto-parens and auto-quotes. Getting this right isn't trivial,
4143 for auto-parens and auto-quotes. Getting this right isn't trivial,
4116 with all the color escapes, different prompt types and optional
4144 with all the color escapes, different prompt types and optional
4117 separators. But it seems to be working in all the combinations.
4145 separators. But it seems to be working in all the combinations.
4118
4146
4119 2001-11-26 Fernando Perez <fperez@colorado.edu>
4147 2001-11-26 Fernando Perez <fperez@colorado.edu>
4120
4148
4121 * Wrote a regexp filter to get option types from the option names
4149 * Wrote a regexp filter to get option types from the option names
4122 string. This eliminates the need to manually keep two duplicate
4150 string. This eliminates the need to manually keep two duplicate
4123 lists.
4151 lists.
4124
4152
4125 * Removed the unneeded check_option_names. Now options are handled
4153 * Removed the unneeded check_option_names. Now options are handled
4126 in a much saner manner and it's easy to visually check that things
4154 in a much saner manner and it's easy to visually check that things
4127 are ok.
4155 are ok.
4128
4156
4129 * Updated version numbers on all files I modified to carry a
4157 * Updated version numbers on all files I modified to carry a
4130 notice so Janko and Nathan have clear version markers.
4158 notice so Janko and Nathan have clear version markers.
4131
4159
4132 * Updated docstring for ultraTB with my changes. I should send
4160 * Updated docstring for ultraTB with my changes. I should send
4133 this to Nathan.
4161 this to Nathan.
4134
4162
4135 * Lots of small fixes. Ran everything through pychecker again.
4163 * Lots of small fixes. Ran everything through pychecker again.
4136
4164
4137 * Made loading of deep_reload an cmd line option. If it's not too
4165 * Made loading of deep_reload an cmd line option. If it's not too
4138 kosher, now people can just disable it. With -nodeep_reload it's
4166 kosher, now people can just disable it. With -nodeep_reload it's
4139 still available as dreload(), it just won't overwrite reload().
4167 still available as dreload(), it just won't overwrite reload().
4140
4168
4141 * Moved many options to the no| form (-opt and -noopt
4169 * Moved many options to the no| form (-opt and -noopt
4142 accepted). Cleaner.
4170 accepted). Cleaner.
4143
4171
4144 * Changed magic_log so that if called with no parameters, it uses
4172 * Changed magic_log so that if called with no parameters, it uses
4145 'rotate' mode. That way auto-generated logs aren't automatically
4173 'rotate' mode. That way auto-generated logs aren't automatically
4146 over-written. For normal logs, now a backup is made if it exists
4174 over-written. For normal logs, now a backup is made if it exists
4147 (only 1 level of backups). A new 'backup' mode was added to the
4175 (only 1 level of backups). A new 'backup' mode was added to the
4148 Logger class to support this. This was a request by Janko.
4176 Logger class to support this. This was a request by Janko.
4149
4177
4150 * Added @logoff/@logon to stop/restart an active log.
4178 * Added @logoff/@logon to stop/restart an active log.
4151
4179
4152 * Fixed a lot of bugs in log saving/replay. It was pretty
4180 * Fixed a lot of bugs in log saving/replay. It was pretty
4153 broken. Now special lines (!@,/) appear properly in the command
4181 broken. Now special lines (!@,/) appear properly in the command
4154 history after a log replay.
4182 history after a log replay.
4155
4183
4156 * Tried and failed to implement full session saving via pickle. My
4184 * Tried and failed to implement full session saving via pickle. My
4157 idea was to pickle __main__.__dict__, but modules can't be
4185 idea was to pickle __main__.__dict__, but modules can't be
4158 pickled. This would be a better alternative to replaying logs, but
4186 pickled. This would be a better alternative to replaying logs, but
4159 seems quite tricky to get to work. Changed -session to be called
4187 seems quite tricky to get to work. Changed -session to be called
4160 -logplay, which more accurately reflects what it does. And if we
4188 -logplay, which more accurately reflects what it does. And if we
4161 ever get real session saving working, -session is now available.
4189 ever get real session saving working, -session is now available.
4162
4190
4163 * Implemented color schemes for prompts also. As for tracebacks,
4191 * Implemented color schemes for prompts also. As for tracebacks,
4164 currently only NoColor and Linux are supported. But now the
4192 currently only NoColor and Linux are supported. But now the
4165 infrastructure is in place, based on a generic ColorScheme
4193 infrastructure is in place, based on a generic ColorScheme
4166 class. So writing and activating new schemes both for the prompts
4194 class. So writing and activating new schemes both for the prompts
4167 and the tracebacks should be straightforward.
4195 and the tracebacks should be straightforward.
4168
4196
4169 * Version 0.1.13 released, 0.1.14 opened.
4197 * Version 0.1.13 released, 0.1.14 opened.
4170
4198
4171 * Changed handling of options for output cache. Now counter is
4199 * Changed handling of options for output cache. Now counter is
4172 hardwired starting at 1 and one specifies the maximum number of
4200 hardwired starting at 1 and one specifies the maximum number of
4173 entries *in the outcache* (not the max prompt counter). This is
4201 entries *in the outcache* (not the max prompt counter). This is
4174 much better, since many statements won't increase the cache
4202 much better, since many statements won't increase the cache
4175 count. It also eliminated some confusing options, now there's only
4203 count. It also eliminated some confusing options, now there's only
4176 one: cache_size.
4204 one: cache_size.
4177
4205
4178 * Added 'alias' magic function and magic_alias option in the
4206 * Added 'alias' magic function and magic_alias option in the
4179 ipythonrc file. Now the user can easily define whatever names he
4207 ipythonrc file. Now the user can easily define whatever names he
4180 wants for the magic functions without having to play weird
4208 wants for the magic functions without having to play weird
4181 namespace games. This gives IPython a real shell-like feel.
4209 namespace games. This gives IPython a real shell-like feel.
4182
4210
4183 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4211 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4184 @ or not).
4212 @ or not).
4185
4213
4186 This was one of the last remaining 'visible' bugs (that I know
4214 This was one of the last remaining 'visible' bugs (that I know
4187 of). I think if I can clean up the session loading so it works
4215 of). I think if I can clean up the session loading so it works
4188 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4216 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4189 about licensing).
4217 about licensing).
4190
4218
4191 2001-11-25 Fernando Perez <fperez@colorado.edu>
4219 2001-11-25 Fernando Perez <fperez@colorado.edu>
4192
4220
4193 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4221 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4194 there's a cleaner distinction between what ? and ?? show.
4222 there's a cleaner distinction between what ? and ?? show.
4195
4223
4196 * Added screen_length option. Now the user can define his own
4224 * Added screen_length option. Now the user can define his own
4197 screen size for page() operations.
4225 screen size for page() operations.
4198
4226
4199 * Implemented magic shell-like functions with automatic code
4227 * Implemented magic shell-like functions with automatic code
4200 generation. Now adding another function is just a matter of adding
4228 generation. Now adding another function is just a matter of adding
4201 an entry to a dict, and the function is dynamically generated at
4229 an entry to a dict, and the function is dynamically generated at
4202 run-time. Python has some really cool features!
4230 run-time. Python has some really cool features!
4203
4231
4204 * Renamed many options to cleanup conventions a little. Now all
4232 * Renamed many options to cleanup conventions a little. Now all
4205 are lowercase, and only underscores where needed. Also in the code
4233 are lowercase, and only underscores where needed. Also in the code
4206 option name tables are clearer.
4234 option name tables are clearer.
4207
4235
4208 * Changed prompts a little. Now input is 'In [n]:' instead of
4236 * Changed prompts a little. Now input is 'In [n]:' instead of
4209 'In[n]:='. This allows it the numbers to be aligned with the
4237 'In[n]:='. This allows it the numbers to be aligned with the
4210 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4238 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4211 Python (it was a Mathematica thing). The '...' continuation prompt
4239 Python (it was a Mathematica thing). The '...' continuation prompt
4212 was also changed a little to align better.
4240 was also changed a little to align better.
4213
4241
4214 * Fixed bug when flushing output cache. Not all _p<n> variables
4242 * Fixed bug when flushing output cache. Not all _p<n> variables
4215 exist, so their deletion needs to be wrapped in a try:
4243 exist, so their deletion needs to be wrapped in a try:
4216
4244
4217 * Figured out how to properly use inspect.formatargspec() (it
4245 * Figured out how to properly use inspect.formatargspec() (it
4218 requires the args preceded by *). So I removed all the code from
4246 requires the args preceded by *). So I removed all the code from
4219 _get_pdef in Magic, which was just replicating that.
4247 _get_pdef in Magic, which was just replicating that.
4220
4248
4221 * Added test to prefilter to allow redefining magic function names
4249 * Added test to prefilter to allow redefining magic function names
4222 as variables. This is ok, since the @ form is always available,
4250 as variables. This is ok, since the @ form is always available,
4223 but whe should allow the user to define a variable called 'ls' if
4251 but whe should allow the user to define a variable called 'ls' if
4224 he needs it.
4252 he needs it.
4225
4253
4226 * Moved the ToDo information from README into a separate ToDo.
4254 * Moved the ToDo information from README into a separate ToDo.
4227
4255
4228 * General code cleanup and small bugfixes. I think it's close to a
4256 * General code cleanup and small bugfixes. I think it's close to a
4229 state where it can be released, obviously with a big 'beta'
4257 state where it can be released, obviously with a big 'beta'
4230 warning on it.
4258 warning on it.
4231
4259
4232 * Got the magic function split to work. Now all magics are defined
4260 * Got the magic function split to work. Now all magics are defined
4233 in a separate class. It just organizes things a bit, and now
4261 in a separate class. It just organizes things a bit, and now
4234 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4262 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4235 was too long).
4263 was too long).
4236
4264
4237 * Changed @clear to @reset to avoid potential confusions with
4265 * Changed @clear to @reset to avoid potential confusions with
4238 the shell command clear. Also renamed @cl to @clear, which does
4266 the shell command clear. Also renamed @cl to @clear, which does
4239 exactly what people expect it to from their shell experience.
4267 exactly what people expect it to from their shell experience.
4240
4268
4241 Added a check to the @reset command (since it's so
4269 Added a check to the @reset command (since it's so
4242 destructive, it's probably a good idea to ask for confirmation).
4270 destructive, it's probably a good idea to ask for confirmation).
4243 But now reset only works for full namespace resetting. Since the
4271 But now reset only works for full namespace resetting. Since the
4244 del keyword is already there for deleting a few specific
4272 del keyword is already there for deleting a few specific
4245 variables, I don't see the point of having a redundant magic
4273 variables, I don't see the point of having a redundant magic
4246 function for the same task.
4274 function for the same task.
4247
4275
4248 2001-11-24 Fernando Perez <fperez@colorado.edu>
4276 2001-11-24 Fernando Perez <fperez@colorado.edu>
4249
4277
4250 * Updated the builtin docs (esp. the ? ones).
4278 * Updated the builtin docs (esp. the ? ones).
4251
4279
4252 * Ran all the code through pychecker. Not terribly impressed with
4280 * Ran all the code through pychecker. Not terribly impressed with
4253 it: lots of spurious warnings and didn't really find anything of
4281 it: lots of spurious warnings and didn't really find anything of
4254 substance (just a few modules being imported and not used).
4282 substance (just a few modules being imported and not used).
4255
4283
4256 * Implemented the new ultraTB functionality into IPython. New
4284 * Implemented the new ultraTB functionality into IPython. New
4257 option: xcolors. This chooses color scheme. xmode now only selects
4285 option: xcolors. This chooses color scheme. xmode now only selects
4258 between Plain and Verbose. Better orthogonality.
4286 between Plain and Verbose. Better orthogonality.
4259
4287
4260 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4288 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4261 mode and color scheme for the exception handlers. Now it's
4289 mode and color scheme for the exception handlers. Now it's
4262 possible to have the verbose traceback with no coloring.
4290 possible to have the verbose traceback with no coloring.
4263
4291
4264 2001-11-23 Fernando Perez <fperez@colorado.edu>
4292 2001-11-23 Fernando Perez <fperez@colorado.edu>
4265
4293
4266 * Version 0.1.12 released, 0.1.13 opened.
4294 * Version 0.1.12 released, 0.1.13 opened.
4267
4295
4268 * Removed option to set auto-quote and auto-paren escapes by
4296 * Removed option to set auto-quote and auto-paren escapes by
4269 user. The chances of breaking valid syntax are just too high. If
4297 user. The chances of breaking valid syntax are just too high. If
4270 someone *really* wants, they can always dig into the code.
4298 someone *really* wants, they can always dig into the code.
4271
4299
4272 * Made prompt separators configurable.
4300 * Made prompt separators configurable.
4273
4301
4274 2001-11-22 Fernando Perez <fperez@colorado.edu>
4302 2001-11-22 Fernando Perez <fperez@colorado.edu>
4275
4303
4276 * Small bugfixes in many places.
4304 * Small bugfixes in many places.
4277
4305
4278 * Removed the MyCompleter class from ipplib. It seemed redundant
4306 * Removed the MyCompleter class from ipplib. It seemed redundant
4279 with the C-p,C-n history search functionality. Less code to
4307 with the C-p,C-n history search functionality. Less code to
4280 maintain.
4308 maintain.
4281
4309
4282 * Moved all the original ipython.py code into ipythonlib.py. Right
4310 * Moved all the original ipython.py code into ipythonlib.py. Right
4283 now it's just one big dump into a function called make_IPython, so
4311 now it's just one big dump into a function called make_IPython, so
4284 no real modularity has been gained. But at least it makes the
4312 no real modularity has been gained. But at least it makes the
4285 wrapper script tiny, and since ipythonlib is a module, it gets
4313 wrapper script tiny, and since ipythonlib is a module, it gets
4286 compiled and startup is much faster.
4314 compiled and startup is much faster.
4287
4315
4288 This is a reasobably 'deep' change, so we should test it for a
4316 This is a reasobably 'deep' change, so we should test it for a
4289 while without messing too much more with the code.
4317 while without messing too much more with the code.
4290
4318
4291 2001-11-21 Fernando Perez <fperez@colorado.edu>
4319 2001-11-21 Fernando Perez <fperez@colorado.edu>
4292
4320
4293 * Version 0.1.11 released, 0.1.12 opened for further work.
4321 * Version 0.1.11 released, 0.1.12 opened for further work.
4294
4322
4295 * Removed dependency on Itpl. It was only needed in one place. It
4323 * Removed dependency on Itpl. It was only needed in one place. It
4296 would be nice if this became part of python, though. It makes life
4324 would be nice if this became part of python, though. It makes life
4297 *a lot* easier in some cases.
4325 *a lot* easier in some cases.
4298
4326
4299 * Simplified the prefilter code a bit. Now all handlers are
4327 * Simplified the prefilter code a bit. Now all handlers are
4300 expected to explicitly return a value (at least a blank string).
4328 expected to explicitly return a value (at least a blank string).
4301
4329
4302 * Heavy edits in ipplib. Removed the help system altogether. Now
4330 * Heavy edits in ipplib. Removed the help system altogether. Now
4303 obj?/?? is used for inspecting objects, a magic @doc prints
4331 obj?/?? is used for inspecting objects, a magic @doc prints
4304 docstrings, and full-blown Python help is accessed via the 'help'
4332 docstrings, and full-blown Python help is accessed via the 'help'
4305 keyword. This cleans up a lot of code (less to maintain) and does
4333 keyword. This cleans up a lot of code (less to maintain) and does
4306 the job. Since 'help' is now a standard Python component, might as
4334 the job. Since 'help' is now a standard Python component, might as
4307 well use it and remove duplicate functionality.
4335 well use it and remove duplicate functionality.
4308
4336
4309 Also removed the option to use ipplib as a standalone program. By
4337 Also removed the option to use ipplib as a standalone program. By
4310 now it's too dependent on other parts of IPython to function alone.
4338 now it's too dependent on other parts of IPython to function alone.
4311
4339
4312 * Fixed bug in genutils.pager. It would crash if the pager was
4340 * Fixed bug in genutils.pager. It would crash if the pager was
4313 exited immediately after opening (broken pipe).
4341 exited immediately after opening (broken pipe).
4314
4342
4315 * Trimmed down the VerboseTB reporting a little. The header is
4343 * Trimmed down the VerboseTB reporting a little. The header is
4316 much shorter now and the repeated exception arguments at the end
4344 much shorter now and the repeated exception arguments at the end
4317 have been removed. For interactive use the old header seemed a bit
4345 have been removed. For interactive use the old header seemed a bit
4318 excessive.
4346 excessive.
4319
4347
4320 * Fixed small bug in output of @whos for variables with multi-word
4348 * Fixed small bug in output of @whos for variables with multi-word
4321 types (only first word was displayed).
4349 types (only first word was displayed).
4322
4350
4323 2001-11-17 Fernando Perez <fperez@colorado.edu>
4351 2001-11-17 Fernando Perez <fperez@colorado.edu>
4324
4352
4325 * Version 0.1.10 released, 0.1.11 opened for further work.
4353 * Version 0.1.10 released, 0.1.11 opened for further work.
4326
4354
4327 * Modified dirs and friends. dirs now *returns* the stack (not
4355 * Modified dirs and friends. dirs now *returns* the stack (not
4328 prints), so one can manipulate it as a variable. Convenient to
4356 prints), so one can manipulate it as a variable. Convenient to
4329 travel along many directories.
4357 travel along many directories.
4330
4358
4331 * Fixed bug in magic_pdef: would only work with functions with
4359 * Fixed bug in magic_pdef: would only work with functions with
4332 arguments with default values.
4360 arguments with default values.
4333
4361
4334 2001-11-14 Fernando Perez <fperez@colorado.edu>
4362 2001-11-14 Fernando Perez <fperez@colorado.edu>
4335
4363
4336 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4364 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4337 example with IPython. Various other minor fixes and cleanups.
4365 example with IPython. Various other minor fixes and cleanups.
4338
4366
4339 * Version 0.1.9 released, 0.1.10 opened for further work.
4367 * Version 0.1.9 released, 0.1.10 opened for further work.
4340
4368
4341 * Added sys.path to the list of directories searched in the
4369 * Added sys.path to the list of directories searched in the
4342 execfile= option. It used to be the current directory and the
4370 execfile= option. It used to be the current directory and the
4343 user's IPYTHONDIR only.
4371 user's IPYTHONDIR only.
4344
4372
4345 2001-11-13 Fernando Perez <fperez@colorado.edu>
4373 2001-11-13 Fernando Perez <fperez@colorado.edu>
4346
4374
4347 * Reinstated the raw_input/prefilter separation that Janko had
4375 * Reinstated the raw_input/prefilter separation that Janko had
4348 initially. This gives a more convenient setup for extending the
4376 initially. This gives a more convenient setup for extending the
4349 pre-processor from the outside: raw_input always gets a string,
4377 pre-processor from the outside: raw_input always gets a string,
4350 and prefilter has to process it. We can then redefine prefilter
4378 and prefilter has to process it. We can then redefine prefilter
4351 from the outside and implement extensions for special
4379 from the outside and implement extensions for special
4352 purposes.
4380 purposes.
4353
4381
4354 Today I got one for inputting PhysicalQuantity objects
4382 Today I got one for inputting PhysicalQuantity objects
4355 (from Scientific) without needing any function calls at
4383 (from Scientific) without needing any function calls at
4356 all. Extremely convenient, and it's all done as a user-level
4384 all. Extremely convenient, and it's all done as a user-level
4357 extension (no IPython code was touched). Now instead of:
4385 extension (no IPython code was touched). Now instead of:
4358 a = PhysicalQuantity(4.2,'m/s**2')
4386 a = PhysicalQuantity(4.2,'m/s**2')
4359 one can simply say
4387 one can simply say
4360 a = 4.2 m/s**2
4388 a = 4.2 m/s**2
4361 or even
4389 or even
4362 a = 4.2 m/s^2
4390 a = 4.2 m/s^2
4363
4391
4364 I use this, but it's also a proof of concept: IPython really is
4392 I use this, but it's also a proof of concept: IPython really is
4365 fully user-extensible, even at the level of the parsing of the
4393 fully user-extensible, even at the level of the parsing of the
4366 command line. It's not trivial, but it's perfectly doable.
4394 command line. It's not trivial, but it's perfectly doable.
4367
4395
4368 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4396 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4369 the problem of modules being loaded in the inverse order in which
4397 the problem of modules being loaded in the inverse order in which
4370 they were defined in
4398 they were defined in
4371
4399
4372 * Version 0.1.8 released, 0.1.9 opened for further work.
4400 * Version 0.1.8 released, 0.1.9 opened for further work.
4373
4401
4374 * Added magics pdef, source and file. They respectively show the
4402 * Added magics pdef, source and file. They respectively show the
4375 definition line ('prototype' in C), source code and full python
4403 definition line ('prototype' in C), source code and full python
4376 file for any callable object. The object inspector oinfo uses
4404 file for any callable object. The object inspector oinfo uses
4377 these to show the same information.
4405 these to show the same information.
4378
4406
4379 * Version 0.1.7 released, 0.1.8 opened for further work.
4407 * Version 0.1.7 released, 0.1.8 opened for further work.
4380
4408
4381 * Separated all the magic functions into a class called Magic. The
4409 * Separated all the magic functions into a class called Magic. The
4382 InteractiveShell class was becoming too big for Xemacs to handle
4410 InteractiveShell class was becoming too big for Xemacs to handle
4383 (de-indenting a line would lock it up for 10 seconds while it
4411 (de-indenting a line would lock it up for 10 seconds while it
4384 backtracked on the whole class!)
4412 backtracked on the whole class!)
4385
4413
4386 FIXME: didn't work. It can be done, but right now namespaces are
4414 FIXME: didn't work. It can be done, but right now namespaces are
4387 all messed up. Do it later (reverted it for now, so at least
4415 all messed up. Do it later (reverted it for now, so at least
4388 everything works as before).
4416 everything works as before).
4389
4417
4390 * Got the object introspection system (magic_oinfo) working! I
4418 * Got the object introspection system (magic_oinfo) working! I
4391 think this is pretty much ready for release to Janko, so he can
4419 think this is pretty much ready for release to Janko, so he can
4392 test it for a while and then announce it. Pretty much 100% of what
4420 test it for a while and then announce it. Pretty much 100% of what
4393 I wanted for the 'phase 1' release is ready. Happy, tired.
4421 I wanted for the 'phase 1' release is ready. Happy, tired.
4394
4422
4395 2001-11-12 Fernando Perez <fperez@colorado.edu>
4423 2001-11-12 Fernando Perez <fperez@colorado.edu>
4396
4424
4397 * Version 0.1.6 released, 0.1.7 opened for further work.
4425 * Version 0.1.6 released, 0.1.7 opened for further work.
4398
4426
4399 * Fixed bug in printing: it used to test for truth before
4427 * Fixed bug in printing: it used to test for truth before
4400 printing, so 0 wouldn't print. Now checks for None.
4428 printing, so 0 wouldn't print. Now checks for None.
4401
4429
4402 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4430 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4403 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4431 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4404 reaches by hand into the outputcache. Think of a better way to do
4432 reaches by hand into the outputcache. Think of a better way to do
4405 this later.
4433 this later.
4406
4434
4407 * Various small fixes thanks to Nathan's comments.
4435 * Various small fixes thanks to Nathan's comments.
4408
4436
4409 * Changed magic_pprint to magic_Pprint. This way it doesn't
4437 * Changed magic_pprint to magic_Pprint. This way it doesn't
4410 collide with pprint() and the name is consistent with the command
4438 collide with pprint() and the name is consistent with the command
4411 line option.
4439 line option.
4412
4440
4413 * Changed prompt counter behavior to be fully like
4441 * Changed prompt counter behavior to be fully like
4414 Mathematica's. That is, even input that doesn't return a result
4442 Mathematica's. That is, even input that doesn't return a result
4415 raises the prompt counter. The old behavior was kind of confusing
4443 raises the prompt counter. The old behavior was kind of confusing
4416 (getting the same prompt number several times if the operation
4444 (getting the same prompt number several times if the operation
4417 didn't return a result).
4445 didn't return a result).
4418
4446
4419 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4447 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4420
4448
4421 * Fixed -Classic mode (wasn't working anymore).
4449 * Fixed -Classic mode (wasn't working anymore).
4422
4450
4423 * Added colored prompts using Nathan's new code. Colors are
4451 * Added colored prompts using Nathan's new code. Colors are
4424 currently hardwired, they can be user-configurable. For
4452 currently hardwired, they can be user-configurable. For
4425 developers, they can be chosen in file ipythonlib.py, at the
4453 developers, they can be chosen in file ipythonlib.py, at the
4426 beginning of the CachedOutput class def.
4454 beginning of the CachedOutput class def.
4427
4455
4428 2001-11-11 Fernando Perez <fperez@colorado.edu>
4456 2001-11-11 Fernando Perez <fperez@colorado.edu>
4429
4457
4430 * Version 0.1.5 released, 0.1.6 opened for further work.
4458 * Version 0.1.5 released, 0.1.6 opened for further work.
4431
4459
4432 * Changed magic_env to *return* the environment as a dict (not to
4460 * Changed magic_env to *return* the environment as a dict (not to
4433 print it). This way it prints, but it can also be processed.
4461 print it). This way it prints, but it can also be processed.
4434
4462
4435 * Added Verbose exception reporting to interactive
4463 * Added Verbose exception reporting to interactive
4436 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4464 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4437 traceback. Had to make some changes to the ultraTB file. This is
4465 traceback. Had to make some changes to the ultraTB file. This is
4438 probably the last 'big' thing in my mental todo list. This ties
4466 probably the last 'big' thing in my mental todo list. This ties
4439 in with the next entry:
4467 in with the next entry:
4440
4468
4441 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4469 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4442 has to specify is Plain, Color or Verbose for all exception
4470 has to specify is Plain, Color or Verbose for all exception
4443 handling.
4471 handling.
4444
4472
4445 * Removed ShellServices option. All this can really be done via
4473 * Removed ShellServices option. All this can really be done via
4446 the magic system. It's easier to extend, cleaner and has automatic
4474 the magic system. It's easier to extend, cleaner and has automatic
4447 namespace protection and documentation.
4475 namespace protection and documentation.
4448
4476
4449 2001-11-09 Fernando Perez <fperez@colorado.edu>
4477 2001-11-09 Fernando Perez <fperez@colorado.edu>
4450
4478
4451 * Fixed bug in output cache flushing (missing parameter to
4479 * Fixed bug in output cache flushing (missing parameter to
4452 __init__). Other small bugs fixed (found using pychecker).
4480 __init__). Other small bugs fixed (found using pychecker).
4453
4481
4454 * Version 0.1.4 opened for bugfixing.
4482 * Version 0.1.4 opened for bugfixing.
4455
4483
4456 2001-11-07 Fernando Perez <fperez@colorado.edu>
4484 2001-11-07 Fernando Perez <fperez@colorado.edu>
4457
4485
4458 * Version 0.1.3 released, mainly because of the raw_input bug.
4486 * Version 0.1.3 released, mainly because of the raw_input bug.
4459
4487
4460 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4488 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4461 and when testing for whether things were callable, a call could
4489 and when testing for whether things were callable, a call could
4462 actually be made to certain functions. They would get called again
4490 actually be made to certain functions. They would get called again
4463 once 'really' executed, with a resulting double call. A disaster
4491 once 'really' executed, with a resulting double call. A disaster
4464 in many cases (list.reverse() would never work!).
4492 in many cases (list.reverse() would never work!).
4465
4493
4466 * Removed prefilter() function, moved its code to raw_input (which
4494 * Removed prefilter() function, moved its code to raw_input (which
4467 after all was just a near-empty caller for prefilter). This saves
4495 after all was just a near-empty caller for prefilter). This saves
4468 a function call on every prompt, and simplifies the class a tiny bit.
4496 a function call on every prompt, and simplifies the class a tiny bit.
4469
4497
4470 * Fix _ip to __ip name in magic example file.
4498 * Fix _ip to __ip name in magic example file.
4471
4499
4472 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4500 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4473 work with non-gnu versions of tar.
4501 work with non-gnu versions of tar.
4474
4502
4475 2001-11-06 Fernando Perez <fperez@colorado.edu>
4503 2001-11-06 Fernando Perez <fperez@colorado.edu>
4476
4504
4477 * Version 0.1.2. Just to keep track of the recent changes.
4505 * Version 0.1.2. Just to keep track of the recent changes.
4478
4506
4479 * Fixed nasty bug in output prompt routine. It used to check 'if
4507 * Fixed nasty bug in output prompt routine. It used to check 'if
4480 arg != None...'. Problem is, this fails if arg implements a
4508 arg != None...'. Problem is, this fails if arg implements a
4481 special comparison (__cmp__) which disallows comparing to
4509 special comparison (__cmp__) which disallows comparing to
4482 None. Found it when trying to use the PhysicalQuantity module from
4510 None. Found it when trying to use the PhysicalQuantity module from
4483 ScientificPython.
4511 ScientificPython.
4484
4512
4485 2001-11-05 Fernando Perez <fperez@colorado.edu>
4513 2001-11-05 Fernando Perez <fperez@colorado.edu>
4486
4514
4487 * Also added dirs. Now the pushd/popd/dirs family functions
4515 * Also added dirs. Now the pushd/popd/dirs family functions
4488 basically like the shell, with the added convenience of going home
4516 basically like the shell, with the added convenience of going home
4489 when called with no args.
4517 when called with no args.
4490
4518
4491 * pushd/popd slightly modified to mimic shell behavior more
4519 * pushd/popd slightly modified to mimic shell behavior more
4492 closely.
4520 closely.
4493
4521
4494 * Added env,pushd,popd from ShellServices as magic functions. I
4522 * Added env,pushd,popd from ShellServices as magic functions. I
4495 think the cleanest will be to port all desired functions from
4523 think the cleanest will be to port all desired functions from
4496 ShellServices as magics and remove ShellServices altogether. This
4524 ShellServices as magics and remove ShellServices altogether. This
4497 will provide a single, clean way of adding functionality
4525 will provide a single, clean way of adding functionality
4498 (shell-type or otherwise) to IP.
4526 (shell-type or otherwise) to IP.
4499
4527
4500 2001-11-04 Fernando Perez <fperez@colorado.edu>
4528 2001-11-04 Fernando Perez <fperez@colorado.edu>
4501
4529
4502 * Added .ipython/ directory to sys.path. This way users can keep
4530 * Added .ipython/ directory to sys.path. This way users can keep
4503 customizations there and access them via import.
4531 customizations there and access them via import.
4504
4532
4505 2001-11-03 Fernando Perez <fperez@colorado.edu>
4533 2001-11-03 Fernando Perez <fperez@colorado.edu>
4506
4534
4507 * Opened version 0.1.1 for new changes.
4535 * Opened version 0.1.1 for new changes.
4508
4536
4509 * Changed version number to 0.1.0: first 'public' release, sent to
4537 * Changed version number to 0.1.0: first 'public' release, sent to
4510 Nathan and Janko.
4538 Nathan and Janko.
4511
4539
4512 * Lots of small fixes and tweaks.
4540 * Lots of small fixes and tweaks.
4513
4541
4514 * Minor changes to whos format. Now strings are shown, snipped if
4542 * Minor changes to whos format. Now strings are shown, snipped if
4515 too long.
4543 too long.
4516
4544
4517 * Changed ShellServices to work on __main__ so they show up in @who
4545 * Changed ShellServices to work on __main__ so they show up in @who
4518
4546
4519 * Help also works with ? at the end of a line:
4547 * Help also works with ? at the end of a line:
4520 ?sin and sin?
4548 ?sin and sin?
4521 both produce the same effect. This is nice, as often I use the
4549 both produce the same effect. This is nice, as often I use the
4522 tab-complete to find the name of a method, but I used to then have
4550 tab-complete to find the name of a method, but I used to then have
4523 to go to the beginning of the line to put a ? if I wanted more
4551 to go to the beginning of the line to put a ? if I wanted more
4524 info. Now I can just add the ? and hit return. Convenient.
4552 info. Now I can just add the ? and hit return. Convenient.
4525
4553
4526 2001-11-02 Fernando Perez <fperez@colorado.edu>
4554 2001-11-02 Fernando Perez <fperez@colorado.edu>
4527
4555
4528 * Python version check (>=2.1) added.
4556 * Python version check (>=2.1) added.
4529
4557
4530 * Added LazyPython documentation. At this point the docs are quite
4558 * Added LazyPython documentation. At this point the docs are quite
4531 a mess. A cleanup is in order.
4559 a mess. A cleanup is in order.
4532
4560
4533 * Auto-installer created. For some bizarre reason, the zipfiles
4561 * Auto-installer created. For some bizarre reason, the zipfiles
4534 module isn't working on my system. So I made a tar version
4562 module isn't working on my system. So I made a tar version
4535 (hopefully the command line options in various systems won't kill
4563 (hopefully the command line options in various systems won't kill
4536 me).
4564 me).
4537
4565
4538 * Fixes to Struct in genutils. Now all dictionary-like methods are
4566 * Fixes to Struct in genutils. Now all dictionary-like methods are
4539 protected (reasonably).
4567 protected (reasonably).
4540
4568
4541 * Added pager function to genutils and changed ? to print usage
4569 * Added pager function to genutils and changed ? to print usage
4542 note through it (it was too long).
4570 note through it (it was too long).
4543
4571
4544 * Added the LazyPython functionality. Works great! I changed the
4572 * Added the LazyPython functionality. Works great! I changed the
4545 auto-quote escape to ';', it's on home row and next to '. But
4573 auto-quote escape to ';', it's on home row and next to '. But
4546 both auto-quote and auto-paren (still /) escapes are command-line
4574 both auto-quote and auto-paren (still /) escapes are command-line
4547 parameters.
4575 parameters.
4548
4576
4549
4577
4550 2001-11-01 Fernando Perez <fperez@colorado.edu>
4578 2001-11-01 Fernando Perez <fperez@colorado.edu>
4551
4579
4552 * Version changed to 0.0.7. Fairly large change: configuration now
4580 * Version changed to 0.0.7. Fairly large change: configuration now
4553 is all stored in a directory, by default .ipython. There, all
4581 is all stored in a directory, by default .ipython. There, all
4554 config files have normal looking names (not .names)
4582 config files have normal looking names (not .names)
4555
4583
4556 * Version 0.0.6 Released first to Lucas and Archie as a test
4584 * Version 0.0.6 Released first to Lucas and Archie as a test
4557 run. Since it's the first 'semi-public' release, change version to
4585 run. Since it's the first 'semi-public' release, change version to
4558 > 0.0.6 for any changes now.
4586 > 0.0.6 for any changes now.
4559
4587
4560 * Stuff I had put in the ipplib.py changelog:
4588 * Stuff I had put in the ipplib.py changelog:
4561
4589
4562 Changes to InteractiveShell:
4590 Changes to InteractiveShell:
4563
4591
4564 - Made the usage message a parameter.
4592 - Made the usage message a parameter.
4565
4593
4566 - Require the name of the shell variable to be given. It's a bit
4594 - Require the name of the shell variable to be given. It's a bit
4567 of a hack, but allows the name 'shell' not to be hardwire in the
4595 of a hack, but allows the name 'shell' not to be hardwire in the
4568 magic (@) handler, which is problematic b/c it requires
4596 magic (@) handler, which is problematic b/c it requires
4569 polluting the global namespace with 'shell'. This in turn is
4597 polluting the global namespace with 'shell'. This in turn is
4570 fragile: if a user redefines a variable called shell, things
4598 fragile: if a user redefines a variable called shell, things
4571 break.
4599 break.
4572
4600
4573 - magic @: all functions available through @ need to be defined
4601 - magic @: all functions available through @ need to be defined
4574 as magic_<name>, even though they can be called simply as
4602 as magic_<name>, even though they can be called simply as
4575 @<name>. This allows the special command @magic to gather
4603 @<name>. This allows the special command @magic to gather
4576 information automatically about all existing magic functions,
4604 information automatically about all existing magic functions,
4577 even if they are run-time user extensions, by parsing the shell
4605 even if they are run-time user extensions, by parsing the shell
4578 instance __dict__ looking for special magic_ names.
4606 instance __dict__ looking for special magic_ names.
4579
4607
4580 - mainloop: added *two* local namespace parameters. This allows
4608 - mainloop: added *two* local namespace parameters. This allows
4581 the class to differentiate between parameters which were there
4609 the class to differentiate between parameters which were there
4582 before and after command line initialization was processed. This
4610 before and after command line initialization was processed. This
4583 way, later @who can show things loaded at startup by the
4611 way, later @who can show things loaded at startup by the
4584 user. This trick was necessary to make session saving/reloading
4612 user. This trick was necessary to make session saving/reloading
4585 really work: ideally after saving/exiting/reloading a session,
4613 really work: ideally after saving/exiting/reloading a session,
4586 *everythin* should look the same, including the output of @who. I
4614 *everythin* should look the same, including the output of @who. I
4587 was only able to make this work with this double namespace
4615 was only able to make this work with this double namespace
4588 trick.
4616 trick.
4589
4617
4590 - added a header to the logfile which allows (almost) full
4618 - added a header to the logfile which allows (almost) full
4591 session restoring.
4619 session restoring.
4592
4620
4593 - prepend lines beginning with @ or !, with a and log
4621 - prepend lines beginning with @ or !, with a and log
4594 them. Why? !lines: may be useful to know what you did @lines:
4622 them. Why? !lines: may be useful to know what you did @lines:
4595 they may affect session state. So when restoring a session, at
4623 they may affect session state. So when restoring a session, at
4596 least inform the user of their presence. I couldn't quite get
4624 least inform the user of their presence. I couldn't quite get
4597 them to properly re-execute, but at least the user is warned.
4625 them to properly re-execute, but at least the user is warned.
4598
4626
4599 * Started ChangeLog.
4627 * Started ChangeLog.
@@ -1,391 +1,390 b''
1 .\" Hey, EMACS: -*- nroff -*-
1 .\" Hey, EMACS: -*- nroff -*-
2 .\" First parameter, NAME, should be all caps
2 .\" First parameter, NAME, should be all caps
3 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
3 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
4 .\" other parameters are allowed: see man(7), man(1)
4 .\" other parameters are allowed: see man(7), man(1)
5 .TH IPYTHON 1 "November 30, 2004"
5 .TH IPYTHON 1 "November 30, 2004"
6 .\" Please adjust this date whenever revising the manpage.
6 .\" Please adjust this date whenever revising the manpage.
7 .\"
7 .\"
8 .\" Some roff macros, for reference:
8 .\" Some roff macros, for reference:
9 .\" .nh disable hyphenation
9 .\" .nh disable hyphenation
10 .\" .hy enable hyphenation
10 .\" .hy enable hyphenation
11 .\" .ad l left justify
11 .\" .ad l left justify
12 .\" .ad b justify to both left and right margins
12 .\" .ad b justify to both left and right margins
13 .\" .nf disable filling
13 .\" .nf disable filling
14 .\" .fi enable filling
14 .\" .fi enable filling
15 .\" .br insert line break
15 .\" .br insert line break
16 .\" .sp <n> insert n+1 empty lines
16 .\" .sp <n> insert n+1 empty lines
17 .\" for manpage-specific macros, see man(7) and groff_man(7)
17 .\" for manpage-specific macros, see man(7) and groff_man(7)
18 .\" .SH section heading
18 .\" .SH section heading
19 .\" .SS secondary section heading
19 .\" .SS secondary section heading
20 .\"
20 .\"
21 .\"
21 .\"
22 .\" To preview this page as plain text: nroff -man ipython.1
22 .\" To preview this page as plain text: nroff -man ipython.1
23 .\"
23 .\"
24 .SH NAME
24 .SH NAME
25 ipython \- An Enhanced Interactive Python
25 ipython \- An Enhanced Interactive Python
26 .SH SYNOPSIS
26 .SH SYNOPSIS
27 .B ipython
27 .B ipython
28 .RI [ options ] " files" ...
28 .RI [ options ] " files" ...
29 .SH DESCRIPTION
29 .SH DESCRIPTION
30 An interactive Python shell with automatic history (input and output),
30 An interactive Python shell with automatic history (input and output),
31 dynamic object introspection, easier configuration, command
31 dynamic object introspection, easier configuration, command
32 completion, access to the system shell, integration with numerical and
32 completion, access to the system shell, integration with numerical and
33 scientific computing tools, and more.
33 scientific computing tools, and more.
34 .SH SPECIAL THREADING OPTIONS
34 .SH SPECIAL THREADING OPTIONS
35 The following special options are ONLY valid at the beginning of the command
35 The following special options are ONLY valid at the beginning of the command
36 line, and not later. This is because they control the initialization of
36 line, and not later. This is because they control the initialization of
37 ipython itself, before the normal option-handling mechanism is active.
37 ipython itself, before the normal option-handling mechanism is active.
38 .TP
38 .TP
39 .B \-gthread, \-qthread, \-wthread, \-pylab
39 .B \-gthread, \-qthread, \-wthread, \-pylab
40 Only ONE of these can be given, and it can only be given as the first option
40 Only ONE of these can be given, and it can only be given as the first option
41 passed to IPython (it will have no effect in any other position). They
41 passed to IPython (it will have no effect in any other position). They
42 provide threading support for the GTK, QT and WXWidgets toolkits, and for the
42 provide threading support for the GTK, QT and WXWidgets toolkits, and for the
43 matplotlib library.
43 matplotlib library.
44 .br
44 .br
45 .sp 1
45 .sp 1
46 With any of the first three options, IPython starts running a separate thread
46 With any of the first three options, IPython starts running a separate thread
47 for the graphical toolkit's operation, so that you can open and control
47 for the graphical toolkit's operation, so that you can open and control
48 graphical elements from within an IPython command line, without blocking. All
48 graphical elements from within an IPython command line, without blocking. All
49 three provide essentially the same functionality, respectively for GTK, QT and
49 three provide essentially the same functionality, respectively for GTK, QT and
50 WXWidgets (via their Python interfaces).
50 WXWidgets (via their Python interfaces).
51 .br
51 .br
52 .sp 1
52 .sp 1
53 If \-pylab is given, IPython loads special support for the matplotlib library
53 If \-pylab is given, IPython loads special support for the matplotlib library
54 (http://matplotlib.sourceforge.net), allowing interactive usage of any of its
54 (http://matplotlib.sourceforge.net), allowing interactive usage of any of its
55 backends as defined in the user's .matplotlibrc file. It automatically
55 backends as defined in the user's .matplotlibrc file. It automatically
56 activates GTK, QT or WX threading for IPyhton if the choice of matplotlib
56 activates GTK, QT or WX threading for IPyhton if the choice of matplotlib
57 backend requires it. It also modifies the %run command to correctly execute
57 backend requires it. It also modifies the %run command to correctly execute
58 (without blocking) any matplotlib-based script which calls show() at the end.
58 (without blocking) any matplotlib-based script which calls show() at the end.
59 .TP
59 .TP
60 .B \-tk
60 .B \-tk
61 The \-g/q/wthread options, and \-pylab (if matplotlib is configured to use
61 The \-g/q/wthread options, and \-pylab (if matplotlib is configured to use
62 GTK, QT or WX), will normally block Tk graphical interfaces. This means that
62 GTK, QT or WX), will normally block Tk graphical interfaces. This means that
63 when GTK, QT or WX threading is active, any attempt to open a Tk GUI will
63 when GTK, QT or WX threading is active, any attempt to open a Tk GUI will
64 result in a dead window, and possibly cause the Python interpreter to crash.
64 result in a dead window, and possibly cause the Python interpreter to crash.
65 An extra option, \-tk, is available to address this issue. It can ONLY be
65 An extra option, \-tk, is available to address this issue. It can ONLY be
66 given as a SECOND option after any of the above (\-gthread, \-qthread,
66 given as a SECOND option after any of the above (\-gthread, \-qthread,
67 \-wthread or \-pylab).
67 \-wthread or \-pylab).
68 .br
68 .br
69 .sp 1
69 .sp 1
70 If \-tk is given, IPython will try to coordinate Tk threading with GTK, QT or
70 If \-tk is given, IPython will try to coordinate Tk threading with GTK, QT or
71 WX. This is however potentially unreliable, and you will have to test on your
71 WX. This is however potentially unreliable, and you will have to test on your
72 platform and Python configuration to determine whether it works for you.
72 platform and Python configuration to determine whether it works for you.
73 Debian users have reported success, apparently due to the fact that Debian
73 Debian users have reported success, apparently due to the fact that Debian
74 builds all of Tcl, Tk, Tkinter and Python with pthreads support. Under other
74 builds all of Tcl, Tk, Tkinter and Python with pthreads support. Under other
75 Linux environments (such as Fedora Core 2), this option has caused random
75 Linux environments (such as Fedora Core 2), this option has caused random
76 crashes and lockups of the Python interpreter. Under other operating systems
76 crashes and lockups of the Python interpreter. Under other operating systems
77 (Mac OSX and Windows), you'll need to try it to find out, since currently no
77 (Mac OSX and Windows), you'll need to try it to find out, since currently no
78 user reports are available.
78 user reports are available.
79 .br
79 .br
80 .sp 1
80 .sp 1
81 There is unfortunately no way for IPython to determine at runtime whether \-tk
81 There is unfortunately no way for IPython to determine at runtime whether \-tk
82 will work reliably or not, so you will need to do some experiments before
82 will work reliably or not, so you will need to do some experiments before
83 relying on it for regular work.
83 relying on it for regular work.
84 .
84 .
85 .SS A WARNING ABOUT SIGNALS AND THREADS
85 .SS A WARNING ABOUT SIGNALS AND THREADS
86 When any of the thread systems (GTK, QT or WX) are active, either directly or
86 When any of the thread systems (GTK, QT or WX) are active, either directly or
87 via \-pylab with a threaded backend, it is impossible to interrupt
87 via \-pylab with a threaded backend, it is impossible to interrupt
88 long-running Python code via Ctrl\-C. IPython can not pass the
88 long-running Python code via Ctrl\-C. IPython can not pass the
89 KeyboardInterrupt exception (or the underlying SIGINT) across threads, so any
89 KeyboardInterrupt exception (or the underlying SIGINT) across threads, so any
90 long-running process started from IPython will run to completion, or will have
90 long-running process started from IPython will run to completion, or will have
91 to be killed via an external (OS-based) mechanism.
91 to be killed via an external (OS-based) mechanism.
92 .br
92 .br
93 .sp 1
93 .sp 1
94 To the best of my knowledge, this limitation is imposed by the Python
94 To the best of my knowledge, this limitation is imposed by the Python
95 interpreter itself, and it comes from the difficulty of writing portable
95 interpreter itself, and it comes from the difficulty of writing portable
96 signal/threaded code. If any user is an expert on this topic and can suggest
96 signal/threaded code. If any user is an expert on this topic and can suggest
97 a better solution, I would love to hear about it. In the IPython sources,
97 a better solution, I would love to hear about it. In the IPython sources,
98 look at the Shell.py module, and in particular at the runcode() method.
98 look at the Shell.py module, and in particular at the runcode() method.
99 .
99 .
100 .SH REGULAR OPTIONS
100 .SH REGULAR OPTIONS
101 After the above threading options have been given, regular options can follow
101 After the above threading options have been given, regular options can follow
102 in any order. All options can be abbreviated to their shortest non-ambiguous
102 in any order. All options can be abbreviated to their shortest non-ambiguous
103 form and are case-sensitive. One or two dashes can be used. Some options
103 form and are case-sensitive. One or two dashes can be used. Some options
104 have an alternate short form, indicated after a |.
104 have an alternate short form, indicated after a |.
105 .br
105 .br
106 .sp 1
106 .sp 1
107 Most options can also be set from your ipythonrc configuration file.
107 Most options can also be set from your ipythonrc configuration file.
108 See the provided examples for assistance. Options given on the
108 See the provided examples for assistance. Options given on the
109 commandline override the values set in the ipythonrc file.
109 commandline override the values set in the ipythonrc file.
110 .br
110 .br
111 .sp 1
111 .sp 1
112 All options with a [no] prepended can be specified in negated form
112 All options with a [no] prepended can be specified in negated form
113 (\-nooption instead of \-option) to turn the feature off.
113 (\-nooption instead of \-option) to turn the feature off.
114 .TP
114 .TP
115 .B \-h, \-\-help
115 .B \-h, \-\-help
116 Show summary of options.
116 Show summary of options.
117 .TP
117 .TP
118 .B \-[no]autocall
118 .B \-[no]autocall
119 Make IPython automatically call any callable object even if you didn't type
119 Make IPython automatically call any callable object even if you didn't type
120 explicit parentheses. For example, 'str 43' becomes 'str(43)' automatically.
120 explicit parentheses. For example, 'str 43' becomes 'str(43)' automatically.
121 .TP
121 .TP
122 .B \-[no]autoindent
122 .B \-[no]autoindent
123 Turn automatic indentation on/off.
123 Turn automatic indentation on/off.
124 .TP
124 .TP
125 .B \-[no]automagic
125 .B \-[no]automagic
126 Make magic commands automatic (without needing their first character
126 Make magic commands automatic (without needing their first character
127 to be %). Type %magic at the IPython prompt for more information.
127 to be %). Type %magic at the IPython prompt for more information.
128 .TP
128 .TP
129 .B \-[no]autoedit_syntax
129 .B \-[no]autoedit_syntax
130 When a syntax error occurs after editing a file, automatically open the file
130 When a syntax error occurs after editing a file, automatically open the file
131 to the trouble causing line for convenient fixing.
131 to the trouble causing line for convenient fixing.
132 .TP
132 .TP
133 .B \-[no]banner
133 .B \-[no]banner
134 Print the intial information banner (default on).
134 Print the intial information banner (default on).
135 .TP
135 .TP
136 .B \-c <command>
136 .B \-c <command>
137 Execute the given command string, and set sys.argv to ['c']. This is similar
137 Execute the given command string, and set sys.argv to ['c']. This is similar
138 to the \-c option in the normal Python interpreter.
138 to the \-c option in the normal Python interpreter.
139 .TP
139 .TP
140 .B \-cache_size|cs <n>
140 .B \-cache_size|cs <n>
141 Size of the output cache (maximum number of entries to hold in
141 Size of the output cache (maximum number of entries to hold in
142 memory). The default is 1000, you can change it permanently in your
142 memory). The default is 1000, you can change it permanently in your
143 config file. Setting it to 0 completely disables the caching system,
143 config file. Setting it to 0 completely disables the caching system,
144 and the minimum value accepted is 20 (if you provide a value less than
144 and the minimum value accepted is 20 (if you provide a value less than
145 20, it is reset to 0 and a warning is issued). This limit is defined
145 20, it is reset to 0 and a warning is issued). This limit is defined
146 because otherwise you'll spend more time re-flushing a too small cache
146 because otherwise you'll spend more time re-flushing a too small cache
147 than working.
147 than working.
148 .TP
148 .TP
149 .B \-classic|cl
149 .B \-classic|cl
150 Gives IPython a similar feel to the classic Python prompt.
150 Gives IPython a similar feel to the classic Python prompt.
151 .TP
151 .TP
152 .B \-colors <scheme>
152 .B \-colors <scheme>
153 Color scheme for prompts and exception reporting. Currently
153 Color scheme for prompts and exception reporting. Currently
154 implemented: NoColor, Linux, and LightBG.
154 implemented: NoColor, Linux, and LightBG.
155 .TP
155 .TP
156 .B \-[no]color_info
156 .B \-[no]color_info
157 IPython can display information about objects via a set of functions,
157 IPython can display information about objects via a set of functions,
158 and optionally can use colors for this, syntax highlighting source
158 and optionally can use colors for this, syntax highlighting source
159 code and various other elements. However, because this information is
159 code and various other elements. However, because this information is
160 passed through a pager (like 'less') and many pagers get confused with
160 passed through a pager (like 'less') and many pagers get confused with
161 color codes, this option is off by default. You can test it and turn
161 color codes, this option is off by default. You can test it and turn
162 it on permanently in your ipythonrc file if it works for you. As a
162 it on permanently in your ipythonrc file if it works for you. As a
163 reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
163 reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
164 that in RedHat 7.2 doesn't.
164 that in RedHat 7.2 doesn't.
165 .br
165 .br
166 .sp 1
166 .sp 1
167 Test it and turn it on permanently if it works with your system. The
167 Test it and turn it on permanently if it works with your system. The
168 magic function @color_info allows you to toggle this interactively for
168 magic function @color_info allows you to toggle this interactively for
169 testing.
169 testing.
170 .TP
170 .TP
171 .B \-[no]confirm_exit
171 .B \-[no]confirm_exit
172 Set to confirm when you try to exit IPython with an EOF (Control-D in
172 Set to confirm when you try to exit IPython with an EOF (Control-D in
173 Unix, Control-Z/Enter in Windows). Note that using the magic functions
173 Unix, Control-Z/Enter in Windows). Note that using the magic functions
174 @Exit or @Quit you can force a direct exit, bypassing any
174 @Exit or @Quit you can force a direct exit, bypassing any
175 confirmation.
175 confirmation.
176 .TP
176 .TP
177 .B \-[no]debug
177 .B \-[no]debug
178 Show information about the loading process. Very useful to pin down
178 Show information about the loading process. Very useful to pin down
179 problems with your configuration files or to get details about session
179 problems with your configuration files or to get details about session
180 restores.
180 restores.
181 .TP
181 .TP
182 .B \-[no]deep_reload
182 .B \-[no]deep_reload
183 IPython can use the deep_reload module which reloads changes in
183 IPython can use the deep_reload module which reloads changes in
184 modules recursively (it replaces the reload() function, so you don't
184 modules recursively (it replaces the reload() function, so you don't
185 need to change anything to use it). deep_reload() forces a full reload
185 need to change anything to use it). deep_reload() forces a full reload
186 of modules whose code may have changed, which the default reload()
186 of modules whose code may have changed, which the default reload()
187 function does not.
187 function does not.
188 .br
188 .br
189 .sp 1
189 .sp 1
190 When deep_reload is off, IPython will use the normal reload(), but
190 When deep_reload is off, IPython will use the normal reload(), but
191 deep_reload will still be available as dreload(). This feature is off
191 deep_reload will still be available as dreload(). This feature is off
192 by default [which means that you have both normal reload() and
192 by default [which means that you have both normal reload() and
193 dreload()].
193 dreload()].
194 .TP
194 .TP
195 .B \-editor <name>
195 .B \-editor <name>
196 Which editor to use with the @edit command. By default, IPython will
196 Which editor to use with the @edit command. By default, IPython will
197 honor your EDITOR environment variable (if not set, vi is the Unix
197 honor your EDITOR environment variable (if not set, vi is the Unix
198 default and notepad the Windows one). Since this editor is invoked on
198 default and notepad the Windows one). Since this editor is invoked on
199 the fly by IPython and is meant for editing small code snippets, you
199 the fly by IPython and is meant for editing small code snippets, you
200 may want to use a small, lightweight editor here (in case your default
200 may want to use a small, lightweight editor here (in case your default
201 EDITOR is something like Emacs).
201 EDITOR is something like Emacs).
202 .TP
202 .TP
203 .B \-ipythondir <name>
203 .B \-ipythondir <name>
204 The name of your IPython configuration directory IPYTHONDIR. This can
204 The name of your IPython configuration directory IPYTHONDIR. This can
205 also be specified through the environment variable IPYTHONDIR.
205 also be specified through the environment variable IPYTHONDIR.
206 .TP
206 .TP
207 .B \-log|l
207 .B \-log|l
208 Generate a log file of all input. The file is named ipython.log in
208 Generate a log file of all input. The file is named ipython_log.py in your
209 your current directory (which prevents logs from multiple IPython
209 current directory (which prevents logs from multiple IPython sessions from
210 sessions from trampling each other). You can use this to later restore
210 trampling each other). You can use this to later restore a session by loading
211 a session by loading your logfile as a file to be executed with option
211 your logfile as a file to be executed with option -logplay (see below).
212 -logplay (see below).
213 .TP
212 .TP
214 .B \-logfile|lf
213 .B \-logfile|lf
215 Specifu the name of your logfile.
214 Specify the name of your logfile.
216 .TP
215 .TP
217 .B \-logplay|lp
216 .B \-logplay|lp
218 Replay a previous log. For restoring a session as close as possible to
217 Replay a previous log. For restoring a session as close as possible to
219 the state you left it in, use this option (don't just run the
218 the state you left it in, use this option (don't just run the
220 logfile). With \-logplay, IPython will try to reconstruct the previous
219 logfile). With \-logplay, IPython will try to reconstruct the previous
221 working environment in full, not just execute the commands in the
220 working environment in full, not just execute the commands in the
222 logfile.
221 logfile.
223 .br
222 .br
224 .sh 1
223 .sh 1
225 When a session is restored, logging is automatically turned on again
224 When a session is restored, logging is automatically turned on again
226 with the name of the logfile it was invoked with (it is read from the
225 with the name of the logfile it was invoked with (it is read from the
227 log header). So once you've turned logging on for a session, you can
226 log header). So once you've turned logging on for a session, you can
228 quit IPython and reload it as many times as you want and it will
227 quit IPython and reload it as many times as you want and it will
229 continue to log its history and restore from the beginning every time.
228 continue to log its history and restore from the beginning every time.
230 .br
229 .br
231 .sp 1
230 .sp 1
232 Caveats: there are limitations in this option. The history variables
231 Caveats: there are limitations in this option. The history variables
233 _i*,_* and _dh don't get restored properly. In the future we will try
232 _i*,_* and _dh don't get restored properly. In the future we will try
234 to implement full session saving by writing and retrieving a
233 to implement full session saving by writing and retrieving a
235 'snapshot' of the memory state of IPython. But our first attempts
234 'snapshot' of the memory state of IPython. But our first attempts
236 failed because of inherent limitations of Python's Pickle module, so
235 failed because of inherent limitations of Python's Pickle module, so
237 this may have to wait.
236 this may have to wait.
238 .TP
237 .TP
239 .B \-[no]messages
238 .B \-[no]messages
240 Print messages which IPython collects about its startup process
239 Print messages which IPython collects about its startup process
241 (default on).
240 (default on).
242 .TP
241 .TP
243 .B \-[no]pdb
242 .B \-[no]pdb
244 Automatically call the pdb debugger after every uncaught exception. If
243 Automatically call the pdb debugger after every uncaught exception. If
245 you are used to debugging using pdb, this puts you automatically
244 you are used to debugging using pdb, this puts you automatically
246 inside of it after any call (either in IPython or in code called by
245 inside of it after any call (either in IPython or in code called by
247 it) which triggers an exception which goes uncaught.
246 it) which triggers an exception which goes uncaught.
248 .TP
247 .TP
249 .B \-[no]pprint
248 .B \-[no]pprint
250 IPython can optionally use the pprint (pretty printer) module for
249 IPython can optionally use the pprint (pretty printer) module for
251 displaying results. pprint tends to give a nicer display of nested
250 displaying results. pprint tends to give a nicer display of nested
252 data structures. If you like it, you can turn it on permanently in
251 data structures. If you like it, you can turn it on permanently in
253 your config file (default off).
252 your config file (default off).
254 .TP
253 .TP
255 .B \-profile|p <name>
254 .B \-profile|p <name>
256 Assume that your config file is ipythonrc-<name> (looks in current dir
255 Assume that your config file is ipythonrc-<name> (looks in current dir
257 first, then in IPYTHONDIR). This is a quick way to keep and load
256 first, then in IPYTHONDIR). This is a quick way to keep and load
258 multiple config files for different tasks, especially if you use the
257 multiple config files for different tasks, especially if you use the
259 include option of config files. You can keep a basic
258 include option of config files. You can keep a basic
260 IPYTHONDIR/ipythonrc file and then have other 'profiles' which include
259 IPYTHONDIR/ipythonrc file and then have other 'profiles' which include
261 this one and load extra things for particular tasks. For example:
260 this one and load extra things for particular tasks. For example:
262 .br
261 .br
263 .sp 1
262 .sp 1
264 1) $HOME/.ipython/ipythonrc : load basic things you always want.
263 1) $HOME/.ipython/ipythonrc : load basic things you always want.
265 .br
264 .br
266 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math-related
265 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math-related
267 modules.
266 modules.
268 .br
267 .br
269 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
268 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
270 plotting modules.
269 plotting modules.
271 .br
270 .br
272 .sp 1
271 .sp 1
273 Since it is possible to create an endless loop by having circular file
272 Since it is possible to create an endless loop by having circular file
274 inclusions, IPython will stop if it reaches 15 recursive inclusions.
273 inclusions, IPython will stop if it reaches 15 recursive inclusions.
275 .TP
274 .TP
276 .B \-prompt_in1|pi1 <string>
275 .B \-prompt_in1|pi1 <string>
277 Specify the string used for input prompts. Note that if you are using
276 Specify the string used for input prompts. Note that if you are using
278 numbered prompts, the number is represented with a '\\#' in the
277 numbered prompts, the number is represented with a '\\#' in the
279 string. Don't forget to quote strings with spaces embedded in
278 string. Don't forget to quote strings with spaces embedded in
280 them. Default: 'In [\\#]:'.
279 them. Default: 'In [\\#]:'.
281 .br
280 .br
282 .sp 1
281 .sp 1
283 Most bash-like escapes can be used to customize IPython's prompts, as well as
282 Most bash-like escapes can be used to customize IPython's prompts, as well as
284 a few additional ones which are IPython-specific. All valid prompt escapes
283 a few additional ones which are IPython-specific. All valid prompt escapes
285 are described in detail in the Customization section of the IPython HTML/PDF
284 are described in detail in the Customization section of the IPython HTML/PDF
286 manual.
285 manual.
287 .TP
286 .TP
288 .B \-prompt_in2|pi2 <string>
287 .B \-prompt_in2|pi2 <string>
289 Similar to the previous option, but used for the continuation prompts. The
288 Similar to the previous option, but used for the continuation prompts. The
290 special sequence '\\D' is similar to '\\#', but with all digits replaced dots
289 special sequence '\\D' is similar to '\\#', but with all digits replaced dots
291 (so you can have your continuation prompt aligned with your input
290 (so you can have your continuation prompt aligned with your input
292 prompt). Default: ' .\\D.:' (note three spaces at the start for alignment
291 prompt). Default: ' .\\D.:' (note three spaces at the start for alignment
293 with 'In [\\#]').
292 with 'In [\\#]').
294 .TP
293 .TP
295 .B \-prompt_out|po <string>
294 .B \-prompt_out|po <string>
296 String used for output prompts, also uses numbers like prompt_in1.
295 String used for output prompts, also uses numbers like prompt_in1.
297 Default: 'Out[\\#]:'.
296 Default: 'Out[\\#]:'.
298 .TP
297 .TP
299 .B \-quick
298 .B \-quick
300 Start in bare bones mode (no config file loaded).
299 Start in bare bones mode (no config file loaded).
301 .TP
300 .TP
302 .B \-rcfile <name>
301 .B \-rcfile <name>
303 Name of your IPython resource configuration file. normally IPython
302 Name of your IPython resource configuration file. normally IPython
304 loads ipythonrc (from current directory) or IPYTHONDIR/ipythonrc. If
303 loads ipythonrc (from current directory) or IPYTHONDIR/ipythonrc. If
305 the loading of your config file fails, IPython starts with a bare
304 the loading of your config file fails, IPython starts with a bare
306 bones configuration (no modules loaded at all).
305 bones configuration (no modules loaded at all).
307 .TP
306 .TP
308 .B \-[no]readline
307 .B \-[no]readline
309 Use the readline library, which is needed to support name completion
308 Use the readline library, which is needed to support name completion
310 and command history, among other things. It is enabled by default, but
309 and command history, among other things. It is enabled by default, but
311 may cause problems for users of X/Emacs in Python comint or shell
310 may cause problems for users of X/Emacs in Python comint or shell
312 buffers.
311 buffers.
313 .br
312 .br
314 .sp 1
313 .sp 1
315 Note that emacs 'eterm' buffers (opened with M-x term) support
314 Note that emacs 'eterm' buffers (opened with M-x term) support
316 IPython's readline and syntax coloring fine, only 'emacs' (M-x shell
315 IPython's readline and syntax coloring fine, only 'emacs' (M-x shell
317 and C-c !) buffers do not.
316 and C-c !) buffers do not.
318 .TP
317 .TP
319 .B \-screen_length|sl <n>
318 .B \-screen_length|sl <n>
320 Number of lines of your screen. This is used to control printing of
319 Number of lines of your screen. This is used to control printing of
321 very long strings. Strings longer than this number of lines will be
320 very long strings. Strings longer than this number of lines will be
322 sent through a pager instead of directly printed.
321 sent through a pager instead of directly printed.
323 .br
322 .br
324 .sp 1
323 .sp 1
325 The default value for this is 0, which means IPython will auto-detect
324 The default value for this is 0, which means IPython will auto-detect
326 your screen size every time it needs to print certain potentially long
325 your screen size every time it needs to print certain potentially long
327 strings (this doesn't change the behavior of the 'print' keyword, it's
326 strings (this doesn't change the behavior of the 'print' keyword, it's
328 only triggered internally). If for some reason this isn't working well
327 only triggered internally). If for some reason this isn't working well
329 (it needs curses support), specify it yourself. Otherwise don't change
328 (it needs curses support), specify it yourself. Otherwise don't change
330 the default.
329 the default.
331 .TP
330 .TP
332 .B \-separate_in|si <string>
331 .B \-separate_in|si <string>
333 Separator before input prompts. Default '\n'.
332 Separator before input prompts. Default '\n'.
334 .TP
333 .TP
335 .B \-separate_out|so <string>
334 .B \-separate_out|so <string>
336 Separator before output prompts. Default: 0 (nothing).
335 Separator before output prompts. Default: 0 (nothing).
337 .TP
336 .TP
338 .B \-separate_out2|so2 <string>
337 .B \-separate_out2|so2 <string>
339 Separator after output prompts. Default: 0 (nothing).
338 Separator after output prompts. Default: 0 (nothing).
340 .TP
339 .TP
341 .B \-nosep
340 .B \-nosep
342 Shorthand for '\-separate_in 0 \-separate_out 0 \-separate_out2 0'.
341 Shorthand for '\-separate_in 0 \-separate_out 0 \-separate_out2 0'.
343 Simply removes all input/output separators.
342 Simply removes all input/output separators.
344 .TP
343 .TP
345 .B \-upgrade
344 .B \-upgrade
346 Allows you to upgrade your IPYTHONDIR configuration when you install a
345 Allows you to upgrade your IPYTHONDIR configuration when you install a
347 new version of IPython. Since new versions may include new command
346 new version of IPython. Since new versions may include new command
348 lines options or example files, this copies updated ipythonrc-type
347 lines options or example files, this copies updated ipythonrc-type
349 files. However, it backs up (with a .old extension) all files which
348 files. However, it backs up (with a .old extension) all files which
350 it overwrites so that you can merge back any custimizations you might
349 it overwrites so that you can merge back any custimizations you might
351 have in your personal files.
350 have in your personal files.
352 .TP
351 .TP
353 .B \-Version
352 .B \-Version
354 Print version information and exit.
353 Print version information and exit.
355 .TP
354 .TP
356 .B \-xmode <modename>
355 .B \-xmode <modename>
357 Mode for exception reporting. The valid modes are Plain, Context, and
356 Mode for exception reporting. The valid modes are Plain, Context, and
358 Verbose.
357 Verbose.
359 .br
358 .br
360 .sp 1
359 .sp 1
361 \- Plain: similar to python's normal traceback printing.
360 \- Plain: similar to python's normal traceback printing.
362 .br
361 .br
363 .sp 1
362 .sp 1
364 \- Context: prints 5 lines of context source code around each line in the
363 \- Context: prints 5 lines of context source code around each line in the
365 traceback.
364 traceback.
366 .br
365 .br
367 .sp 1
366 .sp 1
368 \- Verbose: similar to Context, but additionally prints the variables
367 \- Verbose: similar to Context, but additionally prints the variables
369 currently visible where the exception happened (shortening their strings if
368 currently visible where the exception happened (shortening their strings if
370 too long). This can potentially be very slow, if you happen to have a huge
369 too long). This can potentially be very slow, if you happen to have a huge
371 data structure whose string representation is complex to compute. Your
370 data structure whose string representation is complex to compute. Your
372 computer may appear to freeze for a while with cpu usage at 100%. If this
371 computer may appear to freeze for a while with cpu usage at 100%. If this
373 occurs, you can cancel the traceback with Ctrl-C (maybe hitting it more than
372 occurs, you can cancel the traceback with Ctrl-C (maybe hitting it more than
374 once).
373 once).
375 .
374 .
376 .SH EMBEDDING
375 .SH EMBEDDING
377 It is possible to start an IPython instance inside your own Python
376 It is possible to start an IPython instance inside your own Python
378 programs. In the documentation example files there are some
377 programs. In the documentation example files there are some
379 illustrations on how to do this.
378 illustrations on how to do this.
380 .br
379 .br
381 .sp 1
380 .sp 1
382 This feature allows you to evalutate dynamically the state of your
381 This feature allows you to evalutate dynamically the state of your
383 code, operate with your variables, analyze them, etc. Note however
382 code, operate with your variables, analyze them, etc. Note however
384 that any changes you make to values while in the shell do NOT
383 that any changes you make to values while in the shell do NOT
385 propagate back to the running code, so it is safe to modify your
384 propagate back to the running code, so it is safe to modify your
386 values because you won't break your code in bizarre ways by doing so.
385 values because you won't break your code in bizarre ways by doing so.
387 .SH AUTHOR
386 .SH AUTHOR
388 IPython was written by Fernando Perez <fperez@colorado.edu>, based on earlier
387 IPython was written by Fernando Perez <fperez@colorado.edu>, based on earlier
389 code by Janko Hauser <jh@comunit.de> and Nathaniel Gray
388 code by Janko Hauser <jh@comunit.de> and Nathaniel Gray
390 <n8gray@caltech.edu>. This manual page was written by Jack Moffitt
389 <n8gray@caltech.edu>. This manual page was written by Jack Moffitt
391 <jack@xiph.org>, for the Debian project (but may be used by others).
390 <jack@xiph.org>, for the Debian project (but may be used by others).
@@ -1,9151 +1,9152 b''
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 221
2 \lyxformat 221
3 \textclass article
3 \textclass article
4 \begin_preamble
4 \begin_preamble
5 %\usepackage{ae,aecompl}
5 %\usepackage{ae,aecompl}
6 \usepackage{color}
6 \usepackage{color}
7
7
8 % A few colors to replace the defaults for certain link types
8 % A few colors to replace the defaults for certain link types
9 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
9 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
10 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
10 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
11 \definecolor{darkred}{rgb}{.52,0.08,0.01}
11 \definecolor{darkred}{rgb}{.52,0.08,0.01}
12 \definecolor{darkgreen}{rgb}{.12,.54,.11}
12 \definecolor{darkgreen}{rgb}{.12,.54,.11}
13
13
14 % Use and configure listings package for nicely formatted code
14 % Use and configure listings package for nicely formatted code
15 \usepackage{listings}
15 \usepackage{listings}
16 \lstset{
16 \lstset{
17 language=Python,
17 language=Python,
18 basicstyle=\small\ttfamily,
18 basicstyle=\small\ttfamily,
19 commentstyle=\ttfamily\color{blue},
19 commentstyle=\ttfamily\color{blue},
20 stringstyle=\ttfamily\color{darkorange},
20 stringstyle=\ttfamily\color{darkorange},
21 showstringspaces=false,
21 showstringspaces=false,
22 breaklines=true,
22 breaklines=true,
23 postbreak = \space\dots
23 postbreak = \space\dots
24 }
24 }
25
25
26 \usepackage[%pdftex, % needed for pdflatex
26 \usepackage[%pdftex, % needed for pdflatex
27 breaklinks=true, % so long urls are correctly broken across lines
27 breaklinks=true, % so long urls are correctly broken across lines
28 colorlinks=true,
28 colorlinks=true,
29 urlcolor=blue,
29 urlcolor=blue,
30 linkcolor=darkred,
30 linkcolor=darkred,
31 citecolor=darkgreen,
31 citecolor=darkgreen,
32 ]{hyperref}
32 ]{hyperref}
33
33
34 \usepackage{html}
34 \usepackage{html}
35
35
36 % This helps prevent overly long lines that stretch beyond the margins
36 % This helps prevent overly long lines that stretch beyond the margins
37 \sloppy
37 \sloppy
38
38
39 % Define a \codelist command which either uses listings for latex, or
39 % Define a \codelist command which either uses listings for latex, or
40 % plain verbatim for html (since latex2html doesn't understand the
40 % plain verbatim for html (since latex2html doesn't understand the
41 % listings package).
41 % listings package).
42 \usepackage{verbatim}
42 \usepackage{verbatim}
43 \newcommand{\codelist}[1] {
43 \newcommand{\codelist}[1] {
44 \latex{\lstinputlisting{#1}}
44 \latex{\lstinputlisting{#1}}
45 \html{\verbatiminput{#1}}
45 \html{\verbatiminput{#1}}
46 }
46 }
47 \end_preamble
47 \end_preamble
48 \language english
48 \language english
49 \inputencoding latin1
49 \inputencoding latin1
50 \fontscheme palatino
50 \fontscheme palatino
51 \graphics default
51 \graphics default
52 \paperfontsize 10
52 \paperfontsize 10
53 \spacing single
53 \spacing single
54 \papersize Default
54 \papersize Default
55 \paperpackage a4
55 \paperpackage a4
56 \use_geometry 1
56 \use_geometry 1
57 \use_amsmath 0
57 \use_amsmath 0
58 \use_natbib 0
58 \use_natbib 0
59 \use_numerical_citations 0
59 \use_numerical_citations 0
60 \paperorientation portrait
60 \paperorientation portrait
61 \leftmargin 1.1in
61 \leftmargin 1.1in
62 \topmargin 1in
62 \topmargin 1in
63 \rightmargin 1.1in
63 \rightmargin 1.1in
64 \bottommargin 1in
64 \bottommargin 1in
65 \secnumdepth 3
65 \secnumdepth 3
66 \tocdepth 3
66 \tocdepth 3
67 \paragraph_separation skip
67 \paragraph_separation skip
68 \defskip medskip
68 \defskip medskip
69 \quotes_language english
69 \quotes_language english
70 \quotes_times 2
70 \quotes_times 2
71 \papercolumns 1
71 \papercolumns 1
72 \papersides 1
72 \papersides 1
73 \paperpagestyle fancy
73 \paperpagestyle fancy
74
74
75 \layout Title
75 \layout Title
76
76
77 IPython
77 IPython
78 \newline
78 \newline
79
79
80 \size larger
80 \size larger
81 An enhanced Interactive Python
81 An enhanced Interactive Python
82 \size large
82 \size large
83
83
84 \newline
84 \newline
85 User Manual, v.
85 User Manual, v.
86 __version__
86 __version__
87 \layout Author
87 \layout Author
88
88
89 Fernando P�rez
89 Fernando P�rez
90 \layout Standard
90 \layout Standard
91
91
92
92
93 \begin_inset ERT
93 \begin_inset ERT
94 status Collapsed
94 status Collapsed
95
95
96 \layout Standard
96 \layout Standard
97
97
98 \backslash
98 \backslash
99 latex{
99 latex{
100 \end_inset
100 \end_inset
101
101
102
102
103 \begin_inset LatexCommand \tableofcontents{}
103 \begin_inset LatexCommand \tableofcontents{}
104
104
105 \end_inset
105 \end_inset
106
106
107
107
108 \begin_inset ERT
108 \begin_inset ERT
109 status Collapsed
109 status Collapsed
110
110
111 \layout Standard
111 \layout Standard
112 }
112 }
113 \end_inset
113 \end_inset
114
114
115
115
116 \layout Standard
116 \layout Standard
117
117
118
118
119 \begin_inset ERT
119 \begin_inset ERT
120 status Open
120 status Open
121
121
122 \layout Standard
122 \layout Standard
123
123
124 \backslash
124 \backslash
125 html{
125 html{
126 \backslash
126 \backslash
127 bodytext{bgcolor=#ffffff}}
127 bodytext{bgcolor=#ffffff}}
128 \end_inset
128 \end_inset
129
129
130
130
131 \layout Section
131 \layout Section
132 \pagebreak_top
132 \pagebreak_top
133 Overview
133 Overview
134 \layout Standard
134 \layout Standard
135
135
136 One of Python's most useful features is its interactive interpreter.
136 One of Python's most useful features is its interactive interpreter.
137 This system allows very fast testing of ideas without the overhead of creating
137 This system allows very fast testing of ideas without the overhead of creating
138 test files as is typical in most programming languages.
138 test files as is typical in most programming languages.
139 However, the interpreter supplied with the standard Python distribution
139 However, the interpreter supplied with the standard Python distribution
140 is somewhat limited for extended interactive use.
140 is somewhat limited for extended interactive use.
141 \layout Standard
141 \layout Standard
142
142
143 IPython is a free software project (released under the BSD license) which
143 IPython is a free software project (released under the BSD license) which
144 tries to:
144 tries to:
145 \layout Enumerate
145 \layout Enumerate
146
146
147 Provide an interactive shell superior to Python's default.
147 Provide an interactive shell superior to Python's default.
148 IPython has many features for object introspection, system shell access,
148 IPython has many features for object introspection, system shell access,
149 and its own special command system for adding functionality when working
149 and its own special command system for adding functionality when working
150 interactively.
150 interactively.
151 It tries to be a very efficient environment both for Python code development
151 It tries to be a very efficient environment both for Python code development
152 and for exploration of problems using Python objects (in situations like
152 and for exploration of problems using Python objects (in situations like
153 data analysis).
153 data analysis).
154 \layout Enumerate
154 \layout Enumerate
155
155
156 Serve as an embeddable, ready to use interpreter for your own programs.
156 Serve as an embeddable, ready to use interpreter for your own programs.
157 IPython can be started with a single call from inside another program,
157 IPython can be started with a single call from inside another program,
158 providing access to the current namespace.
158 providing access to the current namespace.
159 This can be very useful both for debugging purposes and for situations
159 This can be very useful both for debugging purposes and for situations
160 where a blend of batch-processing and interactive exploration are needed.
160 where a blend of batch-processing and interactive exploration are needed.
161 \layout Enumerate
161 \layout Enumerate
162
162
163 Offer a flexible framework which can be used as the base environment for
163 Offer a flexible framework which can be used as the base environment for
164 other systems with Python as the underlying language.
164 other systems with Python as the underlying language.
165 Specifically scientific environments like Mathematica, IDL and Matlab inspired
165 Specifically scientific environments like Mathematica, IDL and Matlab inspired
166 its design, but similar ideas can be useful in many fields.
166 its design, but similar ideas can be useful in many fields.
167 \layout Subsection
167 \layout Subsection
168
168
169 Main features
169 Main features
170 \layout Itemize
170 \layout Itemize
171
171
172 Dynamic object introspection.
172 Dynamic object introspection.
173 One can access docstrings, function definition prototypes, source code,
173 One can access docstrings, function definition prototypes, source code,
174 source files and other details of any object accessible to the interpreter
174 source files and other details of any object accessible to the interpreter
175 with a single keystroke (`
175 with a single keystroke (`
176 \family typewriter
176 \family typewriter
177 ?
177 ?
178 \family default
178 \family default
179 ').
179 ').
180 \layout Itemize
180 \layout Itemize
181
181
182 Completion in the local namespace, by typing TAB at the prompt.
182 Completion in the local namespace, by typing TAB at the prompt.
183 This works for keywords, methods, variables and files in the current directory.
183 This works for keywords, methods, variables and files in the current directory.
184 This is supported via the readline library, and full access to configuring
184 This is supported via the readline library, and full access to configuring
185 readline's behavior is provided.
185 readline's behavior is provided.
186 \layout Itemize
186 \layout Itemize
187
187
188 Numbered input/output prompts with command history (persistent across sessions
188 Numbered input/output prompts with command history (persistent across sessions
189 and tied to each profile), full searching in this history and caching of
189 and tied to each profile), full searching in this history and caching of
190 all input and output.
190 all input and output.
191 \layout Itemize
191 \layout Itemize
192
192
193 User-extensible `magic' commands.
193 User-extensible `magic' commands.
194 A set of commands prefixed with
194 A set of commands prefixed with
195 \family typewriter
195 \family typewriter
196 %
196 %
197 \family default
197 \family default
198 is available for controlling IPython itself and provides directory control,
198 is available for controlling IPython itself and provides directory control,
199 namespace information and many aliases to common system shell commands.
199 namespace information and many aliases to common system shell commands.
200 \layout Itemize
200 \layout Itemize
201
201
202 Alias facility for defining your own system aliases.
202 Alias facility for defining your own system aliases.
203 \layout Itemize
203 \layout Itemize
204
204
205 Complete system shell access.
205 Complete system shell access.
206 Lines starting with ! are passed directly to the system shell, and using
206 Lines starting with ! are passed directly to the system shell, and using
207 !! captures shell output into python variables for further use.
207 !! captures shell output into python variables for further use.
208 \layout Itemize
208 \layout Itemize
209
209
210 All calls to the system (via aliases or via !) have their standard output/error
210 All calls to the system (via aliases or via !) have their standard output/error
211 automatically stored as strings, and also available as lists.
211 automatically stored as strings, and also available as lists.
212 \layout Itemize
212 \layout Itemize
213
213
214 Background execution of Python commands in a separate thread.
214 Background execution of Python commands in a separate thread.
215 IPython has an internal job manager called
215 IPython has an internal job manager called
216 \family typewriter
216 \family typewriter
217 jobs
217 jobs
218 \family default
218 \family default
219 , and a conveninence backgrounding magic function called
219 , and a conveninence backgrounding magic function called
220 \family typewriter
220 \family typewriter
221 %bg
221 %bg
222 \family default
222 \family default
223 .
223 .
224 \layout Itemize
224 \layout Itemize
225
225
226 The ability to expand python variables when calling the system shell.
226 The ability to expand python variables when calling the system shell.
227 In a shell command, any python variable prefixed with
227 In a shell command, any python variable prefixed with
228 \family typewriter
228 \family typewriter
229 $
229 $
230 \family default
230 \family default
231 is expanded.
231 is expanded.
232 A double
232 A double
233 \family typewriter
233 \family typewriter
234 $$
234 $$
235 \family default
235 \family default
236 allows passing a literal
236 allows passing a literal
237 \family typewriter
237 \family typewriter
238 $
238 $
239 \family default
239 \family default
240 to the shell (for access to shell and environment variables like
240 to the shell (for access to shell and environment variables like
241 \family typewriter
241 \family typewriter
242 $PATH
242 $PATH
243 \family default
243 \family default
244 ).
244 ).
245 \layout Itemize
245 \layout Itemize
246
246
247 Filesystem navigation, via a magic
247 Filesystem navigation, via a magic
248 \family typewriter
248 \family typewriter
249 %cd
249 %cd
250 \family default
250 \family default
251 command, along with a persistent bookmark system (using
251 command, along with a persistent bookmark system (using
252 \family typewriter
252 \family typewriter
253 %bookmark
253 %bookmark
254 \family default
254 \family default
255 ) for fast access to frequently visited directories.
255 ) for fast access to frequently visited directories.
256 \layout Itemize
256 \layout Itemize
257
257
258 Automatic indentation (optional) of code as you type (through the readline
258 Automatic indentation (optional) of code as you type (through the readline
259 library).
259 library).
260 \layout Itemize
260 \layout Itemize
261
261
262 Macro system for quickly re-executing multiple lines of previous input with
262 Macro system for quickly re-executing multiple lines of previous input with
263 a single name.
263 a single name.
264 \layout Itemize
264 \layout Itemize
265
265
266 Session logging (you can then later use these logs as code in your programs).
266 Session logging (you can then later use these logs as code in your programs).
267 \layout Itemize
267 \layout Itemize
268
268
269 Session restoring: logs can be replayed to restore a previous session to
269 Session restoring: logs can be replayed to restore a previous session to
270 the state where you left it.
270 the state where you left it.
271 \layout Itemize
271 \layout Itemize
272
272
273 Verbose and colored exception traceback printouts.
273 Verbose and colored exception traceback printouts.
274 Easier to parse visually, and in verbose mode they produce a lot of useful
274 Easier to parse visually, and in verbose mode they produce a lot of useful
275 debugging information (basically a terminal version of the cgitb module).
275 debugging information (basically a terminal version of the cgitb module).
276 \layout Itemize
276 \layout Itemize
277
277
278 Auto-parentheses: callable objects can be executed without parentheses:
278 Auto-parentheses: callable objects can be executed without parentheses:
279
279
280 \family typewriter
280 \family typewriter
281 `sin 3'
281 `sin 3'
282 \family default
282 \family default
283 is automatically converted to
283 is automatically converted to
284 \family typewriter
284 \family typewriter
285 `sin(3)
285 `sin(3)
286 \family default
286 \family default
287 '.
287 '.
288 \layout Itemize
288 \layout Itemize
289
289
290 Auto-quoting: using `
290 Auto-quoting: using `
291 \family typewriter
291 \family typewriter
292 ,
292 ,
293 \family default
293 \family default
294 ' or `
294 ' or `
295 \family typewriter
295 \family typewriter
296 ;
296 ;
297 \family default
297 \family default
298 ' as the first character forces auto-quoting of the rest of the line:
298 ' as the first character forces auto-quoting of the rest of the line:
299 \family typewriter
299 \family typewriter
300 `,my_function a\SpecialChar ~
300 `,my_function a\SpecialChar ~
301 b'
301 b'
302 \family default
302 \family default
303 becomes automatically
303 becomes automatically
304 \family typewriter
304 \family typewriter
305 `my_function("a","b")'
305 `my_function("a","b")'
306 \family default
306 \family default
307 , while
307 , while
308 \family typewriter
308 \family typewriter
309 `;my_function a\SpecialChar ~
309 `;my_function a\SpecialChar ~
310 b'
310 b'
311 \family default
311 \family default
312 becomes
312 becomes
313 \family typewriter
313 \family typewriter
314 `my_function("a b")'
314 `my_function("a b")'
315 \family default
315 \family default
316 .
316 .
317 \layout Itemize
317 \layout Itemize
318
318
319 Extensible input syntax.
319 Extensible input syntax.
320 You can define filters that pre-process user input to simplify input in
320 You can define filters that pre-process user input to simplify input in
321 special situations.
321 special situations.
322 This allows for example pasting multi-line code fragments which start with
322 This allows for example pasting multi-line code fragments which start with
323
323
324 \family typewriter
324 \family typewriter
325 `>>>'
325 `>>>'
326 \family default
326 \family default
327 or
327 or
328 \family typewriter
328 \family typewriter
329 `...'
329 `...'
330 \family default
330 \family default
331 such as those from other python sessions or the standard Python documentation.
331 such as those from other python sessions or the standard Python documentation.
332 \layout Itemize
332 \layout Itemize
333
333
334 Flexible configuration system.
334 Flexible configuration system.
335 It uses a configuration file which allows permanent setting of all command-line
335 It uses a configuration file which allows permanent setting of all command-line
336 options, module loading, code and file execution.
336 options, module loading, code and file execution.
337 The system allows recursive file inclusion, so you can have a base file
337 The system allows recursive file inclusion, so you can have a base file
338 with defaults and layers which load other customizations for particular
338 with defaults and layers which load other customizations for particular
339 projects.
339 projects.
340 \layout Itemize
340 \layout Itemize
341
341
342 Embeddable.
342 Embeddable.
343 You can call IPython as a python shell inside your own python programs.
343 You can call IPython as a python shell inside your own python programs.
344 This can be used both for debugging code or for providing interactive abilities
344 This can be used both for debugging code or for providing interactive abilities
345 to your programs with knowledge about the local namespaces (very useful
345 to your programs with knowledge about the local namespaces (very useful
346 in debugging and data analysis situations).
346 in debugging and data analysis situations).
347 \layout Itemize
347 \layout Itemize
348
348
349 Easy debugger access.
349 Easy debugger access.
350 You can set IPython to call up an enhanced version of the Python debugger
350 You can set IPython to call up an enhanced version of the Python debugger
351 (
351 (
352 \family typewriter
352 \family typewriter
353 pdb
353 pdb
354 \family default
354 \family default
355 ) every time there is an uncaught exception.
355 ) every time there is an uncaught exception.
356 This drops you inside the code which triggered the exception with all the
356 This drops you inside the code which triggered the exception with all the
357 data live and it is possible to navigate the stack to rapidly isolate the
357 data live and it is possible to navigate the stack to rapidly isolate the
358 source of a bug.
358 source of a bug.
359 The
359 The
360 \family typewriter
360 \family typewriter
361 %run
361 %run
362 \family default
362 \family default
363 magic command --with the
363 magic command --with the
364 \family typewriter
364 \family typewriter
365 -d
365 -d
366 \family default
366 \family default
367 option-- can run any script under
367 option-- can run any script under
368 \family typewriter
368 \family typewriter
369 pdb
369 pdb
370 \family default
370 \family default
371 's control, automatically setting initial breakpoints for you.
371 's control, automatically setting initial breakpoints for you.
372 This version of
372 This version of
373 \family typewriter
373 \family typewriter
374 pdb
374 pdb
375 \family default
375 \family default
376 has IPython-specific improvements, including tab-completion and traceback
376 has IPython-specific improvements, including tab-completion and traceback
377 coloring support.
377 coloring support.
378 \layout Itemize
378 \layout Itemize
379
379
380 Profiler support.
380 Profiler support.
381 You can run single statements (similar to
381 You can run single statements (similar to
382 \family typewriter
382 \family typewriter
383 profile.run()
383 profile.run()
384 \family default
384 \family default
385 ) or complete programs under the profiler's control.
385 ) or complete programs under the profiler's control.
386 While this is possible with the standard
386 While this is possible with the standard
387 \family typewriter
387 \family typewriter
388 profile
388 profile
389 \family default
389 \family default
390 module, IPython wraps this functionality with magic commands (see
390 module, IPython wraps this functionality with magic commands (see
391 \family typewriter
391 \family typewriter
392 `%prun'
392 `%prun'
393 \family default
393 \family default
394 and
394 and
395 \family typewriter
395 \family typewriter
396 `%run -p
396 `%run -p
397 \family default
397 \family default
398 ') convenient for rapid interactive work.
398 ') convenient for rapid interactive work.
399 \layout Subsection
399 \layout Subsection
400
400
401 Portability and Python requirements
401 Portability and Python requirements
402 \layout Standard
402 \layout Standard
403
403
404
404
405 \series bold
405 \series bold
406 Python requirements:
406 Python requirements:
407 \series default
407 \series default
408 IPython works with Python version 2.2 or newer.
408 IPython works with Python version 2.2 or newer.
409 It has been tested with Python 2.4 and no problems have been reported.
409 It has been tested with Python 2.4 and no problems have been reported.
410 Support for Python 2.1 hasn't been recently tested, since I don't have access
410 Support for Python 2.1 hasn't been recently tested, since I don't have access
411 to it on any of my systems.
411 to it on any of my systems.
412 But I suspect there may be some problems with Python 2.1, because some of
412 But I suspect there may be some problems with Python 2.1, because some of
413 the newer code may use 2.2 features.
413 the newer code may use 2.2 features.
414 \layout Standard
414 \layout Standard
415
415
416 IPython is developed under
416 IPython is developed under
417 \series bold
417 \series bold
418 Linux
418 Linux
419 \series default
419 \series default
420 , but it should work in any reasonable Unix-type system (tested OK under
420 , but it should work in any reasonable Unix-type system (tested OK under
421 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
421 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
422 \layout Standard
422 \layout Standard
423
423
424
424
425 \series bold
425 \series bold
426 Mac OS X
426 Mac OS X
427 \series default
427 \series default
428 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
428 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
429 Livermore for the information).
429 Livermore for the information).
430 Thanks to Andrea Riciputi, Fink support is available.
430 Thanks to Andrea Riciputi, Fink support is available.
431 \layout Standard
431 \layout Standard
432
432
433
433
434 \series bold
434 \series bold
435 CygWin
435 CygWin
436 \series default
436 \series default
437 : it works mostly OK, though some users have reported problems with prompt
437 : it works mostly OK, though some users have reported problems with prompt
438 coloring.
438 coloring.
439 No satisfactory solution to this has been found so far, you may want to
439 No satisfactory solution to this has been found so far, you may want to
440 disable colors permanently in the
440 disable colors permanently in the
441 \family typewriter
441 \family typewriter
442 ipythonrc
442 ipythonrc
443 \family default
443 \family default
444 configuration file if you experience problems.
444 configuration file if you experience problems.
445 If you have proper color support under cygwin, please post to the IPython
445 If you have proper color support under cygwin, please post to the IPython
446 mailing list so this issue can be resolved for all users.
446 mailing list so this issue can be resolved for all users.
447 \layout Standard
447 \layout Standard
448
448
449
449
450 \series bold
450 \series bold
451 Windows
451 Windows
452 \series default
452 \series default
453 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
453 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
454 Section\SpecialChar ~
454 Section\SpecialChar ~
455
455
456 \begin_inset LatexCommand \ref{sub:Under-Windows}
456 \begin_inset LatexCommand \ref{sub:Under-Windows}
457
457
458 \end_inset
458 \end_inset
459
459
460 describes installation details for Windows, including some additional tools
460 describes installation details for Windows, including some additional tools
461 needed on this platform.
461 needed on this platform.
462 \layout Standard
462 \layout Standard
463
463
464 Windows 9x support is present, and has been reported to work fine (at least
464 Windows 9x support is present, and has been reported to work fine (at least
465 on WinME).
465 on WinME).
466 \layout Standard
466 \layout Standard
467
467
468 Please note, however, that I have very little access to and experience with
468 Please note, however, that I have very little access to and experience with
469 Windows development.
469 Windows development.
470 For this reason, Windows-specific bugs tend to linger far longer than I
470 For this reason, Windows-specific bugs tend to linger far longer than I
471 would like, and often I just can't find a satisfactory solution.
471 would like, and often I just can't find a satisfactory solution.
472 If any Windows user wants to join in with development help, all hands are
472 If any Windows user wants to join in with development help, all hands are
473 always welcome.
473 always welcome.
474 \layout Subsection
474 \layout Subsection
475
475
476 Location
476 Location
477 \layout Standard
477 \layout Standard
478
478
479 IPython is generously hosted at
479 IPython is generously hosted at
480 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
480 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
481
481
482 \end_inset
482 \end_inset
483
483
484 by the SciPy project.
484 by the SciPy project.
485 This site offers downloads, subversion access, mailing lists and a bug
485 This site offers downloads, subversion access, mailing lists and a bug
486 tracking system.
486 tracking system.
487 I am very grateful to Enthought (
487 I am very grateful to Enthought (
488 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
488 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
489
489
490 \end_inset
490 \end_inset
491
491
492 ) and all of the SciPy team for their contribution.
492 ) and all of the SciPy team for their contribution.
493 \layout Section
493 \layout Section
494
494
495
495
496 \begin_inset LatexCommand \label{sec:install}
496 \begin_inset LatexCommand \label{sec:install}
497
497
498 \end_inset
498 \end_inset
499
499
500 Installation
500 Installation
501 \layout Subsection
501 \layout Subsection
502
502
503 Instant instructions
503 Instant instructions
504 \layout Standard
504 \layout Standard
505
505
506 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
506 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
507 download, then install with
507 download, then install with
508 \family typewriter
508 \family typewriter
509 `python setup.py install'
509 `python setup.py install'
510 \family default
510 \family default
511 .
511 .
512 Under Windows, double-click on the provided
512 Under Windows, double-click on the provided
513 \family typewriter
513 \family typewriter
514 .exe
514 .exe
515 \family default
515 \family default
516 binary installer.
516 binary installer.
517 \layout Standard
517 \layout Standard
518
518
519 Then, take a look at Sections
519 Then, take a look at Sections
520 \begin_inset LatexCommand \ref{sec:good_config}
520 \begin_inset LatexCommand \ref{sec:good_config}
521
521
522 \end_inset
522 \end_inset
523
523
524 for configuring things optimally and
524 for configuring things optimally and
525 \begin_inset LatexCommand \ref{sec:quick_tips}
525 \begin_inset LatexCommand \ref{sec:quick_tips}
526
526
527 \end_inset
527 \end_inset
528
528
529 for quick tips on efficient use of IPython.
529 for quick tips on efficient use of IPython.
530 You can later refer to the rest of the manual for all the gory details.
530 You can later refer to the rest of the manual for all the gory details.
531 \layout Standard
531 \layout Standard
532
532
533 See the notes in sec.
533 See the notes in sec.
534
534
535 \begin_inset LatexCommand \ref{sec:upgrade}
535 \begin_inset LatexCommand \ref{sec:upgrade}
536
536
537 \end_inset
537 \end_inset
538
538
539 for upgrading IPython versions.
539 for upgrading IPython versions.
540 \layout Subsection
540 \layout Subsection
541
541
542 Detailed Unix instructions (Linux, Mac OS X, etc.)
542 Detailed Unix instructions (Linux, Mac OS X, etc.)
543 \layout Standard
543 \layout Standard
544
544
545 For RPM based systems, simply install the supplied package in the usual
545 For RPM based systems, simply install the supplied package in the usual
546 manner.
546 manner.
547 If you download the tar archive, the process is:
547 If you download the tar archive, the process is:
548 \layout Enumerate
548 \layout Enumerate
549
549
550 Unzip/untar the
550 Unzip/untar the
551 \family typewriter
551 \family typewriter
552 ipython-XXX.tar.gz
552 ipython-XXX.tar.gz
553 \family default
553 \family default
554 file wherever you want (
554 file wherever you want (
555 \family typewriter
555 \family typewriter
556 XXX
556 XXX
557 \family default
557 \family default
558 is the version number).
558 is the version number).
559 It will make a directory called
559 It will make a directory called
560 \family typewriter
560 \family typewriter
561 ipython-XXX.
561 ipython-XXX.
562
562
563 \family default
563 \family default
564 Change into that directory where you will find the files
564 Change into that directory where you will find the files
565 \family typewriter
565 \family typewriter
566 README
566 README
567 \family default
567 \family default
568 and
568 and
569 \family typewriter
569 \family typewriter
570 setup.py
570 setup.py
571 \family default
571 \family default
572 .
572 .
573
573
574 \family typewriter
574 \family typewriter
575 O
575 O
576 \family default
576 \family default
577 nce you've completed the installation, you can safely remove this directory.
577 nce you've completed the installation, you can safely remove this directory.
578
578
579 \layout Enumerate
579 \layout Enumerate
580
580
581 If you are installing over a previous installation of version 0.2.0 or earlier,
581 If you are installing over a previous installation of version 0.2.0 or earlier,
582 first remove your
582 first remove your
583 \family typewriter
583 \family typewriter
584 $HOME/.ipython
584 $HOME/.ipython
585 \family default
585 \family default
586 directory, since the configuration file format has changed somewhat (the
586 directory, since the configuration file format has changed somewhat (the
587 '=' were removed from all option specifications).
587 '=' were removed from all option specifications).
588 Or you can call ipython with the
588 Or you can call ipython with the
589 \family typewriter
589 \family typewriter
590 -upgrade
590 -upgrade
591 \family default
591 \family default
592 option and it will do this automatically for you.
592 option and it will do this automatically for you.
593 \layout Enumerate
593 \layout Enumerate
594
594
595 IPython uses distutils, so you can install it by simply typing at the system
595 IPython uses distutils, so you can install it by simply typing at the system
596 prompt (don't type the
596 prompt (don't type the
597 \family typewriter
597 \family typewriter
598 $
598 $
599 \family default
599 \family default
600 )
600 )
601 \newline
601 \newline
602
602
603 \family typewriter
603 \family typewriter
604 $ python setup.py install
604 $ python setup.py install
605 \family default
605 \family default
606
606
607 \newline
607 \newline
608 Note that this assumes you have root access to your machine.
608 Note that this assumes you have root access to your machine.
609 If you don't have root access or don't want IPython to go in the default
609 If you don't have root access or don't want IPython to go in the default
610 python directories, you'll need to use the
610 python directories, you'll need to use the
611 \begin_inset ERT
611 \begin_inset ERT
612 status Collapsed
612 status Collapsed
613
613
614 \layout Standard
614 \layout Standard
615
615
616 \backslash
616 \backslash
617 verb|--home|
617 verb|--home|
618 \end_inset
618 \end_inset
619
619
620 option (or
620 option (or
621 \begin_inset ERT
621 \begin_inset ERT
622 status Collapsed
622 status Collapsed
623
623
624 \layout Standard
624 \layout Standard
625
625
626 \backslash
626 \backslash
627 verb|--prefix|
627 verb|--prefix|
628 \end_inset
628 \end_inset
629
629
630 ).
630 ).
631 For example:
631 For example:
632 \newline
632 \newline
633
633
634 \begin_inset ERT
634 \begin_inset ERT
635 status Collapsed
635 status Collapsed
636
636
637 \layout Standard
637 \layout Standard
638
638
639 \backslash
639 \backslash
640 verb|$ python setup.py install --home $HOME/local|
640 verb|$ python setup.py install --home $HOME/local|
641 \end_inset
641 \end_inset
642
642
643
643
644 \newline
644 \newline
645 will install IPython into
645 will install IPython into
646 \family typewriter
646 \family typewriter
647 $HOME/local
647 $HOME/local
648 \family default
648 \family default
649 and its subdirectories (creating them if necessary).
649 and its subdirectories (creating them if necessary).
650 \newline
650 \newline
651 You can type
651 You can type
652 \newline
652 \newline
653
653
654 \begin_inset ERT
654 \begin_inset ERT
655 status Collapsed
655 status Collapsed
656
656
657 \layout Standard
657 \layout Standard
658
658
659 \backslash
659 \backslash
660 verb|$ python setup.py --help|
660 verb|$ python setup.py --help|
661 \end_inset
661 \end_inset
662
662
663
663
664 \newline
664 \newline
665 for more details.
665 for more details.
666 \newline
666 \newline
667 Note that if you change the default location for
667 Note that if you change the default location for
668 \begin_inset ERT
668 \begin_inset ERT
669 status Collapsed
669 status Collapsed
670
670
671 \layout Standard
671 \layout Standard
672
672
673 \backslash
673 \backslash
674 verb|--home|
674 verb|--home|
675 \end_inset
675 \end_inset
676
676
677 at installation, IPython may end up installed at a location which is not
677 at installation, IPython may end up installed at a location which is not
678 part of your
678 part of your
679 \family typewriter
679 \family typewriter
680 $PYTHONPATH
680 $PYTHONPATH
681 \family default
681 \family default
682 environment variable.
682 environment variable.
683 In this case, you'll need to configure this variable to include the actual
683 In this case, you'll need to configure this variable to include the actual
684 directory where the
684 directory where the
685 \family typewriter
685 \family typewriter
686 IPython/
686 IPython/
687 \family default
687 \family default
688 directory ended (typically the value you give to
688 directory ended (typically the value you give to
689 \begin_inset ERT
689 \begin_inset ERT
690 status Collapsed
690 status Collapsed
691
691
692 \layout Standard
692 \layout Standard
693
693
694 \backslash
694 \backslash
695 verb|--home|
695 verb|--home|
696 \end_inset
696 \end_inset
697
697
698 plus
698 plus
699 \family typewriter
699 \family typewriter
700 /lib/python
700 /lib/python
701 \family default
701 \family default
702 ).
702 ).
703 \layout Subsubsection
703 \layout Subsubsection
704
704
705 Mac OSX information
705 Mac OSX information
706 \layout Standard
706 \layout Standard
707
707
708 Under OSX, there is a choice you need to make.
708 Under OSX, there is a choice you need to make.
709 Apple ships its own build of Python, which lives in the core OSX filesystem
709 Apple ships its own build of Python, which lives in the core OSX filesystem
710 hierarchy.
710 hierarchy.
711 You can also manually install a separate Python, either purely by hand
711 You can also manually install a separate Python, either purely by hand
712 (typically in
712 (typically in
713 \family typewriter
713 \family typewriter
714 /usr/local
714 /usr/local
715 \family default
715 \family default
716 ) or by using Fink, which puts everything under
716 ) or by using Fink, which puts everything under
717 \family typewriter
717 \family typewriter
718 /sw
718 /sw
719 \family default
719 \family default
720 .
720 .
721 Which route to follow is a matter of personal preference, as I've seen
721 Which route to follow is a matter of personal preference, as I've seen
722 users who favor each of the approaches.
722 users who favor each of the approaches.
723 Here I will simply list the known installation issues under OSX, along
723 Here I will simply list the known installation issues under OSX, along
724 with their solutions.
724 with their solutions.
725 \layout Standard
725 \layout Standard
726
726
727 This page:
727 This page:
728 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
728 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
729
729
730 \end_inset
730 \end_inset
731
731
732 contains information on this topic, with additional details on how to make
732 contains information on this topic, with additional details on how to make
733 IPython and matplotlib play nicely under OSX.
733 IPython and matplotlib play nicely under OSX.
734 \layout Subsubsection*
734 \layout Subsubsection*
735
735
736 GUI problems
736 GUI problems
737 \layout Standard
737 \layout Standard
738
738
739 The following instructions apply to an install of IPython under OSX from
739 The following instructions apply to an install of IPython under OSX from
740 unpacking the
740 unpacking the
741 \family typewriter
741 \family typewriter
742 .tar.gz
742 .tar.gz
743 \family default
743 \family default
744 distribution and installing it for the default Python interpreter shipped
744 distribution and installing it for the default Python interpreter shipped
745 by Apple.
745 by Apple.
746 If you are using a fink install, fink will take care of these details for
746 If you are using a fink install, fink will take care of these details for
747 you, by installing IPython against fink's Python.
747 you, by installing IPython against fink's Python.
748 \layout Standard
748 \layout Standard
749
749
750 IPython offers various forms of support for interacting with graphical applicati
750 IPython offers various forms of support for interacting with graphical applicati
751 ons from the command line, from simple Tk apps (which are in principle always
751 ons from the command line, from simple Tk apps (which are in principle always
752 supported by Python) to interactive control of WX, Qt and GTK apps.
752 supported by Python) to interactive control of WX, Qt and GTK apps.
753 Under OSX, however, this requires that ipython is installed by calling
753 Under OSX, however, this requires that ipython is installed by calling
754 the special
754 the special
755 \family typewriter
755 \family typewriter
756 pythonw
756 pythonw
757 \family default
757 \family default
758 script at installation time, which takes care of coordinating things with
758 script at installation time, which takes care of coordinating things with
759 Apple's graphical environment.
759 Apple's graphical environment.
760 \layout Standard
760 \layout Standard
761
761
762 So when installing under OSX, it is best to use the following command:
762 So when installing under OSX, it is best to use the following command:
763 \family typewriter
763 \family typewriter
764
764
765 \newline
765 \newline
766
766
767 \family default
767 \family default
768
768
769 \begin_inset ERT
769 \begin_inset ERT
770 status Collapsed
770 status Collapsed
771
771
772 \layout Standard
772 \layout Standard
773
773
774 \backslash
774 \backslash
775 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
775 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
776 \end_inset
776 \end_inset
777
777
778
778
779 \newline
779 \newline
780 or
780 or
781 \newline
781 \newline
782
782
783 \begin_inset ERT
783 \begin_inset ERT
784 status Open
784 status Open
785
785
786 \layout Standard
786 \layout Standard
787
787
788 \backslash
788 \backslash
789 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
789 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
790 \end_inset
790 \end_inset
791
791
792
792
793 \newline
793 \newline
794 depending on where you like to keep hand-installed executables.
794 depending on where you like to keep hand-installed executables.
795 \layout Standard
795 \layout Standard
796
796
797 The resulting script will have an appropriate shebang line (the first line
797 The resulting script will have an appropriate shebang line (the first line
798 in the script whic begins with
798 in the script whic begins with
799 \family typewriter
799 \family typewriter
800 #!...
800 #!...
801 \family default
801 \family default
802 ) such that the ipython interpreter can interact with the OS X GUI.
802 ) such that the ipython interpreter can interact with the OS X GUI.
803 If the installed version does not work and has a shebang line that points
803 If the installed version does not work and has a shebang line that points
804 to, for example, just
804 to, for example, just
805 \family typewriter
805 \family typewriter
806 /usr/bin/python
806 /usr/bin/python
807 \family default
807 \family default
808 , then you might have a stale, cached version in your
808 , then you might have a stale, cached version in your
809 \family typewriter
809 \family typewriter
810 build/scripts-<python-version>
810 build/scripts-<python-version>
811 \family default
811 \family default
812 directory.
812 directory.
813 Delete that directory and rerun the
813 Delete that directory and rerun the
814 \family typewriter
814 \family typewriter
815 setup.py
815 setup.py
816 \family default
816 \family default
817 .
817 .
818
818
819 \layout Standard
819 \layout Standard
820
820
821 It is also a good idea to use the special flag
821 It is also a good idea to use the special flag
822 \begin_inset ERT
822 \begin_inset ERT
823 status Collapsed
823 status Collapsed
824
824
825 \layout Standard
825 \layout Standard
826
826
827 \backslash
827 \backslash
828 verb|--install-scripts|
828 verb|--install-scripts|
829 \end_inset
829 \end_inset
830
830
831 as indicated above, to ensure that the ipython scripts end up in a location
831 as indicated above, to ensure that the ipython scripts end up in a location
832 which is part of your
832 which is part of your
833 \family typewriter
833 \family typewriter
834 $PATH
834 $PATH
835 \family default
835 \family default
836 .
836 .
837 Otherwise Apple's Python will put the scripts in an internal directory
837 Otherwise Apple's Python will put the scripts in an internal directory
838 not available by default at the command line (if you use
838 not available by default at the command line (if you use
839 \family typewriter
839 \family typewriter
840 /usr/local/bin
840 /usr/local/bin
841 \family default
841 \family default
842 , you need to make sure this is in your
842 , you need to make sure this is in your
843 \family typewriter
843 \family typewriter
844 $PATH
844 $PATH
845 \family default
845 \family default
846 , which may not be true by default).
846 , which may not be true by default).
847 \layout Subsubsection*
847 \layout Subsubsection*
848
848
849 Readline problems
849 Readline problems
850 \layout Standard
850 \layout Standard
851
851
852 By default, the Python version shipped by Apple does
852 By default, the Python version shipped by Apple does
853 \emph on
853 \emph on
854 not
854 not
855 \emph default
855 \emph default
856 include the readline library, so central to IPython's behavior.
856 include the readline library, so central to IPython's behavior.
857 If you install IPython against Apple's Python, you will not have arrow
857 If you install IPython against Apple's Python, you will not have arrow
858 keys, tab completion, etc.
858 keys, tab completion, etc.
859 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
859 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
860 \newline
860 \newline
861
861
862 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
862 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
863
863
864 \end_inset
864 \end_inset
865
865
866
866
867 \layout Standard
867 \layout Standard
868
868
869 If you are using OSX 10.4 (Tiger), after installing this package you need
869 If you are using OSX 10.4 (Tiger), after installing this package you need
870 to either:
870 to either:
871 \layout Enumerate
871 \layout Enumerate
872
872
873 move
873 move
874 \family typewriter
874 \family typewriter
875 readline.so
875 readline.so
876 \family default
876 \family default
877 from
877 from
878 \family typewriter
878 \family typewriter
879 /Library/Python/2.3
879 /Library/Python/2.3
880 \family default
880 \family default
881 to
881 to
882 \family typewriter
882 \family typewriter
883 /Library/Python/2.3/site-packages
883 /Library/Python/2.3/site-packages
884 \family default
884 \family default
885 , or
885 , or
886 \layout Enumerate
886 \layout Enumerate
887
887
888 install
888 install
889 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
889 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
890
890
891 \end_inset
891 \end_inset
892
892
893
893
894 \layout Standard
894 \layout Standard
895
895
896 Users installing against Fink's Python or a properly hand-built one should
896 Users installing against Fink's Python or a properly hand-built one should
897 not have this problem.
897 not have this problem.
898 \layout Subsubsection*
898 \layout Subsubsection*
899
899
900 DarwinPorts
900 DarwinPorts
901 \layout Standard
901 \layout Standard
902
902
903 I report here a message from an OSX user, who suggests an alternative means
903 I report here a message from an OSX user, who suggests an alternative means
904 of using IPython under this operating system with good results.
904 of using IPython under this operating system with good results.
905 Please let me know of any updates that may be useful for this section.
905 Please let me know of any updates that may be useful for this section.
906 His message is reproduced verbatim below:
906 His message is reproduced verbatim below:
907 \layout Quote
907 \layout Quote
908
908
909 From: Markus Banfi
909 From: Markus Banfi
910 \family typewriter
910 \family typewriter
911 <markus.banfi-AT-mospheira.net>
911 <markus.banfi-AT-mospheira.net>
912 \layout Quote
912 \layout Quote
913
913
914 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
914 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
915 of Fink.
915 of Fink.
916 I had no problems installing ipython with DarwinPorts.
916 I had no problems installing ipython with DarwinPorts.
917 It's just:
917 It's just:
918 \layout Quote
918 \layout Quote
919
919
920
920
921 \family typewriter
921 \family typewriter
922 sudo port install py-ipython
922 sudo port install py-ipython
923 \layout Quote
923 \layout Quote
924
924
925 It automatically resolved all dependencies (python24, readline, py-readline).
925 It automatically resolved all dependencies (python24, readline, py-readline).
926 So far I did not encounter any problems with the DarwinPorts port of ipython.
926 So far I did not encounter any problems with the DarwinPorts port of ipython.
927
927
928 \layout Subsection
928 \layout Subsection
929
929
930
930
931 \begin_inset LatexCommand \label{sub:Under-Windows}
931 \begin_inset LatexCommand \label{sub:Under-Windows}
932
932
933 \end_inset
933 \end_inset
934
934
935 Windows instructions
935 Windows instructions
936 \layout Standard
936 \layout Standard
937
937
938 Some of IPython's very useful features are:
938 Some of IPython's very useful features are:
939 \layout Itemize
939 \layout Itemize
940
940
941 Integrated readline support (Tab-based file, object and attribute completion,
941 Integrated readline support (Tab-based file, object and attribute completion,
942 input history across sessions, editable command line, etc.)
942 input history across sessions, editable command line, etc.)
943 \layout Itemize
943 \layout Itemize
944
944
945 Coloring of prompts, code and tracebacks.
945 Coloring of prompts, code and tracebacks.
946 \layout Standard
946 \layout Standard
947
947
948 These, by default, are only available under Unix-like operating systems.
948 These, by default, are only available under Unix-like operating systems.
949 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
949 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
950 from them.
950 from them.
951 His readline library implements both GNU readline functionality and color
951 His readline library implements both GNU readline functionality and color
952 support, so that IPython under Windows XP/2k can be as friendly and powerful
952 support, so that IPython under Windows XP/2k can be as friendly and powerful
953 as under Unix-like environments.
953 as under Unix-like environments.
954 \layout Standard
954 \layout Standard
955
955
956 The
956 The
957 \family typewriter
957 \family typewriter
958 readline
958 readline
959 \family default
959 \family default
960 extension needs two other libraries to work, so in all you need:
960 extension needs two other libraries to work, so in all you need:
961 \layout Enumerate
961 \layout Enumerate
962
962
963
963
964 \family typewriter
964 \family typewriter
965 PyWin32
965 PyWin32
966 \family default
966 \family default
967 from
967 from
968 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
968 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
969
969
970 \end_inset
970 \end_inset
971
971
972 .
972 .
973 \layout Enumerate
973 \layout Enumerate
974
974
975
975
976 \family typewriter
976 \family typewriter
977 CTypes
977 CTypes
978 \family default
978 \family default
979 from
979 from
980 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
980 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
981
981
982 \end_inset
982 \end_inset
983
983
984 (you
984 (you
985 \emph on
985 \emph on
986 must
986 must
987 \emph default
987 \emph default
988 use version 0.9.1 or newer).
988 use version 0.9.1 or newer).
989 \layout Enumerate
989 \layout Enumerate
990
990
991
991
992 \family typewriter
992 \family typewriter
993 Readline
993 Readline
994 \family default
994 \family default
995 for Windows from
995 for Windows from
996 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
996 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
997
997
998 \end_inset
998 \end_inset
999
999
1000 .
1000 .
1001 \layout Standard
1001 \layout Standard
1002
1002
1003
1003
1004 \series bold
1004 \series bold
1005 Warning about a broken readline-like library:
1005 Warning about a broken readline-like library:
1006 \series default
1006 \series default
1007 several users have reported problems stemming from using the pseudo-readline
1007 several users have reported problems stemming from using the pseudo-readline
1008 library at
1008 library at
1009 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1009 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1010
1010
1011 \end_inset
1011 \end_inset
1012
1012
1013 .
1013 .
1014 This is a broken library which, while called readline, only implements
1014 This is a broken library which, while called readline, only implements
1015 an incomplete subset of the readline API.
1015 an incomplete subset of the readline API.
1016 Since it is still called readline, it fools IPython's detection mechanisms
1016 Since it is still called readline, it fools IPython's detection mechanisms
1017 and causes unpredictable crashes later.
1017 and causes unpredictable crashes later.
1018 If you wish to use IPython under Windows, you must NOT use this library,
1018 If you wish to use IPython under Windows, you must NOT use this library,
1019 which for all purposes is (at least as of version 1.6) terminally broken.
1019 which for all purposes is (at least as of version 1.6) terminally broken.
1020 \layout Subsubsection
1020 \layout Subsubsection
1021
1021
1022 Installation procedure
1022 Installation procedure
1023 \layout Standard
1023 \layout Standard
1024
1024
1025 Once you have the above installed, from the IPython download directory grab
1025 Once you have the above installed, from the IPython download directory grab
1026 the
1026 the
1027 \family typewriter
1027 \family typewriter
1028 ipython-XXX.win32.exe
1028 ipython-XXX.win32.exe
1029 \family default
1029 \family default
1030 file, where
1030 file, where
1031 \family typewriter
1031 \family typewriter
1032 XXX
1032 XXX
1033 \family default
1033 \family default
1034 represents the version number.
1034 represents the version number.
1035 This is a regular windows executable installer, which you can simply double-cli
1035 This is a regular windows executable installer, which you can simply double-cli
1036 ck to install.
1036 ck to install.
1037 It will add an entry for IPython to your Start Menu, as well as registering
1037 It will add an entry for IPython to your Start Menu, as well as registering
1038 IPython in the Windows list of applications, so you can later uninstall
1038 IPython in the Windows list of applications, so you can later uninstall
1039 it from the Control Panel.
1039 it from the Control Panel.
1040
1040
1041 \layout Standard
1041 \layout Standard
1042
1042
1043 IPython tries to install the configuration information in a directory named
1043 IPython tries to install the configuration information in a directory named
1044
1044
1045 \family typewriter
1045 \family typewriter
1046 .ipython
1046 .ipython
1047 \family default
1047 \family default
1048 (
1048 (
1049 \family typewriter
1049 \family typewriter
1050 _ipython
1050 _ipython
1051 \family default
1051 \family default
1052 under Windows) located in your `home' directory.
1052 under Windows) located in your `home' directory.
1053 IPython sets this directory by looking for a
1053 IPython sets this directory by looking for a
1054 \family typewriter
1054 \family typewriter
1055 HOME
1055 HOME
1056 \family default
1056 \family default
1057 environment variable; if such a variable does not exist, it uses
1057 environment variable; if such a variable does not exist, it uses
1058 \family typewriter
1058 \family typewriter
1059 HOMEDRIVE
1059 HOMEDRIVE
1060 \backslash
1060 \backslash
1061 HOMEPATH
1061 HOMEPATH
1062 \family default
1062 \family default
1063 (these are always defined by Windows).
1063 (these are always defined by Windows).
1064 This typically gives something like
1064 This typically gives something like
1065 \family typewriter
1065 \family typewriter
1066 C:
1066 C:
1067 \backslash
1067 \backslash
1068 Documents and Settings
1068 Documents and Settings
1069 \backslash
1069 \backslash
1070 YourUserName
1070 YourUserName
1071 \family default
1071 \family default
1072 , but your local details may vary.
1072 , but your local details may vary.
1073 In this directory you will find all the files that configure IPython's
1073 In this directory you will find all the files that configure IPython's
1074 defaults, and you can put there your profiles and extensions.
1074 defaults, and you can put there your profiles and extensions.
1075 This directory is automatically added by IPython to
1075 This directory is automatically added by IPython to
1076 \family typewriter
1076 \family typewriter
1077 sys.path
1077 sys.path
1078 \family default
1078 \family default
1079 , so anything you place there can be found by
1079 , so anything you place there can be found by
1080 \family typewriter
1080 \family typewriter
1081 import
1081 import
1082 \family default
1082 \family default
1083 statements.
1083 statements.
1084 \layout Paragraph
1084 \layout Paragraph
1085
1085
1086 Upgrading
1086 Upgrading
1087 \layout Standard
1087 \layout Standard
1088
1088
1089 For an IPython upgrade, you should first uninstall the previous version.
1089 For an IPython upgrade, you should first uninstall the previous version.
1090 This will ensure that all files and directories (such as the documentation)
1090 This will ensure that all files and directories (such as the documentation)
1091 which carry embedded version strings in their names are properly removed.
1091 which carry embedded version strings in their names are properly removed.
1092 \layout Paragraph
1092 \layout Paragraph
1093
1093
1094 Manual installation under Win32
1094 Manual installation under Win32
1095 \layout Standard
1095 \layout Standard
1096
1096
1097 In case the automatic installer does not work for some reason, you can download
1097 In case the automatic installer does not work for some reason, you can download
1098 the
1098 the
1099 \family typewriter
1099 \family typewriter
1100 ipython-XXX.tar.gz
1100 ipython-XXX.tar.gz
1101 \family default
1101 \family default
1102 file, which contains the full IPython source distribution (the popular
1102 file, which contains the full IPython source distribution (the popular
1103 WinZip can read
1103 WinZip can read
1104 \family typewriter
1104 \family typewriter
1105 .tar.gz
1105 .tar.gz
1106 \family default
1106 \family default
1107 files).
1107 files).
1108 After uncompressing the archive, you can install it at a command terminal
1108 After uncompressing the archive, you can install it at a command terminal
1109 just like any other Python module, by using
1109 just like any other Python module, by using
1110 \family typewriter
1110 \family typewriter
1111 `python setup.py install'
1111 `python setup.py install'
1112 \family default
1112 \family default
1113 .
1113 .
1114
1114
1115 \layout Standard
1115 \layout Standard
1116
1116
1117 After the installation, run the supplied
1117 After the installation, run the supplied
1118 \family typewriter
1118 \family typewriter
1119 win32_manual_post_install.py
1119 win32_manual_post_install.py
1120 \family default
1120 \family default
1121 script, which creates the necessary Start Menu shortcuts for you.
1121 script, which creates the necessary Start Menu shortcuts for you.
1122 \layout Subsection
1122 \layout Subsection
1123
1123
1124
1124
1125 \begin_inset LatexCommand \label{sec:upgrade}
1125 \begin_inset LatexCommand \label{sec:upgrade}
1126
1126
1127 \end_inset
1127 \end_inset
1128
1128
1129 Upgrading from a previous version
1129 Upgrading from a previous version
1130 \layout Standard
1130 \layout Standard
1131
1131
1132 If you are upgrading from a previous version of IPython, after doing the
1132 If you are upgrading from a previous version of IPython, after doing the
1133 routine installation described above, you should call IPython with the
1133 routine installation described above, you should call IPython with the
1134
1134
1135 \family typewriter
1135 \family typewriter
1136 -upgrade
1136 -upgrade
1137 \family default
1137 \family default
1138 option the first time you run your new copy.
1138 option the first time you run your new copy.
1139 This will automatically update your configuration directory while preserving
1139 This will automatically update your configuration directory while preserving
1140 copies of your old files.
1140 copies of your old files.
1141 You can then later merge back any personal customizations you may have
1141 You can then later merge back any personal customizations you may have
1142 made into the new files.
1142 made into the new files.
1143 It is a good idea to do this as there may be new options available in the
1143 It is a good idea to do this as there may be new options available in the
1144 new configuration files which you will not have.
1144 new configuration files which you will not have.
1145 \layout Standard
1145 \layout Standard
1146
1146
1147 Under Windows, if you don't know how to call python scripts with arguments
1147 Under Windows, if you don't know how to call python scripts with arguments
1148 from a command line, simply delete the old config directory and IPython
1148 from a command line, simply delete the old config directory and IPython
1149 will make a new one.
1149 will make a new one.
1150 Win2k and WinXP users will find it in
1150 Win2k and WinXP users will find it in
1151 \family typewriter
1151 \family typewriter
1152 C:
1152 C:
1153 \backslash
1153 \backslash
1154 Documents and Settings
1154 Documents and Settings
1155 \backslash
1155 \backslash
1156 YourUserName
1156 YourUserName
1157 \backslash
1157 \backslash
1158 _ipython
1158 _ipython
1159 \family default
1159 \family default
1160 , and Win 9x users under
1160 , and Win 9x users under
1161 \family typewriter
1161 \family typewriter
1162 C:
1162 C:
1163 \backslash
1163 \backslash
1164 Program Files
1164 Program Files
1165 \backslash
1165 \backslash
1166 IPython
1166 IPython
1167 \backslash
1167 \backslash
1168 _ipython.
1168 _ipython.
1169 \layout Section
1169 \layout Section
1170
1170
1171
1171
1172 \begin_inset LatexCommand \label{sec:good_config}
1172 \begin_inset LatexCommand \label{sec:good_config}
1173
1173
1174 \end_inset
1174 \end_inset
1175
1175
1176
1176
1177 \begin_inset OptArg
1177 \begin_inset OptArg
1178 collapsed true
1178 collapsed true
1179
1179
1180 \layout Standard
1180 \layout Standard
1181
1181
1182 Initial configuration
1182 Initial configuration
1183 \begin_inset ERT
1183 \begin_inset ERT
1184 status Collapsed
1184 status Collapsed
1185
1185
1186 \layout Standard
1186 \layout Standard
1187
1187
1188 \backslash
1188 \backslash
1189 ldots
1189 ldots
1190 \end_inset
1190 \end_inset
1191
1191
1192
1192
1193 \end_inset
1193 \end_inset
1194
1194
1195 Initial configuration of your environment
1195 Initial configuration of your environment
1196 \layout Standard
1196 \layout Standard
1197
1197
1198 This section will help you set various things in your environment for your
1198 This section will help you set various things in your environment for your
1199 IPython sessions to be as efficient as possible.
1199 IPython sessions to be as efficient as possible.
1200 All of IPython's configuration information, along with several example
1200 All of IPython's configuration information, along with several example
1201 files, is stored in a directory named by default
1201 files, is stored in a directory named by default
1202 \family typewriter
1202 \family typewriter
1203 $HOME/.ipython
1203 $HOME/.ipython
1204 \family default
1204 \family default
1205 .
1205 .
1206 You can change this by defining the environment variable
1206 You can change this by defining the environment variable
1207 \family typewriter
1207 \family typewriter
1208 IPYTHONDIR
1208 IPYTHONDIR
1209 \family default
1209 \family default
1210 , or at runtime with the command line option
1210 , or at runtime with the command line option
1211 \family typewriter
1211 \family typewriter
1212 -ipythondir
1212 -ipythondir
1213 \family default
1213 \family default
1214 .
1214 .
1215 \layout Standard
1215 \layout Standard
1216
1216
1217 If all goes well, the first time you run IPython it should automatically
1217 If all goes well, the first time you run IPython it should automatically
1218 create a user copy of the config directory for you, based on its builtin
1218 create a user copy of the config directory for you, based on its builtin
1219 defaults.
1219 defaults.
1220 You can look at the files it creates to learn more about configuring the
1220 You can look at the files it creates to learn more about configuring the
1221 system.
1221 system.
1222 The main file you will modify to configure IPython's behavior is called
1222 The main file you will modify to configure IPython's behavior is called
1223
1223
1224 \family typewriter
1224 \family typewriter
1225 ipythonrc
1225 ipythonrc
1226 \family default
1226 \family default
1227 (with a
1227 (with a
1228 \family typewriter
1228 \family typewriter
1229 .ini
1229 .ini
1230 \family default
1230 \family default
1231 extension under Windows), included for reference in Sec.
1231 extension under Windows), included for reference in Sec.
1232
1232
1233 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1233 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1234
1234
1235 \end_inset
1235 \end_inset
1236
1236
1237 .
1237 .
1238 This file is very commented and has many variables you can change to suit
1238 This file is very commented and has many variables you can change to suit
1239 your taste, you can find more details in Sec.
1239 your taste, you can find more details in Sec.
1240
1240
1241 \begin_inset LatexCommand \ref{sec:customization}
1241 \begin_inset LatexCommand \ref{sec:customization}
1242
1242
1243 \end_inset
1243 \end_inset
1244
1244
1245 .
1245 .
1246 Here we discuss the basic things you will want to make sure things are
1246 Here we discuss the basic things you will want to make sure things are
1247 working properly from the beginning.
1247 working properly from the beginning.
1248 \layout Subsection
1248 \layout Subsection
1249
1249
1250
1250
1251 \begin_inset LatexCommand \label{sec:help-access}
1251 \begin_inset LatexCommand \label{sec:help-access}
1252
1252
1253 \end_inset
1253 \end_inset
1254
1254
1255 Access to the Python help system
1255 Access to the Python help system
1256 \layout Standard
1256 \layout Standard
1257
1257
1258 This is true for Python in general (not just for IPython): you should have
1258 This is true for Python in general (not just for IPython): you should have
1259 an environment variable called
1259 an environment variable called
1260 \family typewriter
1260 \family typewriter
1261 PYTHONDOCS
1261 PYTHONDOCS
1262 \family default
1262 \family default
1263 pointing to the directory where your HTML Python documentation lives.
1263 pointing to the directory where your HTML Python documentation lives.
1264 In my system it's
1264 In my system it's
1265 \family typewriter
1265 \family typewriter
1266 /usr/share/doc/python-docs-2.3.4/html
1266 /usr/share/doc/python-docs-2.3.4/html
1267 \family default
1267 \family default
1268 , check your local details or ask your systems administrator.
1268 , check your local details or ask your systems administrator.
1269
1269
1270 \layout Standard
1270 \layout Standard
1271
1271
1272 This is the directory which holds the HTML version of the Python manuals.
1272 This is the directory which holds the HTML version of the Python manuals.
1273 Unfortunately it seems that different Linux distributions package these
1273 Unfortunately it seems that different Linux distributions package these
1274 files differently, so you may have to look around a bit.
1274 files differently, so you may have to look around a bit.
1275 Below I show the contents of this directory on my system for reference:
1275 Below I show the contents of this directory on my system for reference:
1276 \layout Standard
1276 \layout Standard
1277
1277
1278
1278
1279 \family typewriter
1279 \family typewriter
1280 [html]> ls
1280 [html]> ls
1281 \newline
1281 \newline
1282 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1282 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1283 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1283 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1284 \layout Standard
1284 \layout Standard
1285
1285
1286 You should really make sure this variable is correctly set so that Python's
1286 You should really make sure this variable is correctly set so that Python's
1287 pydoc-based help system works.
1287 pydoc-based help system works.
1288 It is a powerful and convenient system with full access to the Python manuals
1288 It is a powerful and convenient system with full access to the Python manuals
1289 and all modules accessible to you.
1289 and all modules accessible to you.
1290 \layout Standard
1290 \layout Standard
1291
1291
1292 Under Windows it seems that pydoc finds the documentation automatically,
1292 Under Windows it seems that pydoc finds the documentation automatically,
1293 so no extra setup appears necessary.
1293 so no extra setup appears necessary.
1294 \layout Subsection
1294 \layout Subsection
1295
1295
1296 Editor
1296 Editor
1297 \layout Standard
1297 \layout Standard
1298
1298
1299 The
1299 The
1300 \family typewriter
1300 \family typewriter
1301 %edit
1301 %edit
1302 \family default
1302 \family default
1303 command (and its alias
1303 command (and its alias
1304 \family typewriter
1304 \family typewriter
1305 %ed
1305 %ed
1306 \family default
1306 \family default
1307 ) will invoke the editor set in your environment as
1307 ) will invoke the editor set in your environment as
1308 \family typewriter
1308 \family typewriter
1309 EDITOR
1309 EDITOR
1310 \family default
1310 \family default
1311 .
1311 .
1312 If this variable is not set, it will default to
1312 If this variable is not set, it will default to
1313 \family typewriter
1313 \family typewriter
1314 vi
1314 vi
1315 \family default
1315 \family default
1316 under Linux/Unix and to
1316 under Linux/Unix and to
1317 \family typewriter
1317 \family typewriter
1318 notepad
1318 notepad
1319 \family default
1319 \family default
1320 under Windows.
1320 under Windows.
1321 You may want to set this variable properly and to a lightweight editor
1321 You may want to set this variable properly and to a lightweight editor
1322 which doesn't take too long to start (that is, something other than a new
1322 which doesn't take too long to start (that is, something other than a new
1323 instance of
1323 instance of
1324 \family typewriter
1324 \family typewriter
1325 Emacs
1325 Emacs
1326 \family default
1326 \family default
1327 ).
1327 ).
1328 This way you can edit multi-line code quickly and with the power of a real
1328 This way you can edit multi-line code quickly and with the power of a real
1329 editor right inside IPython.
1329 editor right inside IPython.
1330
1330
1331 \layout Standard
1331 \layout Standard
1332
1332
1333 If you are a dedicated
1333 If you are a dedicated
1334 \family typewriter
1334 \family typewriter
1335 Emacs
1335 Emacs
1336 \family default
1336 \family default
1337 user, you should set up the
1337 user, you should set up the
1338 \family typewriter
1338 \family typewriter
1339 Emacs
1339 Emacs
1340 \family default
1340 \family default
1341 server so that new requests are handled by the original process.
1341 server so that new requests are handled by the original process.
1342 This means that almost no time is spent in handling the request (assuming
1342 This means that almost no time is spent in handling the request (assuming
1343 an
1343 an
1344 \family typewriter
1344 \family typewriter
1345 Emacs
1345 Emacs
1346 \family default
1346 \family default
1347 process is already running).
1347 process is already running).
1348 For this to work, you need to set your
1348 For this to work, you need to set your
1349 \family typewriter
1349 \family typewriter
1350 EDITOR
1350 EDITOR
1351 \family default
1351 \family default
1352 environment variable to
1352 environment variable to
1353 \family typewriter
1353 \family typewriter
1354 'emacsclient'
1354 'emacsclient'
1355 \family default
1355 \family default
1356 .
1356 .
1357
1357
1358 \family typewriter
1358 \family typewriter
1359
1359
1360 \family default
1360 \family default
1361 The code below, supplied by Francois Pinard, can then be used in your
1361 The code below, supplied by Francois Pinard, can then be used in your
1362 \family typewriter
1362 \family typewriter
1363 .emacs
1363 .emacs
1364 \family default
1364 \family default
1365 file to enable the server:
1365 file to enable the server:
1366 \layout Standard
1366 \layout Standard
1367
1367
1368
1368
1369 \family typewriter
1369 \family typewriter
1370 (defvar server-buffer-clients)
1370 (defvar server-buffer-clients)
1371 \newline
1371 \newline
1372 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1372 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1373 \newline
1373 \newline
1374
1374
1375 \begin_inset ERT
1375 \begin_inset ERT
1376 status Collapsed
1376 status Collapsed
1377
1377
1378 \layout Standard
1378 \layout Standard
1379
1379
1380 \backslash
1380 \backslash
1381 hspace*{0mm}
1381 hspace*{0mm}
1382 \end_inset
1382 \end_inset
1383
1383
1384 \SpecialChar ~
1384 \SpecialChar ~
1385 \SpecialChar ~
1385 \SpecialChar ~
1386 (server-start)
1386 (server-start)
1387 \newline
1387 \newline
1388
1388
1389 \begin_inset ERT
1389 \begin_inset ERT
1390 status Collapsed
1390 status Collapsed
1391
1391
1392 \layout Standard
1392 \layout Standard
1393
1393
1394 \backslash
1394 \backslash
1395 hspace*{0mm}
1395 hspace*{0mm}
1396 \end_inset
1396 \end_inset
1397
1397
1398 \SpecialChar ~
1398 \SpecialChar ~
1399 \SpecialChar ~
1399 \SpecialChar ~
1400 (defun fp-kill-server-with-buffer-routine ()
1400 (defun fp-kill-server-with-buffer-routine ()
1401 \newline
1401 \newline
1402
1402
1403 \begin_inset ERT
1403 \begin_inset ERT
1404 status Collapsed
1404 status Collapsed
1405
1405
1406 \layout Standard
1406 \layout Standard
1407
1407
1408 \backslash
1408 \backslash
1409 hspace*{0mm}
1409 hspace*{0mm}
1410 \end_inset
1410 \end_inset
1411
1411
1412 \SpecialChar ~
1412 \SpecialChar ~
1413 \SpecialChar ~
1413 \SpecialChar ~
1414 \SpecialChar ~
1414 \SpecialChar ~
1415 \SpecialChar ~
1415 \SpecialChar ~
1416 (and server-buffer-clients (server-done)))
1416 (and server-buffer-clients (server-done)))
1417 \newline
1417 \newline
1418
1418
1419 \begin_inset ERT
1419 \begin_inset ERT
1420 status Collapsed
1420 status Collapsed
1421
1421
1422 \layout Standard
1422 \layout Standard
1423
1423
1424 \backslash
1424 \backslash
1425 hspace*{0mm}
1425 hspace*{0mm}
1426 \end_inset
1426 \end_inset
1427
1427
1428 \SpecialChar ~
1428 \SpecialChar ~
1429 \SpecialChar ~
1429 \SpecialChar ~
1430 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1430 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1431 \layout Standard
1431 \layout Standard
1432
1432
1433 You can also set the value of this editor via the commmand-line option '-
1433 You can also set the value of this editor via the commmand-line option '-
1434 \family typewriter
1434 \family typewriter
1435 editor'
1435 editor'
1436 \family default
1436 \family default
1437 or in your
1437 or in your
1438 \family typewriter
1438 \family typewriter
1439 ipythonrc
1439 ipythonrc
1440 \family default
1440 \family default
1441 file.
1441 file.
1442 This is useful if you wish to use specifically for IPython an editor different
1442 This is useful if you wish to use specifically for IPython an editor different
1443 from your typical default (and for Windows users who tend to use fewer
1443 from your typical default (and for Windows users who tend to use fewer
1444 environment variables).
1444 environment variables).
1445 \layout Subsection
1445 \layout Subsection
1446
1446
1447 Color
1447 Color
1448 \layout Standard
1448 \layout Standard
1449
1449
1450 The default IPython configuration has most bells and whistles turned on
1450 The default IPython configuration has most bells and whistles turned on
1451 (they're pretty safe).
1451 (they're pretty safe).
1452 But there's one that
1452 But there's one that
1453 \emph on
1453 \emph on
1454 may
1454 may
1455 \emph default
1455 \emph default
1456 cause problems on some systems: the use of color on screen for displaying
1456 cause problems on some systems: the use of color on screen for displaying
1457 information.
1457 information.
1458 This is very useful, since IPython can show prompts and exception tracebacks
1458 This is very useful, since IPython can show prompts and exception tracebacks
1459 with various colors, display syntax-highlighted source code, and in general
1459 with various colors, display syntax-highlighted source code, and in general
1460 make it easier to visually parse information.
1460 make it easier to visually parse information.
1461 \layout Standard
1461 \layout Standard
1462
1462
1463 The following terminals seem to handle the color sequences fine:
1463 The following terminals seem to handle the color sequences fine:
1464 \layout Itemize
1464 \layout Itemize
1465
1465
1466 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1466 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1467 \layout Itemize
1467 \layout Itemize
1468
1468
1469 CDE terminal (tested under Solaris).
1469 CDE terminal (tested under Solaris).
1470 This one boldfaces light colors.
1470 This one boldfaces light colors.
1471 \layout Itemize
1471 \layout Itemize
1472
1472
1473 (X)Emacs buffers.
1473 (X)Emacs buffers.
1474 See sec.
1474 See sec.
1475 \begin_inset LatexCommand \ref{sec:emacs}
1475 \begin_inset LatexCommand \ref{sec:emacs}
1476
1476
1477 \end_inset
1477 \end_inset
1478
1478
1479 for more details on using IPython with (X)Emacs.
1479 for more details on using IPython with (X)Emacs.
1480 \layout Itemize
1480 \layout Itemize
1481
1481
1482 A Windows (XP/2k) command prompt
1482 A Windows (XP/2k) command prompt
1483 \emph on
1483 \emph on
1484 with Gary Bishop's support extensions
1484 with Gary Bishop's support extensions
1485 \emph default
1485 \emph default
1486 .
1486 .
1487 Gary's extensions are discussed in Sec.\SpecialChar ~
1487 Gary's extensions are discussed in Sec.\SpecialChar ~
1488
1488
1489 \begin_inset LatexCommand \ref{sub:Under-Windows}
1489 \begin_inset LatexCommand \ref{sub:Under-Windows}
1490
1490
1491 \end_inset
1491 \end_inset
1492
1492
1493 .
1493 .
1494 \layout Itemize
1494 \layout Itemize
1495
1495
1496 A Windows (XP/2k) CygWin shell.
1496 A Windows (XP/2k) CygWin shell.
1497 Although some users have reported problems; it is not clear whether there
1497 Although some users have reported problems; it is not clear whether there
1498 is an issue for everyone or only under specific configurations.
1498 is an issue for everyone or only under specific configurations.
1499 If you have full color support under cygwin, please post to the IPython
1499 If you have full color support under cygwin, please post to the IPython
1500 mailing list so this issue can be resolved for all users.
1500 mailing list so this issue can be resolved for all users.
1501 \layout Standard
1501 \layout Standard
1502
1502
1503 These have shown problems:
1503 These have shown problems:
1504 \layout Itemize
1504 \layout Itemize
1505
1505
1506 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1506 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1507 or ssh.
1507 or ssh.
1508 \layout Itemize
1508 \layout Itemize
1509
1509
1510 Windows native command prompt in WinXP/2k,
1510 Windows native command prompt in WinXP/2k,
1511 \emph on
1511 \emph on
1512 without
1512 without
1513 \emph default
1513 \emph default
1514 Gary Bishop's extensions.
1514 Gary Bishop's extensions.
1515 Once Gary's readline library is installed, the normal WinXP/2k command
1515 Once Gary's readline library is installed, the normal WinXP/2k command
1516 prompt works perfectly.
1516 prompt works perfectly.
1517 \layout Standard
1517 \layout Standard
1518
1518
1519 Currently the following color schemes are available:
1519 Currently the following color schemes are available:
1520 \layout Itemize
1520 \layout Itemize
1521
1521
1522
1522
1523 \family typewriter
1523 \family typewriter
1524 NoColor
1524 NoColor
1525 \family default
1525 \family default
1526 : uses no color escapes at all (all escapes are empty
1526 : uses no color escapes at all (all escapes are empty
1527 \begin_inset Quotes eld
1527 \begin_inset Quotes eld
1528 \end_inset
1528 \end_inset
1529
1529
1530
1530
1531 \begin_inset Quotes eld
1531 \begin_inset Quotes eld
1532 \end_inset
1532 \end_inset
1533
1533
1534 strings).
1534 strings).
1535 This 'scheme' is thus fully safe to use in any terminal.
1535 This 'scheme' is thus fully safe to use in any terminal.
1536 \layout Itemize
1536 \layout Itemize
1537
1537
1538
1538
1539 \family typewriter
1539 \family typewriter
1540 Linux
1540 Linux
1541 \family default
1541 \family default
1542 : works well in Linux console type environments: dark background with light
1542 : works well in Linux console type environments: dark background with light
1543 fonts.
1543 fonts.
1544 It uses bright colors for information, so it is difficult to read if you
1544 It uses bright colors for information, so it is difficult to read if you
1545 have a light colored background.
1545 have a light colored background.
1546 \layout Itemize
1546 \layout Itemize
1547
1547
1548
1548
1549 \family typewriter
1549 \family typewriter
1550 LightBG
1550 LightBG
1551 \family default
1551 \family default
1552 : the basic colors are similar to those in the
1552 : the basic colors are similar to those in the
1553 \family typewriter
1553 \family typewriter
1554 Linux
1554 Linux
1555 \family default
1555 \family default
1556 scheme but darker.
1556 scheme but darker.
1557 It is easy to read in terminals with light backgrounds.
1557 It is easy to read in terminals with light backgrounds.
1558 \layout Standard
1558 \layout Standard
1559
1559
1560 IPython uses colors for two main groups of things: prompts and tracebacks
1560 IPython uses colors for two main groups of things: prompts and tracebacks
1561 which are directly printed to the terminal, and the object introspection
1561 which are directly printed to the terminal, and the object introspection
1562 system which passes large sets of data through a pager.
1562 system which passes large sets of data through a pager.
1563 \layout Subsubsection
1563 \layout Subsubsection
1564
1564
1565 Input/Output prompts and exception tracebacks
1565 Input/Output prompts and exception tracebacks
1566 \layout Standard
1566 \layout Standard
1567
1567
1568 You can test whether the colored prompts and tracebacks work on your system
1568 You can test whether the colored prompts and tracebacks work on your system
1569 interactively by typing
1569 interactively by typing
1570 \family typewriter
1570 \family typewriter
1571 '%colors Linux'
1571 '%colors Linux'
1572 \family default
1572 \family default
1573 at the prompt (use '
1573 at the prompt (use '
1574 \family typewriter
1574 \family typewriter
1575 %colors LightBG'
1575 %colors LightBG'
1576 \family default
1576 \family default
1577 if your terminal has a light background).
1577 if your terminal has a light background).
1578 If the input prompt shows garbage like:
1578 If the input prompt shows garbage like:
1579 \newline
1579 \newline
1580
1580
1581 \family typewriter
1581 \family typewriter
1582 [0;32mIn [[1;32m1[0;32m]: [0;00m
1582 [0;32mIn [[1;32m1[0;32m]: [0;00m
1583 \family default
1583 \family default
1584
1584
1585 \newline
1585 \newline
1586 instead of (in color) something like:
1586 instead of (in color) something like:
1587 \newline
1587 \newline
1588
1588
1589 \family typewriter
1589 \family typewriter
1590 In [1]:
1590 In [1]:
1591 \family default
1591 \family default
1592
1592
1593 \newline
1593 \newline
1594 this means that your terminal doesn't properly handle color escape sequences.
1594 this means that your terminal doesn't properly handle color escape sequences.
1595 You can go to a 'no color' mode by typing '
1595 You can go to a 'no color' mode by typing '
1596 \family typewriter
1596 \family typewriter
1597 %colors NoColor
1597 %colors NoColor
1598 \family default
1598 \family default
1599 '.
1599 '.
1600
1600
1601 \layout Standard
1601 \layout Standard
1602
1602
1603 You can try using a different terminal emulator program.
1603 You can try using a different terminal emulator program.
1604 To permanently set your color preferences, edit the file
1604 To permanently set your color preferences, edit the file
1605 \family typewriter
1605 \family typewriter
1606 $HOME/.ipython/ipythonrc
1606 $HOME/.ipython/ipythonrc
1607 \family default
1607 \family default
1608 and set the
1608 and set the
1609 \family typewriter
1609 \family typewriter
1610 colors
1610 colors
1611 \family default
1611 \family default
1612 option to the desired value.
1612 option to the desired value.
1613 \layout Subsubsection
1613 \layout Subsubsection
1614
1614
1615 Object details (types, docstrings, source code, etc.)
1615 Object details (types, docstrings, source code, etc.)
1616 \layout Standard
1616 \layout Standard
1617
1617
1618 IPython has a set of special functions for studying the objects you are
1618 IPython has a set of special functions for studying the objects you are
1619 working with, discussed in detail in Sec.
1619 working with, discussed in detail in Sec.
1620
1620
1621 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1621 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1622
1622
1623 \end_inset
1623 \end_inset
1624
1624
1625 .
1625 .
1626 But this system relies on passing information which is longer than your
1626 But this system relies on passing information which is longer than your
1627 screen through a data pager, such as the common Unix
1627 screen through a data pager, such as the common Unix
1628 \family typewriter
1628 \family typewriter
1629 less
1629 less
1630 \family default
1630 \family default
1631 and
1631 and
1632 \family typewriter
1632 \family typewriter
1633 more
1633 more
1634 \family default
1634 \family default
1635 programs.
1635 programs.
1636 In order to be able to see this information in color, your pager needs
1636 In order to be able to see this information in color, your pager needs
1637 to be properly configured.
1637 to be properly configured.
1638 I strongly recommend using
1638 I strongly recommend using
1639 \family typewriter
1639 \family typewriter
1640 less
1640 less
1641 \family default
1641 \family default
1642 instead of
1642 instead of
1643 \family typewriter
1643 \family typewriter
1644 more
1644 more
1645 \family default
1645 \family default
1646 , as it seems that
1646 , as it seems that
1647 \family typewriter
1647 \family typewriter
1648 more
1648 more
1649 \family default
1649 \family default
1650 simply can not understand colored text correctly.
1650 simply can not understand colored text correctly.
1651 \layout Standard
1651 \layout Standard
1652
1652
1653 In order to configure
1653 In order to configure
1654 \family typewriter
1654 \family typewriter
1655 less
1655 less
1656 \family default
1656 \family default
1657 as your default pager, do the following:
1657 as your default pager, do the following:
1658 \layout Enumerate
1658 \layout Enumerate
1659
1659
1660 Set the environment
1660 Set the environment
1661 \family typewriter
1661 \family typewriter
1662 PAGER
1662 PAGER
1663 \family default
1663 \family default
1664 variable to
1664 variable to
1665 \family typewriter
1665 \family typewriter
1666 less
1666 less
1667 \family default
1667 \family default
1668 .
1668 .
1669 \layout Enumerate
1669 \layout Enumerate
1670
1670
1671 Set the environment
1671 Set the environment
1672 \family typewriter
1672 \family typewriter
1673 LESS
1673 LESS
1674 \family default
1674 \family default
1675 variable to
1675 variable to
1676 \family typewriter
1676 \family typewriter
1677 -r
1677 -r
1678 \family default
1678 \family default
1679 (plus any other options you always want to pass to
1679 (plus any other options you always want to pass to
1680 \family typewriter
1680 \family typewriter
1681 less
1681 less
1682 \family default
1682 \family default
1683 by default).
1683 by default).
1684 This tells
1684 This tells
1685 \family typewriter
1685 \family typewriter
1686 less
1686 less
1687 \family default
1687 \family default
1688 to properly interpret control sequences, which is how color information
1688 to properly interpret control sequences, which is how color information
1689 is given to your terminal.
1689 is given to your terminal.
1690 \layout Standard
1690 \layout Standard
1691
1691
1692 For the
1692 For the
1693 \family typewriter
1693 \family typewriter
1694 csh
1694 csh
1695 \family default
1695 \family default
1696 or
1696 or
1697 \family typewriter
1697 \family typewriter
1698 tcsh
1698 tcsh
1699 \family default
1699 \family default
1700 shells, add to your
1700 shells, add to your
1701 \family typewriter
1701 \family typewriter
1702 ~/.cshrc
1702 ~/.cshrc
1703 \family default
1703 \family default
1704 file the lines:
1704 file the lines:
1705 \layout Standard
1705 \layout Standard
1706
1706
1707
1707
1708 \family typewriter
1708 \family typewriter
1709 setenv PAGER less
1709 setenv PAGER less
1710 \newline
1710 \newline
1711 setenv LESS -r
1711 setenv LESS -r
1712 \layout Standard
1712 \layout Standard
1713
1713
1714 There is similar syntax for other Unix shells, look at your system documentation
1714 There is similar syntax for other Unix shells, look at your system documentation
1715 for details.
1715 for details.
1716 \layout Standard
1716 \layout Standard
1717
1717
1718 If you are on a system which lacks proper data pagers (such as Windows),
1718 If you are on a system which lacks proper data pagers (such as Windows),
1719 IPython will use a very limited builtin pager.
1719 IPython will use a very limited builtin pager.
1720 \layout Subsection
1720 \layout Subsection
1721
1721
1722
1722
1723 \begin_inset LatexCommand \label{sec:emacs}
1723 \begin_inset LatexCommand \label{sec:emacs}
1724
1724
1725 \end_inset
1725 \end_inset
1726
1726
1727 (X)Emacs configuration
1727 (X)Emacs configuration
1728 \layout Standard
1728 \layout Standard
1729
1729
1730 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1730 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1731 (X)Emacs and IPython get along very well.
1731 (X)Emacs and IPython get along very well.
1732
1732
1733 \layout Standard
1733 \layout Standard
1734
1734
1735
1735
1736 \series bold
1736 \series bold
1737 Important note:
1737 Important note:
1738 \series default
1738 \series default
1739 You will need to use a recent enough version of
1739 You will need to use a recent enough version of
1740 \family typewriter
1740 \family typewriter
1741 python-mode.el
1741 python-mode.el
1742 \family default
1742 \family default
1743 , along with the file
1743 , along with the file
1744 \family typewriter
1744 \family typewriter
1745 ipython.el
1745 ipython.el
1746 \family default
1746 \family default
1747 .
1747 .
1748 You can check that the version you have of
1748 You can check that the version you have of
1749 \family typewriter
1749 \family typewriter
1750 python-mode.el
1750 python-mode.el
1751 \family default
1751 \family default
1752 is new enough by either looking at the revision number in the file itself,
1752 is new enough by either looking at the revision number in the file itself,
1753 or asking for it in (X)Emacs via
1753 or asking for it in (X)Emacs via
1754 \family typewriter
1754 \family typewriter
1755 M-x py-version
1755 M-x py-version
1756 \family default
1756 \family default
1757 .
1757 .
1758 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1758 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1759 \layout Standard
1759 \layout Standard
1760
1760
1761 The file
1761 The file
1762 \family typewriter
1762 \family typewriter
1763 ipython.el
1763 ipython.el
1764 \family default
1764 \family default
1765 is included with the IPython distribution, in the documentation directory
1765 is included with the IPython distribution, in the documentation directory
1766 (where this manual resides in PDF and HTML formats).
1766 (where this manual resides in PDF and HTML formats).
1767 \layout Standard
1767 \layout Standard
1768
1768
1769 Once you put these files in your Emacs path, all you need in your
1769 Once you put these files in your Emacs path, all you need in your
1770 \family typewriter
1770 \family typewriter
1771 .emacs
1771 .emacs
1772 \family default
1772 \family default
1773 file is:
1773 file is:
1774 \layout Standard
1774 \layout Standard
1775
1775
1776
1776
1777 \family typewriter
1777 \family typewriter
1778 (require 'ipython)
1778 (require 'ipython)
1779 \layout Standard
1779 \layout Standard
1780
1780
1781 This should give you full support for executing code snippets via IPython,
1781 This should give you full support for executing code snippets via IPython,
1782 opening IPython as your Python shell via
1782 opening IPython as your Python shell via
1783 \family typewriter
1783 \family typewriter
1784 C-c\SpecialChar ~
1784 C-c\SpecialChar ~
1785 !
1785 !
1786 \family default
1786 \family default
1787 , etc.
1787 , etc.
1788
1788
1789 \layout Subsubsection*
1789 \layout Subsubsection*
1790
1790
1791 Notes
1791 Notes
1792 \layout Itemize
1792 \layout Itemize
1793
1793
1794 There is one caveat you should be aware of: you must start the IPython shell
1794 There is one caveat you should be aware of: you must start the IPython shell
1795
1795
1796 \emph on
1796 \emph on
1797 before
1797 before
1798 \emph default
1798 \emph default
1799 attempting to execute any code regions via
1799 attempting to execute any code regions via
1800 \family typewriter
1800 \family typewriter
1801 C-c\SpecialChar ~
1801 C-c\SpecialChar ~
1802 |
1802 |
1803 \family default
1803 \family default
1804 .
1804 .
1805 Simply type
1805 Simply type
1806 \family typewriter
1806 \family typewriter
1807 C-c\SpecialChar ~
1807 C-c\SpecialChar ~
1808 !
1808 !
1809 \family default
1809 \family default
1810 to start IPython before passing any code regions to the interpreter, and
1810 to start IPython before passing any code regions to the interpreter, and
1811 you shouldn't experience any problems.
1811 you shouldn't experience any problems.
1812 \newline
1812 \newline
1813 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1813 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1814 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1814 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1815 \layout Itemize
1815 \layout Itemize
1816
1816
1817 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1817 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1818 ts should be directed to him through the IPython mailing lists.
1818 ts should be directed to him through the IPython mailing lists.
1819
1819
1820 \layout Itemize
1820 \layout Itemize
1821
1821
1822 This code is still somewhat experimental so it's a bit rough around the
1822 This code is still somewhat experimental so it's a bit rough around the
1823 edges (although in practice, it works quite well).
1823 edges (although in practice, it works quite well).
1824 \layout Itemize
1824 \layout Itemize
1825
1825
1826 Be aware that if you customize
1826 Be aware that if you customize
1827 \family typewriter
1827 \family typewriter
1828 py-python-command
1828 py-python-command
1829 \family default
1829 \family default
1830 previously, this value will override what
1830 previously, this value will override what
1831 \family typewriter
1831 \family typewriter
1832 ipython.el
1832 ipython.el
1833 \family default
1833 \family default
1834 does (because loading the customization variables comes later).
1834 does (because loading the customization variables comes later).
1835 \layout Section
1835 \layout Section
1836
1836
1837
1837
1838 \begin_inset LatexCommand \label{sec:quick_tips}
1838 \begin_inset LatexCommand \label{sec:quick_tips}
1839
1839
1840 \end_inset
1840 \end_inset
1841
1841
1842 Quick tips
1842 Quick tips
1843 \layout Standard
1843 \layout Standard
1844
1844
1845 IPython can be used as an improved replacement for the Python prompt, and
1845 IPython can be used as an improved replacement for the Python prompt, and
1846 for that you don't really need to read any more of this manual.
1846 for that you don't really need to read any more of this manual.
1847 But in this section we'll try to summarize a few tips on how to make the
1847 But in this section we'll try to summarize a few tips on how to make the
1848 most effective use of it for everyday Python development, highlighting
1848 most effective use of it for everyday Python development, highlighting
1849 things you might miss in the rest of the manual (which is getting long).
1849 things you might miss in the rest of the manual (which is getting long).
1850 We'll give references to parts in the manual which provide more detail
1850 We'll give references to parts in the manual which provide more detail
1851 when appropriate.
1851 when appropriate.
1852 \layout Standard
1852 \layout Standard
1853
1853
1854 The following article by Jeremy Jones provides an introductory tutorial
1854 The following article by Jeremy Jones provides an introductory tutorial
1855 about IPython:
1855 about IPython:
1856 \newline
1856 \newline
1857
1857
1858 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1858 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1859
1859
1860 \end_inset
1860 \end_inset
1861
1861
1862
1862
1863 \layout Itemize
1863 \layout Itemize
1864
1864
1865 The TAB key.
1865 The TAB key.
1866 TAB-completion, especially for attributes, is a convenient way to explore
1866 TAB-completion, especially for attributes, is a convenient way to explore
1867 the structure of any object you're dealing with.
1867 the structure of any object you're dealing with.
1868 Simply type
1868 Simply type
1869 \family typewriter
1869 \family typewriter
1870 object_name.<TAB>
1870 object_name.<TAB>
1871 \family default
1871 \family default
1872 and a list of the object's attributes will be printed (see sec.
1872 and a list of the object's attributes will be printed (see sec.
1873
1873
1874 \begin_inset LatexCommand \ref{sec:readline}
1874 \begin_inset LatexCommand \ref{sec:readline}
1875
1875
1876 \end_inset
1876 \end_inset
1877
1877
1878 for more).
1878 for more).
1879 Tab completion also works on file and directory names, which combined with
1879 Tab completion also works on file and directory names, which combined with
1880 IPython's alias system allows you to do from within IPython many of the
1880 IPython's alias system allows you to do from within IPython many of the
1881 things you normally would need the system shell for.
1881 things you normally would need the system shell for.
1882
1882
1883 \layout Itemize
1883 \layout Itemize
1884
1884
1885 Explore your objects.
1885 Explore your objects.
1886 Typing
1886 Typing
1887 \family typewriter
1887 \family typewriter
1888 object_name?
1888 object_name?
1889 \family default
1889 \family default
1890 will print all sorts of details about any object, including docstrings,
1890 will print all sorts of details about any object, including docstrings,
1891 function definition lines (for call arguments) and constructor details
1891 function definition lines (for call arguments) and constructor details
1892 for classes.
1892 for classes.
1893 The magic commands
1893 The magic commands
1894 \family typewriter
1894 \family typewriter
1895 %pdoc
1895 %pdoc
1896 \family default
1896 \family default
1897 ,
1897 ,
1898 \family typewriter
1898 \family typewriter
1899 %pdef
1899 %pdef
1900 \family default
1900 \family default
1901 ,
1901 ,
1902 \family typewriter
1902 \family typewriter
1903 %psource
1903 %psource
1904 \family default
1904 \family default
1905 and
1905 and
1906 \family typewriter
1906 \family typewriter
1907 %pfile
1907 %pfile
1908 \family default
1908 \family default
1909 will respectively print the docstring, function definition line, full source
1909 will respectively print the docstring, function definition line, full source
1910 code and the complete file for any object (when they can be found).
1910 code and the complete file for any object (when they can be found).
1911 If automagic is on (it is by default), you don't need to type the '
1911 If automagic is on (it is by default), you don't need to type the '
1912 \family typewriter
1912 \family typewriter
1913 %
1913 %
1914 \family default
1914 \family default
1915 ' explicitly.
1915 ' explicitly.
1916 See sec.
1916 See sec.
1917
1917
1918 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1918 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1919
1919
1920 \end_inset
1920 \end_inset
1921
1921
1922 for more.
1922 for more.
1923 \layout Itemize
1923 \layout Itemize
1924
1924
1925 The
1925 The
1926 \family typewriter
1926 \family typewriter
1927 %run
1927 %run
1928 \family default
1928 \family default
1929 magic command allows you to run any python script and load all of its data
1929 magic command allows you to run any python script and load all of its data
1930 directly into the interactive namespace.
1930 directly into the interactive namespace.
1931 Since the file is re-read from disk each time, changes you make to it are
1931 Since the file is re-read from disk each time, changes you make to it are
1932 reflected immediately (in contrast to the behavior of
1932 reflected immediately (in contrast to the behavior of
1933 \family typewriter
1933 \family typewriter
1934 import
1934 import
1935 \family default
1935 \family default
1936 ).
1936 ).
1937 I rarely use
1937 I rarely use
1938 \family typewriter
1938 \family typewriter
1939 import
1939 import
1940 \family default
1940 \family default
1941 for code I am testing, relying on
1941 for code I am testing, relying on
1942 \family typewriter
1942 \family typewriter
1943 %run
1943 %run
1944 \family default
1944 \family default
1945 instead.
1945 instead.
1946 See sec.
1946 See sec.
1947
1947
1948 \begin_inset LatexCommand \ref{sec:magic}
1948 \begin_inset LatexCommand \ref{sec:magic}
1949
1949
1950 \end_inset
1950 \end_inset
1951
1951
1952 for more on this and other magic commands, or type the name of any magic
1952 for more on this and other magic commands, or type the name of any magic
1953 command and ? to get details on it.
1953 command and ? to get details on it.
1954 See also sec.
1954 See also sec.
1955
1955
1956 \begin_inset LatexCommand \ref{sec:dreload}
1956 \begin_inset LatexCommand \ref{sec:dreload}
1957
1957
1958 \end_inset
1958 \end_inset
1959
1959
1960 for a recursive reload command.
1960 for a recursive reload command.
1961 \newline
1961 \newline
1962
1962
1963 \family typewriter
1963 \family typewriter
1964 %run
1964 %run
1965 \family default
1965 \family default
1966 also has special flags for timing the execution of your scripts (
1966 also has special flags for timing the execution of your scripts (
1967 \family typewriter
1967 \family typewriter
1968 -t
1968 -t
1969 \family default
1969 \family default
1970 ) and for executing them under the control of either Python's
1970 ) and for executing them under the control of either Python's
1971 \family typewriter
1971 \family typewriter
1972 pdb
1972 pdb
1973 \family default
1973 \family default
1974 debugger (
1974 debugger (
1975 \family typewriter
1975 \family typewriter
1976 -d
1976 -d
1977 \family default
1977 \family default
1978 ) or profiler (
1978 ) or profiler (
1979 \family typewriter
1979 \family typewriter
1980 -p
1980 -p
1981 \family default
1981 \family default
1982 ).
1982 ).
1983 With all of these,
1983 With all of these,
1984 \family typewriter
1984 \family typewriter
1985 %run
1985 %run
1986 \family default
1986 \family default
1987 can be used as the main tool for efficient interactive development of code
1987 can be used as the main tool for efficient interactive development of code
1988 which you write in your editor of choice.
1988 which you write in your editor of choice.
1989 \layout Itemize
1989 \layout Itemize
1990
1990
1991 Use the Python debugger,
1991 Use the Python debugger,
1992 \family typewriter
1992 \family typewriter
1993 pdb
1993 pdb
1994 \family default
1994 \family default
1995
1995
1996 \begin_inset Foot
1996 \begin_inset Foot
1997 collapsed true
1997 collapsed true
1998
1998
1999 \layout Standard
1999 \layout Standard
2000
2000
2001 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2001 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2002 to IPython's improved debugger and profiler support.
2002 to IPython's improved debugger and profiler support.
2003 \end_inset
2003 \end_inset
2004
2004
2005 .
2005 .
2006 The
2006 The
2007 \family typewriter
2007 \family typewriter
2008 %pdb
2008 %pdb
2009 \family default
2009 \family default
2010 command allows you to toggle on and off the automatic invocation of an
2010 command allows you to toggle on and off the automatic invocation of an
2011 IPython-enhanced
2011 IPython-enhanced
2012 \family typewriter
2012 \family typewriter
2013 pdb
2013 pdb
2014 \family default
2014 \family default
2015 debugger (with coloring, tab completion and more) at any uncaught exception.
2015 debugger (with coloring, tab completion and more) at any uncaught exception.
2016 The advantage of this is that
2016 The advantage of this is that
2017 \family typewriter
2017 \family typewriter
2018 pdb
2018 pdb
2019 \family default
2019 \family default
2020 starts
2020 starts
2021 \emph on
2021 \emph on
2022 inside
2022 inside
2023 \emph default
2023 \emph default
2024 the function where the exception occurred, with all data still available.
2024 the function where the exception occurred, with all data still available.
2025 You can print variables, see code, execute statements and even walk up
2025 You can print variables, see code, execute statements and even walk up
2026 and down the call stack to track down the true source of the problem (which
2026 and down the call stack to track down the true source of the problem (which
2027 often is many layers in the stack above where the exception gets triggered).
2027 often is many layers in the stack above where the exception gets triggered).
2028 \newline
2028 \newline
2029 Running programs with
2029 Running programs with
2030 \family typewriter
2030 \family typewriter
2031 %run
2031 %run
2032 \family default
2032 \family default
2033 and pdb active can be an efficient to develop and debug code, in many cases
2033 and pdb active can be an efficient to develop and debug code, in many cases
2034 eliminating the need for
2034 eliminating the need for
2035 \family typewriter
2035 \family typewriter
2036 print
2036 print
2037 \family default
2037 \family default
2038 statements or external debugging tools.
2038 statements or external debugging tools.
2039 I often simply put a
2039 I often simply put a
2040 \family typewriter
2040 \family typewriter
2041 1/0
2041 1/0
2042 \family default
2042 \family default
2043 in a place where I want to take a look so that pdb gets called, quickly
2043 in a place where I want to take a look so that pdb gets called, quickly
2044 view whatever variables I need to or test various pieces of code and then
2044 view whatever variables I need to or test various pieces of code and then
2045 remove the
2045 remove the
2046 \family typewriter
2046 \family typewriter
2047 1/0
2047 1/0
2048 \family default
2048 \family default
2049 .
2049 .
2050 \newline
2050 \newline
2051 Note also that `
2051 Note also that `
2052 \family typewriter
2052 \family typewriter
2053 %run -d
2053 %run -d
2054 \family default
2054 \family default
2055 ' activates
2055 ' activates
2056 \family typewriter
2056 \family typewriter
2057 pdb
2057 pdb
2058 \family default
2058 \family default
2059 and automatically sets initial breakpoints for you to step through your
2059 and automatically sets initial breakpoints for you to step through your
2060 code, watch variables, etc.
2060 code, watch variables, etc.
2061 See Sec.\SpecialChar ~
2061 See Sec.\SpecialChar ~
2062
2062
2063 \begin_inset LatexCommand \ref{sec:cache_output}
2063 \begin_inset LatexCommand \ref{sec:cache_output}
2064
2064
2065 \end_inset
2065 \end_inset
2066
2066
2067 for details.
2067 for details.
2068 \layout Itemize
2068 \layout Itemize
2069
2069
2070 Use the output cache.
2070 Use the output cache.
2071 All output results are automatically stored in a global dictionary named
2071 All output results are automatically stored in a global dictionary named
2072
2072
2073 \family typewriter
2073 \family typewriter
2074 Out
2074 Out
2075 \family default
2075 \family default
2076 and variables named
2076 and variables named
2077 \family typewriter
2077 \family typewriter
2078 _1
2078 _1
2079 \family default
2079 \family default
2080 ,
2080 ,
2081 \family typewriter
2081 \family typewriter
2082 _2
2082 _2
2083 \family default
2083 \family default
2084 , etc.
2084 , etc.
2085 alias them.
2085 alias them.
2086 For example, the result of input line 4 is available either as
2086 For example, the result of input line 4 is available either as
2087 \family typewriter
2087 \family typewriter
2088 Out[4]
2088 Out[4]
2089 \family default
2089 \family default
2090 or as
2090 or as
2091 \family typewriter
2091 \family typewriter
2092 _4
2092 _4
2093 \family default
2093 \family default
2094 .
2094 .
2095 Additionally, three variables named
2095 Additionally, three variables named
2096 \family typewriter
2096 \family typewriter
2097 _
2097 _
2098 \family default
2098 \family default
2099 ,
2099 ,
2100 \family typewriter
2100 \family typewriter
2101 __
2101 __
2102 \family default
2102 \family default
2103 and
2103 and
2104 \family typewriter
2104 \family typewriter
2105 ___
2105 ___
2106 \family default
2106 \family default
2107 are always kept updated with the for the last three results.
2107 are always kept updated with the for the last three results.
2108 This allows you to recall any previous result and further use it for new
2108 This allows you to recall any previous result and further use it for new
2109 calculations.
2109 calculations.
2110 See Sec.\SpecialChar ~
2110 See Sec.\SpecialChar ~
2111
2111
2112 \begin_inset LatexCommand \ref{sec:cache_output}
2112 \begin_inset LatexCommand \ref{sec:cache_output}
2113
2113
2114 \end_inset
2114 \end_inset
2115
2115
2116 for more.
2116 for more.
2117 \layout Itemize
2117 \layout Itemize
2118
2118
2119 Put a '
2119 Put a '
2120 \family typewriter
2120 \family typewriter
2121 ;
2121 ;
2122 \family default
2122 \family default
2123 ' at the end of a line to supress the printing of output.
2123 ' at the end of a line to supress the printing of output.
2124 This is useful when doing calculations which generate long output you are
2124 This is useful when doing calculations which generate long output you are
2125 not interested in seeing.
2125 not interested in seeing.
2126 The
2126 The
2127 \family typewriter
2127 \family typewriter
2128 _*
2128 _*
2129 \family default
2129 \family default
2130 variables and the
2130 variables and the
2131 \family typewriter
2131 \family typewriter
2132 Out[]
2132 Out[]
2133 \family default
2133 \family default
2134 list do get updated with the contents of the output, even if it is not
2134 list do get updated with the contents of the output, even if it is not
2135 printed.
2135 printed.
2136 You can thus still access the generated results this way for further processing.
2136 You can thus still access the generated results this way for further processing.
2137 \layout Itemize
2137 \layout Itemize
2138
2138
2139 A similar system exists for caching input.
2139 A similar system exists for caching input.
2140 All input is stored in a global list called
2140 All input is stored in a global list called
2141 \family typewriter
2141 \family typewriter
2142 In
2142 In
2143 \family default
2143 \family default
2144 , so you can re-execute lines 22 through 28 plus line 34 by typing
2144 , so you can re-execute lines 22 through 28 plus line 34 by typing
2145 \family typewriter
2145 \family typewriter
2146 'exec In[22:29]+In[34]'
2146 'exec In[22:29]+In[34]'
2147 \family default
2147 \family default
2148 (using Python slicing notation).
2148 (using Python slicing notation).
2149 If you need to execute the same set of lines often, you can assign them
2149 If you need to execute the same set of lines often, you can assign them
2150 to a macro with the
2150 to a macro with the
2151 \family typewriter
2151 \family typewriter
2152 %macro
2152 %macro
2153 \family default
2153 \family default
2154
2154
2155 \family typewriter
2155 \family typewriter
2156 function.
2156 function.
2157
2157
2158 \family default
2158 \family default
2159 See sec.
2159 See sec.
2160
2160
2161 \begin_inset LatexCommand \ref{sec:cache_input}
2161 \begin_inset LatexCommand \ref{sec:cache_input}
2162
2162
2163 \end_inset
2163 \end_inset
2164
2164
2165 for more.
2165 for more.
2166 \layout Itemize
2166 \layout Itemize
2167
2167
2168 Use your input history.
2168 Use your input history.
2169 The
2169 The
2170 \family typewriter
2170 \family typewriter
2171 %hist
2171 %hist
2172 \family default
2172 \family default
2173 command can show you all previous input, without line numbers if desired
2173 command can show you all previous input, without line numbers if desired
2174 (option
2174 (option
2175 \family typewriter
2175 \family typewriter
2176 -n
2176 -n
2177 \family default
2177 \family default
2178 ) so you can directly copy and paste code either back in IPython or in a
2178 ) so you can directly copy and paste code either back in IPython or in a
2179 text editor.
2179 text editor.
2180 You can also save all your history by turning on logging via
2180 You can also save all your history by turning on logging via
2181 \family typewriter
2181 \family typewriter
2182 %logstart
2182 %logstart
2183 \family default
2183 \family default
2184 ; these logs can later be either reloaded as IPython sessions or used as
2184 ; these logs can later be either reloaded as IPython sessions or used as
2185 code for your programs.
2185 code for your programs.
2186 \layout Itemize
2186 \layout Itemize
2187
2187
2188 Define your own macros with
2188 Define your own macros with
2189 \family typewriter
2189 \family typewriter
2190 %macro
2190 %macro
2191 \family default
2191 \family default
2192 .
2192 .
2193 This can be useful for automating sequences of expressions when working
2193 This can be useful for automating sequences of expressions when working
2194 interactively.
2194 interactively.
2195 \layout Itemize
2195 \layout Itemize
2196
2196
2197 Define your own system aliases.
2197 Define your own system aliases.
2198 Even though IPython gives you access to your system shell via the
2198 Even though IPython gives you access to your system shell via the
2199 \family typewriter
2199 \family typewriter
2200 !
2200 !
2201 \family default
2201 \family default
2202 prefix, it is convenient to have aliases to the system commands you use
2202 prefix, it is convenient to have aliases to the system commands you use
2203 most often.
2203 most often.
2204 This allows you to work seamlessly from inside IPython with the same commands
2204 This allows you to work seamlessly from inside IPython with the same commands
2205 you are used to in your system shell.
2205 you are used to in your system shell.
2206 \newline
2206 \newline
2207 IPython comes with some pre-defined aliases and a complete system for changing
2207 IPython comes with some pre-defined aliases and a complete system for changing
2208 directories, both via a stack (see
2208 directories, both via a stack (see
2209 \family typewriter
2209 \family typewriter
2210 %pushd
2210 %pushd
2211 \family default
2211 \family default
2212 ,
2212 ,
2213 \family typewriter
2213 \family typewriter
2214 %popd
2214 %popd
2215 \family default
2215 \family default
2216 and
2216 and
2217 \family typewriter
2217 \family typewriter
2218 %ds
2218 %ds
2219 \family default
2219 \family default
2220 ) and via direct
2220 ) and via direct
2221 \family typewriter
2221 \family typewriter
2222 %cd
2222 %cd
2223 \family default
2223 \family default
2224 .
2224 .
2225 The latter keeps a history of visited directories and allows you to go
2225 The latter keeps a history of visited directories and allows you to go
2226 to any previously visited one.
2226 to any previously visited one.
2227 \layout Itemize
2227 \layout Itemize
2228
2228
2229 Use Python to manipulate the results of system commands.
2229 Use Python to manipulate the results of system commands.
2230 The `
2230 The `
2231 \family typewriter
2231 \family typewriter
2232 !!
2232 !!
2233 \family default
2233 \family default
2234 ' special syntax, and the
2234 ' special syntax, and the
2235 \family typewriter
2235 \family typewriter
2236 %sc
2236 %sc
2237 \family default
2237 \family default
2238 and
2238 and
2239 \family typewriter
2239 \family typewriter
2240 %sx
2240 %sx
2241 \family default
2241 \family default
2242 magic commands allow you to capture system output into Python variables.
2242 magic commands allow you to capture system output into Python variables.
2243 \layout Itemize
2243 \layout Itemize
2244
2244
2245 Expand python variables when calling the shell (either via
2245 Expand python variables when calling the shell (either via
2246 \family typewriter
2246 \family typewriter
2247 `!'
2247 `!'
2248 \family default
2248 \family default
2249 and
2249 and
2250 \family typewriter
2250 \family typewriter
2251 `!!'
2251 `!!'
2252 \family default
2252 \family default
2253 or via aliases) by prepending a
2253 or via aliases) by prepending a
2254 \family typewriter
2254 \family typewriter
2255 $
2255 $
2256 \family default
2256 \family default
2257 in front of them.
2257 in front of them.
2258 You can also expand complete python expressions.
2258 You can also expand complete python expressions.
2259 See sec.\SpecialChar ~
2259 See sec.\SpecialChar ~
2260
2260
2261 \begin_inset LatexCommand \ref{sub:System-shell-access}
2261 \begin_inset LatexCommand \ref{sub:System-shell-access}
2262
2262
2263 \end_inset
2263 \end_inset
2264
2264
2265 for more.
2265 for more.
2266 \layout Itemize
2266 \layout Itemize
2267
2267
2268 Use profiles to maintain different configurations (modules to load, function
2268 Use profiles to maintain different configurations (modules to load, function
2269 definitions, option settings) for particular tasks.
2269 definitions, option settings) for particular tasks.
2270 You can then have customized versions of IPython for specific purposes.
2270 You can then have customized versions of IPython for specific purposes.
2271 See sec.\SpecialChar ~
2271 See sec.\SpecialChar ~
2272
2272
2273 \begin_inset LatexCommand \ref{sec:profiles}
2273 \begin_inset LatexCommand \ref{sec:profiles}
2274
2274
2275 \end_inset
2275 \end_inset
2276
2276
2277 for more.
2277 for more.
2278 \layout Itemize
2278 \layout Itemize
2279
2279
2280 Embed IPython in your programs.
2280 Embed IPython in your programs.
2281 A few lines of code are enough to load a complete IPython inside your own
2281 A few lines of code are enough to load a complete IPython inside your own
2282 programs, giving you the ability to work with your data interactively after
2282 programs, giving you the ability to work with your data interactively after
2283 automatic processing has been completed.
2283 automatic processing has been completed.
2284 See sec.\SpecialChar ~
2284 See sec.\SpecialChar ~
2285
2285
2286 \begin_inset LatexCommand \ref{sec:embed}
2286 \begin_inset LatexCommand \ref{sec:embed}
2287
2287
2288 \end_inset
2288 \end_inset
2289
2289
2290 for more.
2290 for more.
2291 \layout Itemize
2291 \layout Itemize
2292
2292
2293 Use the Python profiler.
2293 Use the Python profiler.
2294 When dealing with performance issues, the
2294 When dealing with performance issues, the
2295 \family typewriter
2295 \family typewriter
2296 %run
2296 %run
2297 \family default
2297 \family default
2298 command with a
2298 command with a
2299 \family typewriter
2299 \family typewriter
2300 -p
2300 -p
2301 \family default
2301 \family default
2302 option allows you to run complete programs under the control of the Python
2302 option allows you to run complete programs under the control of the Python
2303 profiler.
2303 profiler.
2304 The
2304 The
2305 \family typewriter
2305 \family typewriter
2306 %prun
2306 %prun
2307 \family default
2307 \family default
2308 command does a similar job for single Python expressions (like function
2308 command does a similar job for single Python expressions (like function
2309 calls).
2309 calls).
2310 \layout Itemize
2310 \layout Itemize
2311
2311
2312 Use
2312 Use
2313 \family typewriter
2313 \family typewriter
2314 %edit
2314 %edit
2315 \family default
2315 \family default
2316 to have almost multiline editing.
2316 to have almost multiline editing.
2317 While IPython doesn't support true multiline editing, this command allows
2317 While IPython doesn't support true multiline editing, this command allows
2318 you to call an editor on the spot, and IPython will execute the code you
2318 you to call an editor on the spot, and IPython will execute the code you
2319 type in there as if it were typed interactively.
2319 type in there as if it were typed interactively.
2320 \layout Itemize
2320 \layout Itemize
2321
2321
2322 Use the IPython.demo.Demo class to load any Python script as an interactive
2322 Use the IPython.demo.Demo class to load any Python script as an interactive
2323 demo.
2323 demo.
2324 With a minimal amount of simple markup, you can control the execution of
2324 With a minimal amount of simple markup, you can control the execution of
2325 the script, stopping as needed.
2325 the script, stopping as needed.
2326 See sec.\SpecialChar ~
2326 See sec.\SpecialChar ~
2327
2327
2328 \begin_inset LatexCommand \ref{sec:interactive-demos}
2328 \begin_inset LatexCommand \ref{sec:interactive-demos}
2329
2329
2330 \end_inset
2330 \end_inset
2331
2331
2332 for more.
2332 for more.
2333 \layout Standard
2333 \layout Standard
2334
2334
2335
2335
2336 \series bold
2336 \series bold
2337 Effective logging:
2337 Effective logging:
2338 \series default
2338 \series default
2339 a very useful suggestion sent in by Robert Kern follows
2339 a very useful suggestion sent in by Robert Kern follows
2340 \layout Standard
2340 \layout Standard
2341
2341
2342 I recently happened on a nifty way to keep tidy per-project log files.
2342 I recently happened on a nifty way to keep tidy per-project log files.
2343 I made a profile for my project (which is called "parkfield").
2343 I made a profile for my project (which is called "parkfield").
2344 \layout LyX-Code
2344 \layout LyX-Code
2345
2345
2346 include ipythonrc
2346 include ipythonrc
2347 \layout LyX-Code
2347 \layout LyX-Code
2348
2348
2349 logfile '' # cancel earlier logfile invocation
2349 logfile '' # cancel earlier logfile invocation
2350 \layout LyX-Code
2350 \layout LyX-Code
2351
2351
2352 execute import time
2352 execute import time
2353 \layout LyX-Code
2353 \layout LyX-Code
2354
2354
2355 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2355 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2356 \layout LyX-Code
2356 \layout LyX-Code
2357
2357
2358 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2358 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2359 \layout Standard
2359 \layout Standard
2360
2360
2361 I also added a shell alias for convenience:
2361 I also added a shell alias for convenience:
2362 \layout LyX-Code
2362 \layout LyX-Code
2363
2363
2364 alias parkfield="ipython -pylab -profile parkfield"
2364 alias parkfield="ipython -pylab -profile parkfield"
2365 \layout Standard
2365 \layout Standard
2366
2366
2367 Now I have a nice little directory with everything I ever type in, organized
2367 Now I have a nice little directory with everything I ever type in, organized
2368 by project and date.
2368 by project and date.
2369 \layout Standard
2369 \layout Standard
2370
2370
2371
2371
2372 \series bold
2372 \series bold
2373 Contribute your own:
2373 Contribute your own:
2374 \series default
2374 \series default
2375 If you have your own favorite tip on using IPython efficiently for a certain
2375 If you have your own favorite tip on using IPython efficiently for a certain
2376 task (especially things which can't be done in the normal Python interpreter),
2376 task (especially things which can't be done in the normal Python interpreter),
2377 don't hesitate to send it!
2377 don't hesitate to send it!
2378 \layout Section
2378 \layout Section
2379
2379
2380 Command-line use
2380 Command-line use
2381 \layout Standard
2381 \layout Standard
2382
2382
2383 You start IPython with the command:
2383 You start IPython with the command:
2384 \layout Standard
2384 \layout Standard
2385
2385
2386
2386
2387 \family typewriter
2387 \family typewriter
2388 $ ipython [options] files
2388 $ ipython [options] files
2389 \layout Standard
2389 \layout Standard
2390
2390
2391 If invoked with no options, it executes all the files listed in sequence
2391 If invoked with no options, it executes all the files listed in sequence
2392 and drops you into the interpreter while still acknowledging any options
2392 and drops you into the interpreter while still acknowledging any options
2393 you may have set in your ipythonrc file.
2393 you may have set in your ipythonrc file.
2394 This behavior is different from standard Python, which when called as
2394 This behavior is different from standard Python, which when called as
2395 \family typewriter
2395 \family typewriter
2396 python -i
2396 python -i
2397 \family default
2397 \family default
2398 will only execute one file and ignore your configuration setup.
2398 will only execute one file and ignore your configuration setup.
2399 \layout Standard
2399 \layout Standard
2400
2400
2401 Please note that some of the configuration options are not available at
2401 Please note that some of the configuration options are not available at
2402 the command line, simply because they are not practical here.
2402 the command line, simply because they are not practical here.
2403 Look into your ipythonrc configuration file for details on those.
2403 Look into your ipythonrc configuration file for details on those.
2404 This file typically installed in the
2404 This file typically installed in the
2405 \family typewriter
2405 \family typewriter
2406 $HOME/.ipython
2406 $HOME/.ipython
2407 \family default
2407 \family default
2408 directory.
2408 directory.
2409 For Windows users,
2409 For Windows users,
2410 \family typewriter
2410 \family typewriter
2411 $HOME
2411 $HOME
2412 \family default
2412 \family default
2413 resolves to
2413 resolves to
2414 \family typewriter
2414 \family typewriter
2415 C:
2415 C:
2416 \backslash
2416 \backslash
2417
2417
2418 \backslash
2418 \backslash
2419 Documents and Settings
2419 Documents and Settings
2420 \backslash
2420 \backslash
2421
2421
2422 \backslash
2422 \backslash
2423 YourUserName
2423 YourUserName
2424 \family default
2424 \family default
2425 in most instances.
2425 in most instances.
2426 In the rest of this text, we will refer to this directory as
2426 In the rest of this text, we will refer to this directory as
2427 \family typewriter
2427 \family typewriter
2428 IPYTHONDIR
2428 IPYTHONDIR
2429 \family default
2429 \family default
2430 .
2430 .
2431 \layout Subsection
2431 \layout Subsection
2432
2432
2433
2433
2434 \begin_inset LatexCommand \label{sec:threading-opts}
2434 \begin_inset LatexCommand \label{sec:threading-opts}
2435
2435
2436 \end_inset
2436 \end_inset
2437
2437
2438 Special Threading Options
2438 Special Threading Options
2439 \layout Standard
2439 \layout Standard
2440
2440
2441 The following special options are ONLY valid at the beginning of the command
2441 The following special options are ONLY valid at the beginning of the command
2442 line, and not later.
2442 line, and not later.
2443 This is because they control the initial- ization of ipython itself, before
2443 This is because they control the initial- ization of ipython itself, before
2444 the normal option-handling mechanism is active.
2444 the normal option-handling mechanism is active.
2445 \layout List
2445 \layout List
2446 \labelwidthstring 00.00.0000
2446 \labelwidthstring 00.00.0000
2447
2447
2448
2448
2449 \family typewriter
2449 \family typewriter
2450 \series bold
2450 \series bold
2451 -gthread,\SpecialChar ~
2451 -gthread,\SpecialChar ~
2452 -qthread,\SpecialChar ~
2452 -qthread,\SpecialChar ~
2453 -wthread,\SpecialChar ~
2453 -wthread,\SpecialChar ~
2454 -pylab:
2454 -pylab:
2455 \family default
2455 \family default
2456 \series default
2456 \series default
2457 Only
2457 Only
2458 \emph on
2458 \emph on
2459 one
2459 one
2460 \emph default
2460 \emph default
2461 of these can be given, and it can only be given as the first option passed
2461 of these can be given, and it can only be given as the first option passed
2462 to IPython (it will have no effect in any other position).
2462 to IPython (it will have no effect in any other position).
2463 They provide threading support for the GTK Qt and WXPython toolkits, and
2463 They provide threading support for the GTK Qt and WXPython toolkits, and
2464 for the matplotlib library.
2464 for the matplotlib library.
2465 \layout List
2465 \layout List
2466 \labelwidthstring 00.00.0000
2466 \labelwidthstring 00.00.0000
2467
2467
2468 \SpecialChar ~
2468 \SpecialChar ~
2469 With any of the first three options, IPython starts running a separate
2469 With any of the first three options, IPython starts running a separate
2470 thread for the graphical toolkit's operation, so that you can open and
2470 thread for the graphical toolkit's operation, so that you can open and
2471 control graphical elements from within an IPython command line, without
2471 control graphical elements from within an IPython command line, without
2472 blocking.
2472 blocking.
2473 All three provide essentially the same functionality, respectively for
2473 All three provide essentially the same functionality, respectively for
2474 GTK, QT and WXWidgets (via their Python interfaces).
2474 GTK, QT and WXWidgets (via their Python interfaces).
2475 \layout List
2475 \layout List
2476 \labelwidthstring 00.00.0000
2476 \labelwidthstring 00.00.0000
2477
2477
2478 \SpecialChar ~
2478 \SpecialChar ~
2479 If
2479 If
2480 \family typewriter
2480 \family typewriter
2481 -pylab
2481 -pylab
2482 \family default
2482 \family default
2483 is given, IPython loads special support for the mat plotlib library (
2483 is given, IPython loads special support for the mat plotlib library (
2484 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2484 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2485
2485
2486 \end_inset
2486 \end_inset
2487
2487
2488 ), allowing interactive usage of any of its backends as defined in the user's
2488 ), allowing interactive usage of any of its backends as defined in the user's
2489
2489
2490 \family typewriter
2490 \family typewriter
2491 ~/.matplotlib/matplotlibrc
2491 ~/.matplotlib/matplotlibrc
2492 \family default
2492 \family default
2493 file.
2493 file.
2494 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2494 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2495 of matplotlib backend requires it.
2495 of matplotlib backend requires it.
2496 It also modifies the
2496 It also modifies the
2497 \family typewriter
2497 \family typewriter
2498 %run
2498 %run
2499 \family default
2499 \family default
2500 command to correctly execute (without blocking) any matplotlib-based script
2500 command to correctly execute (without blocking) any matplotlib-based script
2501 which calls
2501 which calls
2502 \family typewriter
2502 \family typewriter
2503 show()
2503 show()
2504 \family default
2504 \family default
2505 at the end.
2505 at the end.
2506
2506
2507 \layout List
2507 \layout List
2508 \labelwidthstring 00.00.0000
2508 \labelwidthstring 00.00.0000
2509
2509
2510
2510
2511 \family typewriter
2511 \family typewriter
2512 \series bold
2512 \series bold
2513 -tk
2513 -tk
2514 \family default
2514 \family default
2515 \series default
2515 \series default
2516 The
2516 The
2517 \family typewriter
2517 \family typewriter
2518 -g/q/wthread
2518 -g/q/wthread
2519 \family default
2519 \family default
2520 options, and
2520 options, and
2521 \family typewriter
2521 \family typewriter
2522 -pylab
2522 -pylab
2523 \family default
2523 \family default
2524 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2524 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2525 Tk graphical interfaces.
2525 Tk graphical interfaces.
2526 This means that when either GTK, Qt or WX threading is active, any attempt
2526 This means that when either GTK, Qt or WX threading is active, any attempt
2527 to open a Tk GUI will result in a dead window, and possibly cause the Python
2527 to open a Tk GUI will result in a dead window, and possibly cause the Python
2528 interpreter to crash.
2528 interpreter to crash.
2529 An extra option,
2529 An extra option,
2530 \family typewriter
2530 \family typewriter
2531 -tk
2531 -tk
2532 \family default
2532 \family default
2533 , is available to address this issue.
2533 , is available to address this issue.
2534 It can
2534 It can
2535 \emph on
2535 \emph on
2536 only
2536 only
2537 \emph default
2537 \emph default
2538 be given as a
2538 be given as a
2539 \emph on
2539 \emph on
2540 second
2540 second
2541 \emph default
2541 \emph default
2542 option after any of the above (
2542 option after any of the above (
2543 \family typewriter
2543 \family typewriter
2544 -gthread
2544 -gthread
2545 \family default
2545 \family default
2546 ,
2546 ,
2547 \family typewriter
2547 \family typewriter
2548 -wthread
2548 -wthread
2549 \family default
2549 \family default
2550 or
2550 or
2551 \family typewriter
2551 \family typewriter
2552 -pylab
2552 -pylab
2553 \family default
2553 \family default
2554 ).
2554 ).
2555 \layout List
2555 \layout List
2556 \labelwidthstring 00.00.0000
2556 \labelwidthstring 00.00.0000
2557
2557
2558 \SpecialChar ~
2558 \SpecialChar ~
2559 If
2559 If
2560 \family typewriter
2560 \family typewriter
2561 -tk
2561 -tk
2562 \family default
2562 \family default
2563 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2563 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2564 This is however potentially unreliable, and you will have to test on your
2564 This is however potentially unreliable, and you will have to test on your
2565 platform and Python configuration to determine whether it works for you.
2565 platform and Python configuration to determine whether it works for you.
2566 Debian users have reported success, apparently due to the fact that Debian
2566 Debian users have reported success, apparently due to the fact that Debian
2567 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2567 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2568 Under other Linux environments (such as Fedora Core 2/3), this option has
2568 Under other Linux environments (such as Fedora Core 2/3), this option has
2569 caused random crashes and lockups of the Python interpreter.
2569 caused random crashes and lockups of the Python interpreter.
2570 Under other operating systems (Mac OSX and Windows), you'll need to try
2570 Under other operating systems (Mac OSX and Windows), you'll need to try
2571 it to find out, since currently no user reports are available.
2571 it to find out, since currently no user reports are available.
2572 \layout List
2572 \layout List
2573 \labelwidthstring 00.00.0000
2573 \labelwidthstring 00.00.0000
2574
2574
2575 \SpecialChar ~
2575 \SpecialChar ~
2576 There is unfortunately no way for IPython to determine at run time whether
2576 There is unfortunately no way for IPython to determine at run time whether
2577
2577
2578 \family typewriter
2578 \family typewriter
2579 -tk
2579 -tk
2580 \family default
2580 \family default
2581 will work reliably or not, so you will need to do some experiments before
2581 will work reliably or not, so you will need to do some experiments before
2582 relying on it for regular work.
2582 relying on it for regular work.
2583
2583
2584 \layout Subsection
2584 \layout Subsection
2585
2585
2586
2586
2587 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2587 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2588
2588
2589 \end_inset
2589 \end_inset
2590
2590
2591 Regular Options
2591 Regular Options
2592 \layout Standard
2592 \layout Standard
2593
2593
2594 After the above threading options have been given, regular options can follow
2594 After the above threading options have been given, regular options can follow
2595 in any order.
2595 in any order.
2596 All options can be abbreviated to their shortest non-ambiguous form and
2596 All options can be abbreviated to their shortest non-ambiguous form and
2597 are case-sensitive.
2597 are case-sensitive.
2598 One or two dashes can be used.
2598 One or two dashes can be used.
2599 Some options have an alternate short form, indicated after a
2599 Some options have an alternate short form, indicated after a
2600 \family typewriter
2600 \family typewriter
2601 |
2601 |
2602 \family default
2602 \family default
2603 .
2603 .
2604 \layout Standard
2604 \layout Standard
2605
2605
2606 Most options can also be set from your ipythonrc configuration file.
2606 Most options can also be set from your ipythonrc configuration file.
2607 See the provided example for more details on what the options do.
2607 See the provided example for more details on what the options do.
2608 Options given at the command line override the values set in the ipythonrc
2608 Options given at the command line override the values set in the ipythonrc
2609 file.
2609 file.
2610 \layout Standard
2610 \layout Standard
2611
2611
2612 All options with a
2612 All options with a
2613 \family typewriter
2613 \family typewriter
2614 [no]
2614 [no]
2615 \family default
2615 \family default
2616 prepended can be specified in negated form (
2616 prepended can be specified in negated form (
2617 \family typewriter
2617 \family typewriter
2618 -nooption
2618 -nooption
2619 \family default
2619 \family default
2620 instead of
2620 instead of
2621 \family typewriter
2621 \family typewriter
2622 -option
2622 -option
2623 \family default
2623 \family default
2624 ) to turn the feature off.
2624 ) to turn the feature off.
2625 \layout List
2625 \layout List
2626 \labelwidthstring 00.00.0000
2626 \labelwidthstring 00.00.0000
2627
2627
2628
2628
2629 \family typewriter
2629 \family typewriter
2630 \series bold
2630 \series bold
2631 -help
2631 -help
2632 \family default
2632 \family default
2633 \series default
2633 \series default
2634 : print a help message and exit.
2634 : print a help message and exit.
2635 \layout List
2635 \layout List
2636 \labelwidthstring 00.00.0000
2636 \labelwidthstring 00.00.0000
2637
2637
2638
2638
2639 \family typewriter
2639 \family typewriter
2640 \series bold
2640 \series bold
2641 -pylab:
2641 -pylab:
2642 \family default
2642 \family default
2643 \series default
2643 \series default
2644 this can
2644 this can
2645 \emph on
2645 \emph on
2646 only
2646 only
2647 \emph default
2647 \emph default
2648 be given as the
2648 be given as the
2649 \emph on
2649 \emph on
2650 first
2650 first
2651 \emph default
2651 \emph default
2652 option passed to IPython (it will have no effect in any other position).
2652 option passed to IPython (it will have no effect in any other position).
2653 It adds special support for the matplotlib library (
2653 It adds special support for the matplotlib library (
2654 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2654 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2655
2655
2656 \end_inset
2656 \end_inset
2657
2657
2658 ), allowing interactive usage of any of its backends as defined in the user's
2658 ), allowing interactive usage of any of its backends as defined in the user's
2659
2659
2660 \family typewriter
2660 \family typewriter
2661 .matplotlibrc
2661 .matplotlibrc
2662 \family default
2662 \family default
2663 file.
2663 file.
2664 It automatically activates GTK or WX threading for IPyhton if the choice
2664 It automatically activates GTK or WX threading for IPyhton if the choice
2665 of matplotlib backend requires it.
2665 of matplotlib backend requires it.
2666 It also modifies the
2666 It also modifies the
2667 \family typewriter
2667 \family typewriter
2668 %run
2668 %run
2669 \family default
2669 \family default
2670 command to correctly execute (without blocking) any matplotlib-based script
2670 command to correctly execute (without blocking) any matplotlib-based script
2671 which calls
2671 which calls
2672 \family typewriter
2672 \family typewriter
2673 show()
2673 show()
2674 \family default
2674 \family default
2675 at the end.
2675 at the end.
2676 See Sec.\SpecialChar ~
2676 See Sec.\SpecialChar ~
2677
2677
2678 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2678 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2679
2679
2680 \end_inset
2680 \end_inset
2681
2681
2682 for more details.
2682 for more details.
2683 \layout List
2683 \layout List
2684 \labelwidthstring 00.00.0000
2684 \labelwidthstring 00.00.0000
2685
2685
2686
2686
2687 \family typewriter
2687 \family typewriter
2688 \series bold
2688 \series bold
2689 -[no]autocall:
2689 -[no]autocall:
2690 \family default
2690 \family default
2691 \series default
2691 \series default
2692 Make IPython automatically call any callable object even if you didn't
2692 Make IPython automatically call any callable object even if you didn't
2693 type explicit parentheses.
2693 type explicit parentheses.
2694 For example, `str 43' becomes `str(43)' automatically.
2694 For example, `str 43' becomes `str(43)' automatically.
2695 \layout List
2695 \layout List
2696 \labelwidthstring 00.00.0000
2696 \labelwidthstring 00.00.0000
2697
2697
2698
2698
2699 \family typewriter
2699 \family typewriter
2700 \series bold
2700 \series bold
2701 -[no]autoindent:
2701 -[no]autoindent:
2702 \family default
2702 \family default
2703 \series default
2703 \series default
2704 Turn automatic indentation on/off.
2704 Turn automatic indentation on/off.
2705 \layout List
2705 \layout List
2706 \labelwidthstring 00.00.0000
2706 \labelwidthstring 00.00.0000
2707
2707
2708
2708
2709 \family typewriter
2709 \family typewriter
2710 \series bold
2710 \series bold
2711 -[no]automagic
2711 -[no]automagic
2712 \series default
2712 \series default
2713 :
2713 :
2714 \family default
2714 \family default
2715 make magic commands automatic (without needing their first character to
2715 make magic commands automatic (without needing their first character to
2716 be
2716 be
2717 \family typewriter
2717 \family typewriter
2718 %
2718 %
2719 \family default
2719 \family default
2720 ).
2720 ).
2721 Type
2721 Type
2722 \family typewriter
2722 \family typewriter
2723 %magic
2723 %magic
2724 \family default
2724 \family default
2725 at the IPython prompt for more information.
2725 at the IPython prompt for more information.
2726 \layout List
2726 \layout List
2727 \labelwidthstring 00.00.0000
2727 \labelwidthstring 00.00.0000
2728
2728
2729
2729
2730 \family typewriter
2730 \family typewriter
2731 \series bold
2731 \series bold
2732 -[no]autoedit_syntax:
2732 -[no]autoedit_syntax:
2733 \family default
2733 \family default
2734 \series default
2734 \series default
2735 When a syntax error occurs after editing a file, automatically open the
2735 When a syntax error occurs after editing a file, automatically open the
2736 file to the trouble causing line for convenient fixing.
2736 file to the trouble causing line for convenient fixing.
2737
2737
2738 \layout List
2738 \layout List
2739 \labelwidthstring 00.00.0000
2739 \labelwidthstring 00.00.0000
2740
2740
2741
2741
2742 \family typewriter
2742 \family typewriter
2743 \series bold
2743 \series bold
2744 -[no]banner
2744 -[no]banner
2745 \series default
2745 \series default
2746 :
2746 :
2747 \family default
2747 \family default
2748 Print the initial information banner (default on).
2748 Print the initial information banner (default on).
2749 \layout List
2749 \layout List
2750 \labelwidthstring 00.00.0000
2750 \labelwidthstring 00.00.0000
2751
2751
2752
2752
2753 \family typewriter
2753 \family typewriter
2754 \series bold
2754 \series bold
2755 -c\SpecialChar ~
2755 -c\SpecialChar ~
2756 <command>:
2756 <command>:
2757 \family default
2757 \family default
2758 \series default
2758 \series default
2759 execute the given command string, and set sys.argv to
2759 execute the given command string, and set sys.argv to
2760 \family typewriter
2760 \family typewriter
2761 ['c']
2761 ['c']
2762 \family default
2762 \family default
2763 .
2763 .
2764 This is similar to the
2764 This is similar to the
2765 \family typewriter
2765 \family typewriter
2766 -c
2766 -c
2767 \family default
2767 \family default
2768 option in the normal Python interpreter.
2768 option in the normal Python interpreter.
2769
2769
2770 \layout List
2770 \layout List
2771 \labelwidthstring 00.00.0000
2771 \labelwidthstring 00.00.0000
2772
2772
2773
2773
2774 \family typewriter
2774 \family typewriter
2775 \series bold
2775 \series bold
2776 -cache_size|cs\SpecialChar ~
2776 -cache_size|cs\SpecialChar ~
2777 <n>
2777 <n>
2778 \series default
2778 \series default
2779 :
2779 :
2780 \family default
2780 \family default
2781 size of the output cache (maximum number of entries to hold in memory).
2781 size of the output cache (maximum number of entries to hold in memory).
2782 The default is 1000, you can change it permanently in your config file.
2782 The default is 1000, you can change it permanently in your config file.
2783 Setting it to 0 completely disables the caching system, and the minimum
2783 Setting it to 0 completely disables the caching system, and the minimum
2784 value accepted is 20 (if you provide a value less than 20, it is reset
2784 value accepted is 20 (if you provide a value less than 20, it is reset
2785 to 0 and a warning is issued) This limit is defined because otherwise you'll
2785 to 0 and a warning is issued) This limit is defined because otherwise you'll
2786 spend more time re-flushing a too small cache than working.
2786 spend more time re-flushing a too small cache than working.
2787 \layout List
2787 \layout List
2788 \labelwidthstring 00.00.0000
2788 \labelwidthstring 00.00.0000
2789
2789
2790
2790
2791 \family typewriter
2791 \family typewriter
2792 \series bold
2792 \series bold
2793 -classic|cl
2793 -classic|cl
2794 \series default
2794 \series default
2795 :
2795 :
2796 \family default
2796 \family default
2797 Gives IPython a similar feel to the classic Python prompt.
2797 Gives IPython a similar feel to the classic Python prompt.
2798 \layout List
2798 \layout List
2799 \labelwidthstring 00.00.0000
2799 \labelwidthstring 00.00.0000
2800
2800
2801
2801
2802 \family typewriter
2802 \family typewriter
2803 \series bold
2803 \series bold
2804 -colors\SpecialChar ~
2804 -colors\SpecialChar ~
2805 <scheme>:
2805 <scheme>:
2806 \family default
2806 \family default
2807 \series default
2807 \series default
2808 Color scheme for prompts and exception reporting.
2808 Color scheme for prompts and exception reporting.
2809 Currently implemented: NoColor, Linux and LightBG.
2809 Currently implemented: NoColor, Linux and LightBG.
2810 \layout List
2810 \layout List
2811 \labelwidthstring 00.00.0000
2811 \labelwidthstring 00.00.0000
2812
2812
2813
2813
2814 \family typewriter
2814 \family typewriter
2815 \series bold
2815 \series bold
2816 -[no]color_info:
2816 -[no]color_info:
2817 \family default
2817 \family default
2818 \series default
2818 \series default
2819 IPython can display information about objects via a set of functions, and
2819 IPython can display information about objects via a set of functions, and
2820 optionally can use colors for this, syntax highlighting source code and
2820 optionally can use colors for this, syntax highlighting source code and
2821 various other elements.
2821 various other elements.
2822 However, because this information is passed through a pager (like 'less')
2822 However, because this information is passed through a pager (like 'less')
2823 and many pagers get confused with color codes, this option is off by default.
2823 and many pagers get confused with color codes, this option is off by default.
2824 You can test it and turn it on permanently in your ipythonrc file if it
2824 You can test it and turn it on permanently in your ipythonrc file if it
2825 works for you.
2825 works for you.
2826 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2826 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2827 that in RedHat 7.2 doesn't.
2827 that in RedHat 7.2 doesn't.
2828 \layout List
2828 \layout List
2829 \labelwidthstring 00.00.0000
2829 \labelwidthstring 00.00.0000
2830
2830
2831 \SpecialChar ~
2831 \SpecialChar ~
2832 Test it and turn it on permanently if it works with your system.
2832 Test it and turn it on permanently if it works with your system.
2833 The magic function
2833 The magic function
2834 \family typewriter
2834 \family typewriter
2835 %color_info
2835 %color_info
2836 \family default
2836 \family default
2837 allows you to toggle this interactively for testing.
2837 allows you to toggle this interactively for testing.
2838 \layout List
2838 \layout List
2839 \labelwidthstring 00.00.0000
2839 \labelwidthstring 00.00.0000
2840
2840
2841
2841
2842 \family typewriter
2842 \family typewriter
2843 \series bold
2843 \series bold
2844 -[no]debug
2844 -[no]debug
2845 \family default
2845 \family default
2846 \series default
2846 \series default
2847 : Show information about the loading process.
2847 : Show information about the loading process.
2848 Very useful to pin down problems with your configuration files or to get
2848 Very useful to pin down problems with your configuration files or to get
2849 details about session restores.
2849 details about session restores.
2850 \layout List
2850 \layout List
2851 \labelwidthstring 00.00.0000
2851 \labelwidthstring 00.00.0000
2852
2852
2853
2853
2854 \family typewriter
2854 \family typewriter
2855 \series bold
2855 \series bold
2856 -[no]deep_reload
2856 -[no]deep_reload
2857 \series default
2857 \series default
2858 :
2858 :
2859 \family default
2859 \family default
2860 IPython can use the
2860 IPython can use the
2861 \family typewriter
2861 \family typewriter
2862 deep_reload
2862 deep_reload
2863 \family default
2863 \family default
2864 module which reloads changes in modules recursively (it replaces the
2864 module which reloads changes in modules recursively (it replaces the
2865 \family typewriter
2865 \family typewriter
2866 reload()
2866 reload()
2867 \family default
2867 \family default
2868 function, so you don't need to change anything to use it).
2868 function, so you don't need to change anything to use it).
2869
2869
2870 \family typewriter
2870 \family typewriter
2871 deep_reload()
2871 deep_reload()
2872 \family default
2872 \family default
2873 forces a full reload of modules whose code may have changed, which the
2873 forces a full reload of modules whose code may have changed, which the
2874 default
2874 default
2875 \family typewriter
2875 \family typewriter
2876 reload()
2876 reload()
2877 \family default
2877 \family default
2878 function does not.
2878 function does not.
2879 \layout List
2879 \layout List
2880 \labelwidthstring 00.00.0000
2880 \labelwidthstring 00.00.0000
2881
2881
2882 \SpecialChar ~
2882 \SpecialChar ~
2883 When deep_reload is off, IPython will use the normal
2883 When deep_reload is off, IPython will use the normal
2884 \family typewriter
2884 \family typewriter
2885 reload()
2885 reload()
2886 \family default
2886 \family default
2887 , but deep_reload will still be available as
2887 , but deep_reload will still be available as
2888 \family typewriter
2888 \family typewriter
2889 dreload()
2889 dreload()
2890 \family default
2890 \family default
2891 .
2891 .
2892 This feature is off by default [which means that you have both normal
2892 This feature is off by default [which means that you have both normal
2893 \family typewriter
2893 \family typewriter
2894 reload()
2894 reload()
2895 \family default
2895 \family default
2896 and
2896 and
2897 \family typewriter
2897 \family typewriter
2898 dreload()
2898 dreload()
2899 \family default
2899 \family default
2900 ].
2900 ].
2901 \layout List
2901 \layout List
2902 \labelwidthstring 00.00.0000
2902 \labelwidthstring 00.00.0000
2903
2903
2904
2904
2905 \family typewriter
2905 \family typewriter
2906 \series bold
2906 \series bold
2907 -editor\SpecialChar ~
2907 -editor\SpecialChar ~
2908 <name>
2908 <name>
2909 \family default
2909 \family default
2910 \series default
2910 \series default
2911 : Which editor to use with the
2911 : Which editor to use with the
2912 \family typewriter
2912 \family typewriter
2913 %edit
2913 %edit
2914 \family default
2914 \family default
2915 command.
2915 command.
2916 By default, IPython will honor your
2916 By default, IPython will honor your
2917 \family typewriter
2917 \family typewriter
2918 EDITOR
2918 EDITOR
2919 \family default
2919 \family default
2920 environment variable (if not set, vi is the Unix default and notepad the
2920 environment variable (if not set, vi is the Unix default and notepad the
2921 Windows one).
2921 Windows one).
2922 Since this editor is invoked on the fly by IPython and is meant for editing
2922 Since this editor is invoked on the fly by IPython and is meant for editing
2923 small code snippets, you may want to use a small, lightweight editor here
2923 small code snippets, you may want to use a small, lightweight editor here
2924 (in case your default
2924 (in case your default
2925 \family typewriter
2925 \family typewriter
2926 EDITOR
2926 EDITOR
2927 \family default
2927 \family default
2928 is something like Emacs).
2928 is something like Emacs).
2929 \layout List
2929 \layout List
2930 \labelwidthstring 00.00.0000
2930 \labelwidthstring 00.00.0000
2931
2931
2932
2932
2933 \family typewriter
2933 \family typewriter
2934 \series bold
2934 \series bold
2935 -ipythondir\SpecialChar ~
2935 -ipythondir\SpecialChar ~
2936 <name>
2936 <name>
2937 \series default
2937 \series default
2938 :
2938 :
2939 \family default
2939 \family default
2940 name of your IPython configuration directory
2940 name of your IPython configuration directory
2941 \family typewriter
2941 \family typewriter
2942 IPYTHONDIR
2942 IPYTHONDIR
2943 \family default
2943 \family default
2944 .
2944 .
2945 This can also be specified through the environment variable
2945 This can also be specified through the environment variable
2946 \family typewriter
2946 \family typewriter
2947 IPYTHONDIR
2947 IPYTHONDIR
2948 \family default
2948 \family default
2949 .
2949 .
2950 \layout List
2950 \layout List
2951 \labelwidthstring 00.00.0000
2951 \labelwidthstring 00.00.0000
2952
2952
2953
2953
2954 \family typewriter
2954 \family typewriter
2955 \series bold
2955 \series bold
2956 -log|l
2956 -log|l
2957 \family default
2957 \family default
2958 \series default
2958 \series default
2959 : generate a log file of all input.
2959 : generate a log file of all input.
2960 Defaults to
2960 The file is named
2961 \family typewriter
2961 \family typewriter
2962 $IPYTHONDIR/log
2962 ipython_log.py
2963 \family default
2963 \family default
2964 .
2964 in your current directory (which prevents logs from multiple IPython sessions
2965 from trampling each other).
2965 You can use this to later restore a session by loading your logfile as
2966 You can use this to later restore a session by loading your logfile as
2966 a file to be executed with option
2967 a file to be executed with option
2967 \family typewriter
2968 \family typewriter
2968 -logplay
2969 -logplay
2969 \family default
2970 \family default
2970 (see below).
2971 (see below).
2971 \layout List
2972 \layout List
2972 \labelwidthstring 00.00.0000
2973 \labelwidthstring 00.00.0000
2973
2974
2974
2975
2975 \family typewriter
2976 \family typewriter
2976 \series bold
2977 \series bold
2977 -logfile|lf\SpecialChar ~
2978 -logfile|lf\SpecialChar ~
2978 <name>
2979 <name>
2979 \series default
2980 \series default
2980 :
2981 :
2981 \family default
2982 \family default
2982 specify the name of your logfile.
2983 specify the name of your logfile.
2983 \layout List
2984 \layout List
2984 \labelwidthstring 00.00.0000
2985 \labelwidthstring 00.00.0000
2985
2986
2986
2987
2987 \family typewriter
2988 \family typewriter
2988 \series bold
2989 \series bold
2989 -logplay|lp\SpecialChar ~
2990 -logplay|lp\SpecialChar ~
2990 <name>
2991 <name>
2991 \series default
2992 \series default
2992 :
2993 :
2993 \family default
2994 \family default
2994 you can replay a previous log.
2995 you can replay a previous log.
2995 For restoring a session as close as possible to the state you left it in,
2996 For restoring a session as close as possible to the state you left it in,
2996 use this option (don't just run the logfile).
2997 use this option (don't just run the logfile).
2997 With
2998 With
2998 \family typewriter
2999 \family typewriter
2999 -logplay
3000 -logplay
3000 \family default
3001 \family default
3001 , IPython will try to reconstruct the previous working environment in full,
3002 , IPython will try to reconstruct the previous working environment in full,
3002 not just execute the commands in the logfile.
3003 not just execute the commands in the logfile.
3003 \layout List
3004 \layout List
3004 \labelwidthstring 00.00.0000
3005 \labelwidthstring 00.00.0000
3005
3006
3006 \SpecialChar ~
3007 \SpecialChar ~
3007 When a session is restored, logging is automatically turned on again with
3008 When a session is restored, logging is automatically turned on again with
3008 the name of the logfile it was invoked with (it is read from the log header).
3009 the name of the logfile it was invoked with (it is read from the log header).
3009 So once you've turned logging on for a session, you can quit IPython and
3010 So once you've turned logging on for a session, you can quit IPython and
3010 reload it as many times as you want and it will continue to log its history
3011 reload it as many times as you want and it will continue to log its history
3011 and restore from the beginning every time.
3012 and restore from the beginning every time.
3012 \layout List
3013 \layout List
3013 \labelwidthstring 00.00.0000
3014 \labelwidthstring 00.00.0000
3014
3015
3015 \SpecialChar ~
3016 \SpecialChar ~
3016 Caveats: there are limitations in this option.
3017 Caveats: there are limitations in this option.
3017 The history variables
3018 The history variables
3018 \family typewriter
3019 \family typewriter
3019 _i*
3020 _i*
3020 \family default
3021 \family default
3021 ,
3022 ,
3022 \family typewriter
3023 \family typewriter
3023 _*
3024 _*
3024 \family default
3025 \family default
3025 and
3026 and
3026 \family typewriter
3027 \family typewriter
3027 _dh
3028 _dh
3028 \family default
3029 \family default
3029 don't get restored properly.
3030 don't get restored properly.
3030 In the future we will try to implement full session saving by writing and
3031 In the future we will try to implement full session saving by writing and
3031 retrieving a 'snapshot' of the memory state of IPython.
3032 retrieving a 'snapshot' of the memory state of IPython.
3032 But our first attempts failed because of inherent limitations of Python's
3033 But our first attempts failed because of inherent limitations of Python's
3033 Pickle module, so this may have to wait.
3034 Pickle module, so this may have to wait.
3034 \layout List
3035 \layout List
3035 \labelwidthstring 00.00.0000
3036 \labelwidthstring 00.00.0000
3036
3037
3037
3038
3038 \family typewriter
3039 \family typewriter
3039 \series bold
3040 \series bold
3040 -[no]messages
3041 -[no]messages
3041 \series default
3042 \series default
3042 :
3043 :
3043 \family default
3044 \family default
3044 Print messages which IPython collects about its startup process (default
3045 Print messages which IPython collects about its startup process (default
3045 on).
3046 on).
3046 \layout List
3047 \layout List
3047 \labelwidthstring 00.00.0000
3048 \labelwidthstring 00.00.0000
3048
3049
3049
3050
3050 \family typewriter
3051 \family typewriter
3051 \series bold
3052 \series bold
3052 -[no]pdb
3053 -[no]pdb
3053 \family default
3054 \family default
3054 \series default
3055 \series default
3055 : Automatically call the pdb debugger after every uncaught exception.
3056 : Automatically call the pdb debugger after every uncaught exception.
3056 If you are used to debugging using pdb, this puts you automatically inside
3057 If you are used to debugging using pdb, this puts you automatically inside
3057 of it after any call (either in IPython or in code called by it) which
3058 of it after any call (either in IPython or in code called by it) which
3058 triggers an exception which goes uncaught.
3059 triggers an exception which goes uncaught.
3059 \layout List
3060 \layout List
3060 \labelwidthstring 00.00.0000
3061 \labelwidthstring 00.00.0000
3061
3062
3062
3063
3063 \family typewriter
3064 \family typewriter
3064 \series bold
3065 \series bold
3065 -[no]pprint
3066 -[no]pprint
3066 \series default
3067 \series default
3067 :
3068 :
3068 \family default
3069 \family default
3069 ipython can optionally use the pprint (pretty printer) module for displaying
3070 ipython can optionally use the pprint (pretty printer) module for displaying
3070 results.
3071 results.
3071 pprint tends to give a nicer display of nested data structures.
3072 pprint tends to give a nicer display of nested data structures.
3072 If you like it, you can turn it on permanently in your config file (default
3073 If you like it, you can turn it on permanently in your config file (default
3073 off).
3074 off).
3074 \layout List
3075 \layout List
3075 \labelwidthstring 00.00.0000
3076 \labelwidthstring 00.00.0000
3076
3077
3077
3078
3078 \family typewriter
3079 \family typewriter
3079 \series bold
3080 \series bold
3080 -profile|p <name>
3081 -profile|p <name>
3081 \series default
3082 \series default
3082 :
3083 :
3083 \family default
3084 \family default
3084 assume that your config file is
3085 assume that your config file is
3085 \family typewriter
3086 \family typewriter
3086 ipythonrc-<name>
3087 ipythonrc-<name>
3087 \family default
3088 \family default
3088 (looks in current dir first, then in
3089 (looks in current dir first, then in
3089 \family typewriter
3090 \family typewriter
3090 IPYTHONDIR
3091 IPYTHONDIR
3091 \family default
3092 \family default
3092 ).
3093 ).
3093 This is a quick way to keep and load multiple config files for different
3094 This is a quick way to keep and load multiple config files for different
3094 tasks, especially if you use the include option of config files.
3095 tasks, especially if you use the include option of config files.
3095 You can keep a basic
3096 You can keep a basic
3096 \family typewriter
3097 \family typewriter
3097 IPYTHONDIR/ipythonrc
3098 IPYTHONDIR/ipythonrc
3098 \family default
3099 \family default
3099 file and then have other 'profiles' which include this one and load extra
3100 file and then have other 'profiles' which include this one and load extra
3100 things for particular tasks.
3101 things for particular tasks.
3101 For example:
3102 For example:
3102 \layout List
3103 \layout List
3103 \labelwidthstring 00.00.0000
3104 \labelwidthstring 00.00.0000
3104
3105
3105
3106
3106 \family typewriter
3107 \family typewriter
3107 \SpecialChar ~
3108 \SpecialChar ~
3108
3109
3109 \family default
3110 \family default
3110 1.
3111 1.
3111
3112
3112 \family typewriter
3113 \family typewriter
3113 $HOME/.ipython/ipythonrc
3114 $HOME/.ipython/ipythonrc
3114 \family default
3115 \family default
3115 : load basic things you always want.
3116 : load basic things you always want.
3116 \layout List
3117 \layout List
3117 \labelwidthstring 00.00.0000
3118 \labelwidthstring 00.00.0000
3118
3119
3119
3120
3120 \family typewriter
3121 \family typewriter
3121 \SpecialChar ~
3122 \SpecialChar ~
3122
3123
3123 \family default
3124 \family default
3124 2.
3125 2.
3125
3126
3126 \family typewriter
3127 \family typewriter
3127 $HOME/.ipython/ipythonrc-math
3128 $HOME/.ipython/ipythonrc-math
3128 \family default
3129 \family default
3129 : load (1) and basic math-related modules.
3130 : load (1) and basic math-related modules.
3130
3131
3131 \layout List
3132 \layout List
3132 \labelwidthstring 00.00.0000
3133 \labelwidthstring 00.00.0000
3133
3134
3134
3135
3135 \family typewriter
3136 \family typewriter
3136 \SpecialChar ~
3137 \SpecialChar ~
3137
3138
3138 \family default
3139 \family default
3139 3.
3140 3.
3140
3141
3141 \family typewriter
3142 \family typewriter
3142 $HOME/.ipython/ipythonrc-numeric
3143 $HOME/.ipython/ipythonrc-numeric
3143 \family default
3144 \family default
3144 : load (1) and Numeric and plotting modules.
3145 : load (1) and Numeric and plotting modules.
3145 \layout List
3146 \layout List
3146 \labelwidthstring 00.00.0000
3147 \labelwidthstring 00.00.0000
3147
3148
3148 \SpecialChar ~
3149 \SpecialChar ~
3149 Since it is possible to create an endless loop by having circular file
3150 Since it is possible to create an endless loop by having circular file
3150 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3151 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3151 \layout List
3152 \layout List
3152 \labelwidthstring 00.00.0000
3153 \labelwidthstring 00.00.0000
3153
3154
3154
3155
3155 \family typewriter
3156 \family typewriter
3156 \series bold
3157 \series bold
3157 -prompt_in1|pi1\SpecialChar ~
3158 -prompt_in1|pi1\SpecialChar ~
3158 <string>:
3159 <string>:
3159 \family default
3160 \family default
3160 \series default
3161 \series default
3161 Specify the string used for input prompts.
3162 Specify the string used for input prompts.
3162 Note that if you are using numbered prompts, the number is represented
3163 Note that if you are using numbered prompts, the number is represented
3163 with a '
3164 with a '
3164 \backslash
3165 \backslash
3165 #' in the string.
3166 #' in the string.
3166 Don't forget to quote strings with spaces embedded in them.
3167 Don't forget to quote strings with spaces embedded in them.
3167 Default: '
3168 Default: '
3168 \family typewriter
3169 \family typewriter
3169 In\SpecialChar ~
3170 In\SpecialChar ~
3170 [
3171 [
3171 \backslash
3172 \backslash
3172 #]:
3173 #]:
3173 \family default
3174 \family default
3174 '.
3175 '.
3175 Sec.\SpecialChar ~
3176 Sec.\SpecialChar ~
3176
3177
3177 \begin_inset LatexCommand \ref{sec:prompts}
3178 \begin_inset LatexCommand \ref{sec:prompts}
3178
3179
3179 \end_inset
3180 \end_inset
3180
3181
3181 discusses in detail all the available escapes to customize your prompts.
3182 discusses in detail all the available escapes to customize your prompts.
3182 \layout List
3183 \layout List
3183 \labelwidthstring 00.00.0000
3184 \labelwidthstring 00.00.0000
3184
3185
3185
3186
3186 \family typewriter
3187 \family typewriter
3187 \series bold
3188 \series bold
3188 -prompt_in2|pi2\SpecialChar ~
3189 -prompt_in2|pi2\SpecialChar ~
3189 <string>:
3190 <string>:
3190 \family default
3191 \family default
3191 \series default
3192 \series default
3192 Similar to the previous option, but used for the continuation prompts.
3193 Similar to the previous option, but used for the continuation prompts.
3193 The special sequence '
3194 The special sequence '
3194 \family typewriter
3195 \family typewriter
3195
3196
3196 \backslash
3197 \backslash
3197 D
3198 D
3198 \family default
3199 \family default
3199 ' is similar to '
3200 ' is similar to '
3200 \family typewriter
3201 \family typewriter
3201
3202
3202 \backslash
3203 \backslash
3203 #
3204 #
3204 \family default
3205 \family default
3205 ', but with all digits replaced dots (so you can have your continuation
3206 ', but with all digits replaced dots (so you can have your continuation
3206 prompt aligned with your input prompt).
3207 prompt aligned with your input prompt).
3207 Default: '
3208 Default: '
3208 \family typewriter
3209 \family typewriter
3209 \SpecialChar ~
3210 \SpecialChar ~
3210 \SpecialChar ~
3211 \SpecialChar ~
3211 \SpecialChar ~
3212 \SpecialChar ~
3212 .
3213 .
3213 \backslash
3214 \backslash
3214 D.:
3215 D.:
3215 \family default
3216 \family default
3216 ' (note three spaces at the start for alignment with '
3217 ' (note three spaces at the start for alignment with '
3217 \family typewriter
3218 \family typewriter
3218 In\SpecialChar ~
3219 In\SpecialChar ~
3219 [
3220 [
3220 \backslash
3221 \backslash
3221 #]
3222 #]
3222 \family default
3223 \family default
3223 ').
3224 ').
3224 \layout List
3225 \layout List
3225 \labelwidthstring 00.00.0000
3226 \labelwidthstring 00.00.0000
3226
3227
3227
3228
3228 \family typewriter
3229 \family typewriter
3229 \series bold
3230 \series bold
3230 -prompt_out|po\SpecialChar ~
3231 -prompt_out|po\SpecialChar ~
3231 <string>:
3232 <string>:
3232 \family default
3233 \family default
3233 \series default
3234 \series default
3234 String used for output prompts, also uses numbers like
3235 String used for output prompts, also uses numbers like
3235 \family typewriter
3236 \family typewriter
3236 prompt_in1
3237 prompt_in1
3237 \family default
3238 \family default
3238 .
3239 .
3239 Default: '
3240 Default: '
3240 \family typewriter
3241 \family typewriter
3241 Out[
3242 Out[
3242 \backslash
3243 \backslash
3243 #]:
3244 #]:
3244 \family default
3245 \family default
3245 '
3246 '
3246 \layout List
3247 \layout List
3247 \labelwidthstring 00.00.0000
3248 \labelwidthstring 00.00.0000
3248
3249
3249
3250
3250 \family typewriter
3251 \family typewriter
3251 \series bold
3252 \series bold
3252 -quick
3253 -quick
3253 \family default
3254 \family default
3254 \series default
3255 \series default
3255 : start in bare bones mode (no config file loaded).
3256 : start in bare bones mode (no config file loaded).
3256 \layout List
3257 \layout List
3257 \labelwidthstring 00.00.0000
3258 \labelwidthstring 00.00.0000
3258
3259
3259
3260
3260 \family typewriter
3261 \family typewriter
3261 \series bold
3262 \series bold
3262 -rcfile\SpecialChar ~
3263 -rcfile\SpecialChar ~
3263 <name>
3264 <name>
3264 \series default
3265 \series default
3265 :
3266 :
3266 \family default
3267 \family default
3267 name of your IPython resource configuration file.
3268 name of your IPython resource configuration file.
3268 Normally IPython loads ipythonrc (from current directory) or
3269 Normally IPython loads ipythonrc (from current directory) or
3269 \family typewriter
3270 \family typewriter
3270 IPYTHONDIR/ipythonrc
3271 IPYTHONDIR/ipythonrc
3271 \family default
3272 \family default
3272 .
3273 .
3273 \layout List
3274 \layout List
3274 \labelwidthstring 00.00.0000
3275 \labelwidthstring 00.00.0000
3275
3276
3276 \SpecialChar ~
3277 \SpecialChar ~
3277 If the loading of your config file fails, IPython starts with a bare bones
3278 If the loading of your config file fails, IPython starts with a bare bones
3278 configuration (no modules loaded at all).
3279 configuration (no modules loaded at all).
3279 \layout List
3280 \layout List
3280 \labelwidthstring 00.00.0000
3281 \labelwidthstring 00.00.0000
3281
3282
3282
3283
3283 \family typewriter
3284 \family typewriter
3284 \series bold
3285 \series bold
3285 -[no]readline
3286 -[no]readline
3286 \family default
3287 \family default
3287 \series default
3288 \series default
3288 : use the readline library, which is needed to support name completion and
3289 : use the readline library, which is needed to support name completion and
3289 command history, among other things.
3290 command history, among other things.
3290 It is enabled by default, but may cause problems for users of X/Emacs in
3291 It is enabled by default, but may cause problems for users of X/Emacs in
3291 Python comint or shell buffers.
3292 Python comint or shell buffers.
3292 \layout List
3293 \layout List
3293 \labelwidthstring 00.00.0000
3294 \labelwidthstring 00.00.0000
3294
3295
3295 \SpecialChar ~
3296 \SpecialChar ~
3296 Note that X/Emacs 'eterm' buffers (opened with
3297 Note that X/Emacs 'eterm' buffers (opened with
3297 \family typewriter
3298 \family typewriter
3298 M-x\SpecialChar ~
3299 M-x\SpecialChar ~
3299 term
3300 term
3300 \family default
3301 \family default
3301 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3302 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3302 \family typewriter
3303 \family typewriter
3303 M-x\SpecialChar ~
3304 M-x\SpecialChar ~
3304 shell
3305 shell
3305 \family default
3306 \family default
3306 and
3307 and
3307 \family typewriter
3308 \family typewriter
3308 C-c\SpecialChar ~
3309 C-c\SpecialChar ~
3309 !
3310 !
3310 \family default
3311 \family default
3311 ) buffers do not.
3312 ) buffers do not.
3312 \layout List
3313 \layout List
3313 \labelwidthstring 00.00.0000
3314 \labelwidthstring 00.00.0000
3314
3315
3315
3316
3316 \family typewriter
3317 \family typewriter
3317 \series bold
3318 \series bold
3318 -screen_length|sl\SpecialChar ~
3319 -screen_length|sl\SpecialChar ~
3319 <n>
3320 <n>
3320 \series default
3321 \series default
3321 :
3322 :
3322 \family default
3323 \family default
3323 number of lines of your screen.
3324 number of lines of your screen.
3324 This is used to control printing of very long strings.
3325 This is used to control printing of very long strings.
3325 Strings longer than this number of lines will be sent through a pager instead
3326 Strings longer than this number of lines will be sent through a pager instead
3326 of directly printed.
3327 of directly printed.
3327 \layout List
3328 \layout List
3328 \labelwidthstring 00.00.0000
3329 \labelwidthstring 00.00.0000
3329
3330
3330 \SpecialChar ~
3331 \SpecialChar ~
3331 The default value for this is 0, which means IPython will auto-detect your
3332 The default value for this is 0, which means IPython will auto-detect your
3332 screen size every time it needs to print certain potentially long strings
3333 screen size every time it needs to print certain potentially long strings
3333 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3334 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3334 internally).
3335 internally).
3335 If for some reason this isn't working well (it needs curses support), specify
3336 If for some reason this isn't working well (it needs curses support), specify
3336 it yourself.
3337 it yourself.
3337 Otherwise don't change the default.
3338 Otherwise don't change the default.
3338 \layout List
3339 \layout List
3339 \labelwidthstring 00.00.0000
3340 \labelwidthstring 00.00.0000
3340
3341
3341
3342
3342 \family typewriter
3343 \family typewriter
3343 \series bold
3344 \series bold
3344 -separate_in|si\SpecialChar ~
3345 -separate_in|si\SpecialChar ~
3345 <string>
3346 <string>
3346 \series default
3347 \series default
3347 :
3348 :
3348 \family default
3349 \family default
3349 separator before input prompts.
3350 separator before input prompts.
3350 Default: '
3351 Default: '
3351 \family typewriter
3352 \family typewriter
3352
3353
3353 \backslash
3354 \backslash
3354 n
3355 n
3355 \family default
3356 \family default
3356 '
3357 '
3357 \layout List
3358 \layout List
3358 \labelwidthstring 00.00.0000
3359 \labelwidthstring 00.00.0000
3359
3360
3360
3361
3361 \family typewriter
3362 \family typewriter
3362 \series bold
3363 \series bold
3363 -separate_out|so\SpecialChar ~
3364 -separate_out|so\SpecialChar ~
3364 <string>
3365 <string>
3365 \family default
3366 \family default
3366 \series default
3367 \series default
3367 : separator before output prompts.
3368 : separator before output prompts.
3368 Default: nothing.
3369 Default: nothing.
3369 \layout List
3370 \layout List
3370 \labelwidthstring 00.00.0000
3371 \labelwidthstring 00.00.0000
3371
3372
3372
3373
3373 \family typewriter
3374 \family typewriter
3374 \series bold
3375 \series bold
3375 -separate_out2|so2\SpecialChar ~
3376 -separate_out2|so2\SpecialChar ~
3376 <string>
3377 <string>
3377 \series default
3378 \series default
3378 :
3379 :
3379 \family default
3380 \family default
3380 separator after output prompts.
3381 separator after output prompts.
3381 Default: nothing.
3382 Default: nothing.
3382 \layout List
3383 \layout List
3383 \labelwidthstring 00.00.0000
3384 \labelwidthstring 00.00.0000
3384
3385
3385 \SpecialChar ~
3386 \SpecialChar ~
3386 For these three options, use the value 0 to specify no separator.
3387 For these three options, use the value 0 to specify no separator.
3387 \layout List
3388 \layout List
3388 \labelwidthstring 00.00.0000
3389 \labelwidthstring 00.00.0000
3389
3390
3390
3391
3391 \family typewriter
3392 \family typewriter
3392 \series bold
3393 \series bold
3393 -nosep
3394 -nosep
3394 \series default
3395 \series default
3395 :
3396 :
3396 \family default
3397 \family default
3397 shorthand for
3398 shorthand for
3398 \family typewriter
3399 \family typewriter
3399 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3400 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3400 \family default
3401 \family default
3401 .
3402 .
3402 Simply removes all input/output separators.
3403 Simply removes all input/output separators.
3403 \layout List
3404 \layout List
3404 \labelwidthstring 00.00.0000
3405 \labelwidthstring 00.00.0000
3405
3406
3406
3407
3407 \family typewriter
3408 \family typewriter
3408 \series bold
3409 \series bold
3409 -upgrade
3410 -upgrade
3410 \family default
3411 \family default
3411 \series default
3412 \series default
3412 : allows you to upgrade your
3413 : allows you to upgrade your
3413 \family typewriter
3414 \family typewriter
3414 IPYTHONDIR
3415 IPYTHONDIR
3415 \family default
3416 \family default
3416 configuration when you install a new version of IPython.
3417 configuration when you install a new version of IPython.
3417 Since new versions may include new command line options or example files,
3418 Since new versions may include new command line options or example files,
3418 this copies updated ipythonrc-type files.
3419 this copies updated ipythonrc-type files.
3419 However, it backs up (with a
3420 However, it backs up (with a
3420 \family typewriter
3421 \family typewriter
3421 .old
3422 .old
3422 \family default
3423 \family default
3423 extension) all files which it overwrites so that you can merge back any
3424 extension) all files which it overwrites so that you can merge back any
3424 customizations you might have in your personal files.
3425 customizations you might have in your personal files.
3425 \layout List
3426 \layout List
3426 \labelwidthstring 00.00.0000
3427 \labelwidthstring 00.00.0000
3427
3428
3428
3429
3429 \family typewriter
3430 \family typewriter
3430 \series bold
3431 \series bold
3431 -Version
3432 -Version
3432 \series default
3433 \series default
3433 :
3434 :
3434 \family default
3435 \family default
3435 print version information and exit.
3436 print version information and exit.
3436 \layout List
3437 \layout List
3437 \labelwidthstring 00.00.0000
3438 \labelwidthstring 00.00.0000
3438
3439
3439
3440
3440 \family typewriter
3441 \family typewriter
3441 \series bold
3442 \series bold
3442 -xmode <modename>
3443 -xmode <modename>
3443 \series default
3444 \series default
3444 :
3445 :
3445 \family default
3446 \family default
3446 Mode for exception reporting.
3447 Mode for exception reporting.
3447 \layout List
3448 \layout List
3448 \labelwidthstring 00.00.0000
3449 \labelwidthstring 00.00.0000
3449
3450
3450 \SpecialChar ~
3451 \SpecialChar ~
3451 Valid modes: Plain, Context and Verbose.
3452 Valid modes: Plain, Context and Verbose.
3452 \layout List
3453 \layout List
3453 \labelwidthstring 00.00.0000
3454 \labelwidthstring 00.00.0000
3454
3455
3455 \SpecialChar ~
3456 \SpecialChar ~
3456 Plain: similar to python's normal traceback printing.
3457 Plain: similar to python's normal traceback printing.
3457 \layout List
3458 \layout List
3458 \labelwidthstring 00.00.0000
3459 \labelwidthstring 00.00.0000
3459
3460
3460 \SpecialChar ~
3461 \SpecialChar ~
3461 Context: prints 5 lines of context source code around each line in the
3462 Context: prints 5 lines of context source code around each line in the
3462 traceback.
3463 traceback.
3463 \layout List
3464 \layout List
3464 \labelwidthstring 00.00.0000
3465 \labelwidthstring 00.00.0000
3465
3466
3466 \SpecialChar ~
3467 \SpecialChar ~
3467 Verbose: similar to Context, but additionally prints the variables currently
3468 Verbose: similar to Context, but additionally prints the variables currently
3468 visible where the exception happened (shortening their strings if too long).
3469 visible where the exception happened (shortening their strings if too long).
3469 This can potentially be very slow, if you happen to have a huge data structure
3470 This can potentially be very slow, if you happen to have a huge data structure
3470 whose string representation is complex to compute.
3471 whose string representation is complex to compute.
3471 Your computer may appear to freeze for a while with cpu usage at 100%.
3472 Your computer may appear to freeze for a while with cpu usage at 100%.
3472 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3473 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3473 it more than once).
3474 it more than once).
3474 \layout Section
3475 \layout Section
3475
3476
3476 Interactive use
3477 Interactive use
3477 \layout Standard
3478 \layout Standard
3478
3479
3479
3480
3480 \series bold
3481 \series bold
3481 Warning
3482 Warning
3482 \series default
3483 \series default
3483 : IPython relies on the existence of a global variable called
3484 : IPython relies on the existence of a global variable called
3484 \family typewriter
3485 \family typewriter
3485 __IP
3486 __IP
3486 \family default
3487 \family default
3487 which controls the shell itself.
3488 which controls the shell itself.
3488 If you redefine
3489 If you redefine
3489 \family typewriter
3490 \family typewriter
3490 __IP
3491 __IP
3491 \family default
3492 \family default
3492 to anything, bizarre behavior will quickly occur.
3493 to anything, bizarre behavior will quickly occur.
3493 \layout Standard
3494 \layout Standard
3494
3495
3495 Other than the above warning, IPython is meant to work as a drop-in replacement
3496 Other than the above warning, IPython is meant to work as a drop-in replacement
3496 for the standard interactive interpreter.
3497 for the standard interactive interpreter.
3497 As such, any code which is valid python should execute normally under IPython
3498 As such, any code which is valid python should execute normally under IPython
3498 (cases where this is not true should be reported as bugs).
3499 (cases where this is not true should be reported as bugs).
3499 It does, however, offer many features which are not available at a standard
3500 It does, however, offer many features which are not available at a standard
3500 python prompt.
3501 python prompt.
3501 What follows is a list of these.
3502 What follows is a list of these.
3502 \layout Subsection
3503 \layout Subsection
3503
3504
3504 Caution for Windows users
3505 Caution for Windows users
3505 \layout Standard
3506 \layout Standard
3506
3507
3507 Windows, unfortunately, uses the `
3508 Windows, unfortunately, uses the `
3508 \family typewriter
3509 \family typewriter
3509
3510
3510 \backslash
3511 \backslash
3511
3512
3512 \family default
3513 \family default
3513 ' character as a path separator.
3514 ' character as a path separator.
3514 This is a terrible choice, because `
3515 This is a terrible choice, because `
3515 \family typewriter
3516 \family typewriter
3516
3517
3517 \backslash
3518 \backslash
3518
3519
3519 \family default
3520 \family default
3520 ' also represents the escape character in most modern programming languages,
3521 ' also represents the escape character in most modern programming languages,
3521 including Python.
3522 including Python.
3522 For this reason, issuing many of the commands discussed below (especially
3523 For this reason, issuing many of the commands discussed below (especially
3523 magics which affect the filesystem) with `
3524 magics which affect the filesystem) with `
3524 \family typewriter
3525 \family typewriter
3525
3526
3526 \backslash
3527 \backslash
3527
3528
3528 \family default
3529 \family default
3529 ' in them will cause strange errors.
3530 ' in them will cause strange errors.
3530 \layout Standard
3531 \layout Standard
3531
3532
3532 A partial solution is to use instead the `
3533 A partial solution is to use instead the `
3533 \family typewriter
3534 \family typewriter
3534 /
3535 /
3535 \family default
3536 \family default
3536 ' character as a path separator, which Windows recognizes in
3537 ' character as a path separator, which Windows recognizes in
3537 \emph on
3538 \emph on
3538 most
3539 most
3539 \emph default
3540 \emph default
3540 situations.
3541 situations.
3541 However, in Windows commands `
3542 However, in Windows commands `
3542 \family typewriter
3543 \family typewriter
3543 /
3544 /
3544 \family default
3545 \family default
3545 ' flags options, so you can not use it for the root directory.
3546 ' flags options, so you can not use it for the root directory.
3546 This means that paths beginning at the root must be typed in a contrived
3547 This means that paths beginning at the root must be typed in a contrived
3547 manner like:
3548 manner like:
3548 \newline
3549 \newline
3549
3550
3550 \family typewriter
3551 \family typewriter
3551 %copy
3552 %copy
3552 \backslash
3553 \backslash
3553 opt/foo/bar.txt
3554 opt/foo/bar.txt
3554 \backslash
3555 \backslash
3555 tmp
3556 tmp
3556 \layout Standard
3557 \layout Standard
3557
3558
3558 There is no sensible thing IPython can do to truly work around this flaw
3559 There is no sensible thing IPython can do to truly work around this flaw
3559 in Windows
3560 in Windows
3560 \begin_inset Foot
3561 \begin_inset Foot
3561 collapsed true
3562 collapsed true
3562
3563
3563 \layout Standard
3564 \layout Standard
3564
3565
3565 If anyone comes up with a
3566 If anyone comes up with a
3566 \emph on
3567 \emph on
3567 clean
3568 clean
3568 \emph default
3569 \emph default
3569 solution which works consistently and does not negatively impact other
3570 solution which works consistently and does not negatively impact other
3570 platforms at all, I'll gladly accept a patch.
3571 platforms at all, I'll gladly accept a patch.
3571 \end_inset
3572 \end_inset
3572
3573
3573 .
3574 .
3574 \layout Subsection
3575 \layout Subsection
3575
3576
3576
3577
3577 \begin_inset LatexCommand \label{sec:magic}
3578 \begin_inset LatexCommand \label{sec:magic}
3578
3579
3579 \end_inset
3580 \end_inset
3580
3581
3581 Magic command system
3582 Magic command system
3582 \layout Standard
3583 \layout Standard
3583
3584
3584 IPython will treat any line whose first character is a
3585 IPython will treat any line whose first character is a
3585 \family typewriter
3586 \family typewriter
3586 %
3587 %
3587 \family default
3588 \family default
3588 as a special call to a 'magic' function.
3589 as a special call to a 'magic' function.
3589 These allow you to control the behavior of IPython itself, plus a lot of
3590 These allow you to control the behavior of IPython itself, plus a lot of
3590 system-type features.
3591 system-type features.
3591 They are all prefixed with a
3592 They are all prefixed with a
3592 \family typewriter
3593 \family typewriter
3593 %
3594 %
3594 \family default
3595 \family default
3595 character, but parameters are given without parentheses or quotes.
3596 character, but parameters are given without parentheses or quotes.
3596 \layout Standard
3597 \layout Standard
3597
3598
3598 Example: typing
3599 Example: typing
3599 \family typewriter
3600 \family typewriter
3600 '%cd mydir'
3601 '%cd mydir'
3601 \family default
3602 \family default
3602 (without the quotes) changes you working directory to
3603 (without the quotes) changes you working directory to
3603 \family typewriter
3604 \family typewriter
3604 'mydir'
3605 'mydir'
3605 \family default
3606 \family default
3606 , if it exists.
3607 , if it exists.
3607 \layout Standard
3608 \layout Standard
3608
3609
3609 If you have 'automagic' enabled (in your
3610 If you have 'automagic' enabled (in your
3610 \family typewriter
3611 \family typewriter
3611 ipythonrc
3612 ipythonrc
3612 \family default
3613 \family default
3613 file, via the command line option
3614 file, via the command line option
3614 \family typewriter
3615 \family typewriter
3615 -automagic
3616 -automagic
3616 \family default
3617 \family default
3617 or with the
3618 or with the
3618 \family typewriter
3619 \family typewriter
3619 %automagic
3620 %automagic
3620 \family default
3621 \family default
3621 function), you don't need to type in the
3622 function), you don't need to type in the
3622 \family typewriter
3623 \family typewriter
3623 %
3624 %
3624 \family default
3625 \family default
3625 explicitly.
3626 explicitly.
3626 IPython will scan its internal list of magic functions and call one if
3627 IPython will scan its internal list of magic functions and call one if
3627 it exists.
3628 it exists.
3628 With automagic on you can then just type '
3629 With automagic on you can then just type '
3629 \family typewriter
3630 \family typewriter
3630 cd mydir
3631 cd mydir
3631 \family default
3632 \family default
3632 ' to go to directory '
3633 ' to go to directory '
3633 \family typewriter
3634 \family typewriter
3634 mydir
3635 mydir
3635 \family default
3636 \family default
3636 '.
3637 '.
3637 The automagic system has the lowest possible precedence in name searches,
3638 The automagic system has the lowest possible precedence in name searches,
3638 so defining an identifier with the same name as an existing magic function
3639 so defining an identifier with the same name as an existing magic function
3639 will shadow it for automagic use.
3640 will shadow it for automagic use.
3640 You can still access the shadowed magic function by explicitly using the
3641 You can still access the shadowed magic function by explicitly using the
3641
3642
3642 \family typewriter
3643 \family typewriter
3643 %
3644 %
3644 \family default
3645 \family default
3645 character at the beginning of the line.
3646 character at the beginning of the line.
3646 \layout Standard
3647 \layout Standard
3647
3648
3648 An example (with automagic on) should clarify all this:
3649 An example (with automagic on) should clarify all this:
3649 \layout LyX-Code
3650 \layout LyX-Code
3650
3651
3651 In [1]: cd ipython # %cd is called by automagic
3652 In [1]: cd ipython # %cd is called by automagic
3652 \layout LyX-Code
3653 \layout LyX-Code
3653
3654
3654 /home/fperez/ipython
3655 /home/fperez/ipython
3655 \layout LyX-Code
3656 \layout LyX-Code
3656
3657
3657 In [2]: cd=1 # now cd is just a variable
3658 In [2]: cd=1 # now cd is just a variable
3658 \layout LyX-Code
3659 \layout LyX-Code
3659
3660
3660 In [3]: cd ..
3661 In [3]: cd ..
3661 # and doesn't work as a function anymore
3662 # and doesn't work as a function anymore
3662 \layout LyX-Code
3663 \layout LyX-Code
3663
3664
3664 ------------------------------------------------------------
3665 ------------------------------------------------------------
3665 \layout LyX-Code
3666 \layout LyX-Code
3666
3667
3667 File "<console>", line 1
3668 File "<console>", line 1
3668 \layout LyX-Code
3669 \layout LyX-Code
3669
3670
3670 cd ..
3671 cd ..
3671 \layout LyX-Code
3672 \layout LyX-Code
3672
3673
3673 ^
3674 ^
3674 \layout LyX-Code
3675 \layout LyX-Code
3675
3676
3676 SyntaxError: invalid syntax
3677 SyntaxError: invalid syntax
3677 \layout LyX-Code
3678 \layout LyX-Code
3678
3679
3679 \layout LyX-Code
3680 \layout LyX-Code
3680
3681
3681 In [4]: %cd ..
3682 In [4]: %cd ..
3682 # but %cd always works
3683 # but %cd always works
3683 \layout LyX-Code
3684 \layout LyX-Code
3684
3685
3685 /home/fperez
3686 /home/fperez
3686 \layout LyX-Code
3687 \layout LyX-Code
3687
3688
3688 In [5]: del cd # if you remove the cd variable
3689 In [5]: del cd # if you remove the cd variable
3689 \layout LyX-Code
3690 \layout LyX-Code
3690
3691
3691 In [6]: cd ipython # automagic can work again
3692 In [6]: cd ipython # automagic can work again
3692 \layout LyX-Code
3693 \layout LyX-Code
3693
3694
3694 /home/fperez/ipython
3695 /home/fperez/ipython
3695 \layout Standard
3696 \layout Standard
3696
3697
3697 You can define your own magic functions to extend the system.
3698 You can define your own magic functions to extend the system.
3698 The following is a snippet of code which shows how to do it.
3699 The following is a snippet of code which shows how to do it.
3699 It is provided as file
3700 It is provided as file
3700 \family typewriter
3701 \family typewriter
3701 example-magic.py
3702 example-magic.py
3702 \family default
3703 \family default
3703 in the examples directory:
3704 in the examples directory:
3704 \layout Standard
3705 \layout Standard
3705
3706
3706
3707
3707 \begin_inset ERT
3708 \begin_inset ERT
3708 status Open
3709 status Open
3709
3710
3710 \layout Standard
3711 \layout Standard
3711
3712
3712 \backslash
3713 \backslash
3713 codelist{examples/example-magic.py}
3714 codelist{examples/example-magic.py}
3714 \end_inset
3715 \end_inset
3715
3716
3716
3717
3717 \layout Standard
3718 \layout Standard
3718
3719
3719 You can also define your own aliased names for magic functions.
3720 You can also define your own aliased names for magic functions.
3720 In your
3721 In your
3721 \family typewriter
3722 \family typewriter
3722 ipythonrc
3723 ipythonrc
3723 \family default
3724 \family default
3724 file, placing a line like:
3725 file, placing a line like:
3725 \layout Standard
3726 \layout Standard
3726
3727
3727
3728
3728 \family typewriter
3729 \family typewriter
3729 execute __IP.magic_cl = __IP.magic_clear
3730 execute __IP.magic_cl = __IP.magic_clear
3730 \layout Standard
3731 \layout Standard
3731
3732
3732 will define
3733 will define
3733 \family typewriter
3734 \family typewriter
3734 %cl
3735 %cl
3735 \family default
3736 \family default
3736 as a new name for
3737 as a new name for
3737 \family typewriter
3738 \family typewriter
3738 %clear
3739 %clear
3739 \family default
3740 \family default
3740 .
3741 .
3741 \layout Standard
3742 \layout Standard
3742
3743
3743 Type
3744 Type
3744 \family typewriter
3745 \family typewriter
3745 %magic
3746 %magic
3746 \family default
3747 \family default
3747 for more information, including a list of all available magic functions
3748 for more information, including a list of all available magic functions
3748 at any time and their docstrings.
3749 at any time and their docstrings.
3749 You can also type
3750 You can also type
3750 \family typewriter
3751 \family typewriter
3751 %magic_function_name?
3752 %magic_function_name?
3752 \family default
3753 \family default
3753 (see sec.
3754 (see sec.
3754
3755
3755 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3756 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3756
3757
3757 \end_inset
3758 \end_inset
3758
3759
3759 for information on the
3760 for information on the
3760 \family typewriter
3761 \family typewriter
3761 '?'
3762 '?'
3762 \family default
3763 \family default
3763 system) to get information about any particular magic function you are
3764 system) to get information about any particular magic function you are
3764 interested in.
3765 interested in.
3765 \layout Subsubsection
3766 \layout Subsubsection
3766
3767
3767 Magic commands
3768 Magic commands
3768 \layout Standard
3769 \layout Standard
3769
3770
3770 The rest of this section is automatically generated for each release from
3771 The rest of this section is automatically generated for each release from
3771 the docstrings in the IPython code.
3772 the docstrings in the IPython code.
3772 Therefore the formatting is somewhat minimal, but this method has the advantage
3773 Therefore the formatting is somewhat minimal, but this method has the advantage
3773 of having information always in sync with the code.
3774 of having information always in sync with the code.
3774 \layout Standard
3775 \layout Standard
3775
3776
3776 A list of all the magic commands available in IPython's
3777 A list of all the magic commands available in IPython's
3777 \emph on
3778 \emph on
3778 default
3779 default
3779 \emph default
3780 \emph default
3780 installation follows.
3781 installation follows.
3781 This is similar to what you'll see by simply typing
3782 This is similar to what you'll see by simply typing
3782 \family typewriter
3783 \family typewriter
3783 %magic
3784 %magic
3784 \family default
3785 \family default
3785 at the prompt, but that will also give you information about magic commands
3786 at the prompt, but that will also give you information about magic commands
3786 you may have added as part of your personal customizations.
3787 you may have added as part of your personal customizations.
3787 \layout Standard
3788 \layout Standard
3788
3789
3789
3790
3790 \begin_inset Include \input{magic.tex}
3791 \begin_inset Include \input{magic.tex}
3791 preview false
3792 preview false
3792
3793
3793 \end_inset
3794 \end_inset
3794
3795
3795
3796
3796 \layout Subsection
3797 \layout Subsection
3797
3798
3798 Access to the standard Python help
3799 Access to the standard Python help
3799 \layout Standard
3800 \layout Standard
3800
3801
3801 As of Python 2.1, a help system is available with access to object docstrings
3802 As of Python 2.1, a help system is available with access to object docstrings
3802 and the Python manuals.
3803 and the Python manuals.
3803 Simply type
3804 Simply type
3804 \family typewriter
3805 \family typewriter
3805 'help'
3806 'help'
3806 \family default
3807 \family default
3807 (no quotes) to access it.
3808 (no quotes) to access it.
3808 You can also type
3809 You can also type
3809 \family typewriter
3810 \family typewriter
3810 help(object)
3811 help(object)
3811 \family default
3812 \family default
3812 to obtain information about a given object, and
3813 to obtain information about a given object, and
3813 \family typewriter
3814 \family typewriter
3814 help('keyword')
3815 help('keyword')
3815 \family default
3816 \family default
3816 for information on a keyword.
3817 for information on a keyword.
3817 As noted in sec.
3818 As noted in sec.
3818
3819
3819 \begin_inset LatexCommand \ref{sec:help-access}
3820 \begin_inset LatexCommand \ref{sec:help-access}
3820
3821
3821 \end_inset
3822 \end_inset
3822
3823
3823 , you need to properly configure your environment variable
3824 , you need to properly configure your environment variable
3824 \family typewriter
3825 \family typewriter
3825 PYTHONDOCS
3826 PYTHONDOCS
3826 \family default
3827 \family default
3827 for this feature to work correctly.
3828 for this feature to work correctly.
3828 \layout Subsection
3829 \layout Subsection
3829
3830
3830
3831
3831 \begin_inset LatexCommand \label{sec:dyn-object-info}
3832 \begin_inset LatexCommand \label{sec:dyn-object-info}
3832
3833
3833 \end_inset
3834 \end_inset
3834
3835
3835 Dynamic object information
3836 Dynamic object information
3836 \layout Standard
3837 \layout Standard
3837
3838
3838 Typing
3839 Typing
3839 \family typewriter
3840 \family typewriter
3840 ?word
3841 ?word
3841 \family default
3842 \family default
3842 or
3843 or
3843 \family typewriter
3844 \family typewriter
3844 word?
3845 word?
3845 \family default
3846 \family default
3846 prints detailed information about an object.
3847 prints detailed information about an object.
3847 If certain strings in the object are too long (docstrings, code, etc.) they
3848 If certain strings in the object are too long (docstrings, code, etc.) they
3848 get snipped in the center for brevity.
3849 get snipped in the center for brevity.
3849 This system gives access variable types and values, full source code for
3850 This system gives access variable types and values, full source code for
3850 any object (if available), function prototypes and other useful information.
3851 any object (if available), function prototypes and other useful information.
3851 \layout Standard
3852 \layout Standard
3852
3853
3853 Typing
3854 Typing
3854 \family typewriter
3855 \family typewriter
3855 ??word
3856 ??word
3856 \family default
3857 \family default
3857 or
3858 or
3858 \family typewriter
3859 \family typewriter
3859 word??
3860 word??
3860 \family default
3861 \family default
3861 gives access to the full information without snipping long strings.
3862 gives access to the full information without snipping long strings.
3862 Long strings are sent to the screen through the
3863 Long strings are sent to the screen through the
3863 \family typewriter
3864 \family typewriter
3864 less
3865 less
3865 \family default
3866 \family default
3866 pager if longer than the screen and printed otherwise.
3867 pager if longer than the screen and printed otherwise.
3867 On systems lacking the
3868 On systems lacking the
3868 \family typewriter
3869 \family typewriter
3869 less
3870 less
3870 \family default
3871 \family default
3871 command, IPython uses a very basic internal pager.
3872 command, IPython uses a very basic internal pager.
3872 \layout Standard
3873 \layout Standard
3873
3874
3874 The following magic functions are particularly useful for gathering information
3875 The following magic functions are particularly useful for gathering information
3875 about your working environment.
3876 about your working environment.
3876 You can get more details by typing
3877 You can get more details by typing
3877 \family typewriter
3878 \family typewriter
3878 %magic
3879 %magic
3879 \family default
3880 \family default
3880 or querying them individually (use
3881 or querying them individually (use
3881 \family typewriter
3882 \family typewriter
3882 %function_name?
3883 %function_name?
3883 \family default
3884 \family default
3884 with or without the
3885 with or without the
3885 \family typewriter
3886 \family typewriter
3886 %
3887 %
3887 \family default
3888 \family default
3888 ), this is just a summary:
3889 ), this is just a summary:
3889 \layout List
3890 \layout List
3890 \labelwidthstring 00.00.0000
3891 \labelwidthstring 00.00.0000
3891
3892
3892
3893
3893 \family typewriter
3894 \family typewriter
3894 \series bold
3895 \series bold
3895 %pdoc\SpecialChar ~
3896 %pdoc\SpecialChar ~
3896 <object>
3897 <object>
3897 \family default
3898 \family default
3898 \series default
3899 \series default
3899 : Print (or run through a pager if too long) the docstring for an object.
3900 : Print (or run through a pager if too long) the docstring for an object.
3900 If the given object is a class, it will print both the class and the constructo
3901 If the given object is a class, it will print both the class and the constructo
3901 r docstrings.
3902 r docstrings.
3902 \layout List
3903 \layout List
3903 \labelwidthstring 00.00.0000
3904 \labelwidthstring 00.00.0000
3904
3905
3905
3906
3906 \family typewriter
3907 \family typewriter
3907 \series bold
3908 \series bold
3908 %pdef\SpecialChar ~
3909 %pdef\SpecialChar ~
3909 <object>
3910 <object>
3910 \family default
3911 \family default
3911 \series default
3912 \series default
3912 : Print the definition header for any callable object.
3913 : Print the definition header for any callable object.
3913 If the object is a class, print the constructor information.
3914 If the object is a class, print the constructor information.
3914 \layout List
3915 \layout List
3915 \labelwidthstring 00.00.0000
3916 \labelwidthstring 00.00.0000
3916
3917
3917
3918
3918 \family typewriter
3919 \family typewriter
3919 \series bold
3920 \series bold
3920 %psource\SpecialChar ~
3921 %psource\SpecialChar ~
3921 <object>
3922 <object>
3922 \family default
3923 \family default
3923 \series default
3924 \series default
3924 : Print (or run through a pager if too long) the source code for an object.
3925 : Print (or run through a pager if too long) the source code for an object.
3925 \layout List
3926 \layout List
3926 \labelwidthstring 00.00.0000
3927 \labelwidthstring 00.00.0000
3927
3928
3928
3929
3929 \family typewriter
3930 \family typewriter
3930 \series bold
3931 \series bold
3931 %pfile\SpecialChar ~
3932 %pfile\SpecialChar ~
3932 <object>
3933 <object>
3933 \family default
3934 \family default
3934 \series default
3935 \series default
3935 : Show the entire source file where an object was defined via a pager, opening
3936 : Show the entire source file where an object was defined via a pager, opening
3936 it at the line where the object definition begins.
3937 it at the line where the object definition begins.
3937 \layout List
3938 \layout List
3938 \labelwidthstring 00.00.0000
3939 \labelwidthstring 00.00.0000
3939
3940
3940
3941
3941 \family typewriter
3942 \family typewriter
3942 \series bold
3943 \series bold
3943 %who/%whos
3944 %who/%whos
3944 \family default
3945 \family default
3945 \series default
3946 \series default
3946 : These functions give information about identifiers you have defined interactiv
3947 : These functions give information about identifiers you have defined interactiv
3947 ely (not things you loaded or defined in your configuration files).
3948 ely (not things you loaded or defined in your configuration files).
3948
3949
3949 \family typewriter
3950 \family typewriter
3950 %who
3951 %who
3951 \family default
3952 \family default
3952 just prints a list of identifiers and
3953 just prints a list of identifiers and
3953 \family typewriter
3954 \family typewriter
3954 %whos
3955 %whos
3955 \family default
3956 \family default
3956 prints a table with some basic details about each identifier.
3957 prints a table with some basic details about each identifier.
3957 \layout Standard
3958 \layout Standard
3958
3959
3959 Note that the dynamic object information functions (
3960 Note that the dynamic object information functions (
3960 \family typewriter
3961 \family typewriter
3961 ?/??, %pdoc, %pfile, %pdef, %psource
3962 ?/??, %pdoc, %pfile, %pdef, %psource
3962 \family default
3963 \family default
3963 ) give you access to documentation even on things which are not really defined
3964 ) give you access to documentation even on things which are not really defined
3964 as separate identifiers.
3965 as separate identifiers.
3965 Try for example typing
3966 Try for example typing
3966 \family typewriter
3967 \family typewriter
3967 {}.get?
3968 {}.get?
3968 \family default
3969 \family default
3969 or after doing
3970 or after doing
3970 \family typewriter
3971 \family typewriter
3971 import os
3972 import os
3972 \family default
3973 \family default
3973 , type
3974 , type
3974 \family typewriter
3975 \family typewriter
3975 os.path.abspath??
3976 os.path.abspath??
3976 \family default
3977 \family default
3977 .
3978 .
3978 \layout Subsection
3979 \layout Subsection
3979
3980
3980
3981
3981 \begin_inset LatexCommand \label{sec:readline}
3982 \begin_inset LatexCommand \label{sec:readline}
3982
3983
3983 \end_inset
3984 \end_inset
3984
3985
3985 Readline-based features
3986 Readline-based features
3986 \layout Standard
3987 \layout Standard
3987
3988
3988 These features require the GNU readline library, so they won't work if your
3989 These features require the GNU readline library, so they won't work if your
3989 Python installation lacks readline support.
3990 Python installation lacks readline support.
3990 We will first describe the default behavior IPython uses, and then how
3991 We will first describe the default behavior IPython uses, and then how
3991 to change it to suit your preferences.
3992 to change it to suit your preferences.
3992 \layout Subsubsection
3993 \layout Subsubsection
3993
3994
3994 Command line completion
3995 Command line completion
3995 \layout Standard
3996 \layout Standard
3996
3997
3997 At any time, hitting TAB will complete any available python commands or
3998 At any time, hitting TAB will complete any available python commands or
3998 variable names, and show you a list of the possible completions if there's
3999 variable names, and show you a list of the possible completions if there's
3999 no unambiguous one.
4000 no unambiguous one.
4000 It will also complete filenames in the current directory if no python names
4001 It will also complete filenames in the current directory if no python names
4001 match what you've typed so far.
4002 match what you've typed so far.
4002 \layout Subsubsection
4003 \layout Subsubsection
4003
4004
4004 Search command history
4005 Search command history
4005 \layout Standard
4006 \layout Standard
4006
4007
4007 IPython provides two ways for searching through previous input and thus
4008 IPython provides two ways for searching through previous input and thus
4008 reduce the need for repetitive typing:
4009 reduce the need for repetitive typing:
4009 \layout Enumerate
4010 \layout Enumerate
4010
4011
4011 Start typing, and then use
4012 Start typing, and then use
4012 \family typewriter
4013 \family typewriter
4013 Ctrl-p
4014 Ctrl-p
4014 \family default
4015 \family default
4015 (previous,up) and
4016 (previous,up) and
4016 \family typewriter
4017 \family typewriter
4017 Ctrl-n
4018 Ctrl-n
4018 \family default
4019 \family default
4019 (next,down) to search through only the history items that match what you've
4020 (next,down) to search through only the history items that match what you've
4020 typed so far.
4021 typed so far.
4021 If you use
4022 If you use
4022 \family typewriter
4023 \family typewriter
4023 Ctrl-p/Ctrl-n
4024 Ctrl-p/Ctrl-n
4024 \family default
4025 \family default
4025 at a blank prompt, they just behave like normal arrow keys.
4026 at a blank prompt, they just behave like normal arrow keys.
4026 \layout Enumerate
4027 \layout Enumerate
4027
4028
4028 Hit
4029 Hit
4029 \family typewriter
4030 \family typewriter
4030 Ctrl-r
4031 Ctrl-r
4031 \family default
4032 \family default
4032 : opens a search prompt.
4033 : opens a search prompt.
4033 Begin typing and the system searches your history for lines that contain
4034 Begin typing and the system searches your history for lines that contain
4034 what you've typed so far, completing as much as it can.
4035 what you've typed so far, completing as much as it can.
4035 \layout Subsubsection
4036 \layout Subsubsection
4036
4037
4037 Persistent command history across sessions
4038 Persistent command history across sessions
4038 \layout Standard
4039 \layout Standard
4039
4040
4040 IPython will save your input history when it leaves and reload it next time
4041 IPython will save your input history when it leaves and reload it next time
4041 you restart it.
4042 you restart it.
4042 By default, the history file is named
4043 By default, the history file is named
4043 \family typewriter
4044 \family typewriter
4044 $IPYTHONDIR/history
4045 $IPYTHONDIR/history
4045 \family default
4046 \family default
4046 , but if you've loaded a named profile, '
4047 , but if you've loaded a named profile, '
4047 \family typewriter
4048 \family typewriter
4048 -PROFILE_NAME
4049 -PROFILE_NAME
4049 \family default
4050 \family default
4050 ' is appended to the name.
4051 ' is appended to the name.
4051 This allows you to keep separate histories related to various tasks: commands
4052 This allows you to keep separate histories related to various tasks: commands
4052 related to numerical work will not be clobbered by a system shell history,
4053 related to numerical work will not be clobbered by a system shell history,
4053 for example.
4054 for example.
4054 \layout Subsubsection
4055 \layout Subsubsection
4055
4056
4056 Autoindent
4057 Autoindent
4057 \layout Standard
4058 \layout Standard
4058
4059
4059 IPython can recognize lines ending in ':' and indent the next line, while
4060 IPython can recognize lines ending in ':' and indent the next line, while
4060 also un-indenting automatically after 'raise' or 'return'.
4061 also un-indenting automatically after 'raise' or 'return'.
4061
4062
4062 \layout Standard
4063 \layout Standard
4063
4064
4064 This feature uses the readline library, so it will honor your
4065 This feature uses the readline library, so it will honor your
4065 \family typewriter
4066 \family typewriter
4066 ~/.inputrc
4067 ~/.inputrc
4067 \family default
4068 \family default
4068 configuration (or whatever file your
4069 configuration (or whatever file your
4069 \family typewriter
4070 \family typewriter
4070 INPUTRC
4071 INPUTRC
4071 \family default
4072 \family default
4072 variable points to).
4073 variable points to).
4073 Adding the following lines to your
4074 Adding the following lines to your
4074 \family typewriter
4075 \family typewriter
4075 .inputrc
4076 .inputrc
4076 \family default
4077 \family default
4077 file can make indenting/unindenting more convenient (
4078 file can make indenting/unindenting more convenient (
4078 \family typewriter
4079 \family typewriter
4079 M-i
4080 M-i
4080 \family default
4081 \family default
4081 indents,
4082 indents,
4082 \family typewriter
4083 \family typewriter
4083 M-u
4084 M-u
4084 \family default
4085 \family default
4085 unindents):
4086 unindents):
4086 \layout Standard
4087 \layout Standard
4087
4088
4088
4089
4089 \family typewriter
4090 \family typewriter
4090 $if Python
4091 $if Python
4091 \newline
4092 \newline
4092 "
4093 "
4093 \backslash
4094 \backslash
4094 M-i": "\SpecialChar ~
4095 M-i": "\SpecialChar ~
4095 \SpecialChar ~
4096 \SpecialChar ~
4096 \SpecialChar ~
4097 \SpecialChar ~
4097 \SpecialChar ~
4098 \SpecialChar ~
4098 "
4099 "
4099 \newline
4100 \newline
4100 "
4101 "
4101 \backslash
4102 \backslash
4102 M-u": "
4103 M-u": "
4103 \backslash
4104 \backslash
4104 d
4105 d
4105 \backslash
4106 \backslash
4106 d
4107 d
4107 \backslash
4108 \backslash
4108 d
4109 d
4109 \backslash
4110 \backslash
4110 d"
4111 d"
4111 \newline
4112 \newline
4112 $endif
4113 $endif
4113 \layout Standard
4114 \layout Standard
4114
4115
4115 Note that there are 4 spaces between the quote marks after
4116 Note that there are 4 spaces between the quote marks after
4116 \family typewriter
4117 \family typewriter
4117 "M-i"
4118 "M-i"
4118 \family default
4119 \family default
4119 above.
4120 above.
4120 \layout Standard
4121 \layout Standard
4121
4122
4122
4123
4123 \series bold
4124 \series bold
4124 Warning:
4125 Warning:
4125 \series default
4126 \series default
4126 this feature is ON by default, but it can cause problems with the pasting
4127 this feature is ON by default, but it can cause problems with the pasting
4127 of multi-line indented code (the pasted code gets re-indented on each line).
4128 of multi-line indented code (the pasted code gets re-indented on each line).
4128 A magic function
4129 A magic function
4129 \family typewriter
4130 \family typewriter
4130 %autoindent
4131 %autoindent
4131 \family default
4132 \family default
4132 allows you to toggle it on/off at runtime.
4133 allows you to toggle it on/off at runtime.
4133 You can also disable it permanently on in your
4134 You can also disable it permanently on in your
4134 \family typewriter
4135 \family typewriter
4135 ipythonrc
4136 ipythonrc
4136 \family default
4137 \family default
4137 file (set
4138 file (set
4138 \family typewriter
4139 \family typewriter
4139 autoindent 0
4140 autoindent 0
4140 \family default
4141 \family default
4141 ).
4142 ).
4142 \layout Subsubsection
4143 \layout Subsubsection
4143
4144
4144 Customizing readline behavior
4145 Customizing readline behavior
4145 \layout Standard
4146 \layout Standard
4146
4147
4147 All these features are based on the GNU readline library, which has an extremely
4148 All these features are based on the GNU readline library, which has an extremely
4148 customizable interface.
4149 customizable interface.
4149 Normally, readline is configured via a file which defines the behavior
4150 Normally, readline is configured via a file which defines the behavior
4150 of the library; the details of the syntax for this can be found in the
4151 of the library; the details of the syntax for this can be found in the
4151 readline documentation available with your system or on the Internet.
4152 readline documentation available with your system or on the Internet.
4152 IPython doesn't read this file (if it exists) directly, but it does support
4153 IPython doesn't read this file (if it exists) directly, but it does support
4153 passing to readline valid options via a simple interface.
4154 passing to readline valid options via a simple interface.
4154 In brief, you can customize readline by setting the following options in
4155 In brief, you can customize readline by setting the following options in
4155 your
4156 your
4156 \family typewriter
4157 \family typewriter
4157 ipythonrc
4158 ipythonrc
4158 \family default
4159 \family default
4159 configuration file (note that these options can
4160 configuration file (note that these options can
4160 \emph on
4161 \emph on
4161 not
4162 not
4162 \emph default
4163 \emph default
4163 be specified at the command line):
4164 be specified at the command line):
4164 \layout List
4165 \layout List
4165 \labelwidthstring 00.00.0000
4166 \labelwidthstring 00.00.0000
4166
4167
4167
4168
4168 \family typewriter
4169 \family typewriter
4169 \series bold
4170 \series bold
4170 readline_parse_and_bind:
4171 readline_parse_and_bind:
4171 \family default
4172 \family default
4172 \series default
4173 \series default
4173 this option can appear as many times as you want, each time defining a
4174 this option can appear as many times as you want, each time defining a
4174 string to be executed via a
4175 string to be executed via a
4175 \family typewriter
4176 \family typewriter
4176 readline.parse_and_bind()
4177 readline.parse_and_bind()
4177 \family default
4178 \family default
4178 command.
4179 command.
4179 The syntax for valid commands of this kind can be found by reading the
4180 The syntax for valid commands of this kind can be found by reading the
4180 documentation for the GNU readline library, as these commands are of the
4181 documentation for the GNU readline library, as these commands are of the
4181 kind which readline accepts in its configuration file.
4182 kind which readline accepts in its configuration file.
4182 \layout List
4183 \layout List
4183 \labelwidthstring 00.00.0000
4184 \labelwidthstring 00.00.0000
4184
4185
4185
4186
4186 \family typewriter
4187 \family typewriter
4187 \series bold
4188 \series bold
4188 readline_remove_delims:
4189 readline_remove_delims:
4189 \family default
4190 \family default
4190 \series default
4191 \series default
4191 a string of characters to be removed from the default word-delimiters list
4192 a string of characters to be removed from the default word-delimiters list
4192 used by readline, so that completions may be performed on strings which
4193 used by readline, so that completions may be performed on strings which
4193 contain them.
4194 contain them.
4194 Do not change the default value unless you know what you're doing.
4195 Do not change the default value unless you know what you're doing.
4195 \layout List
4196 \layout List
4196 \labelwidthstring 00.00.0000
4197 \labelwidthstring 00.00.0000
4197
4198
4198
4199
4199 \family typewriter
4200 \family typewriter
4200 \series bold
4201 \series bold
4201 readline_omit__names
4202 readline_omit__names
4202 \family default
4203 \family default
4203 \series default
4204 \series default
4204 : when tab-completion is enabled, hitting
4205 : when tab-completion is enabled, hitting
4205 \family typewriter
4206 \family typewriter
4206 <tab>
4207 <tab>
4207 \family default
4208 \family default
4208 after a '
4209 after a '
4209 \family typewriter
4210 \family typewriter
4210 .
4211 .
4211 \family default
4212 \family default
4212 ' in a name will complete all attributes of an object, including all the
4213 ' in a name will complete all attributes of an object, including all the
4213 special methods whose names include double underscores (like
4214 special methods whose names include double underscores (like
4214 \family typewriter
4215 \family typewriter
4215 __getitem__
4216 __getitem__
4216 \family default
4217 \family default
4217 or
4218 or
4218 \family typewriter
4219 \family typewriter
4219 __class__
4220 __class__
4220 \family default
4221 \family default
4221 ).
4222 ).
4222 If you'd rather not see these names by default, you can set this option
4223 If you'd rather not see these names by default, you can set this option
4223 to 1.
4224 to 1.
4224 Note that even when this option is set, you can still see those names by
4225 Note that even when this option is set, you can still see those names by
4225 explicitly typing a
4226 explicitly typing a
4226 \family typewriter
4227 \family typewriter
4227 _
4228 _
4228 \family default
4229 \family default
4229 after the period and hitting
4230 after the period and hitting
4230 \family typewriter
4231 \family typewriter
4231 <tab>
4232 <tab>
4232 \family default
4233 \family default
4233 : '
4234 : '
4234 \family typewriter
4235 \family typewriter
4235 name._<tab>
4236 name._<tab>
4236 \family default
4237 \family default
4237 ' will always complete attribute names starting with '
4238 ' will always complete attribute names starting with '
4238 \family typewriter
4239 \family typewriter
4239 _
4240 _
4240 \family default
4241 \family default
4241 '.
4242 '.
4242 \layout List
4243 \layout List
4243 \labelwidthstring 00.00.0000
4244 \labelwidthstring 00.00.0000
4244
4245
4245 \SpecialChar ~
4246 \SpecialChar ~
4246 This option is off by default so that new users see all attributes of any
4247 This option is off by default so that new users see all attributes of any
4247 objects they are dealing with.
4248 objects they are dealing with.
4248 \layout Standard
4249 \layout Standard
4249
4250
4250 You will find the default values along with a corresponding detailed explanation
4251 You will find the default values along with a corresponding detailed explanation
4251 in your
4252 in your
4252 \family typewriter
4253 \family typewriter
4253 ipythonrc
4254 ipythonrc
4254 \family default
4255 \family default
4255 file.
4256 file.
4256 \layout Subsection
4257 \layout Subsection
4257
4258
4258 Session logging and restoring
4259 Session logging and restoring
4259 \layout Standard
4260 \layout Standard
4260
4261
4261 You can log all input from a session either by starting IPython with the
4262 You can log all input from a session either by starting IPython with the
4262 command line switches
4263 command line switches
4263 \family typewriter
4264 \family typewriter
4264 -log
4265 -log
4265 \family default
4266 \family default
4266 or
4267 or
4267 \family typewriter
4268 \family typewriter
4268 -logfile
4269 -logfile
4269 \family default
4270 \family default
4270 (see sec.
4271 (see sec.
4271
4272
4272 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4273 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4273
4274
4274 \end_inset
4275 \end_inset
4275
4276
4276 )or by activating the logging at any moment with the magic function
4277 )or by activating the logging at any moment with the magic function
4277 \family typewriter
4278 \family typewriter
4278 %logstart
4279 %logstart
4279 \family default
4280 \family default
4280 .
4281 .
4281
4282
4282 \layout Standard
4283 \layout Standard
4283
4284
4284 Log files can later be reloaded with the
4285 Log files can later be reloaded with the
4285 \family typewriter
4286 \family typewriter
4286 -logplay
4287 -logplay
4287 \family default
4288 \family default
4288 option and IPython will attempt to 'replay' the log by executing all the
4289 option and IPython will attempt to 'replay' the log by executing all the
4289 lines in it, thus restoring the state of a previous session.
4290 lines in it, thus restoring the state of a previous session.
4290 This feature is not quite perfect, but can still be useful in many cases.
4291 This feature is not quite perfect, but can still be useful in many cases.
4291 \layout Standard
4292 \layout Standard
4292
4293
4293 The log files can also be used as a way to have a permanent record of any
4294 The log files can also be used as a way to have a permanent record of any
4294 code you wrote while experimenting.
4295 code you wrote while experimenting.
4295 Log files are regular text files which you can later open in your favorite
4296 Log files are regular text files which you can later open in your favorite
4296 text editor to extract code or to 'clean them up' before using them to
4297 text editor to extract code or to 'clean them up' before using them to
4297 replay a session.
4298 replay a session.
4298 \layout Standard
4299 \layout Standard
4299
4300
4300 The
4301 The
4301 \family typewriter
4302 \family typewriter
4302 %logstart
4303 %logstart
4303 \family default
4304 \family default
4304 function for activating logging in mid-session is used as follows:
4305 function for activating logging in mid-session is used as follows:
4305 \layout Standard
4306 \layout Standard
4306
4307
4307
4308
4308 \family typewriter
4309 \family typewriter
4309 %logstart [log_name [log_mode]]
4310 %logstart [log_name [log_mode]]
4310 \layout Standard
4311 \layout Standard
4311
4312
4312 If no name is given, it defaults to a file named
4313 If no name is given, it defaults to a file named
4313 \family typewriter
4314 \family typewriter
4314 'log'
4315 'log'
4315 \family default
4316 \family default
4316 in your IPYTHONDIR directory, in
4317 in your IPYTHONDIR directory, in
4317 \family typewriter
4318 \family typewriter
4318 'rotate'
4319 'rotate'
4319 \family default
4320 \family default
4320 mode (see below).
4321 mode (see below).
4321 \layout Standard
4322 \layout Standard
4322
4323
4323 '
4324 '
4324 \family typewriter
4325 \family typewriter
4325 %logstart name
4326 %logstart name
4326 \family default
4327 \family default
4327 ' saves to file
4328 ' saves to file
4328 \family typewriter
4329 \family typewriter
4329 'name'
4330 'name'
4330 \family default
4331 \family default
4331 in
4332 in
4332 \family typewriter
4333 \family typewriter
4333 'backup'
4334 'backup'
4334 \family default
4335 \family default
4335 mode.
4336 mode.
4336 It saves your history up to that point and then continues logging.
4337 It saves your history up to that point and then continues logging.
4337 \layout Standard
4338 \layout Standard
4338
4339
4339
4340
4340 \family typewriter
4341 \family typewriter
4341 %logstart
4342 %logstart
4342 \family default
4343 \family default
4343 takes a second optional parameter: logging mode.
4344 takes a second optional parameter: logging mode.
4344 This can be one of (note that the modes are given unquoted):
4345 This can be one of (note that the modes are given unquoted):
4345 \layout List
4346 \layout List
4346 \labelwidthstring 00.00.0000
4347 \labelwidthstring 00.00.0000
4347
4348
4348
4349
4349 \family typewriter
4350 \family typewriter
4350 over
4351 over
4351 \family default
4352 \family default
4352 : overwrite existing
4353 : overwrite existing
4353 \family typewriter
4354 \family typewriter
4354 log_name
4355 log_name
4355 \family default
4356 \family default
4356 .
4357 .
4357 \layout List
4358 \layout List
4358 \labelwidthstring 00.00.0000
4359 \labelwidthstring 00.00.0000
4359
4360
4360
4361
4361 \family typewriter
4362 \family typewriter
4362 backup
4363 backup
4363 \family default
4364 \family default
4364 : rename (if exists) to
4365 : rename (if exists) to
4365 \family typewriter
4366 \family typewriter
4366 log_name~
4367 log_name~
4367 \family default
4368 \family default
4368 and start
4369 and start
4369 \family typewriter
4370 \family typewriter
4370 log_name
4371 log_name
4371 \family default
4372 \family default
4372 .
4373 .
4373 \layout List
4374 \layout List
4374 \labelwidthstring 00.00.0000
4375 \labelwidthstring 00.00.0000
4375
4376
4376
4377
4377 \family typewriter
4378 \family typewriter
4378 append
4379 append
4379 \family default
4380 \family default
4380 : well, that says it.
4381 : well, that says it.
4381 \layout List
4382 \layout List
4382 \labelwidthstring 00.00.0000
4383 \labelwidthstring 00.00.0000
4383
4384
4384
4385
4385 \family typewriter
4386 \family typewriter
4386 rotate
4387 rotate
4387 \family default
4388 \family default
4388 : create rotating logs
4389 : create rotating logs
4389 \family typewriter
4390 \family typewriter
4390 log_name
4391 log_name
4391 \family default
4392 \family default
4392 .
4393 .
4393 \family typewriter
4394 \family typewriter
4394 1~
4395 1~
4395 \family default
4396 \family default
4396 ,
4397 ,
4397 \family typewriter
4398 \family typewriter
4398 log_name.2~
4399 log_name.2~
4399 \family default
4400 \family default
4400 , etc.
4401 , etc.
4401 \layout Standard
4402 \layout Standard
4402
4403
4403 The
4404 The
4404 \family typewriter
4405 \family typewriter
4405 %logoff
4406 %logoff
4406 \family default
4407 \family default
4407 and
4408 and
4408 \family typewriter
4409 \family typewriter
4409 %logon
4410 %logon
4410 \family default
4411 \family default
4411 functions allow you to temporarily stop and resume logging to a file which
4412 functions allow you to temporarily stop and resume logging to a file which
4412 had previously been started with
4413 had previously been started with
4413 \family typewriter
4414 \family typewriter
4414 %logstart
4415 %logstart
4415 \family default
4416 \family default
4416 .
4417 .
4417 They will fail (with an explanation) if you try to use them before logging
4418 They will fail (with an explanation) if you try to use them before logging
4418 has been started.
4419 has been started.
4419 \layout Subsection
4420 \layout Subsection
4420
4421
4421
4422
4422 \begin_inset LatexCommand \label{sub:System-shell-access}
4423 \begin_inset LatexCommand \label{sub:System-shell-access}
4423
4424
4424 \end_inset
4425 \end_inset
4425
4426
4426 System shell access
4427 System shell access
4427 \layout Standard
4428 \layout Standard
4428
4429
4429 Any input line beginning with a
4430 Any input line beginning with a
4430 \family typewriter
4431 \family typewriter
4431 !
4432 !
4432 \family default
4433 \family default
4433 character is passed verbatim (minus the
4434 character is passed verbatim (minus the
4434 \family typewriter
4435 \family typewriter
4435 !
4436 !
4436 \family default
4437 \family default
4437 , of course) to the underlying operating system.
4438 , of course) to the underlying operating system.
4438 For example, typing
4439 For example, typing
4439 \family typewriter
4440 \family typewriter
4440 !ls
4441 !ls
4441 \family default
4442 \family default
4442 will run
4443 will run
4443 \family typewriter
4444 \family typewriter
4444 'ls'
4445 'ls'
4445 \family default
4446 \family default
4446 in the current directory.
4447 in the current directory.
4447 \layout Subsubsection
4448 \layout Subsubsection
4448
4449
4449 Manual capture of command output
4450 Manual capture of command output
4450 \layout Standard
4451 \layout Standard
4451
4452
4452 If the input line begins with
4453 If the input line begins with
4453 \emph on
4454 \emph on
4454 two
4455 two
4455 \emph default
4456 \emph default
4456 exclamation marks,
4457 exclamation marks,
4457 \family typewriter
4458 \family typewriter
4458 !!
4459 !!
4459 \family default
4460 \family default
4460 , the command is executed but its output is captured and returned as a python
4461 , the command is executed but its output is captured and returned as a python
4461 list, split on newlines.
4462 list, split on newlines.
4462 Any output sent by the subprocess to standard error is printed separately,
4463 Any output sent by the subprocess to standard error is printed separately,
4463 so that the resulting list only captures standard output.
4464 so that the resulting list only captures standard output.
4464 The
4465 The
4465 \family typewriter
4466 \family typewriter
4466 !!
4467 !!
4467 \family default
4468 \family default
4468 syntax is a shorthand for the
4469 syntax is a shorthand for the
4469 \family typewriter
4470 \family typewriter
4470 %sx
4471 %sx
4471 \family default
4472 \family default
4472 magic command.
4473 magic command.
4473 \layout Standard
4474 \layout Standard
4474
4475
4475 Finally, the
4476 Finally, the
4476 \family typewriter
4477 \family typewriter
4477 %sc
4478 %sc
4478 \family default
4479 \family default
4479 magic (short for `shell capture') is similar to
4480 magic (short for `shell capture') is similar to
4480 \family typewriter
4481 \family typewriter
4481 %sx
4482 %sx
4482 \family default
4483 \family default
4483 , but allowing more fine-grained control of the capture details, and storing
4484 , but allowing more fine-grained control of the capture details, and storing
4484 the result directly into a named variable.
4485 the result directly into a named variable.
4485 \layout Standard
4486 \layout Standard
4486
4487
4487 See Sec.\SpecialChar ~
4488 See Sec.\SpecialChar ~
4488
4489
4489 \begin_inset LatexCommand \ref{sec:magic}
4490 \begin_inset LatexCommand \ref{sec:magic}
4490
4491
4491 \end_inset
4492 \end_inset
4492
4493
4493 for details on the magics
4494 for details on the magics
4494 \family typewriter
4495 \family typewriter
4495 %sc
4496 %sc
4496 \family default
4497 \family default
4497 and
4498 and
4498 \family typewriter
4499 \family typewriter
4499 %sx
4500 %sx
4500 \family default
4501 \family default
4501 , or use IPython's own help (
4502 , or use IPython's own help (
4502 \family typewriter
4503 \family typewriter
4503 sc?
4504 sc?
4504 \family default
4505 \family default
4505 and
4506 and
4506 \family typewriter
4507 \family typewriter
4507 sx?
4508 sx?
4508 \family default
4509 \family default
4509 ) for further details.
4510 ) for further details.
4510 \layout Standard
4511 \layout Standard
4511
4512
4512 IPython also allows you to expand the value of python variables when making
4513 IPython also allows you to expand the value of python variables when making
4513 system calls.
4514 system calls.
4514 Any python variable or expression which you prepend with
4515 Any python variable or expression which you prepend with
4515 \family typewriter
4516 \family typewriter
4516 $
4517 $
4517 \family default
4518 \family default
4518 will get expanded before the system call is made.
4519 will get expanded before the system call is made.
4519
4520
4520 \layout Standard
4521 \layout Standard
4521
4522
4522
4523
4523 \family typewriter
4524 \family typewriter
4524 In [1]: pyvar='Hello world'
4525 In [1]: pyvar='Hello world'
4525 \newline
4526 \newline
4526 In [2]: !echo "A python variable: $pyvar"
4527 In [2]: !echo "A python variable: $pyvar"
4527 \newline
4528 \newline
4528 A python variable: Hello world
4529 A python variable: Hello world
4529 \layout Standard
4530 \layout Standard
4530
4531
4531 If you want the shell to actually see a literal
4532 If you want the shell to actually see a literal
4532 \family typewriter
4533 \family typewriter
4533 $
4534 $
4534 \family default
4535 \family default
4535 , you need to type it twice:
4536 , you need to type it twice:
4536 \layout Standard
4537 \layout Standard
4537
4538
4538
4539
4539 \family typewriter
4540 \family typewriter
4540 In [3]: !echo "A system variable: $$HOME"
4541 In [3]: !echo "A system variable: $$HOME"
4541 \newline
4542 \newline
4542 A system variable: /home/fperez
4543 A system variable: /home/fperez
4543 \layout Standard
4544 \layout Standard
4544
4545
4545 You can pass arbitrary expressions, though you'll need to delimit them with
4546 You can pass arbitrary expressions, though you'll need to delimit them with
4546
4547
4547 \family typewriter
4548 \family typewriter
4548 {}
4549 {}
4549 \family default
4550 \family default
4550 if there is ambiguity as to the extent of the expression:
4551 if there is ambiguity as to the extent of the expression:
4551 \layout Standard
4552 \layout Standard
4552
4553
4553
4554
4554 \family typewriter
4555 \family typewriter
4555 In [5]: x=10
4556 In [5]: x=10
4556 \newline
4557 \newline
4557 In [6]: y=20
4558 In [6]: y=20
4558 \newline
4559 \newline
4559 In [13]: !echo $x+y
4560 In [13]: !echo $x+y
4560 \newline
4561 \newline
4561 10+y
4562 10+y
4562 \newline
4563 \newline
4563 In [7]: !echo ${x+y}
4564 In [7]: !echo ${x+y}
4564 \newline
4565 \newline
4565 30
4566 30
4566 \layout Standard
4567 \layout Standard
4567
4568
4568 Even object attributes can be expanded:
4569 Even object attributes can be expanded:
4569 \layout Standard
4570 \layout Standard
4570
4571
4571
4572
4572 \family typewriter
4573 \family typewriter
4573 In [12]: !echo $sys.argv
4574 In [12]: !echo $sys.argv
4574 \newline
4575 \newline
4575 [/home/fperez/usr/bin/ipython]
4576 [/home/fperez/usr/bin/ipython]
4576 \layout Subsection
4577 \layout Subsection
4577
4578
4578 System command aliases
4579 System command aliases
4579 \layout Standard
4580 \layout Standard
4580
4581
4581 The
4582 The
4582 \family typewriter
4583 \family typewriter
4583 %alias
4584 %alias
4584 \family default
4585 \family default
4585 magic function and the
4586 magic function and the
4586 \family typewriter
4587 \family typewriter
4587 alias
4588 alias
4588 \family default
4589 \family default
4589 option in the
4590 option in the
4590 \family typewriter
4591 \family typewriter
4591 ipythonrc
4592 ipythonrc
4592 \family default
4593 \family default
4593 configuration file allow you to define magic functions which are in fact
4594 configuration file allow you to define magic functions which are in fact
4594 system shell commands.
4595 system shell commands.
4595 These aliases can have parameters.
4596 These aliases can have parameters.
4596
4597
4597 \layout Standard
4598 \layout Standard
4598
4599
4599 '
4600 '
4600 \family typewriter
4601 \family typewriter
4601 %alias alias_name cmd
4602 %alias alias_name cmd
4602 \family default
4603 \family default
4603 ' defines '
4604 ' defines '
4604 \family typewriter
4605 \family typewriter
4605 alias_name
4606 alias_name
4606 \family default
4607 \family default
4607 ' as an alias for '
4608 ' as an alias for '
4608 \family typewriter
4609 \family typewriter
4609 cmd
4610 cmd
4610 \family default
4611 \family default
4611 '
4612 '
4612 \layout Standard
4613 \layout Standard
4613
4614
4614 Then, typing '
4615 Then, typing '
4615 \family typewriter
4616 \family typewriter
4616 %alias_name params
4617 %alias_name params
4617 \family default
4618 \family default
4618 ' will execute the system command '
4619 ' will execute the system command '
4619 \family typewriter
4620 \family typewriter
4620 cmd params
4621 cmd params
4621 \family default
4622 \family default
4622 ' (from your underlying operating system).
4623 ' (from your underlying operating system).
4623
4624
4624 \layout Standard
4625 \layout Standard
4625
4626
4626 You can also define aliases with parameters using
4627 You can also define aliases with parameters using
4627 \family typewriter
4628 \family typewriter
4628 %s
4629 %s
4629 \family default
4630 \family default
4630 specifiers (one per parameter).
4631 specifiers (one per parameter).
4631 The following example defines the
4632 The following example defines the
4632 \family typewriter
4633 \family typewriter
4633 %parts
4634 %parts
4634 \family default
4635 \family default
4635 function as an alias to the command '
4636 function as an alias to the command '
4636 \family typewriter
4637 \family typewriter
4637 echo first %s second %s
4638 echo first %s second %s
4638 \family default
4639 \family default
4639 ' where each
4640 ' where each
4640 \family typewriter
4641 \family typewriter
4641 %s
4642 %s
4642 \family default
4643 \family default
4643 will be replaced by a positional parameter to the call to
4644 will be replaced by a positional parameter to the call to
4644 \family typewriter
4645 \family typewriter
4645 %parts:
4646 %parts:
4646 \layout Standard
4647 \layout Standard
4647
4648
4648
4649
4649 \family typewriter
4650 \family typewriter
4650 In [1]: alias parts echo first %s second %s
4651 In [1]: alias parts echo first %s second %s
4651 \newline
4652 \newline
4652 In [2]: %parts A B
4653 In [2]: %parts A B
4653 \newline
4654 \newline
4654 first A second B
4655 first A second B
4655 \newline
4656 \newline
4656 In [3]: %parts A
4657 In [3]: %parts A
4657 \newline
4658 \newline
4658 Incorrect number of arguments: 2 expected.
4659 Incorrect number of arguments: 2 expected.
4659
4660
4660 \newline
4661 \newline
4661 parts is an alias to: 'echo first %s second %s'
4662 parts is an alias to: 'echo first %s second %s'
4662 \layout Standard
4663 \layout Standard
4663
4664
4664 If called with no parameters,
4665 If called with no parameters,
4665 \family typewriter
4666 \family typewriter
4666 %alias
4667 %alias
4667 \family default
4668 \family default
4668 prints the table of currently defined aliases.
4669 prints the table of currently defined aliases.
4669 \layout Standard
4670 \layout Standard
4670
4671
4671 The
4672 The
4672 \family typewriter
4673 \family typewriter
4673 %rehash/rehashx
4674 %rehash/rehashx
4674 \family default
4675 \family default
4675 magics allow you to load your entire
4676 magics allow you to load your entire
4676 \family typewriter
4677 \family typewriter
4677 $PATH
4678 $PATH
4678 \family default
4679 \family default
4679 as ipython aliases.
4680 as ipython aliases.
4680 See their respective docstrings (or sec.\SpecialChar ~
4681 See their respective docstrings (or sec.\SpecialChar ~
4681
4682
4682 \begin_inset LatexCommand \ref{sec:magic}
4683 \begin_inset LatexCommand \ref{sec:magic}
4683
4684
4684 \end_inset
4685 \end_inset
4685
4686
4686 for further details).
4687 for further details).
4687 \layout Subsection
4688 \layout Subsection
4688
4689
4689
4690
4690 \begin_inset LatexCommand \label{sec:dreload}
4691 \begin_inset LatexCommand \label{sec:dreload}
4691
4692
4692 \end_inset
4693 \end_inset
4693
4694
4694 Recursive reload
4695 Recursive reload
4695 \layout Standard
4696 \layout Standard
4696
4697
4697 The
4698 The
4698 \family typewriter
4699 \family typewriter
4699 %dreload
4700 %dreload
4700 \family default
4701 \family default
4701 command does a recursive reload of a module: changes made to the module
4702 command does a recursive reload of a module: changes made to the module
4702 since you imported will actually be available without having to exit.
4703 since you imported will actually be available without having to exit.
4703 \layout Subsection
4704 \layout Subsection
4704
4705
4705 Verbose and colored exception traceback printouts
4706 Verbose and colored exception traceback printouts
4706 \layout Standard
4707 \layout Standard
4707
4708
4708 IPython provides the option to see very detailed exception tracebacks, which
4709 IPython provides the option to see very detailed exception tracebacks, which
4709 can be especially useful when debugging large programs.
4710 can be especially useful when debugging large programs.
4710 You can run any Python file with the
4711 You can run any Python file with the
4711 \family typewriter
4712 \family typewriter
4712 %run
4713 %run
4713 \family default
4714 \family default
4714 function to benefit from these detailed tracebacks.
4715 function to benefit from these detailed tracebacks.
4715 Furthermore, both normal and verbose tracebacks can be colored (if your
4716 Furthermore, both normal and verbose tracebacks can be colored (if your
4716 terminal supports it) which makes them much easier to parse visually.
4717 terminal supports it) which makes them much easier to parse visually.
4717 \layout Standard
4718 \layout Standard
4718
4719
4719 See the magic
4720 See the magic
4720 \family typewriter
4721 \family typewriter
4721 xmode
4722 xmode
4722 \family default
4723 \family default
4723 and
4724 and
4724 \family typewriter
4725 \family typewriter
4725 colors
4726 colors
4726 \family default
4727 \family default
4727 functions for details (just type
4728 functions for details (just type
4728 \family typewriter
4729 \family typewriter
4729 %magic
4730 %magic
4730 \family default
4731 \family default
4731 ).
4732 ).
4732 \layout Standard
4733 \layout Standard
4733
4734
4734 These features are basically a terminal version of Ka-Ping Yee's
4735 These features are basically a terminal version of Ka-Ping Yee's
4735 \family typewriter
4736 \family typewriter
4736 cgitb
4737 cgitb
4737 \family default
4738 \family default
4738 module, now part of the standard Python library.
4739 module, now part of the standard Python library.
4739 \layout Subsection
4740 \layout Subsection
4740
4741
4741
4742
4742 \begin_inset LatexCommand \label{sec:cache_input}
4743 \begin_inset LatexCommand \label{sec:cache_input}
4743
4744
4744 \end_inset
4745 \end_inset
4745
4746
4746 Input caching system
4747 Input caching system
4747 \layout Standard
4748 \layout Standard
4748
4749
4749 IPython offers numbered prompts (In/Out) with input and output caching.
4750 IPython offers numbered prompts (In/Out) with input and output caching.
4750 All input is saved and can be retrieved as variables (besides the usual
4751 All input is saved and can be retrieved as variables (besides the usual
4751 arrow key recall).
4752 arrow key recall).
4752 \layout Standard
4753 \layout Standard
4753
4754
4754 The following GLOBAL variables always exist (so don't overwrite them!):
4755 The following GLOBAL variables always exist (so don't overwrite them!):
4755
4756
4756 \family typewriter
4757 \family typewriter
4757 _i
4758 _i
4758 \family default
4759 \family default
4759 : stores previous input.
4760 : stores previous input.
4760
4761
4761 \family typewriter
4762 \family typewriter
4762 _ii
4763 _ii
4763 \family default
4764 \family default
4764 : next previous.
4765 : next previous.
4765
4766
4766 \family typewriter
4767 \family typewriter
4767 _iii
4768 _iii
4768 \family default
4769 \family default
4769 : next-next previous.
4770 : next-next previous.
4770
4771
4771 \family typewriter
4772 \family typewriter
4772 _ih
4773 _ih
4773 \family default
4774 \family default
4774 : a list of all input
4775 : a list of all input
4775 \family typewriter
4776 \family typewriter
4776 _ih[n]
4777 _ih[n]
4777 \family default
4778 \family default
4778 is the input from line
4779 is the input from line
4779 \family typewriter
4780 \family typewriter
4780 n
4781 n
4781 \family default
4782 \family default
4782 and this list is aliased to the global variable
4783 and this list is aliased to the global variable
4783 \family typewriter
4784 \family typewriter
4784 In
4785 In
4785 \family default
4786 \family default
4786 .
4787 .
4787 If you overwrite
4788 If you overwrite
4788 \family typewriter
4789 \family typewriter
4789 In
4790 In
4790 \family default
4791 \family default
4791 with a variable of your own, you can remake the assignment to the internal
4792 with a variable of your own, you can remake the assignment to the internal
4792 list with a simple
4793 list with a simple
4793 \family typewriter
4794 \family typewriter
4794 'In=_ih'
4795 'In=_ih'
4795 \family default
4796 \family default
4796 .
4797 .
4797 \layout Standard
4798 \layout Standard
4798
4799
4799 Additionally, global variables named
4800 Additionally, global variables named
4800 \family typewriter
4801 \family typewriter
4801 _i<n>
4802 _i<n>
4802 \family default
4803 \family default
4803 are dynamically created (
4804 are dynamically created (
4804 \family typewriter
4805 \family typewriter
4805 <n>
4806 <n>
4806 \family default
4807 \family default
4807 being the prompt counter), such that
4808 being the prompt counter), such that
4808 \newline
4809 \newline
4809
4810
4810 \family typewriter
4811 \family typewriter
4811 _i<n> == _ih[<n>] == In[<n>].
4812 _i<n> == _ih[<n>] == In[<n>].
4812 \layout Standard
4813 \layout Standard
4813
4814
4814 For example, what you typed at prompt 14 is available as
4815 For example, what you typed at prompt 14 is available as
4815 \family typewriter
4816 \family typewriter
4816 _i14,
4817 _i14,
4817 \family default
4818 \family default
4818
4819
4819 \family typewriter
4820 \family typewriter
4820 _ih[14]
4821 _ih[14]
4821 \family default
4822 \family default
4822 and
4823 and
4823 \family typewriter
4824 \family typewriter
4824 In[14]
4825 In[14]
4825 \family default
4826 \family default
4826 .
4827 .
4827 \layout Standard
4828 \layout Standard
4828
4829
4829 This allows you to easily cut and paste multi line interactive prompts by
4830 This allows you to easily cut and paste multi line interactive prompts by
4830 printing them out: they print like a clean string, without prompt characters.
4831 printing them out: they print like a clean string, without prompt characters.
4831 You can also manipulate them like regular variables (they are strings),
4832 You can also manipulate them like regular variables (they are strings),
4832 modify or exec them (typing
4833 modify or exec them (typing
4833 \family typewriter
4834 \family typewriter
4834 'exec _i9'
4835 'exec _i9'
4835 \family default
4836 \family default
4836 will re-execute the contents of input prompt 9, '
4837 will re-execute the contents of input prompt 9, '
4837 \family typewriter
4838 \family typewriter
4838 exec In[9:14]+In[18]
4839 exec In[9:14]+In[18]
4839 \family default
4840 \family default
4840 ' will re-execute lines 9 through 13 and line 18).
4841 ' will re-execute lines 9 through 13 and line 18).
4841 \layout Standard
4842 \layout Standard
4842
4843
4843 You can also re-execute multiple lines of input easily by using the magic
4844 You can also re-execute multiple lines of input easily by using the magic
4844
4845
4845 \family typewriter
4846 \family typewriter
4846 %macro
4847 %macro
4847 \family default
4848 \family default
4848 function (which automates the process and allows re-execution without having
4849 function (which automates the process and allows re-execution without having
4849 to type '
4850 to type '
4850 \family typewriter
4851 \family typewriter
4851 exec
4852 exec
4852 \family default
4853 \family default
4853 ' every time).
4854 ' every time).
4854 The macro system also allows you to re-execute previous lines which include
4855 The macro system also allows you to re-execute previous lines which include
4855 magic function calls (which require special processing).
4856 magic function calls (which require special processing).
4856 Type
4857 Type
4857 \family typewriter
4858 \family typewriter
4858 %macro?
4859 %macro?
4859 \family default
4860 \family default
4860 or see sec.
4861 or see sec.
4861
4862
4862 \begin_inset LatexCommand \ref{sec:magic}
4863 \begin_inset LatexCommand \ref{sec:magic}
4863
4864
4864 \end_inset
4865 \end_inset
4865
4866
4866 for more details on the macro system.
4867 for more details on the macro system.
4867 \layout Standard
4868 \layout Standard
4868
4869
4869 A history function
4870 A history function
4870 \family typewriter
4871 \family typewriter
4871 %hist
4872 %hist
4872 \family default
4873 \family default
4873 allows you to see any part of your input history by printing a range of
4874 allows you to see any part of your input history by printing a range of
4874 the
4875 the
4875 \family typewriter
4876 \family typewriter
4876 _i
4877 _i
4877 \family default
4878 \family default
4878 variables.
4879 variables.
4879 \layout Subsection
4880 \layout Subsection
4880
4881
4881
4882
4882 \begin_inset LatexCommand \label{sec:cache_output}
4883 \begin_inset LatexCommand \label{sec:cache_output}
4883
4884
4884 \end_inset
4885 \end_inset
4885
4886
4886 Output caching system
4887 Output caching system
4887 \layout Standard
4888 \layout Standard
4888
4889
4889 For output that is returned from actions, a system similar to the input
4890 For output that is returned from actions, a system similar to the input
4890 cache exists but using
4891 cache exists but using
4891 \family typewriter
4892 \family typewriter
4892 _
4893 _
4893 \family default
4894 \family default
4894 instead of
4895 instead of
4895 \family typewriter
4896 \family typewriter
4896 _i
4897 _i
4897 \family default
4898 \family default
4898 .
4899 .
4899 Only actions that produce a result (NOT assignments, for example) are cached.
4900 Only actions that produce a result (NOT assignments, for example) are cached.
4900 If you are familiar with Mathematica, IPython's
4901 If you are familiar with Mathematica, IPython's
4901 \family typewriter
4902 \family typewriter
4902 _
4903 _
4903 \family default
4904 \family default
4904 variables behave exactly like Mathematica's
4905 variables behave exactly like Mathematica's
4905 \family typewriter
4906 \family typewriter
4906 %
4907 %
4907 \family default
4908 \family default
4908 variables.
4909 variables.
4909 \layout Standard
4910 \layout Standard
4910
4911
4911 The following GLOBAL variables always exist (so don't overwrite them!):
4912 The following GLOBAL variables always exist (so don't overwrite them!):
4912
4913
4913 \layout List
4914 \layout List
4914 \labelwidthstring 00.00.0000
4915 \labelwidthstring 00.00.0000
4915
4916
4916
4917
4917 \family typewriter
4918 \family typewriter
4918 \series bold
4919 \series bold
4919 _
4920 _
4920 \family default
4921 \family default
4921 \series default
4922 \series default
4922 (a
4923 (a
4923 \emph on
4924 \emph on
4924 single
4925 single
4925 \emph default
4926 \emph default
4926 underscore) : stores previous output, like Python's default interpreter.
4927 underscore) : stores previous output, like Python's default interpreter.
4927 \layout List
4928 \layout List
4928 \labelwidthstring 00.00.0000
4929 \labelwidthstring 00.00.0000
4929
4930
4930
4931
4931 \family typewriter
4932 \family typewriter
4932 \series bold
4933 \series bold
4933 __
4934 __
4934 \family default
4935 \family default
4935 \series default
4936 \series default
4936 (two underscores): next previous.
4937 (two underscores): next previous.
4937 \layout List
4938 \layout List
4938 \labelwidthstring 00.00.0000
4939 \labelwidthstring 00.00.0000
4939
4940
4940
4941
4941 \family typewriter
4942 \family typewriter
4942 \series bold
4943 \series bold
4943 ___
4944 ___
4944 \family default
4945 \family default
4945 \series default
4946 \series default
4946 (three underscores): next-next previous.
4947 (three underscores): next-next previous.
4947 \layout Standard
4948 \layout Standard
4948
4949
4949 Additionally, global variables named
4950 Additionally, global variables named
4950 \family typewriter
4951 \family typewriter
4951 _<n>
4952 _<n>
4952 \family default
4953 \family default
4953 are dynamically created (
4954 are dynamically created (
4954 \family typewriter
4955 \family typewriter
4955 <n>
4956 <n>
4956 \family default
4957 \family default
4957 being the prompt counter), such that the result of output
4958 being the prompt counter), such that the result of output
4958 \family typewriter
4959 \family typewriter
4959 <n>
4960 <n>
4960 \family default
4961 \family default
4961 is always available as
4962 is always available as
4962 \family typewriter
4963 \family typewriter
4963 _<n>
4964 _<n>
4964 \family default
4965 \family default
4965 (don't use the angle brackets, just the number, e.g.
4966 (don't use the angle brackets, just the number, e.g.
4966
4967
4967 \family typewriter
4968 \family typewriter
4968 _21
4969 _21
4969 \family default
4970 \family default
4970 ).
4971 ).
4971 \layout Standard
4972 \layout Standard
4972
4973
4973 These global variables are all stored in a global dictionary (not a list,
4974 These global variables are all stored in a global dictionary (not a list,
4974 since it only has entries for lines which returned a result) available
4975 since it only has entries for lines which returned a result) available
4975 under the names
4976 under the names
4976 \family typewriter
4977 \family typewriter
4977 _oh
4978 _oh
4978 \family default
4979 \family default
4979 and
4980 and
4980 \family typewriter
4981 \family typewriter
4981 Out
4982 Out
4982 \family default
4983 \family default
4983 (similar to
4984 (similar to
4984 \family typewriter
4985 \family typewriter
4985 _ih
4986 _ih
4986 \family default
4987 \family default
4987 and
4988 and
4988 \family typewriter
4989 \family typewriter
4989 In
4990 In
4990 \family default
4991 \family default
4991 ).
4992 ).
4992 So the output from line 12 can be obtained as
4993 So the output from line 12 can be obtained as
4993 \family typewriter
4994 \family typewriter
4994 _12
4995 _12
4995 \family default
4996 \family default
4996 ,
4997 ,
4997 \family typewriter
4998 \family typewriter
4998 Out[12]
4999 Out[12]
4999 \family default
5000 \family default
5000 or
5001 or
5001 \family typewriter
5002 \family typewriter
5002 _oh[12]
5003 _oh[12]
5003 \family default
5004 \family default
5004 .
5005 .
5005 If you accidentally overwrite the
5006 If you accidentally overwrite the
5006 \family typewriter
5007 \family typewriter
5007 Out
5008 Out
5008 \family default
5009 \family default
5009 variable you can recover it by typing
5010 variable you can recover it by typing
5010 \family typewriter
5011 \family typewriter
5011 'Out=_oh
5012 'Out=_oh
5012 \family default
5013 \family default
5013 ' at the prompt.
5014 ' at the prompt.
5014 \layout Standard
5015 \layout Standard
5015
5016
5016 This system obviously can potentially put heavy memory demands on your system,
5017 This system obviously can potentially put heavy memory demands on your system,
5017 since it prevents Python's garbage collector from removing any previously
5018 since it prevents Python's garbage collector from removing any previously
5018 computed results.
5019 computed results.
5019 You can control how many results are kept in memory with the option (at
5020 You can control how many results are kept in memory with the option (at
5020 the command line or in your
5021 the command line or in your
5021 \family typewriter
5022 \family typewriter
5022 ipythonrc
5023 ipythonrc
5023 \family default
5024 \family default
5024 file)
5025 file)
5025 \family typewriter
5026 \family typewriter
5026 cache_size
5027 cache_size
5027 \family default
5028 \family default
5028 .
5029 .
5029 If you set it to 0, the whole system is completely disabled and the prompts
5030 If you set it to 0, the whole system is completely disabled and the prompts
5030 revert to the classic
5031 revert to the classic
5031 \family typewriter
5032 \family typewriter
5032 '>>>'
5033 '>>>'
5033 \family default
5034 \family default
5034 of normal Python.
5035 of normal Python.
5035 \layout Subsection
5036 \layout Subsection
5036
5037
5037 Directory history
5038 Directory history
5038 \layout Standard
5039 \layout Standard
5039
5040
5040 Your history of visited directories is kept in the global list
5041 Your history of visited directories is kept in the global list
5041 \family typewriter
5042 \family typewriter
5042 _dh
5043 _dh
5043 \family default
5044 \family default
5044 , and the magic
5045 , and the magic
5045 \family typewriter
5046 \family typewriter
5046 %cd
5047 %cd
5047 \family default
5048 \family default
5048 command can be used to go to any entry in that list.
5049 command can be used to go to any entry in that list.
5049 The
5050 The
5050 \family typewriter
5051 \family typewriter
5051 %dhist
5052 %dhist
5052 \family default
5053 \family default
5053 command allows you to view this history.
5054 command allows you to view this history.
5054 \layout Subsection
5055 \layout Subsection
5055
5056
5056 Automatic parentheses and quotes
5057 Automatic parentheses and quotes
5057 \layout Standard
5058 \layout Standard
5058
5059
5059 These features were adapted from Nathan Gray's LazyPython.
5060 These features were adapted from Nathan Gray's LazyPython.
5060 They are meant to allow less typing for common situations.
5061 They are meant to allow less typing for common situations.
5061 \layout Subsubsection
5062 \layout Subsubsection
5062
5063
5063 Automatic parentheses
5064 Automatic parentheses
5064 \layout Standard
5065 \layout Standard
5065
5066
5066 Callable objects (i.e.
5067 Callable objects (i.e.
5067 functions, methods, etc) can be invoked like this (notice the commas between
5068 functions, methods, etc) can be invoked like this (notice the commas between
5068 the arguments):
5069 the arguments):
5069 \layout Standard
5070 \layout Standard
5070
5071
5071
5072
5072 \family typewriter
5073 \family typewriter
5073 >>> callable_ob arg1, arg2, arg3
5074 >>> callable_ob arg1, arg2, arg3
5074 \layout Standard
5075 \layout Standard
5075
5076
5076 and the input will be translated to this:
5077 and the input will be translated to this:
5077 \layout Standard
5078 \layout Standard
5078
5079
5079
5080
5080 \family typewriter
5081 \family typewriter
5081 --> callable_ob(arg1, arg2, arg3)
5082 --> callable_ob(arg1, arg2, arg3)
5082 \layout Standard
5083 \layout Standard
5083
5084
5084 You can force automatic parentheses by using '/' as the first character
5085 You can force automatic parentheses by using '/' as the first character
5085 of a line.
5086 of a line.
5086 For example:
5087 For example:
5087 \layout Standard
5088 \layout Standard
5088
5089
5089
5090
5090 \family typewriter
5091 \family typewriter
5091 >>> /globals # becomes 'globals()'
5092 >>> /globals # becomes 'globals()'
5092 \layout Standard
5093 \layout Standard
5093
5094
5094 Note that the '/' MUST be the first character on the line! This won't work:
5095 Note that the '/' MUST be the first character on the line! This won't work:
5095
5096
5096 \layout Standard
5097 \layout Standard
5097
5098
5098
5099
5099 \family typewriter
5100 \family typewriter
5100 >>> print /globals # syntax error
5101 >>> print /globals # syntax error
5101 \layout Standard
5102 \layout Standard
5102
5103
5103 In most cases the automatic algorithm should work, so you should rarely
5104 In most cases the automatic algorithm should work, so you should rarely
5104 need to explicitly invoke /.
5105 need to explicitly invoke /.
5105 One notable exception is if you are trying to call a function with a list
5106 One notable exception is if you are trying to call a function with a list
5106 of tuples as arguments (the parenthesis will confuse IPython):
5107 of tuples as arguments (the parenthesis will confuse IPython):
5107 \layout Standard
5108 \layout Standard
5108
5109
5109
5110
5110 \family typewriter
5111 \family typewriter
5111 In [1]: zip (1,2,3),(4,5,6) # won't work
5112 In [1]: zip (1,2,3),(4,5,6) # won't work
5112 \layout Standard
5113 \layout Standard
5113
5114
5114 but this will work:
5115 but this will work:
5115 \layout Standard
5116 \layout Standard
5116
5117
5117
5118
5118 \family typewriter
5119 \family typewriter
5119 In [2]: /zip (1,2,3),(4,5,6)
5120 In [2]: /zip (1,2,3),(4,5,6)
5120 \newline
5121 \newline
5121 ------> zip ((1,2,3),(4,5,6))
5122 ------> zip ((1,2,3),(4,5,6))
5122 \newline
5123 \newline
5123 Out[2]= [(1, 4), (2, 5), (3, 6)]
5124 Out[2]= [(1, 4), (2, 5), (3, 6)]
5124 \layout Standard
5125 \layout Standard
5125
5126
5126 IPython tells you that it has altered your command line by displaying the
5127 IPython tells you that it has altered your command line by displaying the
5127 new command line preceded by
5128 new command line preceded by
5128 \family typewriter
5129 \family typewriter
5129 -->
5130 -->
5130 \family default
5131 \family default
5131 .
5132 .
5132 e.g.:
5133 e.g.:
5133 \layout Standard
5134 \layout Standard
5134
5135
5135
5136
5136 \family typewriter
5137 \family typewriter
5137 In [18]: callable list
5138 In [18]: callable list
5138 \newline
5139 \newline
5139 -------> callable (list)
5140 -------> callable (list)
5140 \layout Subsubsection
5141 \layout Subsubsection
5141
5142
5142 Automatic quoting
5143 Automatic quoting
5143 \layout Standard
5144 \layout Standard
5144
5145
5145 You can force automatic quoting of a function's arguments by using
5146 You can force automatic quoting of a function's arguments by using
5146 \family typewriter
5147 \family typewriter
5147 `,'
5148 `,'
5148 \family default
5149 \family default
5149 or
5150 or
5150 \family typewriter
5151 \family typewriter
5151 `;'
5152 `;'
5152 \family default
5153 \family default
5153 as the first character of a line.
5154 as the first character of a line.
5154 For example:
5155 For example:
5155 \layout Standard
5156 \layout Standard
5156
5157
5157
5158
5158 \family typewriter
5159 \family typewriter
5159 >>> ,my_function /home/me # becomes my_function("/home/me")
5160 >>> ,my_function /home/me # becomes my_function("/home/me")
5160 \layout Standard
5161 \layout Standard
5161
5162
5162 If you use
5163 If you use
5163 \family typewriter
5164 \family typewriter
5164 `;'
5165 `;'
5165 \family default
5166 \family default
5166 instead, the whole argument is quoted as a single string (while
5167 instead, the whole argument is quoted as a single string (while
5167 \family typewriter
5168 \family typewriter
5168 `,'
5169 `,'
5169 \family default
5170 \family default
5170 splits on whitespace):
5171 splits on whitespace):
5171 \layout Standard
5172 \layout Standard
5172
5173
5173
5174
5174 \family typewriter
5175 \family typewriter
5175 >>> ,my_function a b c # becomes my_function("a","b","c")
5176 >>> ,my_function a b c # becomes my_function("a","b","c")
5176 \layout Standard
5177 \layout Standard
5177
5178
5178
5179
5179 \family typewriter
5180 \family typewriter
5180 >>> ;my_function a b c # becomes my_function("a b c")
5181 >>> ;my_function a b c # becomes my_function("a b c")
5181 \layout Standard
5182 \layout Standard
5182
5183
5183 Note that the `
5184 Note that the `
5184 \family typewriter
5185 \family typewriter
5185 ,
5186 ,
5186 \family default
5187 \family default
5187 ' or `
5188 ' or `
5188 \family typewriter
5189 \family typewriter
5189 ;
5190 ;
5190 \family default
5191 \family default
5191 ' MUST be the first character on the line! This won't work:
5192 ' MUST be the first character on the line! This won't work:
5192 \layout Standard
5193 \layout Standard
5193
5194
5194
5195
5195 \family typewriter
5196 \family typewriter
5196 >>> x = ,my_function /home/me # syntax error
5197 >>> x = ,my_function /home/me # syntax error
5197 \layout Section
5198 \layout Section
5198
5199
5199
5200
5200 \begin_inset LatexCommand \label{sec:customization}
5201 \begin_inset LatexCommand \label{sec:customization}
5201
5202
5202 \end_inset
5203 \end_inset
5203
5204
5204 Customization
5205 Customization
5205 \layout Standard
5206 \layout Standard
5206
5207
5207 As we've already mentioned, IPython reads a configuration file which can
5208 As we've already mentioned, IPython reads a configuration file which can
5208 be specified at the command line (
5209 be specified at the command line (
5209 \family typewriter
5210 \family typewriter
5210 -rcfile
5211 -rcfile
5211 \family default
5212 \family default
5212 ) or which by default is assumed to be called
5213 ) or which by default is assumed to be called
5213 \family typewriter
5214 \family typewriter
5214 ipythonrc
5215 ipythonrc
5215 \family default
5216 \family default
5216 .
5217 .
5217 Such a file is looked for in the current directory where IPython is started
5218 Such a file is looked for in the current directory where IPython is started
5218 and then in your
5219 and then in your
5219 \family typewriter
5220 \family typewriter
5220 IPYTHONDIR
5221 IPYTHONDIR
5221 \family default
5222 \family default
5222 , which allows you to have local configuration files for specific projects.
5223 , which allows you to have local configuration files for specific projects.
5223 In this section we will call these types of configuration files simply
5224 In this section we will call these types of configuration files simply
5224 rcfiles (short for resource configuration file).
5225 rcfiles (short for resource configuration file).
5225 \layout Standard
5226 \layout Standard
5226
5227
5227 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5228 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5228 one per line.
5229 one per line.
5229 Lines beginning with a
5230 Lines beginning with a
5230 \family typewriter
5231 \family typewriter
5231 #
5232 #
5232 \family default
5233 \family default
5233 are ignored as comments, but comments can
5234 are ignored as comments, but comments can
5234 \series bold
5235 \series bold
5235 not
5236 not
5236 \series default
5237 \series default
5237 be put on lines with data (the parser is fairly primitive).
5238 be put on lines with data (the parser is fairly primitive).
5238 Note that these are not python files, and this is deliberate, because it
5239 Note that these are not python files, and this is deliberate, because it
5239 allows us to do some things which would be quite tricky to implement if
5240 allows us to do some things which would be quite tricky to implement if
5240 they were normal python files.
5241 they were normal python files.
5241 \layout Standard
5242 \layout Standard
5242
5243
5243 First, an rcfile can contain permanent default values for almost all command
5244 First, an rcfile can contain permanent default values for almost all command
5244 line options (except things like
5245 line options (except things like
5245 \family typewriter
5246 \family typewriter
5246 -help
5247 -help
5247 \family default
5248 \family default
5248 or
5249 or
5249 \family typewriter
5250 \family typewriter
5250 -Version
5251 -Version
5251 \family default
5252 \family default
5252 ).
5253 ).
5253 Sec\SpecialChar ~
5254 Sec\SpecialChar ~
5254
5255
5255 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5256 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5256
5257
5257 \end_inset
5258 \end_inset
5258
5259
5259 contains a description of all command-line options.
5260 contains a description of all command-line options.
5260 However, values you explicitly specify at the command line override the
5261 However, values you explicitly specify at the command line override the
5261 values defined in the rcfile.
5262 values defined in the rcfile.
5262 \layout Standard
5263 \layout Standard
5263
5264
5264 Besides command line option values, the rcfile can specify values for certain
5265 Besides command line option values, the rcfile can specify values for certain
5265 extra special options which are not available at the command line.
5266 extra special options which are not available at the command line.
5266 These options are briefly described below.
5267 These options are briefly described below.
5267
5268
5268 \layout Standard
5269 \layout Standard
5269
5270
5270 Each of these options may appear as many times as you need it in the file.
5271 Each of these options may appear as many times as you need it in the file.
5271 \layout List
5272 \layout List
5272 \labelwidthstring 00.00.0000
5273 \labelwidthstring 00.00.0000
5273
5274
5274
5275
5275 \family typewriter
5276 \family typewriter
5276 \series bold
5277 \series bold
5277 include\SpecialChar ~
5278 include\SpecialChar ~
5278 <file1>\SpecialChar ~
5279 <file1>\SpecialChar ~
5279 <file2>\SpecialChar ~
5280 <file2>\SpecialChar ~
5280 ...
5281 ...
5281 \family default
5282 \family default
5282 \series default
5283 \series default
5283 : you can name
5284 : you can name
5284 \emph on
5285 \emph on
5285 other
5286 other
5286 \emph default
5287 \emph default
5287 rcfiles you want to recursively load up to 15 levels (don't use the
5288 rcfiles you want to recursively load up to 15 levels (don't use the
5288 \family typewriter
5289 \family typewriter
5289 <>
5290 <>
5290 \family default
5291 \family default
5291 brackets in your names!).
5292 brackets in your names!).
5292 This feature allows you to define a 'base' rcfile with general options
5293 This feature allows you to define a 'base' rcfile with general options
5293 and special-purpose files which can be loaded only when needed with particular
5294 and special-purpose files which can be loaded only when needed with particular
5294 configuration options.
5295 configuration options.
5295 To make this more convenient, IPython accepts the
5296 To make this more convenient, IPython accepts the
5296 \family typewriter
5297 \family typewriter
5297 -profile <name>
5298 -profile <name>
5298 \family default
5299 \family default
5299 option (abbreviates to
5300 option (abbreviates to
5300 \family typewriter
5301 \family typewriter
5301 -p <name
5302 -p <name
5302 \family default
5303 \family default
5303 >)
5304 >)
5304 \family typewriter
5305 \family typewriter
5305 which
5306 which
5306 \family default
5307 \family default
5307 tells it to look for an rcfile named
5308 tells it to look for an rcfile named
5308 \family typewriter
5309 \family typewriter
5309 ipythonrc-<name>
5310 ipythonrc-<name>
5310 \family default
5311 \family default
5311 .
5312 .
5312
5313
5313 \layout List
5314 \layout List
5314 \labelwidthstring 00.00.0000
5315 \labelwidthstring 00.00.0000
5315
5316
5316
5317
5317 \family typewriter
5318 \family typewriter
5318 \series bold
5319 \series bold
5319 import_mod\SpecialChar ~
5320 import_mod\SpecialChar ~
5320 <mod1>\SpecialChar ~
5321 <mod1>\SpecialChar ~
5321 <mod2>\SpecialChar ~
5322 <mod2>\SpecialChar ~
5322 ...
5323 ...
5323 \family default
5324 \family default
5324 \series default
5325 \series default
5325 : import modules with '
5326 : import modules with '
5326 \family typewriter
5327 \family typewriter
5327 import
5328 import
5328 \family default
5329 \family default
5329
5330
5330 \family typewriter
5331 \family typewriter
5331 <mod1>,<mod2>,...
5332 <mod1>,<mod2>,...
5332 \family default
5333 \family default
5333 '
5334 '
5334 \layout List
5335 \layout List
5335 \labelwidthstring 00.00.0000
5336 \labelwidthstring 00.00.0000
5336
5337
5337
5338
5338 \family typewriter
5339 \family typewriter
5339 \series bold
5340 \series bold
5340 import_some\SpecialChar ~
5341 import_some\SpecialChar ~
5341 <mod>\SpecialChar ~
5342 <mod>\SpecialChar ~
5342 <f1>\SpecialChar ~
5343 <f1>\SpecialChar ~
5343 <f2>\SpecialChar ~
5344 <f2>\SpecialChar ~
5344 ...
5345 ...
5345 \family default
5346 \family default
5346 \series default
5347 \series default
5347 : import functions with '
5348 : import functions with '
5348 \family typewriter
5349 \family typewriter
5349 from <mod> import
5350 from <mod> import
5350 \family default
5351 \family default
5351
5352
5352 \family typewriter
5353 \family typewriter
5353 <f1>,<f2>,...
5354 <f1>,<f2>,...
5354 \family default
5355 \family default
5355 '
5356 '
5356 \layout List
5357 \layout List
5357 \labelwidthstring 00.00.0000
5358 \labelwidthstring 00.00.0000
5358
5359
5359
5360
5360 \family typewriter
5361 \family typewriter
5361 \series bold
5362 \series bold
5362 import_all\SpecialChar ~
5363 import_all\SpecialChar ~
5363 <mod1>\SpecialChar ~
5364 <mod1>\SpecialChar ~
5364 <mod2>\SpecialChar ~
5365 <mod2>\SpecialChar ~
5365 ...
5366 ...
5366 \family default
5367 \family default
5367 \series default
5368 \series default
5368 : for each module listed import functions with '
5369 : for each module listed import functions with '
5369 \family typewriter
5370 \family typewriter
5370 from <mod> import *
5371 from <mod> import *
5371 \family default
5372 \family default
5372 '
5373 '
5373 \layout List
5374 \layout List
5374 \labelwidthstring 00.00.0000
5375 \labelwidthstring 00.00.0000
5375
5376
5376
5377
5377 \family typewriter
5378 \family typewriter
5378 \series bold
5379 \series bold
5379 execute\SpecialChar ~
5380 execute\SpecialChar ~
5380 <python\SpecialChar ~
5381 <python\SpecialChar ~
5381 code>
5382 code>
5382 \family default
5383 \family default
5383 \series default
5384 \series default
5384 : give any single-line python code to be executed.
5385 : give any single-line python code to be executed.
5385 \layout List
5386 \layout List
5386 \labelwidthstring 00.00.0000
5387 \labelwidthstring 00.00.0000
5387
5388
5388
5389
5389 \family typewriter
5390 \family typewriter
5390 \series bold
5391 \series bold
5391 execfile\SpecialChar ~
5392 execfile\SpecialChar ~
5392 <filename>
5393 <filename>
5393 \family default
5394 \family default
5394 \series default
5395 \series default
5395 : execute the python file given with an '
5396 : execute the python file given with an '
5396 \family typewriter
5397 \family typewriter
5397 execfile(filename)
5398 execfile(filename)
5398 \family default
5399 \family default
5399 ' command.
5400 ' command.
5400 Username expansion is performed on the given names.
5401 Username expansion is performed on the given names.
5401 So if you need any amount of extra fancy customization that won't fit in
5402 So if you need any amount of extra fancy customization that won't fit in
5402 any of the above 'canned' options, you can just put it in a separate python
5403 any of the above 'canned' options, you can just put it in a separate python
5403 file and execute it.
5404 file and execute it.
5404 \layout List
5405 \layout List
5405 \labelwidthstring 00.00.0000
5406 \labelwidthstring 00.00.0000
5406
5407
5407
5408
5408 \family typewriter
5409 \family typewriter
5409 \series bold
5410 \series bold
5410 alias\SpecialChar ~
5411 alias\SpecialChar ~
5411 <alias_def>
5412 <alias_def>
5412 \family default
5413 \family default
5413 \series default
5414 \series default
5414 : this is equivalent to calling '
5415 : this is equivalent to calling '
5415 \family typewriter
5416 \family typewriter
5416 %alias\SpecialChar ~
5417 %alias\SpecialChar ~
5417 <alias_def>
5418 <alias_def>
5418 \family default
5419 \family default
5419 ' at the IPython command line.
5420 ' at the IPython command line.
5420 This way, from within IPython you can do common system tasks without having
5421 This way, from within IPython you can do common system tasks without having
5421 to exit it or use the
5422 to exit it or use the
5422 \family typewriter
5423 \family typewriter
5423 !
5424 !
5424 \family default
5425 \family default
5425 escape.
5426 escape.
5426 IPython isn't meant to be a shell replacement, but it is often very useful
5427 IPython isn't meant to be a shell replacement, but it is often very useful
5427 to be able to do things with files while testing code.
5428 to be able to do things with files while testing code.
5428 This gives you the flexibility to have within IPython any aliases you may
5429 This gives you the flexibility to have within IPython any aliases you may
5429 be used to under your normal system shell.
5430 be used to under your normal system shell.
5430 \layout Subsection
5431 \layout Subsection
5431
5432
5432
5433
5433 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5434 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5434
5435
5435 \end_inset
5436 \end_inset
5436
5437
5437 Sample
5438 Sample
5438 \family typewriter
5439 \family typewriter
5439 ipythonrc
5440 ipythonrc
5440 \family default
5441 \family default
5441 file
5442 file
5442 \layout Standard
5443 \layout Standard
5443
5444
5444 The default rcfile, called
5445 The default rcfile, called
5445 \family typewriter
5446 \family typewriter
5446 ipythonrc
5447 ipythonrc
5447 \family default
5448 \family default
5448 and supplied in your
5449 and supplied in your
5449 \family typewriter
5450 \family typewriter
5450 IPYTHONDIR
5451 IPYTHONDIR
5451 \family default
5452 \family default
5452 directory contains lots of comments on all of these options.
5453 directory contains lots of comments on all of these options.
5453 We reproduce it here for reference:
5454 We reproduce it here for reference:
5454 \layout Standard
5455 \layout Standard
5455
5456
5456
5457
5457 \begin_inset ERT
5458 \begin_inset ERT
5458 status Open
5459 status Open
5459
5460
5460 \layout Standard
5461 \layout Standard
5461
5462
5462 \backslash
5463 \backslash
5463 codelist{../IPython/UserConfig/ipythonrc}
5464 codelist{../IPython/UserConfig/ipythonrc}
5464 \end_inset
5465 \end_inset
5465
5466
5466
5467
5467 \layout Subsection
5468 \layout Subsection
5468
5469
5469
5470
5470 \begin_inset LatexCommand \label{sec:prompts}
5471 \begin_inset LatexCommand \label{sec:prompts}
5471
5472
5472 \end_inset
5473 \end_inset
5473
5474
5474 Fine-tuning your prompt
5475 Fine-tuning your prompt
5475 \layout Standard
5476 \layout Standard
5476
5477
5477 IPython's prompts can be customized using a syntax similar to that of the
5478 IPython's prompts can be customized using a syntax similar to that of the
5478
5479
5479 \family typewriter
5480 \family typewriter
5480 bash
5481 bash
5481 \family default
5482 \family default
5482 shell.
5483 shell.
5483 Many of
5484 Many of
5484 \family typewriter
5485 \family typewriter
5485 bash
5486 bash
5486 \family default
5487 \family default
5487 's escapes are supported, as well as a few additional ones.
5488 's escapes are supported, as well as a few additional ones.
5488 We list them below:
5489 We list them below:
5489 \layout Description
5490 \layout Description
5490
5491
5491
5492
5492 \backslash
5493 \backslash
5493 # the prompt/history count number
5494 # the prompt/history count number
5494 \layout Description
5495 \layout Description
5495
5496
5496
5497
5497 \backslash
5498 \backslash
5498 D the prompt/history count, with the actual digits replaced by dots.
5499 D the prompt/history count, with the actual digits replaced by dots.
5499 Used mainly in continuation prompts (prompt_in2)
5500 Used mainly in continuation prompts (prompt_in2)
5500 \layout Description
5501 \layout Description
5501
5502
5502
5503
5503 \backslash
5504 \backslash
5504 w the current working directory
5505 w the current working directory
5505 \layout Description
5506 \layout Description
5506
5507
5507
5508
5508 \backslash
5509 \backslash
5509 W the basename of current working directory
5510 W the basename of current working directory
5510 \layout Description
5511 \layout Description
5511
5512
5512
5513
5513 \backslash
5514 \backslash
5514 X
5515 X
5515 \emph on
5516 \emph on
5516 n
5517 n
5517 \emph default
5518 \emph default
5518 where
5519 where
5519 \begin_inset Formula $n=0\ldots5.$
5520 \begin_inset Formula $n=0\ldots5.$
5520 \end_inset
5521 \end_inset
5521
5522
5522 The current working directory, with
5523 The current working directory, with
5523 \family typewriter
5524 \family typewriter
5524 $HOME
5525 $HOME
5525 \family default
5526 \family default
5526 replaced by
5527 replaced by
5527 \family typewriter
5528 \family typewriter
5528 ~
5529 ~
5529 \family default
5530 \family default
5530 , and filtered out to contain only
5531 , and filtered out to contain only
5531 \begin_inset Formula $n$
5532 \begin_inset Formula $n$
5532 \end_inset
5533 \end_inset
5533
5534
5534 path elements
5535 path elements
5535 \layout Description
5536 \layout Description
5536
5537
5537
5538
5538 \backslash
5539 \backslash
5539 Y
5540 Y
5540 \emph on
5541 \emph on
5541 n
5542 n
5542 \emph default
5543 \emph default
5543 Similar to
5544 Similar to
5544 \backslash
5545 \backslash
5545 X
5546 X
5546 \emph on
5547 \emph on
5547 n
5548 n
5548 \emph default
5549 \emph default
5549 , but with the
5550 , but with the
5550 \begin_inset Formula $n+1$
5551 \begin_inset Formula $n+1$
5551 \end_inset
5552 \end_inset
5552
5553
5553 element included if it is
5554 element included if it is
5554 \family typewriter
5555 \family typewriter
5555 ~
5556 ~
5556 \family default
5557 \family default
5557 (this is similar to the behavior of the %c
5558 (this is similar to the behavior of the %c
5558 \emph on
5559 \emph on
5559 n
5560 n
5560 \emph default
5561 \emph default
5561 escapes in
5562 escapes in
5562 \family typewriter
5563 \family typewriter
5563 tcsh
5564 tcsh
5564 \family default
5565 \family default
5565 )
5566 )
5566 \layout Description
5567 \layout Description
5567
5568
5568
5569
5569 \backslash
5570 \backslash
5570 u the username of the current user
5571 u the username of the current user
5571 \layout Description
5572 \layout Description
5572
5573
5573
5574
5574 \backslash
5575 \backslash
5575 $ if the effective UID is 0, a #, otherwise a $
5576 $ if the effective UID is 0, a #, otherwise a $
5576 \layout Description
5577 \layout Description
5577
5578
5578
5579
5579 \backslash
5580 \backslash
5580 h the hostname up to the first `.'
5581 h the hostname up to the first `.'
5581 \layout Description
5582 \layout Description
5582
5583
5583
5584
5584 \backslash
5585 \backslash
5585 H the hostname
5586 H the hostname
5586 \layout Description
5587 \layout Description
5587
5588
5588
5589
5589 \backslash
5590 \backslash
5590 n a newline
5591 n a newline
5591 \layout Description
5592 \layout Description
5592
5593
5593
5594
5594 \backslash
5595 \backslash
5595 r a carriage return
5596 r a carriage return
5596 \layout Description
5597 \layout Description
5597
5598
5598
5599
5599 \backslash
5600 \backslash
5600 v IPython version string
5601 v IPython version string
5601 \layout Standard
5602 \layout Standard
5602
5603
5603 In addition to these, ANSI color escapes can be insterted into the prompts,
5604 In addition to these, ANSI color escapes can be insterted into the prompts,
5604 as
5605 as
5605 \family typewriter
5606 \family typewriter
5606
5607
5607 \backslash
5608 \backslash
5608 C_
5609 C_
5609 \emph on
5610 \emph on
5610 ColorName
5611 ColorName
5611 \family default
5612 \family default
5612 \emph default
5613 \emph default
5613 .
5614 .
5614 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5615 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5615 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5616 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5616 Normal, Purple, Red, White, Yellow.
5617 Normal, Purple, Red, White, Yellow.
5617 \layout Standard
5618 \layout Standard
5618
5619
5619 Finally, IPython supports the evaluation of arbitrary expressions in your
5620 Finally, IPython supports the evaluation of arbitrary expressions in your
5620 prompt string.
5621 prompt string.
5621 The prompt strings are evaluated through the syntax of PEP 215, but basically
5622 The prompt strings are evaluated through the syntax of PEP 215, but basically
5622 you can use
5623 you can use
5623 \family typewriter
5624 \family typewriter
5624 $x.y
5625 $x.y
5625 \family default
5626 \family default
5626 to expand the value of
5627 to expand the value of
5627 \family typewriter
5628 \family typewriter
5628 x.y
5629 x.y
5629 \family default
5630 \family default
5630 , and for more complicated expressions you can use braces:
5631 , and for more complicated expressions you can use braces:
5631 \family typewriter
5632 \family typewriter
5632 ${foo()+x}
5633 ${foo()+x}
5633 \family default
5634 \family default
5634 will call function
5635 will call function
5635 \family typewriter
5636 \family typewriter
5636 foo
5637 foo
5637 \family default
5638 \family default
5638 and add to it the value of
5639 and add to it the value of
5639 \family typewriter
5640 \family typewriter
5640 x
5641 x
5641 \family default
5642 \family default
5642 , before putting the result into your prompt.
5643 , before putting the result into your prompt.
5643 For example, using
5644 For example, using
5644 \newline
5645 \newline
5645
5646
5646 \family typewriter
5647 \family typewriter
5647 prompt_in1 '${commands.getoutput("uptime")}
5648 prompt_in1 '${commands.getoutput("uptime")}
5648 \backslash
5649 \backslash
5649 nIn [
5650 nIn [
5650 \backslash
5651 \backslash
5651 #]: '
5652 #]: '
5652 \newline
5653 \newline
5653
5654
5654 \family default
5655 \family default
5655 will print the result of the uptime command on each prompt (assuming the
5656 will print the result of the uptime command on each prompt (assuming the
5656
5657
5657 \family typewriter
5658 \family typewriter
5658 commands
5659 commands
5659 \family default
5660 \family default
5660 module has been imported in your
5661 module has been imported in your
5661 \family typewriter
5662 \family typewriter
5662 ipythonrc
5663 ipythonrc
5663 \family default
5664 \family default
5664 file).
5665 file).
5665 \layout Subsubsection
5666 \layout Subsubsection
5666
5667
5667 Prompt examples
5668 Prompt examples
5668 \layout Standard
5669 \layout Standard
5669
5670
5670 The following options in an ipythonrc file will give you IPython's default
5671 The following options in an ipythonrc file will give you IPython's default
5671 prompts:
5672 prompts:
5672 \layout Standard
5673 \layout Standard
5673
5674
5674
5675
5675 \family typewriter
5676 \family typewriter
5676 prompt_in1 'In [
5677 prompt_in1 'In [
5677 \backslash
5678 \backslash
5678 #]:'
5679 #]:'
5679 \newline
5680 \newline
5680 prompt_in2 '\SpecialChar ~
5681 prompt_in2 '\SpecialChar ~
5681 \SpecialChar ~
5682 \SpecialChar ~
5682 \SpecialChar ~
5683 \SpecialChar ~
5683 .
5684 .
5684 \backslash
5685 \backslash
5685 D.:'
5686 D.:'
5686 \newline
5687 \newline
5687 prompt_out 'Out[
5688 prompt_out 'Out[
5688 \backslash
5689 \backslash
5689 #]:'
5690 #]:'
5690 \layout Standard
5691 \layout Standard
5691
5692
5692 which look like this:
5693 which look like this:
5693 \layout Standard
5694 \layout Standard
5694
5695
5695
5696
5696 \family typewriter
5697 \family typewriter
5697 In [1]: 1+2
5698 In [1]: 1+2
5698 \newline
5699 \newline
5699 Out[1]: 3
5700 Out[1]: 3
5700 \layout Standard
5701 \layout Standard
5701
5702
5702
5703
5703 \family typewriter
5704 \family typewriter
5704 In [2]: for i in (1,2,3):
5705 In [2]: for i in (1,2,3):
5705 \newline
5706 \newline
5706
5707
5707 \begin_inset ERT
5708 \begin_inset ERT
5708 status Collapsed
5709 status Collapsed
5709
5710
5710 \layout Standard
5711 \layout Standard
5711
5712
5712 \backslash
5713 \backslash
5713 hspace*{0mm}
5714 hspace*{0mm}
5714 \end_inset
5715 \end_inset
5715
5716
5716 \SpecialChar ~
5717 \SpecialChar ~
5717 \SpecialChar ~
5718 \SpecialChar ~
5718 \SpecialChar ~
5719 \SpecialChar ~
5719 ...: \SpecialChar ~
5720 ...: \SpecialChar ~
5720 \SpecialChar ~
5721 \SpecialChar ~
5721 \SpecialChar ~
5722 \SpecialChar ~
5722 \SpecialChar ~
5723 \SpecialChar ~
5723 print i,
5724 print i,
5724 \newline
5725 \newline
5725
5726
5726 \begin_inset ERT
5727 \begin_inset ERT
5727 status Collapsed
5728 status Collapsed
5728
5729
5729 \layout Standard
5730 \layout Standard
5730
5731
5731 \backslash
5732 \backslash
5732 hspace*{0mm}
5733 hspace*{0mm}
5733 \end_inset
5734 \end_inset
5734
5735
5735 \SpecialChar ~
5736 \SpecialChar ~
5736 \SpecialChar ~
5737 \SpecialChar ~
5737 \SpecialChar ~
5738 \SpecialChar ~
5738 ...:
5739 ...:
5739 \newline
5740 \newline
5740 1 2 3
5741 1 2 3
5741 \layout Standard
5742 \layout Standard
5742
5743
5743 These will give you a very colorful prompt with path information:
5744 These will give you a very colorful prompt with path information:
5744 \layout Standard
5745 \layout Standard
5745
5746
5746
5747
5747 \family typewriter
5748 \family typewriter
5748 #prompt_in1 '
5749 #prompt_in1 '
5749 \backslash
5750 \backslash
5750 C_Red
5751 C_Red
5751 \backslash
5752 \backslash
5752 u
5753 u
5753 \backslash
5754 \backslash
5754 C_Blue[
5755 C_Blue[
5755 \backslash
5756 \backslash
5756 C_Cyan
5757 C_Cyan
5757 \backslash
5758 \backslash
5758 Y1
5759 Y1
5759 \backslash
5760 \backslash
5760 C_Blue]
5761 C_Blue]
5761 \backslash
5762 \backslash
5762 C_LightGreen
5763 C_LightGreen
5763 \backslash
5764 \backslash
5764 #>'
5765 #>'
5765 \newline
5766 \newline
5766 prompt_in2 ' ..
5767 prompt_in2 ' ..
5767 \backslash
5768 \backslash
5768 D>'
5769 D>'
5769 \newline
5770 \newline
5770 prompt_out '<
5771 prompt_out '<
5771 \backslash
5772 \backslash
5772 #>'
5773 #>'
5773 \layout Standard
5774 \layout Standard
5774
5775
5775 which look like this:
5776 which look like this:
5776 \layout Standard
5777 \layout Standard
5777
5778
5778
5779
5779 \family typewriter
5780 \family typewriter
5780 \color red
5781 \color red
5781 fperez
5782 fperez
5782 \color blue
5783 \color blue
5783 [
5784 [
5784 \color cyan
5785 \color cyan
5785 ~/ipython
5786 ~/ipython
5786 \color blue
5787 \color blue
5787 ]
5788 ]
5788 \color green
5789 \color green
5789 1>
5790 1>
5790 \color default
5791 \color default
5791 1+2
5792 1+2
5792 \newline
5793 \newline
5793
5794
5794 \begin_inset ERT
5795 \begin_inset ERT
5795 status Collapsed
5796 status Collapsed
5796
5797
5797 \layout Standard
5798 \layout Standard
5798
5799
5799 \backslash
5800 \backslash
5800 hspace*{0mm}
5801 hspace*{0mm}
5801 \end_inset
5802 \end_inset
5802
5803
5803 \SpecialChar ~
5804 \SpecialChar ~
5804 \SpecialChar ~
5805 \SpecialChar ~
5805 \SpecialChar ~
5806 \SpecialChar ~
5806 \SpecialChar ~
5807 \SpecialChar ~
5807 \SpecialChar ~
5808 \SpecialChar ~
5808 \SpecialChar ~
5809 \SpecialChar ~
5809 \SpecialChar ~
5810 \SpecialChar ~
5810 \SpecialChar ~
5811 \SpecialChar ~
5811 \SpecialChar ~
5812 \SpecialChar ~
5812 \SpecialChar ~
5813 \SpecialChar ~
5813 \SpecialChar ~
5814 \SpecialChar ~
5814 \SpecialChar ~
5815 \SpecialChar ~
5815 \SpecialChar ~
5816 \SpecialChar ~
5816 \SpecialChar ~
5817 \SpecialChar ~
5817 \SpecialChar ~
5818 \SpecialChar ~
5818 \SpecialChar ~
5819 \SpecialChar ~
5819
5820
5820 \color red
5821 \color red
5821 <1>
5822 <1>
5822 \color default
5823 \color default
5823 3
5824 3
5824 \newline
5825 \newline
5825
5826
5826 \color red
5827 \color red
5827 fperez
5828 fperez
5828 \color blue
5829 \color blue
5829 [
5830 [
5830 \color cyan
5831 \color cyan
5831 ~/ipython
5832 ~/ipython
5832 \color blue
5833 \color blue
5833 ]
5834 ]
5834 \color green
5835 \color green
5835 2>
5836 2>
5836 \color default
5837 \color default
5837 for i in (1,2,3):
5838 for i in (1,2,3):
5838 \newline
5839 \newline
5839
5840
5840 \begin_inset ERT
5841 \begin_inset ERT
5841 status Collapsed
5842 status Collapsed
5842
5843
5843 \layout Standard
5844 \layout Standard
5844
5845
5845 \backslash
5846 \backslash
5846 hspace*{0mm}
5847 hspace*{0mm}
5847 \end_inset
5848 \end_inset
5848
5849
5849 \SpecialChar ~
5850 \SpecialChar ~
5850 \SpecialChar ~
5851 \SpecialChar ~
5851 \SpecialChar ~
5852 \SpecialChar ~
5852 \SpecialChar ~
5853 \SpecialChar ~
5853 \SpecialChar ~
5854 \SpecialChar ~
5854 \SpecialChar ~
5855 \SpecialChar ~
5855 \SpecialChar ~
5856 \SpecialChar ~
5856 \SpecialChar ~
5857 \SpecialChar ~
5857 \SpecialChar ~
5858 \SpecialChar ~
5858 \SpecialChar ~
5859 \SpecialChar ~
5859 \SpecialChar ~
5860 \SpecialChar ~
5860 \SpecialChar ~
5861 \SpecialChar ~
5861 \SpecialChar ~
5862 \SpecialChar ~
5862 \SpecialChar ~
5863 \SpecialChar ~
5863 \SpecialChar ~
5864 \SpecialChar ~
5864
5865
5865 \color green
5866 \color green
5866 ...>
5867 ...>
5867 \color default
5868 \color default
5868 \SpecialChar ~
5869 \SpecialChar ~
5869 \SpecialChar ~
5870 \SpecialChar ~
5870 \SpecialChar ~
5871 \SpecialChar ~
5871 \SpecialChar ~
5872 \SpecialChar ~
5872 print i,
5873 print i,
5873 \newline
5874 \newline
5874
5875
5875 \begin_inset ERT
5876 \begin_inset ERT
5876 status Collapsed
5877 status Collapsed
5877
5878
5878 \layout Standard
5879 \layout Standard
5879
5880
5880 \backslash
5881 \backslash
5881 hspace*{0mm}
5882 hspace*{0mm}
5882 \end_inset
5883 \end_inset
5883
5884
5884 \SpecialChar ~
5885 \SpecialChar ~
5885 \SpecialChar ~
5886 \SpecialChar ~
5886 \SpecialChar ~
5887 \SpecialChar ~
5887 \SpecialChar ~
5888 \SpecialChar ~
5888 \SpecialChar ~
5889 \SpecialChar ~
5889 \SpecialChar ~
5890 \SpecialChar ~
5890 \SpecialChar ~
5891 \SpecialChar ~
5891 \SpecialChar ~
5892 \SpecialChar ~
5892 \SpecialChar ~
5893 \SpecialChar ~
5893 \SpecialChar ~
5894 \SpecialChar ~
5894 \SpecialChar ~
5895 \SpecialChar ~
5895 \SpecialChar ~
5896 \SpecialChar ~
5896 \SpecialChar ~
5897 \SpecialChar ~
5897 \SpecialChar ~
5898 \SpecialChar ~
5898 \SpecialChar ~
5899 \SpecialChar ~
5899
5900
5900 \color green
5901 \color green
5901 ...>
5902 ...>
5902 \color default
5903 \color default
5903
5904
5904 \newline
5905 \newline
5905 1 2 3
5906 1 2 3
5906 \layout Standard
5907 \layout Standard
5907
5908
5908 The following shows the usage of dynamic expression evaluation:
5909 The following shows the usage of dynamic expression evaluation:
5909 \layout Subsection
5910 \layout Subsection
5910
5911
5911
5912
5912 \begin_inset LatexCommand \label{sec:profiles}
5913 \begin_inset LatexCommand \label{sec:profiles}
5913
5914
5914 \end_inset
5915 \end_inset
5915
5916
5916 IPython profiles
5917 IPython profiles
5917 \layout Standard
5918 \layout Standard
5918
5919
5919 As we already mentioned, IPython supports the
5920 As we already mentioned, IPython supports the
5920 \family typewriter
5921 \family typewriter
5921 -profile
5922 -profile
5922 \family default
5923 \family default
5923 command-line option (see sec.
5924 command-line option (see sec.
5924
5925
5925 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5926 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5926
5927
5927 \end_inset
5928 \end_inset
5928
5929
5929 ).
5930 ).
5930 A profile is nothing more than a particular configuration file like your
5931 A profile is nothing more than a particular configuration file like your
5931 basic
5932 basic
5932 \family typewriter
5933 \family typewriter
5933 ipythonrc
5934 ipythonrc
5934 \family default
5935 \family default
5935 one, but with particular customizations for a specific purpose.
5936 one, but with particular customizations for a specific purpose.
5936 When you start IPython with '
5937 When you start IPython with '
5937 \family typewriter
5938 \family typewriter
5938 ipython -profile <name>
5939 ipython -profile <name>
5939 \family default
5940 \family default
5940 ', it assumes that in your
5941 ', it assumes that in your
5941 \family typewriter
5942 \family typewriter
5942 IPYTHONDIR
5943 IPYTHONDIR
5943 \family default
5944 \family default
5944 there is a file called
5945 there is a file called
5945 \family typewriter
5946 \family typewriter
5946 ipythonrc-<name>
5947 ipythonrc-<name>
5947 \family default
5948 \family default
5948 , and loads it instead of the normal
5949 , and loads it instead of the normal
5949 \family typewriter
5950 \family typewriter
5950 ipythonrc
5951 ipythonrc
5951 \family default
5952 \family default
5952 .
5953 .
5953 \layout Standard
5954 \layout Standard
5954
5955
5955 This system allows you to maintain multiple configurations which load modules,
5956 This system allows you to maintain multiple configurations which load modules,
5956 set options, define functions, etc.
5957 set options, define functions, etc.
5957 suitable for different tasks and activate them in a very simple manner.
5958 suitable for different tasks and activate them in a very simple manner.
5958 In order to avoid having to repeat all of your basic options (common things
5959 In order to avoid having to repeat all of your basic options (common things
5959 that don't change such as your color preferences, for example), any profile
5960 that don't change such as your color preferences, for example), any profile
5960 can include another configuration file.
5961 can include another configuration file.
5961 The most common way to use profiles is then to have each one include your
5962 The most common way to use profiles is then to have each one include your
5962 basic
5963 basic
5963 \family typewriter
5964 \family typewriter
5964 ipythonrc
5965 ipythonrc
5965 \family default
5966 \family default
5966 file as a starting point, and then add further customizations.
5967 file as a starting point, and then add further customizations.
5967 \layout Standard
5968 \layout Standard
5968
5969
5969 In sections
5970 In sections
5970 \begin_inset LatexCommand \ref{sec:syntax-extensions}
5971 \begin_inset LatexCommand \ref{sec:syntax-extensions}
5971
5972
5972 \end_inset
5973 \end_inset
5973
5974
5974 and
5975 and
5975 \begin_inset LatexCommand \ref{sec:Gnuplot}
5976 \begin_inset LatexCommand \ref{sec:Gnuplot}
5976
5977
5977 \end_inset
5978 \end_inset
5978
5979
5979 we discuss some particular profiles which come as part of the standard
5980 we discuss some particular profiles which come as part of the standard
5980 IPython distribution.
5981 IPython distribution.
5981 You may also look in your
5982 You may also look in your
5982 \family typewriter
5983 \family typewriter
5983 IPYTHONDIR
5984 IPYTHONDIR
5984 \family default
5985 \family default
5985 directory, any file whose name begins with
5986 directory, any file whose name begins with
5986 \family typewriter
5987 \family typewriter
5987 ipythonrc-
5988 ipythonrc-
5988 \family default
5989 \family default
5989 is a profile.
5990 is a profile.
5990 You can use those as examples for further customizations to suit your own
5991 You can use those as examples for further customizations to suit your own
5991 needs.
5992 needs.
5992 \layout Section
5993 \layout Section
5993
5994
5994
5995
5995 \begin_inset OptArg
5996 \begin_inset OptArg
5996 collapsed false
5997 collapsed false
5997
5998
5998 \layout Standard
5999 \layout Standard
5999
6000
6000 IPython as default...
6001 IPython as default...
6001 \end_inset
6002 \end_inset
6002
6003
6003 IPython as your default Python environment
6004 IPython as your default Python environment
6004 \layout Standard
6005 \layout Standard
6005
6006
6006 Python honors the environment variable
6007 Python honors the environment variable
6007 \family typewriter
6008 \family typewriter
6008 PYTHONSTARTUP
6009 PYTHONSTARTUP
6009 \family default
6010 \family default
6010 and will execute at startup the file referenced by this variable.
6011 and will execute at startup the file referenced by this variable.
6011 If you put at the end of this file the following two lines of code:
6012 If you put at the end of this file the following two lines of code:
6012 \layout Standard
6013 \layout Standard
6013
6014
6014
6015
6015 \family typewriter
6016 \family typewriter
6016 import IPython
6017 import IPython
6017 \newline
6018 \newline
6018 IPython.Shell.IPShell().mainloop(sys_exit=1)
6019 IPython.Shell.IPShell().mainloop(sys_exit=1)
6019 \layout Standard
6020 \layout Standard
6020
6021
6021 then IPython will be your working environment anytime you start Python.
6022 then IPython will be your working environment anytime you start Python.
6022 The
6023 The
6023 \family typewriter
6024 \family typewriter
6024 sys_exit=1
6025 sys_exit=1
6025 \family default
6026 \family default
6026 is needed to have IPython issue a call to
6027 is needed to have IPython issue a call to
6027 \family typewriter
6028 \family typewriter
6028 sys.exit()
6029 sys.exit()
6029 \family default
6030 \family default
6030 when it finishes, otherwise you'll be back at the normal Python '
6031 when it finishes, otherwise you'll be back at the normal Python '
6031 \family typewriter
6032 \family typewriter
6032 >>>
6033 >>>
6033 \family default
6034 \family default
6034 ' prompt
6035 ' prompt
6035 \begin_inset Foot
6036 \begin_inset Foot
6036 collapsed true
6037 collapsed true
6037
6038
6038 \layout Standard
6039 \layout Standard
6039
6040
6040 Based on an idea by Holger Krekel.
6041 Based on an idea by Holger Krekel.
6041 \end_inset
6042 \end_inset
6042
6043
6043 .
6044 .
6044 \layout Standard
6045 \layout Standard
6045
6046
6046 This is probably useful to developers who manage multiple Python versions
6047 This is probably useful to developers who manage multiple Python versions
6047 and don't want to have correspondingly multiple IPython versions.
6048 and don't want to have correspondingly multiple IPython versions.
6048 Note that in this mode, there is no way to pass IPython any command-line
6049 Note that in this mode, there is no way to pass IPython any command-line
6049 options, as those are trapped first by Python itself.
6050 options, as those are trapped first by Python itself.
6050 \layout Section
6051 \layout Section
6051
6052
6052
6053
6053 \begin_inset LatexCommand \label{sec:embed}
6054 \begin_inset LatexCommand \label{sec:embed}
6054
6055
6055 \end_inset
6056 \end_inset
6056
6057
6057 Embedding IPython
6058 Embedding IPython
6058 \layout Standard
6059 \layout Standard
6059
6060
6060 It is possible to start an IPython instance
6061 It is possible to start an IPython instance
6061 \emph on
6062 \emph on
6062 inside
6063 inside
6063 \emph default
6064 \emph default
6064 your own Python programs.
6065 your own Python programs.
6065 This allows you to evaluate dynamically the state of your code, operate
6066 This allows you to evaluate dynamically the state of your code, operate
6066 with your variables, analyze them, etc.
6067 with your variables, analyze them, etc.
6067 Note however that any changes you make to values while in the shell do
6068 Note however that any changes you make to values while in the shell do
6068
6069
6069 \emph on
6070 \emph on
6070 not
6071 not
6071 \emph default
6072 \emph default
6072 propagate back to the running code, so it is safe to modify your values
6073 propagate back to the running code, so it is safe to modify your values
6073 because you won't break your code in bizarre ways by doing so.
6074 because you won't break your code in bizarre ways by doing so.
6074 \layout Standard
6075 \layout Standard
6075
6076
6076 This feature allows you to easily have a fully functional python environment
6077 This feature allows you to easily have a fully functional python environment
6077 for doing object introspection anywhere in your code with a simple function
6078 for doing object introspection anywhere in your code with a simple function
6078 call.
6079 call.
6079 In some cases a simple print statement is enough, but if you need to do
6080 In some cases a simple print statement is enough, but if you need to do
6080 more detailed analysis of a code fragment this feature can be very valuable.
6081 more detailed analysis of a code fragment this feature can be very valuable.
6081 \layout Standard
6082 \layout Standard
6082
6083
6083 It can also be useful in scientific computing situations where it is common
6084 It can also be useful in scientific computing situations where it is common
6084 to need to do some automatic, computationally intensive part and then stop
6085 to need to do some automatic, computationally intensive part and then stop
6085 to look at data, plots, etc
6086 to look at data, plots, etc
6086 \begin_inset Foot
6087 \begin_inset Foot
6087 collapsed true
6088 collapsed true
6088
6089
6089 \layout Standard
6090 \layout Standard
6090
6091
6091 This functionality was inspired by IDL's combination of the
6092 This functionality was inspired by IDL's combination of the
6092 \family typewriter
6093 \family typewriter
6093 stop
6094 stop
6094 \family default
6095 \family default
6095 keyword and the
6096 keyword and the
6096 \family typewriter
6097 \family typewriter
6097 .continue
6098 .continue
6098 \family default
6099 \family default
6099 executive command, which I have found very useful in the past, and by a
6100 executive command, which I have found very useful in the past, and by a
6100 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6101 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6101 06/01 concerning similar uses of pyrepl.
6102 06/01 concerning similar uses of pyrepl.
6102 \end_inset
6103 \end_inset
6103
6104
6104 .
6105 .
6105 Opening an IPython instance will give you full access to your data and
6106 Opening an IPython instance will give you full access to your data and
6106 functions, and you can resume program execution once you are done with
6107 functions, and you can resume program execution once you are done with
6107 the interactive part (perhaps to stop again later, as many times as needed).
6108 the interactive part (perhaps to stop again later, as many times as needed).
6108 \layout Standard
6109 \layout Standard
6109
6110
6110 The following code snippet is the bare minimum you need to include in your
6111 The following code snippet is the bare minimum you need to include in your
6111 Python programs for this to work (detailed examples follow later):
6112 Python programs for this to work (detailed examples follow later):
6112 \layout LyX-Code
6113 \layout LyX-Code
6113
6114
6114 from IPython.Shell import IPShellEmbed
6115 from IPython.Shell import IPShellEmbed
6115 \layout LyX-Code
6116 \layout LyX-Code
6116
6117
6117 ipshell = IPShellEmbed()
6118 ipshell = IPShellEmbed()
6118 \layout LyX-Code
6119 \layout LyX-Code
6119
6120
6120 ipshell() # this call anywhere in your program will start IPython
6121 ipshell() # this call anywhere in your program will start IPython
6121 \layout Standard
6122 \layout Standard
6122
6123
6123 You can run embedded instances even in code which is itself being run at
6124 You can run embedded instances even in code which is itself being run at
6124 the IPython interactive prompt with '
6125 the IPython interactive prompt with '
6125 \family typewriter
6126 \family typewriter
6126 %run\SpecialChar ~
6127 %run\SpecialChar ~
6127 <filename>
6128 <filename>
6128 \family default
6129 \family default
6129 '.
6130 '.
6130 Since it's easy to get lost as to where you are (in your top-level IPython
6131 Since it's easy to get lost as to where you are (in your top-level IPython
6131 or in your embedded one), it's a good idea in such cases to set the in/out
6132 or in your embedded one), it's a good idea in such cases to set the in/out
6132 prompts to something different for the embedded instances.
6133 prompts to something different for the embedded instances.
6133 The code examples below illustrate this.
6134 The code examples below illustrate this.
6134 \layout Standard
6135 \layout Standard
6135
6136
6136 You can also have multiple IPython instances in your program and open them
6137 You can also have multiple IPython instances in your program and open them
6137 separately, for example with different options for data presentation.
6138 separately, for example with different options for data presentation.
6138 If you close and open the same instance multiple times, its prompt counters
6139 If you close and open the same instance multiple times, its prompt counters
6139 simply continue from each execution to the next.
6140 simply continue from each execution to the next.
6140 \layout Standard
6141 \layout Standard
6141
6142
6142 Please look at the docstrings in the
6143 Please look at the docstrings in the
6143 \family typewriter
6144 \family typewriter
6144 Shell.py
6145 Shell.py
6145 \family default
6146 \family default
6146 module for more details on the use of this system.
6147 module for more details on the use of this system.
6147 \layout Standard
6148 \layout Standard
6148
6149
6149 The following sample file illustrating how to use the embedding functionality
6150 The following sample file illustrating how to use the embedding functionality
6150 is provided in the examples directory as
6151 is provided in the examples directory as
6151 \family typewriter
6152 \family typewriter
6152 example-embed.py
6153 example-embed.py
6153 \family default
6154 \family default
6154 .
6155 .
6155 It should be fairly self-explanatory:
6156 It should be fairly self-explanatory:
6156 \layout Standard
6157 \layout Standard
6157
6158
6158
6159
6159 \begin_inset ERT
6160 \begin_inset ERT
6160 status Open
6161 status Open
6161
6162
6162 \layout Standard
6163 \layout Standard
6163
6164
6164 \backslash
6165 \backslash
6165 codelist{examples/example-embed.py}
6166 codelist{examples/example-embed.py}
6166 \end_inset
6167 \end_inset
6167
6168
6168
6169
6169 \layout Standard
6170 \layout Standard
6170
6171
6171 Once you understand how the system functions, you can use the following
6172 Once you understand how the system functions, you can use the following
6172 code fragments in your programs which are ready for cut and paste:
6173 code fragments in your programs which are ready for cut and paste:
6173 \layout Standard
6174 \layout Standard
6174
6175
6175
6176
6176 \begin_inset ERT
6177 \begin_inset ERT
6177 status Open
6178 status Open
6178
6179
6179 \layout Standard
6180 \layout Standard
6180
6181
6181 \backslash
6182 \backslash
6182 codelist{examples/example-embed-short.py}
6183 codelist{examples/example-embed-short.py}
6183 \end_inset
6184 \end_inset
6184
6185
6185
6186
6186 \layout Section
6187 \layout Section
6187
6188
6188
6189
6189 \begin_inset LatexCommand \label{sec:using-pdb}
6190 \begin_inset LatexCommand \label{sec:using-pdb}
6190
6191
6191 \end_inset
6192 \end_inset
6192
6193
6193 Using the Python debugger (
6194 Using the Python debugger (
6194 \family typewriter
6195 \family typewriter
6195 pdb
6196 pdb
6196 \family default
6197 \family default
6197 )
6198 )
6198 \layout Subsection
6199 \layout Subsection
6199
6200
6200 Running entire programs via
6201 Running entire programs via
6201 \family typewriter
6202 \family typewriter
6202 pdb
6203 pdb
6203 \layout Standard
6204 \layout Standard
6204
6205
6205
6206
6206 \family typewriter
6207 \family typewriter
6207 pdb
6208 pdb
6208 \family default
6209 \family default
6209 , the Python debugger, is a powerful interactive debugger which allows you
6210 , the Python debugger, is a powerful interactive debugger which allows you
6210 to step through code, set breakpoints, watch variables, etc.
6211 to step through code, set breakpoints, watch variables, etc.
6211 IPython makes it very easy to start any script under the control of
6212 IPython makes it very easy to start any script under the control of
6212 \family typewriter
6213 \family typewriter
6213 pdb
6214 pdb
6214 \family default
6215 \family default
6215 , regardless of whether you have wrapped it into a
6216 , regardless of whether you have wrapped it into a
6216 \family typewriter
6217 \family typewriter
6217 `main()'
6218 `main()'
6218 \family default
6219 \family default
6219 function or not.
6220 function or not.
6220 For this, simply type
6221 For this, simply type
6221 \family typewriter
6222 \family typewriter
6222 `%run -d myscript'
6223 `%run -d myscript'
6223 \family default
6224 \family default
6224 at an IPython prompt.
6225 at an IPython prompt.
6225 See the
6226 See the
6226 \family typewriter
6227 \family typewriter
6227 %run
6228 %run
6228 \family default
6229 \family default
6229 command's documentation (via
6230 command's documentation (via
6230 \family typewriter
6231 \family typewriter
6231 `%run?'
6232 `%run?'
6232 \family default
6233 \family default
6233 or in Sec.\SpecialChar ~
6234 or in Sec.\SpecialChar ~
6234
6235
6235 \begin_inset LatexCommand \ref{sec:magic}
6236 \begin_inset LatexCommand \ref{sec:magic}
6236
6237
6237 \end_inset
6238 \end_inset
6238
6239
6239 ) for more details, including how to control where
6240 ) for more details, including how to control where
6240 \family typewriter
6241 \family typewriter
6241 pdb
6242 pdb
6242 \family default
6243 \family default
6243 will stop execution first.
6244 will stop execution first.
6244 \layout Standard
6245 \layout Standard
6245
6246
6246 For more information on the use of the
6247 For more information on the use of the
6247 \family typewriter
6248 \family typewriter
6248 pdb
6249 pdb
6249 \family default
6250 \family default
6250 debugger, read the included
6251 debugger, read the included
6251 \family typewriter
6252 \family typewriter
6252 pdb.doc
6253 pdb.doc
6253 \family default
6254 \family default
6254 file (part of the standard Python distribution).
6255 file (part of the standard Python distribution).
6255 On a stock Linux system it is located at
6256 On a stock Linux system it is located at
6256 \family typewriter
6257 \family typewriter
6257 /usr/lib/python2.3/pdb.doc
6258 /usr/lib/python2.3/pdb.doc
6258 \family default
6259 \family default
6259 , but the easiest way to read it is by using the
6260 , but the easiest way to read it is by using the
6260 \family typewriter
6261 \family typewriter
6261 help()
6262 help()
6262 \family default
6263 \family default
6263 function of the
6264 function of the
6264 \family typewriter
6265 \family typewriter
6265 pdb
6266 pdb
6266 \family default
6267 \family default
6267 module as follows (in an IPython prompt):
6268 module as follows (in an IPython prompt):
6268 \layout Standard
6269 \layout Standard
6269
6270
6270
6271
6271 \family typewriter
6272 \family typewriter
6272 In [1]: import pdb
6273 In [1]: import pdb
6273 \newline
6274 \newline
6274 In [2]: pdb.help()
6275 In [2]: pdb.help()
6275 \layout Standard
6276 \layout Standard
6276
6277
6277 This will load the
6278 This will load the
6278 \family typewriter
6279 \family typewriter
6279 pdb.doc
6280 pdb.doc
6280 \family default
6281 \family default
6281 document in a file viewer for you automatically.
6282 document in a file viewer for you automatically.
6282 \layout Subsection
6283 \layout Subsection
6283
6284
6284 Automatic invocation of
6285 Automatic invocation of
6285 \family typewriter
6286 \family typewriter
6286 pdb
6287 pdb
6287 \family default
6288 \family default
6288 on exceptions
6289 on exceptions
6289 \layout Standard
6290 \layout Standard
6290
6291
6291 IPython, if started with the
6292 IPython, if started with the
6292 \family typewriter
6293 \family typewriter
6293 -pdb
6294 -pdb
6294 \family default
6295 \family default
6295 option (or if the option is set in your rc file) can call the Python
6296 option (or if the option is set in your rc file) can call the Python
6296 \family typewriter
6297 \family typewriter
6297 pdb
6298 pdb
6298 \family default
6299 \family default
6299 debugger every time your code triggers an uncaught exception
6300 debugger every time your code triggers an uncaught exception
6300 \begin_inset Foot
6301 \begin_inset Foot
6301 collapsed true
6302 collapsed true
6302
6303
6303 \layout Standard
6304 \layout Standard
6304
6305
6305 Many thanks to Christopher Hart for the request which prompted adding this
6306 Many thanks to Christopher Hart for the request which prompted adding this
6306 feature to IPython.
6307 feature to IPython.
6307 \end_inset
6308 \end_inset
6308
6309
6309 .
6310 .
6310 This feature can also be toggled at any time with the
6311 This feature can also be toggled at any time with the
6311 \family typewriter
6312 \family typewriter
6312 %pdb
6313 %pdb
6313 \family default
6314 \family default
6314 magic command.
6315 magic command.
6315 This can be extremely useful in order to find the origin of subtle bugs,
6316 This can be extremely useful in order to find the origin of subtle bugs,
6316 because
6317 because
6317 \family typewriter
6318 \family typewriter
6318 pdb
6319 pdb
6319 \family default
6320 \family default
6320 opens up at the point in your code which triggered the exception, and while
6321 opens up at the point in your code which triggered the exception, and while
6321 your program is at this point `dead', all the data is still available and
6322 your program is at this point `dead', all the data is still available and
6322 you can walk up and down the stack frame and understand the origin of the
6323 you can walk up and down the stack frame and understand the origin of the
6323 problem.
6324 problem.
6324 \layout Standard
6325 \layout Standard
6325
6326
6326 Furthermore, you can use these debugging facilities both with the embedded
6327 Furthermore, you can use these debugging facilities both with the embedded
6327 IPython mode and without IPython at all.
6328 IPython mode and without IPython at all.
6328 For an embedded shell (see sec.
6329 For an embedded shell (see sec.
6329
6330
6330 \begin_inset LatexCommand \ref{sec:embed}
6331 \begin_inset LatexCommand \ref{sec:embed}
6331
6332
6332 \end_inset
6333 \end_inset
6333
6334
6334 ), simply call the constructor with
6335 ), simply call the constructor with
6335 \family typewriter
6336 \family typewriter
6336 `-pdb'
6337 `-pdb'
6337 \family default
6338 \family default
6338 in the argument string and automatically
6339 in the argument string and automatically
6339 \family typewriter
6340 \family typewriter
6340 pdb
6341 pdb
6341 \family default
6342 \family default
6342 will be called if an uncaught exception is triggered by your code.
6343 will be called if an uncaught exception is triggered by your code.
6343
6344
6344 \layout Standard
6345 \layout Standard
6345
6346
6346 For stand-alone use of the feature in your programs which do not use IPython
6347 For stand-alone use of the feature in your programs which do not use IPython
6347 at all, put the following lines toward the top of your `main' routine:
6348 at all, put the following lines toward the top of your `main' routine:
6348 \layout Standard
6349 \layout Standard
6349 \align left
6350 \align left
6350
6351
6351 \family typewriter
6352 \family typewriter
6352 import sys,IPython.ultraTB
6353 import sys,IPython.ultraTB
6353 \newline
6354 \newline
6354 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6355 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6355 call_pdb=1)
6356 call_pdb=1)
6356 \layout Standard
6357 \layout Standard
6357
6358
6358 The
6359 The
6359 \family typewriter
6360 \family typewriter
6360 mode
6361 mode
6361 \family default
6362 \family default
6362 keyword can be either
6363 keyword can be either
6363 \family typewriter
6364 \family typewriter
6364 `Verbose'
6365 `Verbose'
6365 \family default
6366 \family default
6366 or
6367 or
6367 \family typewriter
6368 \family typewriter
6368 `Plain'
6369 `Plain'
6369 \family default
6370 \family default
6370 , giving either very detailed or normal tracebacks respectively.
6371 , giving either very detailed or normal tracebacks respectively.
6371 The
6372 The
6372 \family typewriter
6373 \family typewriter
6373 color_scheme
6374 color_scheme
6374 \family default
6375 \family default
6375 keyword can be one of
6376 keyword can be one of
6376 \family typewriter
6377 \family typewriter
6377 `NoColor'
6378 `NoColor'
6378 \family default
6379 \family default
6379 ,
6380 ,
6380 \family typewriter
6381 \family typewriter
6381 `Linux'
6382 `Linux'
6382 \family default
6383 \family default
6383 (default) or
6384 (default) or
6384 \family typewriter
6385 \family typewriter
6385 `LightBG'
6386 `LightBG'
6386 \family default
6387 \family default
6387 .
6388 .
6388 These are the same options which can be set in IPython with
6389 These are the same options which can be set in IPython with
6389 \family typewriter
6390 \family typewriter
6390 -colors
6391 -colors
6391 \family default
6392 \family default
6392 and
6393 and
6393 \family typewriter
6394 \family typewriter
6394 -xmode
6395 -xmode
6395 \family default
6396 \family default
6396 .
6397 .
6397 \layout Standard
6398 \layout Standard
6398
6399
6399 This will give any of your programs detailed, colored tracebacks with automatic
6400 This will give any of your programs detailed, colored tracebacks with automatic
6400 invocation of
6401 invocation of
6401 \family typewriter
6402 \family typewriter
6402 pdb
6403 pdb
6403 \family default
6404 \family default
6404 .
6405 .
6405 \layout Section
6406 \layout Section
6406
6407
6407
6408
6408 \begin_inset LatexCommand \label{sec:syntax-extensions}
6409 \begin_inset LatexCommand \label{sec:syntax-extensions}
6409
6410
6410 \end_inset
6411 \end_inset
6411
6412
6412 Extensions for syntax processing
6413 Extensions for syntax processing
6413 \layout Standard
6414 \layout Standard
6414
6415
6415 This isn't for the faint of heart, because the potential for breaking things
6416 This isn't for the faint of heart, because the potential for breaking things
6416 is quite high.
6417 is quite high.
6417 But it can be a very powerful and useful feature.
6418 But it can be a very powerful and useful feature.
6418 In a nutshell, you can redefine the way IPython processes the user input
6419 In a nutshell, you can redefine the way IPython processes the user input
6419 line to accept new, special extensions to the syntax without needing to
6420 line to accept new, special extensions to the syntax without needing to
6420 change any of IPython's own code.
6421 change any of IPython's own code.
6421 \layout Standard
6422 \layout Standard
6422
6423
6423 In the
6424 In the
6424 \family typewriter
6425 \family typewriter
6425 IPython/Extensions
6426 IPython/Extensions
6426 \family default
6427 \family default
6427 directory you will find some examples supplied, which we will briefly describe
6428 directory you will find some examples supplied, which we will briefly describe
6428 now.
6429 now.
6429 These can be used `as is' (and both provide very useful functionality),
6430 These can be used `as is' (and both provide very useful functionality),
6430 or you can use them as a starting point for writing your own extensions.
6431 or you can use them as a starting point for writing your own extensions.
6431 \layout Subsection
6432 \layout Subsection
6432
6433
6433 Pasting of code starting with
6434 Pasting of code starting with
6434 \family typewriter
6435 \family typewriter
6435 `>>>
6436 `>>>
6436 \family default
6437 \family default
6437 ' or
6438 ' or
6438 \family typewriter
6439 \family typewriter
6439 `...
6440 `...
6440
6441
6441 \family default
6442 \family default
6442 '
6443 '
6443 \layout Standard
6444 \layout Standard
6444
6445
6445 In the python tutorial it is common to find code examples which have been
6446 In the python tutorial it is common to find code examples which have been
6446 taken from real python sessions.
6447 taken from real python sessions.
6447 The problem with those is that all the lines begin with either
6448 The problem with those is that all the lines begin with either
6448 \family typewriter
6449 \family typewriter
6449 `>>>
6450 `>>>
6450 \family default
6451 \family default
6451 ' or
6452 ' or
6452 \family typewriter
6453 \family typewriter
6453 `...
6454 `...
6454
6455
6455 \family default
6456 \family default
6456 ', which makes it impossible to paste them all at once.
6457 ', which makes it impossible to paste them all at once.
6457 One must instead do a line by line manual copying, carefully removing the
6458 One must instead do a line by line manual copying, carefully removing the
6458 leading extraneous characters.
6459 leading extraneous characters.
6459 \layout Standard
6460 \layout Standard
6460
6461
6461 This extension identifies those starting characters and removes them from
6462 This extension identifies those starting characters and removes them from
6462 the input automatically, so that one can paste multi-line examples directly
6463 the input automatically, so that one can paste multi-line examples directly
6463 into IPython, saving a lot of time.
6464 into IPython, saving a lot of time.
6464 Please look at the file
6465 Please look at the file
6465 \family typewriter
6466 \family typewriter
6466 InterpreterPasteInput.py
6467 InterpreterPasteInput.py
6467 \family default
6468 \family default
6468 in the
6469 in the
6469 \family typewriter
6470 \family typewriter
6470 IPython/Extensions
6471 IPython/Extensions
6471 \family default
6472 \family default
6472 directory for details on how this is done.
6473 directory for details on how this is done.
6473 \layout Standard
6474 \layout Standard
6474
6475
6475 IPython comes with a special profile enabling this feature, called
6476 IPython comes with a special profile enabling this feature, called
6476 \family typewriter
6477 \family typewriter
6477 tutorial
6478 tutorial
6478 \family default
6479 \family default
6479 \emph on
6480 \emph on
6480 .
6481 .
6481
6482
6482 \emph default
6483 \emph default
6483 Simply start IPython via
6484 Simply start IPython via
6484 \family typewriter
6485 \family typewriter
6485 `ipython\SpecialChar ~
6486 `ipython\SpecialChar ~
6486 -p\SpecialChar ~
6487 -p\SpecialChar ~
6487 tutorial'
6488 tutorial'
6488 \family default
6489 \family default
6489 and the feature will be available.
6490 and the feature will be available.
6490 In a normal IPython session you can activate the feature by importing the
6491 In a normal IPython session you can activate the feature by importing the
6491 corresponding module with:
6492 corresponding module with:
6492 \newline
6493 \newline
6493
6494
6494 \family typewriter
6495 \family typewriter
6495 In [1]: import IPython.Extensions.InterpreterPasteInput
6496 In [1]: import IPython.Extensions.InterpreterPasteInput
6496 \layout Standard
6497 \layout Standard
6497
6498
6498 The following is a 'screenshot' of how things work when this extension is
6499 The following is a 'screenshot' of how things work when this extension is
6499 on, copying an example from the standard tutorial:
6500 on, copying an example from the standard tutorial:
6500 \layout Standard
6501 \layout Standard
6501
6502
6502
6503
6503 \family typewriter
6504 \family typewriter
6504 IPython profile: tutorial
6505 IPython profile: tutorial
6505 \newline
6506 \newline
6506 \SpecialChar ~
6507 \SpecialChar ~
6507
6508
6508 \newline
6509 \newline
6509 *** Pasting of code with ">>>" or "..." has been enabled.
6510 *** Pasting of code with ">>>" or "..." has been enabled.
6510 \newline
6511 \newline
6511 \SpecialChar ~
6512 \SpecialChar ~
6512
6513
6513 \newline
6514 \newline
6514 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6515 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6515 \newline
6516 \newline
6516
6517
6517 \begin_inset ERT
6518 \begin_inset ERT
6518 status Collapsed
6519 status Collapsed
6519
6520
6520 \layout Standard
6521 \layout Standard
6521
6522
6522 \backslash
6523 \backslash
6523 hspace*{0mm}
6524 hspace*{0mm}
6524 \end_inset
6525 \end_inset
6525
6526
6526 \SpecialChar ~
6527 \SpecialChar ~
6527 \SpecialChar ~
6528 \SpecialChar ~
6528 ...: ...\SpecialChar ~
6529 ...: ...\SpecialChar ~
6529 \SpecialChar ~
6530 \SpecialChar ~
6530 \SpecialChar ~
6531 \SpecialChar ~
6531 \SpecialChar ~
6532 \SpecialChar ~
6532 """Return a list containing the Fibonacci series up to n."""
6533 """Return a list containing the Fibonacci series up to n."""
6533 \newline
6534 \newline
6534
6535
6535 \begin_inset ERT
6536 \begin_inset ERT
6536 status Collapsed
6537 status Collapsed
6537
6538
6538 \layout Standard
6539 \layout Standard
6539
6540
6540 \backslash
6541 \backslash
6541 hspace*{0mm}
6542 hspace*{0mm}
6542 \end_inset
6543 \end_inset
6543
6544
6544 \SpecialChar ~
6545 \SpecialChar ~
6545 \SpecialChar ~
6546 \SpecialChar ~
6546 ...: ...\SpecialChar ~
6547 ...: ...\SpecialChar ~
6547 \SpecialChar ~
6548 \SpecialChar ~
6548 \SpecialChar ~
6549 \SpecialChar ~
6549 \SpecialChar ~
6550 \SpecialChar ~
6550 result = []
6551 result = []
6551 \newline
6552 \newline
6552
6553
6553 \begin_inset ERT
6554 \begin_inset ERT
6554 status Collapsed
6555 status Collapsed
6555
6556
6556 \layout Standard
6557 \layout Standard
6557
6558
6558 \backslash
6559 \backslash
6559 hspace*{0mm}
6560 hspace*{0mm}
6560 \end_inset
6561 \end_inset
6561
6562
6562 \SpecialChar ~
6563 \SpecialChar ~
6563 \SpecialChar ~
6564 \SpecialChar ~
6564 ...: ...\SpecialChar ~
6565 ...: ...\SpecialChar ~
6565 \SpecialChar ~
6566 \SpecialChar ~
6566 \SpecialChar ~
6567 \SpecialChar ~
6567 \SpecialChar ~
6568 \SpecialChar ~
6568 a, b = 0, 1
6569 a, b = 0, 1
6569 \newline
6570 \newline
6570
6571
6571 \begin_inset ERT
6572 \begin_inset ERT
6572 status Collapsed
6573 status Collapsed
6573
6574
6574 \layout Standard
6575 \layout Standard
6575
6576
6576 \backslash
6577 \backslash
6577 hspace*{0mm}
6578 hspace*{0mm}
6578 \end_inset
6579 \end_inset
6579
6580
6580 \SpecialChar ~
6581 \SpecialChar ~
6581 \SpecialChar ~
6582 \SpecialChar ~
6582 ...: ...\SpecialChar ~
6583 ...: ...\SpecialChar ~
6583 \SpecialChar ~
6584 \SpecialChar ~
6584 \SpecialChar ~
6585 \SpecialChar ~
6585 \SpecialChar ~
6586 \SpecialChar ~
6586 while b < n:
6587 while b < n:
6587 \newline
6588 \newline
6588
6589
6589 \begin_inset ERT
6590 \begin_inset ERT
6590 status Collapsed
6591 status Collapsed
6591
6592
6592 \layout Standard
6593 \layout Standard
6593
6594
6594 \backslash
6595 \backslash
6595 hspace*{0mm}
6596 hspace*{0mm}
6596 \end_inset
6597 \end_inset
6597
6598
6598 \SpecialChar ~
6599 \SpecialChar ~
6599 \SpecialChar ~
6600 \SpecialChar ~
6600 ...: ...\SpecialChar ~
6601 ...: ...\SpecialChar ~
6601 \SpecialChar ~
6602 \SpecialChar ~
6602 \SpecialChar ~
6603 \SpecialChar ~
6603 \SpecialChar ~
6604 \SpecialChar ~
6604 \SpecialChar ~
6605 \SpecialChar ~
6605 \SpecialChar ~
6606 \SpecialChar ~
6606 \SpecialChar ~
6607 \SpecialChar ~
6607 \SpecialChar ~
6608 \SpecialChar ~
6608 result.append(b)\SpecialChar ~
6609 result.append(b)\SpecialChar ~
6609 \SpecialChar ~
6610 \SpecialChar ~
6610 \SpecialChar ~
6611 \SpecialChar ~
6611 # see below
6612 # see below
6612 \newline
6613 \newline
6613
6614
6614 \begin_inset ERT
6615 \begin_inset ERT
6615 status Collapsed
6616 status Collapsed
6616
6617
6617 \layout Standard
6618 \layout Standard
6618
6619
6619 \backslash
6620 \backslash
6620 hspace*{0mm}
6621 hspace*{0mm}
6621 \end_inset
6622 \end_inset
6622
6623
6623 \SpecialChar ~
6624 \SpecialChar ~
6624 \SpecialChar ~
6625 \SpecialChar ~
6625 ...: ...\SpecialChar ~
6626 ...: ...\SpecialChar ~
6626 \SpecialChar ~
6627 \SpecialChar ~
6627 \SpecialChar ~
6628 \SpecialChar ~
6628 \SpecialChar ~
6629 \SpecialChar ~
6629 \SpecialChar ~
6630 \SpecialChar ~
6630 \SpecialChar ~
6631 \SpecialChar ~
6631 \SpecialChar ~
6632 \SpecialChar ~
6632 \SpecialChar ~
6633 \SpecialChar ~
6633 a, b = b, a+b
6634 a, b = b, a+b
6634 \newline
6635 \newline
6635
6636
6636 \begin_inset ERT
6637 \begin_inset ERT
6637 status Collapsed
6638 status Collapsed
6638
6639
6639 \layout Standard
6640 \layout Standard
6640
6641
6641 \backslash
6642 \backslash
6642 hspace*{0mm}
6643 hspace*{0mm}
6643 \end_inset
6644 \end_inset
6644
6645
6645 \SpecialChar ~
6646 \SpecialChar ~
6646 \SpecialChar ~
6647 \SpecialChar ~
6647 ...: ...\SpecialChar ~
6648 ...: ...\SpecialChar ~
6648 \SpecialChar ~
6649 \SpecialChar ~
6649 \SpecialChar ~
6650 \SpecialChar ~
6650 \SpecialChar ~
6651 \SpecialChar ~
6651 return result
6652 return result
6652 \newline
6653 \newline
6653
6654
6654 \begin_inset ERT
6655 \begin_inset ERT
6655 status Collapsed
6656 status Collapsed
6656
6657
6657 \layout Standard
6658 \layout Standard
6658
6659
6659 \backslash
6660 \backslash
6660 hspace*{0mm}
6661 hspace*{0mm}
6661 \end_inset
6662 \end_inset
6662
6663
6663 \SpecialChar ~
6664 \SpecialChar ~
6664 \SpecialChar ~
6665 \SpecialChar ~
6665 ...:
6666 ...:
6666 \newline
6667 \newline
6667 \SpecialChar ~
6668 \SpecialChar ~
6668
6669
6669 \newline
6670 \newline
6670 In [2]: fib2(10)
6671 In [2]: fib2(10)
6671 \newline
6672 \newline
6672 Out[2]: [1, 1, 2, 3, 5, 8]
6673 Out[2]: [1, 1, 2, 3, 5, 8]
6673 \layout Standard
6674 \layout Standard
6674
6675
6675 Note that as currently written, this extension does
6676 Note that as currently written, this extension does
6676 \emph on
6677 \emph on
6677 not
6678 not
6678 \emph default
6679 \emph default
6679 recognize IPython's prompts for pasting.
6680 recognize IPython's prompts for pasting.
6680 Those are more complicated, since the user can change them very easily,
6681 Those are more complicated, since the user can change them very easily,
6681 they involve numbers and can vary in length.
6682 they involve numbers and can vary in length.
6682 One could however extract all the relevant information from the IPython
6683 One could however extract all the relevant information from the IPython
6683 instance and build an appropriate regular expression.
6684 instance and build an appropriate regular expression.
6684 This is left as an exercise for the reader.
6685 This is left as an exercise for the reader.
6685 \layout Subsection
6686 \layout Subsection
6686
6687
6687 Input of physical quantities with units
6688 Input of physical quantities with units
6688 \layout Standard
6689 \layout Standard
6689
6690
6690 The module
6691 The module
6691 \family typewriter
6692 \family typewriter
6692 PhysicalQInput
6693 PhysicalQInput
6693 \family default
6694 \family default
6694 allows a simplified form of input for physical quantities with units.
6695 allows a simplified form of input for physical quantities with units.
6695 This file is meant to be used in conjunction with the
6696 This file is meant to be used in conjunction with the
6696 \family typewriter
6697 \family typewriter
6697 PhysicalQInteractive
6698 PhysicalQInteractive
6698 \family default
6699 \family default
6699 module (in the same directory) and
6700 module (in the same directory) and
6700 \family typewriter
6701 \family typewriter
6701 Physics.PhysicalQuantities
6702 Physics.PhysicalQuantities
6702 \family default
6703 \family default
6703 from Konrad Hinsen's ScientificPython (
6704 from Konrad Hinsen's ScientificPython (
6704 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6705 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6705
6706
6706 \end_inset
6707 \end_inset
6707
6708
6708 ).
6709 ).
6709 \layout Standard
6710 \layout Standard
6710
6711
6711 The
6712 The
6712 \family typewriter
6713 \family typewriter
6713 Physics.PhysicalQuantities
6714 Physics.PhysicalQuantities
6714 \family default
6715 \family default
6715 module defines
6716 module defines
6716 \family typewriter
6717 \family typewriter
6717 PhysicalQuantity
6718 PhysicalQuantity
6718 \family default
6719 \family default
6719 objects, but these must be declared as instances of a class.
6720 objects, but these must be declared as instances of a class.
6720 For example, to define
6721 For example, to define
6721 \family typewriter
6722 \family typewriter
6722 v
6723 v
6723 \family default
6724 \family default
6724 as a velocity of 3\SpecialChar ~
6725 as a velocity of 3\SpecialChar ~
6725 m/s, normally you would write:
6726 m/s, normally you would write:
6726 \family typewriter
6727 \family typewriter
6727
6728
6728 \newline
6729 \newline
6729 In [1]: v = PhysicalQuantity(3,'m/s')
6730 In [1]: v = PhysicalQuantity(3,'m/s')
6730 \layout Standard
6731 \layout Standard
6731
6732
6732 Using the
6733 Using the
6733 \family typewriter
6734 \family typewriter
6734 PhysicalQ_Input
6735 PhysicalQ_Input
6735 \family default
6736 \family default
6736 extension this can be input instead as:
6737 extension this can be input instead as:
6737 \family typewriter
6738 \family typewriter
6738
6739
6739 \newline
6740 \newline
6740 In [1]: v = 3 m/s
6741 In [1]: v = 3 m/s
6741 \family default
6742 \family default
6742
6743
6743 \newline
6744 \newline
6744 which is much more convenient for interactive use (even though it is blatantly
6745 which is much more convenient for interactive use (even though it is blatantly
6745 invalid Python syntax).
6746 invalid Python syntax).
6746 \layout Standard
6747 \layout Standard
6747
6748
6748 The
6749 The
6749 \family typewriter
6750 \family typewriter
6750 physics
6751 physics
6751 \family default
6752 \family default
6752 profile supplied with IPython (enabled via
6753 profile supplied with IPython (enabled via
6753 \family typewriter
6754 \family typewriter
6754 'ipython -p physics'
6755 'ipython -p physics'
6755 \family default
6756 \family default
6756 ) uses these extensions, which you can also activate with:
6757 ) uses these extensions, which you can also activate with:
6757 \layout Standard
6758 \layout Standard
6758
6759
6759
6760
6760 \family typewriter
6761 \family typewriter
6761 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6762 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6762 \newline
6763 \newline
6763 from IPython.Extensions.PhysicalQInteractive import *
6764 from IPython.Extensions.PhysicalQInteractive import *
6764 \newline
6765 \newline
6765 import IPython.Extensions.PhysicalQInput
6766 import IPython.Extensions.PhysicalQInput
6766 \layout Section
6767 \layout Section
6767
6768
6768 IPython as a system shell
6769 IPython as a system shell
6769 \layout Standard
6770 \layout Standard
6770
6771
6771 IPython ships with a special profile called
6772 IPython ships with a special profile called
6772 \family typewriter
6773 \family typewriter
6773 pysh
6774 pysh
6774 \family default
6775 \family default
6775 , which you can activate at the command line as
6776 , which you can activate at the command line as
6776 \family typewriter
6777 \family typewriter
6777 `ipython -p pysh'
6778 `ipython -p pysh'
6778 \family default
6779 \family default
6779 .
6780 .
6780 This loads
6781 This loads
6781 \family typewriter
6782 \family typewriter
6782 InterpreterExec
6783 InterpreterExec
6783 \family default
6784 \family default
6784 , along with some additional facilities and a prompt customized for filesystem
6785 , along with some additional facilities and a prompt customized for filesystem
6785 navigation.
6786 navigation.
6786 \layout Standard
6787 \layout Standard
6787
6788
6788 Note that this does
6789 Note that this does
6789 \emph on
6790 \emph on
6790 not
6791 not
6791 \emph default
6792 \emph default
6792 make IPython a full-fledged system shell.
6793 make IPython a full-fledged system shell.
6793 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6794 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6794 you'll suspend pysh itself, not the process you just started.
6795 you'll suspend pysh itself, not the process you just started.
6795
6796
6796 \layout Standard
6797 \layout Standard
6797
6798
6798 What the shell profile allows you to do is to use the convenient and powerful
6799 What the shell profile allows you to do is to use the convenient and powerful
6799 syntax of Python to do quick scripting at the command line.
6800 syntax of Python to do quick scripting at the command line.
6800 Below we describe some of its features.
6801 Below we describe some of its features.
6801 \layout Subsection
6802 \layout Subsection
6802
6803
6803 Aliases
6804 Aliases
6804 \layout Standard
6805 \layout Standard
6805
6806
6806 All of your
6807 All of your
6807 \family typewriter
6808 \family typewriter
6808 $PATH
6809 $PATH
6809 \family default
6810 \family default
6810 has been loaded as IPython aliases, so you should be able to type any normal
6811 has been loaded as IPython aliases, so you should be able to type any normal
6811 system command and have it executed.
6812 system command and have it executed.
6812 See
6813 See
6813 \family typewriter
6814 \family typewriter
6814 %alias?
6815 %alias?
6815 \family default
6816 \family default
6816 and
6817 and
6817 \family typewriter
6818 \family typewriter
6818 %unalias?
6819 %unalias?
6819 \family default
6820 \family default
6820 for details on the alias facilities.
6821 for details on the alias facilities.
6821 See also
6822 See also
6822 \family typewriter
6823 \family typewriter
6823 %rehash?
6824 %rehash?
6824 \family default
6825 \family default
6825 and
6826 and
6826 \family typewriter
6827 \family typewriter
6827 %rehashx?
6828 %rehashx?
6828 \family default
6829 \family default
6829 for details on the mechanism used to load
6830 for details on the mechanism used to load
6830 \family typewriter
6831 \family typewriter
6831 $PATH
6832 $PATH
6832 \family default
6833 \family default
6833 .
6834 .
6834 \layout Subsection
6835 \layout Subsection
6835
6836
6836 Special syntax
6837 Special syntax
6837 \layout Standard
6838 \layout Standard
6838
6839
6839 Any lines which begin with
6840 Any lines which begin with
6840 \family typewriter
6841 \family typewriter
6841 `~'
6842 `~'
6842 \family default
6843 \family default
6843 ,
6844 ,
6844 \family typewriter
6845 \family typewriter
6845 `/'
6846 `/'
6846 \family default
6847 \family default
6847 and
6848 and
6848 \family typewriter
6849 \family typewriter
6849 `.'
6850 `.'
6850 \family default
6851 \family default
6851 will be executed as shell commands instead of as Python code.
6852 will be executed as shell commands instead of as Python code.
6852 The special escapes below are also recognized.
6853 The special escapes below are also recognized.
6853
6854
6854 \family typewriter
6855 \family typewriter
6855 !cmd
6856 !cmd
6856 \family default
6857 \family default
6857 is valid in single or multi-line input, all others are only valid in single-lin
6858 is valid in single or multi-line input, all others are only valid in single-lin
6858 e input:
6859 e input:
6859 \layout Description
6860 \layout Description
6860
6861
6861
6862
6862 \family typewriter
6863 \family typewriter
6863 !cmd
6864 !cmd
6864 \family default
6865 \family default
6865 pass `cmd' directly to the shell
6866 pass `cmd' directly to the shell
6866 \layout Description
6867 \layout Description
6867
6868
6868
6869
6869 \family typewriter
6870 \family typewriter
6870 !!cmd
6871 !!cmd
6871 \family default
6872 \family default
6872 execute `cmd' and return output as a list (split on `
6873 execute `cmd' and return output as a list (split on `
6873 \backslash
6874 \backslash
6874 n')
6875 n')
6875 \layout Description
6876 \layout Description
6876
6877
6877
6878
6878 \family typewriter
6879 \family typewriter
6879 $var=cmd
6880 $var=cmd
6880 \family default
6881 \family default
6881 capture output of cmd into var, as a string
6882 capture output of cmd into var, as a string
6882 \layout Description
6883 \layout Description
6883
6884
6884
6885
6885 \family typewriter
6886 \family typewriter
6886 $$var=cmd
6887 $$var=cmd
6887 \family default
6888 \family default
6888 capture output of cmd into var, as a list (split on `
6889 capture output of cmd into var, as a list (split on `
6889 \backslash
6890 \backslash
6890 n')
6891 n')
6891 \layout Standard
6892 \layout Standard
6892
6893
6893 The
6894 The
6894 \family typewriter
6895 \family typewriter
6895 $
6896 $
6896 \family default
6897 \family default
6897 /
6898 /
6898 \family typewriter
6899 \family typewriter
6899 $$
6900 $$
6900 \family default
6901 \family default
6901 syntaxes make Python variables from system output, which you can later
6902 syntaxes make Python variables from system output, which you can later
6902 use for further scripting.
6903 use for further scripting.
6903 The converse is also possible: when executing an alias or calling to the
6904 The converse is also possible: when executing an alias or calling to the
6904 system via
6905 system via
6905 \family typewriter
6906 \family typewriter
6906 !
6907 !
6907 \family default
6908 \family default
6908 /
6909 /
6909 \family typewriter
6910 \family typewriter
6910 !!
6911 !!
6911 \family default
6912 \family default
6912 , you can expand any python variable or expression by prepending it with
6913 , you can expand any python variable or expression by prepending it with
6913
6914
6914 \family typewriter
6915 \family typewriter
6915 $
6916 $
6916 \family default
6917 \family default
6917 .
6918 .
6918 Full details of the allowed syntax can be found in Python's PEP 215.
6919 Full details of the allowed syntax can be found in Python's PEP 215.
6919 \layout Standard
6920 \layout Standard
6920
6921
6921 A few brief examples will illustrate these (note that the indentation below
6922 A few brief examples will illustrate these (note that the indentation below
6922 may be incorrectly displayed):
6923 may be incorrectly displayed):
6923 \layout Standard
6924 \layout Standard
6924
6925
6925
6926
6926 \family typewriter
6927 \family typewriter
6927 fperez[~/test]|3> !ls *s.py
6928 fperez[~/test]|3> !ls *s.py
6928 \newline
6929 \newline
6929 scopes.py strings.py
6930 scopes.py strings.py
6930 \layout Standard
6931 \layout Standard
6931
6932
6932 ls is an internal alias, so there's no need to use
6933 ls is an internal alias, so there's no need to use
6933 \family typewriter
6934 \family typewriter
6934 !
6935 !
6935 \family default
6936 \family default
6936 :
6937 :
6937 \layout Standard
6938 \layout Standard
6938
6939
6939
6940
6940 \family typewriter
6941 \family typewriter
6941 fperez[~/test]|4> ls *s.py
6942 fperez[~/test]|4> ls *s.py
6942 \newline
6943 \newline
6943 scopes.py* strings.py
6944 scopes.py* strings.py
6944 \layout Standard
6945 \layout Standard
6945
6946
6946 !!ls will return the output into a Python variable:
6947 !!ls will return the output into a Python variable:
6947 \layout Standard
6948 \layout Standard
6948
6949
6949
6950
6950 \family typewriter
6951 \family typewriter
6951 fperez[~/test]|5> !!ls *s.py
6952 fperez[~/test]|5> !!ls *s.py
6952 \newline
6953 \newline
6953
6954
6954 \begin_inset ERT
6955 \begin_inset ERT
6955 status Collapsed
6956 status Collapsed
6956
6957
6957 \layout Standard
6958 \layout Standard
6958
6959
6959 \backslash
6960 \backslash
6960 hspace*{0mm}
6961 hspace*{0mm}
6961 \end_inset
6962 \end_inset
6962
6963
6963 \SpecialChar ~
6964 \SpecialChar ~
6964 \SpecialChar ~
6965 \SpecialChar ~
6965 \SpecialChar ~
6966 \SpecialChar ~
6966 \SpecialChar ~
6967 \SpecialChar ~
6967 \SpecialChar ~
6968 \SpecialChar ~
6968 \SpecialChar ~
6969 \SpecialChar ~
6969 \SpecialChar ~
6970 \SpecialChar ~
6970 \SpecialChar ~
6971 \SpecialChar ~
6971 \SpecialChar ~
6972 \SpecialChar ~
6972 \SpecialChar ~
6973 \SpecialChar ~
6973 \SpecialChar ~
6974 \SpecialChar ~
6974 \SpecialChar ~
6975 \SpecialChar ~
6975 \SpecialChar ~
6976 \SpecialChar ~
6976 \SpecialChar ~
6977 \SpecialChar ~
6977 <5> ['scopes.py', 'strings.py']
6978 <5> ['scopes.py', 'strings.py']
6978 \newline
6979 \newline
6979 fperez[~/test]|6> print _5
6980 fperez[~/test]|6> print _5
6980 \newline
6981 \newline
6981 ['scopes.py', 'strings.py']
6982 ['scopes.py', 'strings.py']
6982 \layout Standard
6983 \layout Standard
6983
6984
6984
6985
6985 \family typewriter
6986 \family typewriter
6986 $
6987 $
6987 \family default
6988 \family default
6988 and
6989 and
6989 \family typewriter
6990 \family typewriter
6990 $$
6991 $$
6991 \family default
6992 \family default
6992 allow direct capture to named variables:
6993 allow direct capture to named variables:
6993 \layout Standard
6994 \layout Standard
6994
6995
6995
6996
6996 \family typewriter
6997 \family typewriter
6997 fperez[~/test]|7> $astr = ls *s.py
6998 fperez[~/test]|7> $astr = ls *s.py
6998 \newline
6999 \newline
6999 fperez[~/test]|8> astr
7000 fperez[~/test]|8> astr
7000 \newline
7001 \newline
7001
7002
7002 \begin_inset ERT
7003 \begin_inset ERT
7003 status Collapsed
7004 status Collapsed
7004
7005
7005 \layout Standard
7006 \layout Standard
7006
7007
7007 \backslash
7008 \backslash
7008 hspace*{0mm}
7009 hspace*{0mm}
7009 \end_inset
7010 \end_inset
7010
7011
7011 \SpecialChar ~
7012 \SpecialChar ~
7012 \SpecialChar ~
7013 \SpecialChar ~
7013 \SpecialChar ~
7014 \SpecialChar ~
7014 \SpecialChar ~
7015 \SpecialChar ~
7015 \SpecialChar ~
7016 \SpecialChar ~
7016 \SpecialChar ~
7017 \SpecialChar ~
7017 \SpecialChar ~
7018 \SpecialChar ~
7018 \SpecialChar ~
7019 \SpecialChar ~
7019 \SpecialChar ~
7020 \SpecialChar ~
7020 \SpecialChar ~
7021 \SpecialChar ~
7021 \SpecialChar ~
7022 \SpecialChar ~
7022 \SpecialChar ~
7023 \SpecialChar ~
7023 \SpecialChar ~
7024 \SpecialChar ~
7024 \SpecialChar ~
7025 \SpecialChar ~
7025 <8> 'scopes.py
7026 <8> 'scopes.py
7026 \backslash
7027 \backslash
7027 nstrings.py'
7028 nstrings.py'
7028 \layout Standard
7029 \layout Standard
7029
7030
7030
7031
7031 \family typewriter
7032 \family typewriter
7032 fperez[~/test]|9> $$alist = ls *s.py
7033 fperez[~/test]|9> $$alist = ls *s.py
7033 \newline
7034 \newline
7034 fperez[~/test]|10> alist
7035 fperez[~/test]|10> alist
7035 \newline
7036 \newline
7036
7037
7037 \begin_inset ERT
7038 \begin_inset ERT
7038 status Collapsed
7039 status Collapsed
7039
7040
7040 \layout Standard
7041 \layout Standard
7041
7042
7042 \backslash
7043 \backslash
7043 hspace*{0mm}
7044 hspace*{0mm}
7044 \end_inset
7045 \end_inset
7045
7046
7046 \SpecialChar ~
7047 \SpecialChar ~
7047 \SpecialChar ~
7048 \SpecialChar ~
7048 \SpecialChar ~
7049 \SpecialChar ~
7049 \SpecialChar ~
7050 \SpecialChar ~
7050 \SpecialChar ~
7051 \SpecialChar ~
7051 \SpecialChar ~
7052 \SpecialChar ~
7052 \SpecialChar ~
7053 \SpecialChar ~
7053 \SpecialChar ~
7054 \SpecialChar ~
7054 \SpecialChar ~
7055 \SpecialChar ~
7055 \SpecialChar ~
7056 \SpecialChar ~
7056 \SpecialChar ~
7057 \SpecialChar ~
7057 \SpecialChar ~
7058 \SpecialChar ~
7058 \SpecialChar ~
7059 \SpecialChar ~
7059 \SpecialChar ~
7060 \SpecialChar ~
7060 <10> ['scopes.py', 'strings.py']
7061 <10> ['scopes.py', 'strings.py']
7061 \layout Standard
7062 \layout Standard
7062
7063
7063 alist is now a normal python list you can loop over.
7064 alist is now a normal python list you can loop over.
7064 Using
7065 Using
7065 \family typewriter
7066 \family typewriter
7066 $
7067 $
7067 \family default
7068 \family default
7068 will expand back the python values when alias calls are made:
7069 will expand back the python values when alias calls are made:
7069 \layout Standard
7070 \layout Standard
7070
7071
7071
7072
7072 \family typewriter
7073 \family typewriter
7073 fperez[~/test]|11> for f in alist:
7074 fperez[~/test]|11> for f in alist:
7074 \newline
7075 \newline
7075
7076
7076 \begin_inset ERT
7077 \begin_inset ERT
7077 status Collapsed
7078 status Collapsed
7078
7079
7079 \layout Standard
7080 \layout Standard
7080
7081
7081 \backslash
7082 \backslash
7082 hspace*{0mm}
7083 hspace*{0mm}
7083 \end_inset
7084 \end_inset
7084
7085
7085 \SpecialChar ~
7086 \SpecialChar ~
7086 \SpecialChar ~
7087 \SpecialChar ~
7087 \SpecialChar ~
7088 \SpecialChar ~
7088 \SpecialChar ~
7089 \SpecialChar ~
7089 \SpecialChar ~
7090 \SpecialChar ~
7090 \SpecialChar ~
7091 \SpecialChar ~
7091 \SpecialChar ~
7092 \SpecialChar ~
7092 \SpecialChar ~
7093 \SpecialChar ~
7093 \SpecialChar ~
7094 \SpecialChar ~
7094 \SpecialChar ~
7095 \SpecialChar ~
7095 \SpecialChar ~
7096 \SpecialChar ~
7096 \SpecialChar ~
7097 \SpecialChar ~
7097 \SpecialChar ~
7098 \SpecialChar ~
7098 \SpecialChar ~
7099 \SpecialChar ~
7099 |..> \SpecialChar ~
7100 |..> \SpecialChar ~
7100 \SpecialChar ~
7101 \SpecialChar ~
7101 \SpecialChar ~
7102 \SpecialChar ~
7102 \SpecialChar ~
7103 \SpecialChar ~
7103 print 'file',f,
7104 print 'file',f,
7104 \newline
7105 \newline
7105
7106
7106 \begin_inset ERT
7107 \begin_inset ERT
7107 status Collapsed
7108 status Collapsed
7108
7109
7109 \layout Standard
7110 \layout Standard
7110
7111
7111 \backslash
7112 \backslash
7112 hspace*{0mm}
7113 hspace*{0mm}
7113 \end_inset
7114 \end_inset
7114
7115
7115 \SpecialChar ~
7116 \SpecialChar ~
7116 \SpecialChar ~
7117 \SpecialChar ~
7117 \SpecialChar ~
7118 \SpecialChar ~
7118 \SpecialChar ~
7119 \SpecialChar ~
7119 \SpecialChar ~
7120 \SpecialChar ~
7120 \SpecialChar ~
7121 \SpecialChar ~
7121 \SpecialChar ~
7122 \SpecialChar ~
7122 \SpecialChar ~
7123 \SpecialChar ~
7123 \SpecialChar ~
7124 \SpecialChar ~
7124 \SpecialChar ~
7125 \SpecialChar ~
7125 \SpecialChar ~
7126 \SpecialChar ~
7126 \SpecialChar ~
7127 \SpecialChar ~
7127 \SpecialChar ~
7128 \SpecialChar ~
7128 \SpecialChar ~
7129 \SpecialChar ~
7129 |..> \SpecialChar ~
7130 |..> \SpecialChar ~
7130 \SpecialChar ~
7131 \SpecialChar ~
7131 \SpecialChar ~
7132 \SpecialChar ~
7132 \SpecialChar ~
7133 \SpecialChar ~
7133 wc -l $f
7134 wc -l $f
7134 \newline
7135 \newline
7135
7136
7136 \begin_inset ERT
7137 \begin_inset ERT
7137 status Collapsed
7138 status Collapsed
7138
7139
7139 \layout Standard
7140 \layout Standard
7140
7141
7141 \backslash
7142 \backslash
7142 hspace*{0mm}
7143 hspace*{0mm}
7143 \end_inset
7144 \end_inset
7144
7145
7145 \SpecialChar ~
7146 \SpecialChar ~
7146 \SpecialChar ~
7147 \SpecialChar ~
7147 \SpecialChar ~
7148 \SpecialChar ~
7148 \SpecialChar ~
7149 \SpecialChar ~
7149 \SpecialChar ~
7150 \SpecialChar ~
7150 \SpecialChar ~
7151 \SpecialChar ~
7151 \SpecialChar ~
7152 \SpecialChar ~
7152 \SpecialChar ~
7153 \SpecialChar ~
7153 \SpecialChar ~
7154 \SpecialChar ~
7154 \SpecialChar ~
7155 \SpecialChar ~
7155 \SpecialChar ~
7156 \SpecialChar ~
7156 \SpecialChar ~
7157 \SpecialChar ~
7157 \SpecialChar ~
7158 \SpecialChar ~
7158 \SpecialChar ~
7159 \SpecialChar ~
7159 |..>
7160 |..>
7160 \newline
7161 \newline
7161 file scopes.py 13 scopes.py
7162 file scopes.py 13 scopes.py
7162 \newline
7163 \newline
7163 file strings.py 4 strings.py
7164 file strings.py 4 strings.py
7164 \layout Standard
7165 \layout Standard
7165
7166
7166 Note that you may need to protect your variables with braces if you want
7167 Note that you may need to protect your variables with braces if you want
7167 to append strings to their names.
7168 to append strings to their names.
7168 To copy all files in alist to
7169 To copy all files in alist to
7169 \family typewriter
7170 \family typewriter
7170 .bak
7171 .bak
7171 \family default
7172 \family default
7172 extensions, you must use:
7173 extensions, you must use:
7173 \layout Standard
7174 \layout Standard
7174
7175
7175
7176
7176 \family typewriter
7177 \family typewriter
7177 fperez[~/test]|12> for f in alist:
7178 fperez[~/test]|12> for f in alist:
7178 \newline
7179 \newline
7179
7180
7180 \begin_inset ERT
7181 \begin_inset ERT
7181 status Collapsed
7182 status Collapsed
7182
7183
7183 \layout Standard
7184 \layout Standard
7184
7185
7185 \backslash
7186 \backslash
7186 hspace*{0mm}
7187 hspace*{0mm}
7187 \end_inset
7188 \end_inset
7188
7189
7189 \SpecialChar ~
7190 \SpecialChar ~
7190 \SpecialChar ~
7191 \SpecialChar ~
7191 \SpecialChar ~
7192 \SpecialChar ~
7192 \SpecialChar ~
7193 \SpecialChar ~
7193 \SpecialChar ~
7194 \SpecialChar ~
7194 \SpecialChar ~
7195 \SpecialChar ~
7195 \SpecialChar ~
7196 \SpecialChar ~
7196 \SpecialChar ~
7197 \SpecialChar ~
7197 \SpecialChar ~
7198 \SpecialChar ~
7198 \SpecialChar ~
7199 \SpecialChar ~
7199 \SpecialChar ~
7200 \SpecialChar ~
7200 \SpecialChar ~
7201 \SpecialChar ~
7201 \SpecialChar ~
7202 \SpecialChar ~
7202 \SpecialChar ~
7203 \SpecialChar ~
7203 |..> \SpecialChar ~
7204 |..> \SpecialChar ~
7204 \SpecialChar ~
7205 \SpecialChar ~
7205 \SpecialChar ~
7206 \SpecialChar ~
7206 \SpecialChar ~
7207 \SpecialChar ~
7207 cp $f ${f}.bak
7208 cp $f ${f}.bak
7208 \layout Standard
7209 \layout Standard
7209
7210
7210 If you try using
7211 If you try using
7211 \family typewriter
7212 \family typewriter
7212 $f.bak
7213 $f.bak
7213 \family default
7214 \family default
7214 , you'll get an AttributeError exception saying that your string object
7215 , you'll get an AttributeError exception saying that your string object
7215 doesn't have a
7216 doesn't have a
7216 \family typewriter
7217 \family typewriter
7217 .bak
7218 .bak
7218 \family default
7219 \family default
7219 attribute.
7220 attribute.
7220 This is because the
7221 This is because the
7221 \family typewriter
7222 \family typewriter
7222 $
7223 $
7223 \family default
7224 \family default
7224 expansion mechanism allows you to expand full Python expressions:
7225 expansion mechanism allows you to expand full Python expressions:
7225 \layout Standard
7226 \layout Standard
7226
7227
7227
7228
7228 \family typewriter
7229 \family typewriter
7229 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7230 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7230 \newline
7231 \newline
7231 sys.platform is: linux2
7232 sys.platform is: linux2
7232 \layout Standard
7233 \layout Standard
7233
7234
7234 IPython's input history handling is still active, which allows you to rerun
7235 IPython's input history handling is still active, which allows you to rerun
7235 a single block of multi-line input by simply using exec:
7236 a single block of multi-line input by simply using exec:
7236 \newline
7237 \newline
7237
7238
7238 \family typewriter
7239 \family typewriter
7239 fperez[~/test]|14> $$alist = ls *.eps
7240 fperez[~/test]|14> $$alist = ls *.eps
7240 \newline
7241 \newline
7241 fperez[~/test]|15> exec _i11
7242 fperez[~/test]|15> exec _i11
7242 \newline
7243 \newline
7243 file image2.eps 921 image2.eps
7244 file image2.eps 921 image2.eps
7244 \newline
7245 \newline
7245 file image.eps 921 image.eps
7246 file image.eps 921 image.eps
7246 \layout Standard
7247 \layout Standard
7247
7248
7248 While these are new special-case syntaxes, they are designed to allow very
7249 While these are new special-case syntaxes, they are designed to allow very
7249 efficient use of the shell with minimal typing.
7250 efficient use of the shell with minimal typing.
7250 At an interactive shell prompt, conciseness of expression wins over readability.
7251 At an interactive shell prompt, conciseness of expression wins over readability.
7251 \layout Subsection
7252 \layout Subsection
7252
7253
7253 Useful functions and modules
7254 Useful functions and modules
7254 \layout Standard
7255 \layout Standard
7255
7256
7256 The os, sys and shutil modules from the Python standard library are automaticall
7257 The os, sys and shutil modules from the Python standard library are automaticall
7257 y loaded.
7258 y loaded.
7258 Some additional functions, useful for shell usage, are listed below.
7259 Some additional functions, useful for shell usage, are listed below.
7259 You can request more help about them with `
7260 You can request more help about them with `
7260 \family typewriter
7261 \family typewriter
7261 ?
7262 ?
7262 \family default
7263 \family default
7263 '.
7264 '.
7264 \layout Description
7265 \layout Description
7265
7266
7266
7267
7267 \family typewriter
7268 \family typewriter
7268 shell
7269 shell
7269 \family default
7270 \family default
7270 - execute a command in the underlying system shell
7271 - execute a command in the underlying system shell
7271 \layout Description
7272 \layout Description
7272
7273
7273
7274
7274 \family typewriter
7275 \family typewriter
7275 system
7276 system
7276 \family default
7277 \family default
7277 - like
7278 - like
7278 \family typewriter
7279 \family typewriter
7279 shell()
7280 shell()
7280 \family default
7281 \family default
7281 , but return the exit status of the command
7282 , but return the exit status of the command
7282 \layout Description
7283 \layout Description
7283
7284
7284
7285
7285 \family typewriter
7286 \family typewriter
7286 sout
7287 sout
7287 \family default
7288 \family default
7288 - capture the output of a command as a string
7289 - capture the output of a command as a string
7289 \layout Description
7290 \layout Description
7290
7291
7291
7292
7292 \family typewriter
7293 \family typewriter
7293 lout
7294 lout
7294 \family default
7295 \family default
7295 - capture the output of a command as a list (split on `
7296 - capture the output of a command as a list (split on `
7296 \backslash
7297 \backslash
7297 n')
7298 n')
7298 \layout Description
7299 \layout Description
7299
7300
7300
7301
7301 \family typewriter
7302 \family typewriter
7302 getoutputerror
7303 getoutputerror
7303 \family default
7304 \family default
7304 - capture (output,error) of a shell commandss
7305 - capture (output,error) of a shell commandss
7305 \layout Standard
7306 \layout Standard
7306
7307
7307
7308
7308 \family typewriter
7309 \family typewriter
7309 sout
7310 sout
7310 \family default
7311 \family default
7311 /
7312 /
7312 \family typewriter
7313 \family typewriter
7313 lout
7314 lout
7314 \family default
7315 \family default
7315 are the functional equivalents of
7316 are the functional equivalents of
7316 \family typewriter
7317 \family typewriter
7317 $
7318 $
7318 \family default
7319 \family default
7319 /
7320 /
7320 \family typewriter
7321 \family typewriter
7321 $$
7322 $$
7322 \family default
7323 \family default
7323 .
7324 .
7324 They are provided to allow you to capture system output in the middle of
7325 They are provided to allow you to capture system output in the middle of
7325 true python code, function definitions, etc (where
7326 true python code, function definitions, etc (where
7326 \family typewriter
7327 \family typewriter
7327 $
7328 $
7328 \family default
7329 \family default
7329 and
7330 and
7330 \family typewriter
7331 \family typewriter
7331 $$
7332 $$
7332 \family default
7333 \family default
7333 are invalid).
7334 are invalid).
7334 \layout Subsection
7335 \layout Subsection
7335
7336
7336 Directory management
7337 Directory management
7337 \layout Standard
7338 \layout Standard
7338
7339
7339 Since each command passed by pysh to the underlying system is executed in
7340 Since each command passed by pysh to the underlying system is executed in
7340 a subshell which exits immediately, you can NOT use !cd to navigate the
7341 a subshell which exits immediately, you can NOT use !cd to navigate the
7341 filesystem.
7342 filesystem.
7342 \layout Standard
7343 \layout Standard
7343
7344
7344 Pysh provides its own builtin
7345 Pysh provides its own builtin
7345 \family typewriter
7346 \family typewriter
7346 `%cd
7347 `%cd
7347 \family default
7348 \family default
7348 ' magic command to move in the filesystem (the
7349 ' magic command to move in the filesystem (the
7349 \family typewriter
7350 \family typewriter
7350 %
7351 %
7351 \family default
7352 \family default
7352 is not required with automagic on).
7353 is not required with automagic on).
7353 It also maintains a list of visited directories (use
7354 It also maintains a list of visited directories (use
7354 \family typewriter
7355 \family typewriter
7355 %dhist
7356 %dhist
7356 \family default
7357 \family default
7357 to see it) and allows direct switching to any of them.
7358 to see it) and allows direct switching to any of them.
7358 Type
7359 Type
7359 \family typewriter
7360 \family typewriter
7360 `cd?
7361 `cd?
7361 \family default
7362 \family default
7362 ' for more details.
7363 ' for more details.
7363 \layout Standard
7364 \layout Standard
7364
7365
7365
7366
7366 \family typewriter
7367 \family typewriter
7367 %pushd
7368 %pushd
7368 \family default
7369 \family default
7369 ,
7370 ,
7370 \family typewriter
7371 \family typewriter
7371 %popd
7372 %popd
7372 \family default
7373 \family default
7373 and
7374 and
7374 \family typewriter
7375 \family typewriter
7375 %dirs
7376 %dirs
7376 \family default
7377 \family default
7377 are provided for directory stack handling.
7378 are provided for directory stack handling.
7378 \layout Subsection
7379 \layout Subsection
7379
7380
7380 Prompt customization
7381 Prompt customization
7381 \layout Standard
7382 \layout Standard
7382
7383
7383 The supplied
7384 The supplied
7384 \family typewriter
7385 \family typewriter
7385 ipythonrc-pysh
7386 ipythonrc-pysh
7386 \family default
7387 \family default
7387 profile comes with an example of a very colored and detailed prompt, mainly
7388 profile comes with an example of a very colored and detailed prompt, mainly
7388 to serve as an illustration.
7389 to serve as an illustration.
7389 The valid escape sequences, besides color names, are:
7390 The valid escape sequences, besides color names, are:
7390 \layout Description
7391 \layout Description
7391
7392
7392
7393
7393 \backslash
7394 \backslash
7394 # - Prompt number.
7395 # - Prompt number.
7395 \layout Description
7396 \layout Description
7396
7397
7397
7398
7398 \backslash
7399 \backslash
7399 D - Dots, as many as there are digits in
7400 D - Dots, as many as there are digits in
7400 \backslash
7401 \backslash
7401 # (so they align).
7402 # (so they align).
7402 \layout Description
7403 \layout Description
7403
7404
7404
7405
7405 \backslash
7406 \backslash
7406 w - Current working directory (cwd).
7407 w - Current working directory (cwd).
7407 \layout Description
7408 \layout Description
7408
7409
7409
7410
7410 \backslash
7411 \backslash
7411 W - Basename of current working directory.
7412 W - Basename of current working directory.
7412 \layout Description
7413 \layout Description
7413
7414
7414
7415
7415 \backslash
7416 \backslash
7416 X
7417 X
7417 \emph on
7418 \emph on
7418 N
7419 N
7419 \emph default
7420 \emph default
7420 - Where
7421 - Where
7421 \emph on
7422 \emph on
7422 N
7423 N
7423 \emph default
7424 \emph default
7424 =0..5.
7425 =0..5.
7425 N terms of the cwd, with $HOME written as ~.
7426 N terms of the cwd, with $HOME written as ~.
7426 \layout Description
7427 \layout Description
7427
7428
7428
7429
7429 \backslash
7430 \backslash
7430 Y
7431 Y
7431 \emph on
7432 \emph on
7432 N
7433 N
7433 \emph default
7434 \emph default
7434 - Where
7435 - Where
7435 \emph on
7436 \emph on
7436 N
7437 N
7437 \emph default
7438 \emph default
7438 =0..5.
7439 =0..5.
7439 Like X
7440 Like X
7440 \emph on
7441 \emph on
7441 N
7442 N
7442 \emph default
7443 \emph default
7443 , but if ~ is term
7444 , but if ~ is term
7444 \emph on
7445 \emph on
7445 N
7446 N
7446 \emph default
7447 \emph default
7447 +1 it's also shown.
7448 +1 it's also shown.
7448 \layout Description
7449 \layout Description
7449
7450
7450
7451
7451 \backslash
7452 \backslash
7452 u - Username.
7453 u - Username.
7453 \layout Description
7454 \layout Description
7454
7455
7455
7456
7456 \backslash
7457 \backslash
7457 H - Full hostname.
7458 H - Full hostname.
7458 \layout Description
7459 \layout Description
7459
7460
7460
7461
7461 \backslash
7462 \backslash
7462 h - Hostname up to first '.'
7463 h - Hostname up to first '.'
7463 \layout Description
7464 \layout Description
7464
7465
7465
7466
7466 \backslash
7467 \backslash
7467 $ - Root symbol ($ or #).
7468 $ - Root symbol ($ or #).
7468
7469
7469 \layout Description
7470 \layout Description
7470
7471
7471
7472
7472 \backslash
7473 \backslash
7473 t - Current time, in H:M:S format.
7474 t - Current time, in H:M:S format.
7474 \layout Description
7475 \layout Description
7475
7476
7476
7477
7477 \backslash
7478 \backslash
7478 v - IPython release version.
7479 v - IPython release version.
7479
7480
7480 \layout Description
7481 \layout Description
7481
7482
7482
7483
7483 \backslash
7484 \backslash
7484 n - Newline.
7485 n - Newline.
7485
7486
7486 \layout Description
7487 \layout Description
7487
7488
7488
7489
7489 \backslash
7490 \backslash
7490 r - Carriage return.
7491 r - Carriage return.
7491
7492
7492 \layout Description
7493 \layout Description
7493
7494
7494
7495
7495 \backslash
7496 \backslash
7496
7497
7497 \backslash
7498 \backslash
7498 - An explicitly escaped '
7499 - An explicitly escaped '
7499 \backslash
7500 \backslash
7500 '.
7501 '.
7501 \layout Standard
7502 \layout Standard
7502
7503
7503 You can configure your prompt colors using any ANSI color escape.
7504 You can configure your prompt colors using any ANSI color escape.
7504 Each color escape sets the color for any subsequent text, until another
7505 Each color escape sets the color for any subsequent text, until another
7505 escape comes in and changes things.
7506 escape comes in and changes things.
7506 The valid color escapes are:
7507 The valid color escapes are:
7507 \layout Description
7508 \layout Description
7508
7509
7509
7510
7510 \backslash
7511 \backslash
7511 C_Black
7512 C_Black
7512 \layout Description
7513 \layout Description
7513
7514
7514
7515
7515 \backslash
7516 \backslash
7516 C_Blue
7517 C_Blue
7517 \layout Description
7518 \layout Description
7518
7519
7519
7520
7520 \backslash
7521 \backslash
7521 C_Brown
7522 C_Brown
7522 \layout Description
7523 \layout Description
7523
7524
7524
7525
7525 \backslash
7526 \backslash
7526 C_Cyan
7527 C_Cyan
7527 \layout Description
7528 \layout Description
7528
7529
7529
7530
7530 \backslash
7531 \backslash
7531 C_DarkGray
7532 C_DarkGray
7532 \layout Description
7533 \layout Description
7533
7534
7534
7535
7535 \backslash
7536 \backslash
7536 C_Green
7537 C_Green
7537 \layout Description
7538 \layout Description
7538
7539
7539
7540
7540 \backslash
7541 \backslash
7541 C_LightBlue
7542 C_LightBlue
7542 \layout Description
7543 \layout Description
7543
7544
7544
7545
7545 \backslash
7546 \backslash
7546 C_LightCyan
7547 C_LightCyan
7547 \layout Description
7548 \layout Description
7548
7549
7549
7550
7550 \backslash
7551 \backslash
7551 C_LightGray
7552 C_LightGray
7552 \layout Description
7553 \layout Description
7553
7554
7554
7555
7555 \backslash
7556 \backslash
7556 C_LightGreen
7557 C_LightGreen
7557 \layout Description
7558 \layout Description
7558
7559
7559
7560
7560 \backslash
7561 \backslash
7561 C_LightPurple
7562 C_LightPurple
7562 \layout Description
7563 \layout Description
7563
7564
7564
7565
7565 \backslash
7566 \backslash
7566 C_LightRed
7567 C_LightRed
7567 \layout Description
7568 \layout Description
7568
7569
7569
7570
7570 \backslash
7571 \backslash
7571 C_Purple
7572 C_Purple
7572 \layout Description
7573 \layout Description
7573
7574
7574
7575
7575 \backslash
7576 \backslash
7576 C_Red
7577 C_Red
7577 \layout Description
7578 \layout Description
7578
7579
7579
7580
7580 \backslash
7581 \backslash
7581 C_White
7582 C_White
7582 \layout Description
7583 \layout Description
7583
7584
7584
7585
7585 \backslash
7586 \backslash
7586 C_Yellow
7587 C_Yellow
7587 \layout Description
7588 \layout Description
7588
7589
7589
7590
7590 \backslash
7591 \backslash
7591 C_Normal Stop coloring, defaults to your terminal settings.
7592 C_Normal Stop coloring, defaults to your terminal settings.
7592 \layout Section
7593 \layout Section
7593
7594
7594
7595
7595 \begin_inset LatexCommand \label{sec:Threading-support}
7596 \begin_inset LatexCommand \label{sec:Threading-support}
7596
7597
7597 \end_inset
7598 \end_inset
7598
7599
7599 Threading support
7600 Threading support
7600 \layout Standard
7601 \layout Standard
7601
7602
7602
7603
7603 \series bold
7604 \series bold
7604 WARNING:
7605 WARNING:
7605 \series default
7606 \series default
7606 The threading support is still somewhat experimental, and it has only seen
7607 The threading support is still somewhat experimental, and it has only seen
7607 reasonable testing under Linux.
7608 reasonable testing under Linux.
7608 Threaded code is particularly tricky to debug, and it tends to show extremely
7609 Threaded code is particularly tricky to debug, and it tends to show extremely
7609 platform-dependent behavior.
7610 platform-dependent behavior.
7610 Since I only have access to Linux machines, I will have to rely on user's
7611 Since I only have access to Linux machines, I will have to rely on user's
7611 experiences and assistance for this area of IPython to improve under other
7612 experiences and assistance for this area of IPython to improve under other
7612 platforms.
7613 platforms.
7613 \layout Standard
7614 \layout Standard
7614
7615
7615 IPython, via the
7616 IPython, via the
7616 \family typewriter
7617 \family typewriter
7617 -gthread
7618 -gthread
7618 \family default
7619 \family default
7619 ,
7620 ,
7620 \family typewriter
7621 \family typewriter
7621 -qthread
7622 -qthread
7622 \family default
7623 \family default
7623 and
7624 and
7624 \family typewriter
7625 \family typewriter
7625 -wthread
7626 -wthread
7626 \family default
7627 \family default
7627 options (described in Sec.\SpecialChar ~
7628 options (described in Sec.\SpecialChar ~
7628
7629
7629 \begin_inset LatexCommand \ref{sec:threading-opts}
7630 \begin_inset LatexCommand \ref{sec:threading-opts}
7630
7631
7631 \end_inset
7632 \end_inset
7632
7633
7633 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7634 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7634 respectively.
7635 respectively.
7635 These GUI toolkits need to control the python main loop of execution, so
7636 These GUI toolkits need to control the python main loop of execution, so
7636 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7637 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7637 will immediately freeze the shell.
7638 will immediately freeze the shell.
7638
7639
7639 \layout Standard
7640 \layout Standard
7640
7641
7641 IPython, with one of these options (you can only use one at a time), separates
7642 IPython, with one of these options (you can only use one at a time), separates
7642 the graphical loop and IPython's code execution run into different threads.
7643 the graphical loop and IPython's code execution run into different threads.
7643 This allows you to test interactively (with
7644 This allows you to test interactively (with
7644 \family typewriter
7645 \family typewriter
7645 %run
7646 %run
7646 \family default
7647 \family default
7647 , for example) your GUI code without blocking.
7648 , for example) your GUI code without blocking.
7648 \layout Standard
7649 \layout Standard
7649
7650
7650 A nice mini-tutorial on using IPython along with the Qt Designer application
7651 A nice mini-tutorial on using IPython along with the Qt Designer application
7651 is available at the SciPy wiki:
7652 is available at the SciPy wiki:
7652 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7653 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7653
7654
7654 \end_inset
7655 \end_inset
7655
7656
7656 .
7657 .
7657 \layout Subsection
7658 \layout Subsection
7658
7659
7659 Tk issues
7660 Tk issues
7660 \layout Standard
7661 \layout Standard
7661
7662
7662 As indicated in Sec.\SpecialChar ~
7663 As indicated in Sec.\SpecialChar ~
7663
7664
7664 \begin_inset LatexCommand \ref{sec:threading-opts}
7665 \begin_inset LatexCommand \ref{sec:threading-opts}
7665
7666
7666 \end_inset
7667 \end_inset
7667
7668
7668 , a special
7669 , a special
7669 \family typewriter
7670 \family typewriter
7670 -tk
7671 -tk
7671 \family default
7672 \family default
7672 option is provided to try and allow Tk graphical applications to coexist
7673 option is provided to try and allow Tk graphical applications to coexist
7673 interactively with WX, Qt or GTK ones.
7674 interactively with WX, Qt or GTK ones.
7674 Whether this works at all, however, is very platform and configuration
7675 Whether this works at all, however, is very platform and configuration
7675 dependent.
7676 dependent.
7676 Please experiment with simple test cases before committing to using this
7677 Please experiment with simple test cases before committing to using this
7677 combination of Tk and GTK/Qt/WX threading in a production environment.
7678 combination of Tk and GTK/Qt/WX threading in a production environment.
7678 \layout Subsection
7679 \layout Subsection
7679
7680
7680 Signals and Threads
7681 Signals and Threads
7681 \layout Standard
7682 \layout Standard
7682
7683
7683 When any of the thread systems (GTK, Qt or WX) are active, either directly
7684 When any of the thread systems (GTK, Qt or WX) are active, either directly
7684 or via
7685 or via
7685 \family typewriter
7686 \family typewriter
7686 -pylab
7687 -pylab
7687 \family default
7688 \family default
7688 with a threaded backend, it is impossible to interrupt long-running Python
7689 with a threaded backend, it is impossible to interrupt long-running Python
7689 code via
7690 code via
7690 \family typewriter
7691 \family typewriter
7691 Ctrl-C
7692 Ctrl-C
7692 \family default
7693 \family default
7693 .
7694 .
7694 IPython can not pass the KeyboardInterrupt exception (or the underlying
7695 IPython can not pass the KeyboardInterrupt exception (or the underlying
7695
7696
7696 \family typewriter
7697 \family typewriter
7697 SIGINT
7698 SIGINT
7698 \family default
7699 \family default
7699 ) across threads, so any long-running process started from IPython will
7700 ) across threads, so any long-running process started from IPython will
7700 run to completion, or will have to be killed via an external (OS-based)
7701 run to completion, or will have to be killed via an external (OS-based)
7701 mechanism.
7702 mechanism.
7702 \layout Standard
7703 \layout Standard
7703
7704
7704 To the best of my knowledge, this limitation is imposed by the Python interprete
7705 To the best of my knowledge, this limitation is imposed by the Python interprete
7705 r itself, and it comes from the difficulty of writing portable signal/threaded
7706 r itself, and it comes from the difficulty of writing portable signal/threaded
7706 code.
7707 code.
7707 If any user is an expert on this topic and can suggest a better solution,
7708 If any user is an expert on this topic and can suggest a better solution,
7708 I would love to hear about it.
7709 I would love to hear about it.
7709 In the IPython sources, look at the
7710 In the IPython sources, look at the
7710 \family typewriter
7711 \family typewriter
7711 Shell.py
7712 Shell.py
7712 \family default
7713 \family default
7713 module, and in particular at the
7714 module, and in particular at the
7714 \family typewriter
7715 \family typewriter
7715 runcode()
7716 runcode()
7716 \family default
7717 \family default
7717 method.
7718 method.
7718
7719
7719 \layout Subsection
7720 \layout Subsection
7720
7721
7721 I/O pitfalls
7722 I/O pitfalls
7722 \layout Standard
7723 \layout Standard
7723
7724
7724 Be mindful that the Python interpreter switches between threads every
7725 Be mindful that the Python interpreter switches between threads every
7725 \begin_inset Formula $N$
7726 \begin_inset Formula $N$
7726 \end_inset
7727 \end_inset
7727
7728
7728 bytecodes, where the default value as of Python\SpecialChar ~
7729 bytecodes, where the default value as of Python\SpecialChar ~
7729 2.3 is
7730 2.3 is
7730 \begin_inset Formula $N=100.$
7731 \begin_inset Formula $N=100.$
7731 \end_inset
7732 \end_inset
7732
7733
7733 This value can be read by using the
7734 This value can be read by using the
7734 \family typewriter
7735 \family typewriter
7735 sys.getcheckinterval()
7736 sys.getcheckinterval()
7736 \family default
7737 \family default
7737 function, and it can be reset via
7738 function, and it can be reset via
7738 \family typewriter
7739 \family typewriter
7739 sys.setcheckinterval(
7740 sys.setcheckinterval(
7740 \emph on
7741 \emph on
7741 N
7742 N
7742 \emph default
7743 \emph default
7743 )
7744 )
7744 \family default
7745 \family default
7745 .
7746 .
7746 This switching of threads can cause subtly confusing effects if one of
7747 This switching of threads can cause subtly confusing effects if one of
7747 your threads is doing file I/O.
7748 your threads is doing file I/O.
7748 In text mode, most systems only flush file buffers when they encounter
7749 In text mode, most systems only flush file buffers when they encounter
7749 a
7750 a
7750 \family typewriter
7751 \family typewriter
7751 `
7752 `
7752 \backslash
7753 \backslash
7753 n'
7754 n'
7754 \family default
7755 \family default
7755 .
7756 .
7756 An instruction as simple as
7757 An instruction as simple as
7757 \family typewriter
7758 \family typewriter
7758
7759
7759 \newline
7760 \newline
7760 \SpecialChar ~
7761 \SpecialChar ~
7761 \SpecialChar ~
7762 \SpecialChar ~
7762 print >> filehandle,
7763 print >> filehandle,
7763 \begin_inset Quotes eld
7764 \begin_inset Quotes eld
7764 \end_inset
7765 \end_inset
7765
7766
7766 hello world
7767 hello world
7767 \begin_inset Quotes erd
7768 \begin_inset Quotes erd
7768 \end_inset
7769 \end_inset
7769
7770
7770
7771
7771 \family default
7772 \family default
7772
7773
7773 \newline
7774 \newline
7774 actually consists of several bytecodes, so it is possible that the newline
7775 actually consists of several bytecodes, so it is possible that the newline
7775 does not reach your file before the next thread switch.
7776 does not reach your file before the next thread switch.
7776 Similarly, if you are writing to a file in binary mode, the file won't
7777 Similarly, if you are writing to a file in binary mode, the file won't
7777 be flushed until the buffer fills, and your other thread may see apparently
7778 be flushed until the buffer fills, and your other thread may see apparently
7778 truncated files.
7779 truncated files.
7779
7780
7780 \layout Standard
7781 \layout Standard
7781
7782
7782 For this reason, if you are using IPython's thread support and have (for
7783 For this reason, if you are using IPython's thread support and have (for
7783 example) a GUI application which will read data generated by files written
7784 example) a GUI application which will read data generated by files written
7784 to from the IPython thread, the safest approach is to open all of your
7785 to from the IPython thread, the safest approach is to open all of your
7785 files in unbuffered mode (the third argument to the
7786 files in unbuffered mode (the third argument to the
7786 \family typewriter
7787 \family typewriter
7787 file/open
7788 file/open
7788 \family default
7789 \family default
7789 function is the buffering value):
7790 function is the buffering value):
7790 \newline
7791 \newline
7791
7792
7792 \family typewriter
7793 \family typewriter
7793 \SpecialChar ~
7794 \SpecialChar ~
7794 \SpecialChar ~
7795 \SpecialChar ~
7795 filehandle = open(filename,mode,0)
7796 filehandle = open(filename,mode,0)
7796 \layout Standard
7797 \layout Standard
7797
7798
7798 This is obviously a brute force way of avoiding race conditions with the
7799 This is obviously a brute force way of avoiding race conditions with the
7799 file buffering.
7800 file buffering.
7800 If you want to do it cleanly, and you have a resource which is being shared
7801 If you want to do it cleanly, and you have a resource which is being shared
7801 by the interactive IPython loop and your GUI thread, you should really
7802 by the interactive IPython loop and your GUI thread, you should really
7802 handle it with thread locking and syncrhonization properties.
7803 handle it with thread locking and syncrhonization properties.
7803 The Python documentation discusses these.
7804 The Python documentation discusses these.
7804 \layout Section
7805 \layout Section
7805
7806
7806
7807
7807 \begin_inset LatexCommand \label{sec:interactive-demos}
7808 \begin_inset LatexCommand \label{sec:interactive-demos}
7808
7809
7809 \end_inset
7810 \end_inset
7810
7811
7811 Interactive demos with IPython
7812 Interactive demos with IPython
7812 \layout Standard
7813 \layout Standard
7813
7814
7814 IPython ships with a basic system for running scripts interactively in sections,
7815 IPython ships with a basic system for running scripts interactively in sections,
7815 useful when presenting code to audiences.
7816 useful when presenting code to audiences.
7816 A few tags embedded in comments (so that the script remains valid Python
7817 A few tags embedded in comments (so that the script remains valid Python
7817 code) divide a file into separate blocks, and the demo can be run one block
7818 code) divide a file into separate blocks, and the demo can be run one block
7818 at a time, with IPython printing (with syntax highlighting) the block before
7819 at a time, with IPython printing (with syntax highlighting) the block before
7819 executing it, and returning to the interactive prompt after each block.
7820 executing it, and returning to the interactive prompt after each block.
7820 The interactive namespace is updated after each block is run with the contents
7821 The interactive namespace is updated after each block is run with the contents
7821 of the demo's namespace.
7822 of the demo's namespace.
7822 \layout Standard
7823 \layout Standard
7823
7824
7824 This allows you to show a piece of code, run it and then execute interactively
7825 This allows you to show a piece of code, run it and then execute interactively
7825 commands based on the variables just created.
7826 commands based on the variables just created.
7826 Once you want to continue, you simply execute the next block of the demo.
7827 Once you want to continue, you simply execute the next block of the demo.
7827 The following listing shows the markup necessary for dividing a script
7828 The following listing shows the markup necessary for dividing a script
7828 into sections for execution as a demo.
7829 into sections for execution as a demo.
7829 \layout Standard
7830 \layout Standard
7830
7831
7831
7832
7832 \begin_inset ERT
7833 \begin_inset ERT
7833 status Open
7834 status Open
7834
7835
7835 \layout Standard
7836 \layout Standard
7836
7837
7837 \backslash
7838 \backslash
7838 codelist{examples/example-demo.py}
7839 codelist{examples/example-demo.py}
7839 \end_inset
7840 \end_inset
7840
7841
7841
7842
7842 \layout Standard
7843 \layout Standard
7843
7844
7844 In order to run a file as a demo, you must first make a
7845 In order to run a file as a demo, you must first make a
7845 \family typewriter
7846 \family typewriter
7846 Demo
7847 Demo
7847 \family default
7848 \family default
7848 object out of it.
7849 object out of it.
7849 If the file is named
7850 If the file is named
7850 \family typewriter
7851 \family typewriter
7851 myscript.py
7852 myscript.py
7852 \family default
7853 \family default
7853 , the following code will make a demo:
7854 , the following code will make a demo:
7854 \layout LyX-Code
7855 \layout LyX-Code
7855
7856
7856 from IPython.demo import Demo
7857 from IPython.demo import Demo
7857 \layout LyX-Code
7858 \layout LyX-Code
7858
7859
7859 mydemo = Demo('myscript.py')
7860 mydemo = Demo('myscript.py')
7860 \layout Standard
7861 \layout Standard
7861
7862
7862 This creates the
7863 This creates the
7863 \family typewriter
7864 \family typewriter
7864 mydemo
7865 mydemo
7865 \family default
7866 \family default
7866 object, whose blocks you run one at a time by simply calling the object
7867 object, whose blocks you run one at a time by simply calling the object
7867 with no arguments.
7868 with no arguments.
7868 If you have autocall active in IPython (the default), all you need to do
7869 If you have autocall active in IPython (the default), all you need to do
7869 is type
7870 is type
7870 \layout LyX-Code
7871 \layout LyX-Code
7871
7872
7872 mydemo
7873 mydemo
7873 \layout Standard
7874 \layout Standard
7874
7875
7875 and IPython will call it, executing each block.
7876 and IPython will call it, executing each block.
7876 Demo objects can be restarted, you can move forward or back skipping blocks,
7877 Demo objects can be restarted, you can move forward or back skipping blocks,
7877 re-execute the last block, etc.
7878 re-execute the last block, etc.
7878 Simply use the Tab key on a demo object to see its methods, and call
7879 Simply use the Tab key on a demo object to see its methods, and call
7879 \family typewriter
7880 \family typewriter
7880 `?'
7881 `?'
7881 \family default
7882 \family default
7882 on them to see their docstrings for more usage details.
7883 on them to see their docstrings for more usage details.
7883 In addition, the
7884 In addition, the
7884 \family typewriter
7885 \family typewriter
7885 demo
7886 demo
7886 \family default
7887 \family default
7887 module itself contains a comprehensive docstring, which you can access
7888 module itself contains a comprehensive docstring, which you can access
7888 via
7889 via
7889 \layout LyX-Code
7890 \layout LyX-Code
7890
7891
7891 from IPython import demo
7892 from IPython import demo
7892 \layout LyX-Code
7893 \layout LyX-Code
7893
7894
7894 demo?
7895 demo?
7895 \layout Standard
7896 \layout Standard
7896
7897
7897
7898
7898 \series bold
7899 \series bold
7899 Limitations:
7900 Limitations:
7900 \series default
7901 \series default
7901 It is important to note that these demos are limited to fairly simple uses.
7902 It is important to note that these demos are limited to fairly simple uses.
7902 In particular, you can
7903 In particular, you can
7903 \emph on
7904 \emph on
7904 not
7905 not
7905 \emph default
7906 \emph default
7906 put division marks in indented code (loops, if statements, function definitions
7907 put division marks in indented code (loops, if statements, function definitions
7907 , etc.) Supporting something like this would basically require tracking the
7908 , etc.) Supporting something like this would basically require tracking the
7908 internal execution state of the Python interpreter, so only top-level divisions
7909 internal execution state of the Python interpreter, so only top-level divisions
7909 are allowed.
7910 are allowed.
7910 If you want to be able to open an IPython instance at an arbitrary point
7911 If you want to be able to open an IPython instance at an arbitrary point
7911 in a program, you can use IPython's embedding facilities, described in
7912 in a program, you can use IPython's embedding facilities, described in
7912 detail in Sec\SpecialChar \@.
7913 detail in Sec\SpecialChar \@.
7913 \SpecialChar ~
7914 \SpecialChar ~
7914
7915
7915 \begin_inset LatexCommand \ref{sec:embed}
7916 \begin_inset LatexCommand \ref{sec:embed}
7916
7917
7917 \end_inset
7918 \end_inset
7918
7919
7919 .
7920 .
7920 \layout Section
7921 \layout Section
7921
7922
7922
7923
7923 \begin_inset LatexCommand \label{sec:matplotlib-support}
7924 \begin_inset LatexCommand \label{sec:matplotlib-support}
7924
7925
7925 \end_inset
7926 \end_inset
7926
7927
7927 Plotting with
7928 Plotting with
7928 \family typewriter
7929 \family typewriter
7929 matplotlib
7930 matplotlib
7930 \family default
7931 \family default
7931
7932
7932 \layout Standard
7933 \layout Standard
7933
7934
7934 The matplotlib library (
7935 The matplotlib library (
7935 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
7936 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
7936
7937
7937 \end_inset
7938 \end_inset
7938
7939
7939 ) provides high quality 2D plotting for Python.
7940 ) provides high quality 2D plotting for Python.
7940 Matplotlib can produce plots on screen using a variety of GUI toolkits,
7941 Matplotlib can produce plots on screen using a variety of GUI toolkits,
7941 including Tk, GTK and WXPython.
7942 including Tk, GTK and WXPython.
7942 It also provides a number of commands useful for scientific computing,
7943 It also provides a number of commands useful for scientific computing,
7943 all with a syntax compatible with that of the popular Matlab program.
7944 all with a syntax compatible with that of the popular Matlab program.
7944 \layout Standard
7945 \layout Standard
7945
7946
7946 IPython accepts the special option
7947 IPython accepts the special option
7947 \family typewriter
7948 \family typewriter
7948 -pylab
7949 -pylab
7949 \family default
7950 \family default
7950 (Sec.\SpecialChar ~
7951 (Sec.\SpecialChar ~
7951
7952
7952 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
7953 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
7953
7954
7954 \end_inset
7955 \end_inset
7955
7956
7956 ).
7957 ).
7957 This configures it to support matplotlib, honoring the settings in the
7958 This configures it to support matplotlib, honoring the settings in the
7958
7959
7959 \family typewriter
7960 \family typewriter
7960 .matplotlibrc
7961 .matplotlibrc
7961 \family default
7962 \family default
7962 file.
7963 file.
7963 IPython will detect the user's choice of matplotlib GUI backend, and automatica
7964 IPython will detect the user's choice of matplotlib GUI backend, and automatica
7964 lly select the proper threading model to prevent blocking.
7965 lly select the proper threading model to prevent blocking.
7965 It also sets matplotlib in interactive mode and modifies
7966 It also sets matplotlib in interactive mode and modifies
7966 \family typewriter
7967 \family typewriter
7967 %run
7968 %run
7968 \family default
7969 \family default
7969 slightly, so that any matplotlib-based script can be executed using
7970 slightly, so that any matplotlib-based script can be executed using
7970 \family typewriter
7971 \family typewriter
7971 %run
7972 %run
7972 \family default
7973 \family default
7973 and the final
7974 and the final
7974 \family typewriter
7975 \family typewriter
7975 show()
7976 show()
7976 \family default
7977 \family default
7977 command does not block the interactive shell.
7978 command does not block the interactive shell.
7978 \layout Standard
7979 \layout Standard
7979
7980
7980 The
7981 The
7981 \family typewriter
7982 \family typewriter
7982 -pylab
7983 -pylab
7983 \family default
7984 \family default
7984 option must be given first in order for IPython to configure its threading
7985 option must be given first in order for IPython to configure its threading
7985 mode.
7986 mode.
7986 However, you can still issue other options afterwards.
7987 However, you can still issue other options afterwards.
7987 This allows you to have a matplotlib-based environment customized with
7988 This allows you to have a matplotlib-based environment customized with
7988 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
7989 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
7989
7990
7990 \begin_inset LatexCommand \ref{sec:profiles}
7991 \begin_inset LatexCommand \ref{sec:profiles}
7991
7992
7992 \end_inset
7993 \end_inset
7993
7994
7994 ): ``
7995 ): ``
7995 \family typewriter
7996 \family typewriter
7996 ipython -pylab -p myprofile
7997 ipython -pylab -p myprofile
7997 \family default
7998 \family default
7998 '' will load the profile defined in
7999 '' will load the profile defined in
7999 \family typewriter
8000 \family typewriter
8000 ipythonrc-myprofile
8001 ipythonrc-myprofile
8001 \family default
8002 \family default
8002 after configuring matplotlib.
8003 after configuring matplotlib.
8003 \layout Section
8004 \layout Section
8004
8005
8005
8006
8006 \begin_inset LatexCommand \label{sec:Gnuplot}
8007 \begin_inset LatexCommand \label{sec:Gnuplot}
8007
8008
8008 \end_inset
8009 \end_inset
8009
8010
8010 Plotting with
8011 Plotting with
8011 \family typewriter
8012 \family typewriter
8012 Gnuplot
8013 Gnuplot
8013 \layout Standard
8014 \layout Standard
8014
8015
8015 Through the magic extension system described in sec.
8016 Through the magic extension system described in sec.
8016
8017
8017 \begin_inset LatexCommand \ref{sec:magic}
8018 \begin_inset LatexCommand \ref{sec:magic}
8018
8019
8019 \end_inset
8020 \end_inset
8020
8021
8021 , IPython incorporates a mechanism for conveniently interfacing with the
8022 , IPython incorporates a mechanism for conveniently interfacing with the
8022 Gnuplot system (
8023 Gnuplot system (
8023 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
8024 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
8024
8025
8025 \end_inset
8026 \end_inset
8026
8027
8027 ).
8028 ).
8028 Gnuplot is a very complete 2D and 3D plotting package available for many
8029 Gnuplot is a very complete 2D and 3D plotting package available for many
8029 operating systems and commonly included in modern Linux distributions.
8030 operating systems and commonly included in modern Linux distributions.
8030
8031
8031 \layout Standard
8032 \layout Standard
8032
8033
8033 Besides having Gnuplot installed, this functionality requires the
8034 Besides having Gnuplot installed, this functionality requires the
8034 \family typewriter
8035 \family typewriter
8035 Gnuplot.py
8036 Gnuplot.py
8036 \family default
8037 \family default
8037 module for interfacing python with Gnuplot.
8038 module for interfacing python with Gnuplot.
8038 It can be downloaded from:
8039 It can be downloaded from:
8039 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8040 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8040
8041
8041 \end_inset
8042 \end_inset
8042
8043
8043 .
8044 .
8044 \layout Subsection
8045 \layout Subsection
8045
8046
8046 Proper Gnuplot configuration
8047 Proper Gnuplot configuration
8047 \layout Standard
8048 \layout Standard
8048
8049
8049 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8050 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8050 However, as of
8051 However, as of
8051 \family typewriter
8052 \family typewriter
8052 Gnuplot.py
8053 Gnuplot.py
8053 \family default
8054 \family default
8054 version 1.7, a new option was added to communicate between Python and Gnuplot
8055 version 1.7, a new option was added to communicate between Python and Gnuplot
8055 via FIFOs (pipes).
8056 via FIFOs (pipes).
8056 This mechanism, while fast, also breaks the mouse system.
8057 This mechanism, while fast, also breaks the mouse system.
8057 You must therefore set the variable
8058 You must therefore set the variable
8058 \family typewriter
8059 \family typewriter
8059 prefer_fifo_data
8060 prefer_fifo_data
8060 \family default
8061 \family default
8061 to
8062 to
8062 \family typewriter
8063 \family typewriter
8063 0
8064 0
8064 \family default
8065 \family default
8065 in file
8066 in file
8066 \family typewriter
8067 \family typewriter
8067 gp_unix.py
8068 gp_unix.py
8068 \family default
8069 \family default
8069 if you wish to keep the interactive mouse and keyboard features working
8070 if you wish to keep the interactive mouse and keyboard features working
8070 properly (
8071 properly (
8071 \family typewriter
8072 \family typewriter
8072 prefer_inline_data
8073 prefer_inline_data
8073 \family default
8074 \family default
8074 also must be
8075 also must be
8075 \family typewriter
8076 \family typewriter
8076 0
8077 0
8077 \family default
8078 \family default
8078 , but this is the default so unless you've changed it manually you should
8079 , but this is the default so unless you've changed it manually you should
8079 be fine).
8080 be fine).
8080 \layout Standard
8081 \layout Standard
8081
8082
8082 'Out of the box', Gnuplot is configured with a rather poor set of size,
8083 'Out of the box', Gnuplot is configured with a rather poor set of size,
8083 color and linewidth choices which make the graphs fairly hard to read on
8084 color and linewidth choices which make the graphs fairly hard to read on
8084 modern high-resolution displays (although they work fine on old 640x480
8085 modern high-resolution displays (although they work fine on old 640x480
8085 ones).
8086 ones).
8086 Below is a section of my
8087 Below is a section of my
8087 \family typewriter
8088 \family typewriter
8088 .Xdefaults
8089 .Xdefaults
8089 \family default
8090 \family default
8090 file which I use for having a more convenient Gnuplot setup.
8091 file which I use for having a more convenient Gnuplot setup.
8091 Remember to load it by running
8092 Remember to load it by running
8092 \family typewriter
8093 \family typewriter
8093 `xrdb .Xdefaults`
8094 `xrdb .Xdefaults`
8094 \family default
8095 \family default
8095 :
8096 :
8096 \layout Standard
8097 \layout Standard
8097
8098
8098
8099
8099 \family typewriter
8100 \family typewriter
8100 !******************************************************************
8101 !******************************************************************
8101 \newline
8102 \newline
8102 ! gnuplot options
8103 ! gnuplot options
8103 \newline
8104 \newline
8104 ! modify this for a convenient window size
8105 ! modify this for a convenient window size
8105 \newline
8106 \newline
8106 gnuplot*geometry: 780x580
8107 gnuplot*geometry: 780x580
8107 \layout Standard
8108 \layout Standard
8108
8109
8109
8110
8110 \family typewriter
8111 \family typewriter
8111 ! on-screen font (not for PostScript)
8112 ! on-screen font (not for PostScript)
8112 \newline
8113 \newline
8113 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8114 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8114 \layout Standard
8115 \layout Standard
8115
8116
8116
8117
8117 \family typewriter
8118 \family typewriter
8118 ! color options
8119 ! color options
8119 \newline
8120 \newline
8120 gnuplot*background: black
8121 gnuplot*background: black
8121 \newline
8122 \newline
8122 gnuplot*textColor: white
8123 gnuplot*textColor: white
8123 \newline
8124 \newline
8124 gnuplot*borderColor: white
8125 gnuplot*borderColor: white
8125 \newline
8126 \newline
8126 gnuplot*axisColor: white
8127 gnuplot*axisColor: white
8127 \newline
8128 \newline
8128 gnuplot*line1Color: red
8129 gnuplot*line1Color: red
8129 \newline
8130 \newline
8130 gnuplot*line2Color: green
8131 gnuplot*line2Color: green
8131 \newline
8132 \newline
8132 gnuplot*line3Color: blue
8133 gnuplot*line3Color: blue
8133 \newline
8134 \newline
8134 gnuplot*line4Color: magenta
8135 gnuplot*line4Color: magenta
8135 \newline
8136 \newline
8136 gnuplot*line5Color: cyan
8137 gnuplot*line5Color: cyan
8137 \newline
8138 \newline
8138 gnuplot*line6Color: sienna
8139 gnuplot*line6Color: sienna
8139 \newline
8140 \newline
8140 gnuplot*line7Color: orange
8141 gnuplot*line7Color: orange
8141 \newline
8142 \newline
8142 gnuplot*line8Color: coral
8143 gnuplot*line8Color: coral
8143 \layout Standard
8144 \layout Standard
8144
8145
8145
8146
8146 \family typewriter
8147 \family typewriter
8147 ! multiplicative factor for point styles
8148 ! multiplicative factor for point styles
8148 \newline
8149 \newline
8149 gnuplot*pointsize: 2
8150 gnuplot*pointsize: 2
8150 \layout Standard
8151 \layout Standard
8151
8152
8152
8153
8153 \family typewriter
8154 \family typewriter
8154 ! line width options (in pixels)
8155 ! line width options (in pixels)
8155 \newline
8156 \newline
8156 gnuplot*borderWidth: 2
8157 gnuplot*borderWidth: 2
8157 \newline
8158 \newline
8158 gnuplot*axisWidth: 2
8159 gnuplot*axisWidth: 2
8159 \newline
8160 \newline
8160 gnuplot*line1Width: 2
8161 gnuplot*line1Width: 2
8161 \newline
8162 \newline
8162 gnuplot*line2Width: 2
8163 gnuplot*line2Width: 2
8163 \newline
8164 \newline
8164 gnuplot*line3Width: 2
8165 gnuplot*line3Width: 2
8165 \newline
8166 \newline
8166 gnuplot*line4Width: 2
8167 gnuplot*line4Width: 2
8167 \newline
8168 \newline
8168 gnuplot*line5Width: 2
8169 gnuplot*line5Width: 2
8169 \newline
8170 \newline
8170 gnuplot*line6Width: 2
8171 gnuplot*line6Width: 2
8171 \newline
8172 \newline
8172 gnuplot*line7Width: 2
8173 gnuplot*line7Width: 2
8173 \newline
8174 \newline
8174 gnuplot*line8Width: 2
8175 gnuplot*line8Width: 2
8175 \layout Subsection
8176 \layout Subsection
8176
8177
8177 The
8178 The
8178 \family typewriter
8179 \family typewriter
8179 IPython.GnuplotRuntime
8180 IPython.GnuplotRuntime
8180 \family default
8181 \family default
8181 module
8182 module
8182 \layout Standard
8183 \layout Standard
8183
8184
8184 IPython includes a module called
8185 IPython includes a module called
8185 \family typewriter
8186 \family typewriter
8186 Gnuplot2.py
8187 Gnuplot2.py
8187 \family default
8188 \family default
8188 which extends and improves the default
8189 which extends and improves the default
8189 \family typewriter
8190 \family typewriter
8190 Gnuplot
8191 Gnuplot
8191 \family default
8192 \family default
8192 .
8193 .
8193 \family typewriter
8194 \family typewriter
8194 py
8195 py
8195 \family default
8196 \family default
8196 (which it still relies upon).
8197 (which it still relies upon).
8197 For example, the new
8198 For example, the new
8198 \family typewriter
8199 \family typewriter
8199 plot
8200 plot
8200 \family default
8201 \family default
8201 function adds several improvements to the original making it more convenient
8202 function adds several improvements to the original making it more convenient
8202 for interactive use, and
8203 for interactive use, and
8203 \family typewriter
8204 \family typewriter
8204 hardcopy
8205 hardcopy
8205 \family default
8206 \family default
8206 fixes a bug in the original which under some circumstances blocks the creation
8207 fixes a bug in the original which under some circumstances blocks the creation
8207 of PostScript output.
8208 of PostScript output.
8208 \layout Standard
8209 \layout Standard
8209
8210
8210 For scripting use,
8211 For scripting use,
8211 \family typewriter
8212 \family typewriter
8212 GnuplotRuntime.py
8213 GnuplotRuntime.py
8213 \family default
8214 \family default
8214 is provided, which wraps
8215 is provided, which wraps
8215 \family typewriter
8216 \family typewriter
8216 Gnuplot2.py
8217 Gnuplot2.py
8217 \family default
8218 \family default
8218 and creates a series of global aliases.
8219 and creates a series of global aliases.
8219 These make it easy to control Gnuplot plotting jobs through the Python
8220 These make it easy to control Gnuplot plotting jobs through the Python
8220 language.
8221 language.
8221 \layout Standard
8222 \layout Standard
8222
8223
8223 Below is some example code which illustrates how to configure Gnuplot inside
8224 Below is some example code which illustrates how to configure Gnuplot inside
8224 your own programs but have it available for further interactive use through
8225 your own programs but have it available for further interactive use through
8225 an embedded IPython instance.
8226 an embedded IPython instance.
8226 Simply run this file at a system prompt.
8227 Simply run this file at a system prompt.
8227 This file is provided as
8228 This file is provided as
8228 \family typewriter
8229 \family typewriter
8229 example-gnuplot.py
8230 example-gnuplot.py
8230 \family default
8231 \family default
8231 in the examples directory:
8232 in the examples directory:
8232 \layout Standard
8233 \layout Standard
8233
8234
8234
8235
8235 \begin_inset ERT
8236 \begin_inset ERT
8236 status Open
8237 status Open
8237
8238
8238 \layout Standard
8239 \layout Standard
8239
8240
8240 \backslash
8241 \backslash
8241 codelist{examples/example-gnuplot.py}
8242 codelist{examples/example-gnuplot.py}
8242 \end_inset
8243 \end_inset
8243
8244
8244
8245
8245 \layout Subsection
8246 \layout Subsection
8246
8247
8247 The
8248 The
8248 \family typewriter
8249 \family typewriter
8249 numeric
8250 numeric
8250 \family default
8251 \family default
8251 profile: a scientific computing environment
8252 profile: a scientific computing environment
8252 \layout Standard
8253 \layout Standard
8253
8254
8254 The
8255 The
8255 \family typewriter
8256 \family typewriter
8256 numeric
8257 numeric
8257 \family default
8258 \family default
8258 IPython profile, which you can activate with
8259 IPython profile, which you can activate with
8259 \family typewriter
8260 \family typewriter
8260 `ipython -p numeric
8261 `ipython -p numeric
8261 \family default
8262 \family default
8262 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8263 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8263 other useful things for numerical computing), contained in the
8264 other useful things for numerical computing), contained in the
8264 \family typewriter
8265 \family typewriter
8265 IPython.GnuplotInteractive
8266 IPython.GnuplotInteractive
8266 \family default
8267 \family default
8267 module.
8268 module.
8268 This will create the globals
8269 This will create the globals
8269 \family typewriter
8270 \family typewriter
8270 Gnuplot
8271 Gnuplot
8271 \family default
8272 \family default
8272 (an alias to the improved Gnuplot2 module),
8273 (an alias to the improved Gnuplot2 module),
8273 \family typewriter
8274 \family typewriter
8274 gp
8275 gp
8275 \family default
8276 \family default
8276 (a Gnuplot active instance), the new magic commands
8277 (a Gnuplot active instance), the new magic commands
8277 \family typewriter
8278 \family typewriter
8278 %gpc
8279 %gpc
8279 \family default
8280 \family default
8280 and
8281 and
8281 \family typewriter
8282 \family typewriter
8282 %gp_set_instance
8283 %gp_set_instance
8283 \family default
8284 \family default
8284 and several other convenient globals.
8285 and several other convenient globals.
8285 Type
8286 Type
8286 \family typewriter
8287 \family typewriter
8287 gphelp()
8288 gphelp()
8288 \family default
8289 \family default
8289 for further details.
8290 for further details.
8290 \layout Standard
8291 \layout Standard
8291
8292
8292 This should turn IPython into a convenient environment for numerical computing,
8293 This should turn IPython into a convenient environment for numerical computing,
8293 with all the functions in the NumPy library and the Gnuplot facilities
8294 with all the functions in the NumPy library and the Gnuplot facilities
8294 for plotting.
8295 for plotting.
8295 Further improvements can be obtained by loading the SciPy libraries for
8296 Further improvements can be obtained by loading the SciPy libraries for
8296 scientific computing, available at
8297 scientific computing, available at
8297 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8298 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8298
8299
8299 \end_inset
8300 \end_inset
8300
8301
8301 .
8302 .
8302 \layout Standard
8303 \layout Standard
8303
8304
8304 If you are in the middle of a working session with numerical objects and
8305 If you are in the middle of a working session with numerical objects and
8305 need to plot them but you didn't start the
8306 need to plot them but you didn't start the
8306 \family typewriter
8307 \family typewriter
8307 numeric
8308 numeric
8308 \family default
8309 \family default
8309 profile, you can load these extensions at any time by typing
8310 profile, you can load these extensions at any time by typing
8310 \newline
8311 \newline
8311
8312
8312 \family typewriter
8313 \family typewriter
8313 from IPython.GnuplotInteractive import *
8314 from IPython.GnuplotInteractive import *
8314 \newline
8315 \newline
8315
8316
8316 \family default
8317 \family default
8317 at the IPython prompt.
8318 at the IPython prompt.
8318 This will allow you to keep your objects intact and start using Gnuplot
8319 This will allow you to keep your objects intact and start using Gnuplot
8319 to view them.
8320 to view them.
8320 \layout Section
8321 \layout Section
8321
8322
8322 Reporting bugs
8323 Reporting bugs
8323 \layout Subsection*
8324 \layout Subsection*
8324
8325
8325 Automatic crash reports
8326 Automatic crash reports
8326 \layout Standard
8327 \layout Standard
8327
8328
8328 Ideally, IPython itself shouldn't crash.
8329 Ideally, IPython itself shouldn't crash.
8329 It will catch exceptions produced by you, but bugs in its internals will
8330 It will catch exceptions produced by you, but bugs in its internals will
8330 still crash it.
8331 still crash it.
8331 \layout Standard
8332 \layout Standard
8332
8333
8333 In such a situation, IPython will leave a file named
8334 In such a situation, IPython will leave a file named
8334 \family typewriter
8335 \family typewriter
8335 IPython_crash_report.txt
8336 IPython_crash_report.txt
8336 \family default
8337 \family default
8337 in your IPYTHONDIR directory (that way if crashes happen several times
8338 in your IPYTHONDIR directory (that way if crashes happen several times
8338 it won't litter many directories, the post-mortem file is always located
8339 it won't litter many directories, the post-mortem file is always located
8339 in the same place and new occurrences just overwrite the previous one).
8340 in the same place and new occurrences just overwrite the previous one).
8340 If you can mail this file to the developers (see sec.
8341 If you can mail this file to the developers (see sec.
8341
8342
8342 \begin_inset LatexCommand \ref{sec:credits}
8343 \begin_inset LatexCommand \ref{sec:credits}
8343
8344
8344 \end_inset
8345 \end_inset
8345
8346
8346 for names and addresses), it will help us
8347 for names and addresses), it will help us
8347 \emph on
8348 \emph on
8348 a lot
8349 a lot
8349 \emph default
8350 \emph default
8350 in understanding the cause of the problem and fixing it sooner.
8351 in understanding the cause of the problem and fixing it sooner.
8351 \layout Subsection*
8352 \layout Subsection*
8352
8353
8353 The bug tracker
8354 The bug tracker
8354 \layout Standard
8355 \layout Standard
8355
8356
8356 IPython also has an online bug-tracker, located at
8357 IPython also has an online bug-tracker, located at
8357 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8358 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8358
8359
8359 \end_inset
8360 \end_inset
8360
8361
8361 .
8362 .
8362 In addition to mailing the developers, it would be a good idea to file
8363 In addition to mailing the developers, it would be a good idea to file
8363 a bug report here.
8364 a bug report here.
8364 This will ensure that the issue is properly followed to conclusion.
8365 This will ensure that the issue is properly followed to conclusion.
8365 \layout Standard
8366 \layout Standard
8366
8367
8367 You can also use this bug tracker to file feature requests.
8368 You can also use this bug tracker to file feature requests.
8368 \layout Section
8369 \layout Section
8369
8370
8370 Brief history
8371 Brief history
8371 \layout Subsection
8372 \layout Subsection
8372
8373
8373 Origins
8374 Origins
8374 \layout Standard
8375 \layout Standard
8375
8376
8376 The current IPython system grew out of the following three projects:
8377 The current IPython system grew out of the following three projects:
8377 \layout List
8378 \layout List
8378 \labelwidthstring 00.00.0000
8379 \labelwidthstring 00.00.0000
8379
8380
8380 ipython by Fernando Pérez.
8381 ipython by Fernando Pérez.
8381 I was working on adding Mathematica-type prompts and a flexible configuration
8382 I was working on adding Mathematica-type prompts and a flexible configuration
8382 system (something better than
8383 system (something better than
8383 \family typewriter
8384 \family typewriter
8384 $PYTHONSTARTUP
8385 $PYTHONSTARTUP
8385 \family default
8386 \family default
8386 ) to the standard Python interactive interpreter.
8387 ) to the standard Python interactive interpreter.
8387 \layout List
8388 \layout List
8388 \labelwidthstring 00.00.0000
8389 \labelwidthstring 00.00.0000
8389
8390
8390 IPP by Janko Hauser.
8391 IPP by Janko Hauser.
8391 Very well organized, great usability.
8392 Very well organized, great usability.
8392 Had an old help system.
8393 Had an old help system.
8393 IPP was used as the `container' code into which I added the functionality
8394 IPP was used as the `container' code into which I added the functionality
8394 from ipython and LazyPython.
8395 from ipython and LazyPython.
8395 \layout List
8396 \layout List
8396 \labelwidthstring 00.00.0000
8397 \labelwidthstring 00.00.0000
8397
8398
8398 LazyPython by Nathan Gray.
8399 LazyPython by Nathan Gray.
8399 Simple but
8400 Simple but
8400 \emph on
8401 \emph on
8401 very
8402 very
8402 \emph default
8403 \emph default
8403 powerful.
8404 powerful.
8404 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8405 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8405 were all taken from here.
8406 were all taken from here.
8406 \layout Standard
8407 \layout Standard
8407
8408
8408 When I found out (see sec.
8409 When I found out (see sec.
8409
8410
8410 \begin_inset LatexCommand \ref{figgins}
8411 \begin_inset LatexCommand \ref{figgins}
8411
8412
8412 \end_inset
8413 \end_inset
8413
8414
8414 ) about IPP and LazyPython I tried to join all three into a unified system.
8415 ) about IPP and LazyPython I tried to join all three into a unified system.
8415 I thought this could provide a very nice working environment, both for
8416 I thought this could provide a very nice working environment, both for
8416 regular programming and scientific computing: shell-like features, IDL/Matlab
8417 regular programming and scientific computing: shell-like features, IDL/Matlab
8417 numerics, Mathematica-type prompt history and great object introspection
8418 numerics, Mathematica-type prompt history and great object introspection
8418 and help facilities.
8419 and help facilities.
8419 I think it worked reasonably well, though it was a lot more work than I
8420 I think it worked reasonably well, though it was a lot more work than I
8420 had initially planned.
8421 had initially planned.
8421 \layout Subsection
8422 \layout Subsection
8422
8423
8423 Current status
8424 Current status
8424 \layout Standard
8425 \layout Standard
8425
8426
8426 The above listed features work, and quite well for the most part.
8427 The above listed features work, and quite well for the most part.
8427 But until a major internal restructuring is done (see below), only bug
8428 But until a major internal restructuring is done (see below), only bug
8428 fixing will be done, no other features will be added (unless very minor
8429 fixing will be done, no other features will be added (unless very minor
8429 and well localized in the cleaner parts of the code).
8430 and well localized in the cleaner parts of the code).
8430 \layout Standard
8431 \layout Standard
8431
8432
8432 IPython consists of some 12000 lines of pure python code, of which roughly
8433 IPython consists of some 12000 lines of pure python code, of which roughly
8433 50% are fairly clean.
8434 50% are fairly clean.
8434 The other 50% are fragile, messy code which needs a massive restructuring
8435 The other 50% are fragile, messy code which needs a massive restructuring
8435 before any further major work is done.
8436 before any further major work is done.
8436 Even the messy code is fairly well documented though, and most of the problems
8437 Even the messy code is fairly well documented though, and most of the problems
8437 in the (non-existent) class design are well pointed to by a PyChecker run.
8438 in the (non-existent) class design are well pointed to by a PyChecker run.
8438 So the rewriting work isn't that bad, it will just be time-consuming.
8439 So the rewriting work isn't that bad, it will just be time-consuming.
8439 \layout Subsection
8440 \layout Subsection
8440
8441
8441 Future
8442 Future
8442 \layout Standard
8443 \layout Standard
8443
8444
8444 See the separate
8445 See the separate
8445 \family typewriter
8446 \family typewriter
8446 new_design
8447 new_design
8447 \family default
8448 \family default
8448 document for details.
8449 document for details.
8449 Ultimately, I would like to see IPython become part of the standard Python
8450 Ultimately, I would like to see IPython become part of the standard Python
8450 distribution as a `big brother with batteries' to the standard Python interacti
8451 distribution as a `big brother with batteries' to the standard Python interacti
8451 ve interpreter.
8452 ve interpreter.
8452 But that will never happen with the current state of the code, so all contribut
8453 But that will never happen with the current state of the code, so all contribut
8453 ions are welcome.
8454 ions are welcome.
8454 \layout Section
8455 \layout Section
8455
8456
8456 License
8457 License
8457 \layout Standard
8458 \layout Standard
8458
8459
8459 IPython is released under the terms of the BSD license, whose general form
8460 IPython is released under the terms of the BSD license, whose general form
8460 can be found at:
8461 can be found at:
8461 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8462 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8462
8463
8463 \end_inset
8464 \end_inset
8464
8465
8465 .
8466 .
8466 The full text of the IPython license is reproduced below:
8467 The full text of the IPython license is reproduced below:
8467 \layout Quote
8468 \layout Quote
8468
8469
8469
8470
8470 \family typewriter
8471 \family typewriter
8471 \size small
8472 \size small
8472 IPython is released under a BSD-type license.
8473 IPython is released under a BSD-type license.
8473 \layout Quote
8474 \layout Quote
8474
8475
8475
8476
8476 \family typewriter
8477 \family typewriter
8477 \size small
8478 \size small
8478 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8479 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8479 \layout Quote
8480 \layout Quote
8480
8481
8481
8482
8482 \family typewriter
8483 \family typewriter
8483 \size small
8484 \size small
8484 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8485 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8485 \newline
8486 \newline
8486 Nathaniel Gray <n8gray@caltech.edu>.
8487 Nathaniel Gray <n8gray@caltech.edu>.
8487 \layout Quote
8488 \layout Quote
8488
8489
8489
8490
8490 \family typewriter
8491 \family typewriter
8491 \size small
8492 \size small
8492 All rights reserved.
8493 All rights reserved.
8493 \layout Quote
8494 \layout Quote
8494
8495
8495
8496
8496 \family typewriter
8497 \family typewriter
8497 \size small
8498 \size small
8498 Redistribution and use in source and binary forms, with or without modification,
8499 Redistribution and use in source and binary forms, with or without modification,
8499 are permitted provided that the following conditions are met:
8500 are permitted provided that the following conditions are met:
8500 \layout Quote
8501 \layout Quote
8501
8502
8502
8503
8503 \family typewriter
8504 \family typewriter
8504 \size small
8505 \size small
8505 a.
8506 a.
8506 Redistributions of source code must retain the above copyright notice,
8507 Redistributions of source code must retain the above copyright notice,
8507 this list of conditions and the following disclaimer.
8508 this list of conditions and the following disclaimer.
8508 \layout Quote
8509 \layout Quote
8509
8510
8510
8511
8511 \family typewriter
8512 \family typewriter
8512 \size small
8513 \size small
8513 b.
8514 b.
8514 Redistributions in binary form must reproduce the above copyright notice,
8515 Redistributions in binary form must reproduce the above copyright notice,
8515 this list of conditions and the following disclaimer in the documentation
8516 this list of conditions and the following disclaimer in the documentation
8516 and/or other materials provided with the distribution.
8517 and/or other materials provided with the distribution.
8517 \layout Quote
8518 \layout Quote
8518
8519
8519
8520
8520 \family typewriter
8521 \family typewriter
8521 \size small
8522 \size small
8522 c.
8523 c.
8523 Neither the name of the copyright holders nor the names of any contributors
8524 Neither the name of the copyright holders nor the names of any contributors
8524 to this software may be used to endorse or promote products derived from
8525 to this software may be used to endorse or promote products derived from
8525 this software without specific prior written permission.
8526 this software without specific prior written permission.
8526 \layout Quote
8527 \layout Quote
8527
8528
8528
8529
8529 \family typewriter
8530 \family typewriter
8530 \size small
8531 \size small
8531 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8532 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8532 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8533 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8533 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8534 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8534 PURPOSE ARE DISCLAIMED.
8535 PURPOSE ARE DISCLAIMED.
8535 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8536 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8536 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8537 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8537 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8538 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8538 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8539 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8539 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8540 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8540 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8541 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8541 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8542 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8542
8543
8543 \layout Standard
8544 \layout Standard
8544
8545
8545 Individual authors are the holders of the copyright for their code and are
8546 Individual authors are the holders of the copyright for their code and are
8546 listed in each file.
8547 listed in each file.
8547 \layout Standard
8548 \layout Standard
8548
8549
8549 Some files (
8550 Some files (
8550 \family typewriter
8551 \family typewriter
8551 DPyGetOpt.py
8552 DPyGetOpt.py
8552 \family default
8553 \family default
8553 , for example) may be licensed under different conditions.
8554 , for example) may be licensed under different conditions.
8554 Ultimately each file indicates clearly the conditions under which its author/au
8555 Ultimately each file indicates clearly the conditions under which its author/au
8555 thors have decided to publish the code.
8556 thors have decided to publish the code.
8556 \layout Standard
8557 \layout Standard
8557
8558
8558 Versions of IPython up to and including 0.6.3 were released under the GNU
8559 Versions of IPython up to and including 0.6.3 were released under the GNU
8559 Lesser General Public License (LGPL), available at
8560 Lesser General Public License (LGPL), available at
8560 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8561 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8561
8562
8562 \end_inset
8563 \end_inset
8563
8564
8564 .
8565 .
8565 \layout Section
8566 \layout Section
8566
8567
8567
8568
8568 \begin_inset LatexCommand \label{sec:credits}
8569 \begin_inset LatexCommand \label{sec:credits}
8569
8570
8570 \end_inset
8571 \end_inset
8571
8572
8572 Credits
8573 Credits
8573 \layout Standard
8574 \layout Standard
8574
8575
8575 IPython is mainly developed by Fernando Pérez
8576 IPython is mainly developed by Fernando Pérez
8576 \family typewriter
8577 \family typewriter
8577 <fperez@colorado.edu>
8578 <fperez@colorado.edu>
8578 \family default
8579 \family default
8579 , but the project was born from mixing in Fernando's code with the IPP project
8580 , but the project was born from mixing in Fernando's code with the IPP project
8580 by Janko Hauser
8581 by Janko Hauser
8581 \family typewriter
8582 \family typewriter
8582 <jhauser-AT-zscout.de>
8583 <jhauser-AT-zscout.de>
8583 \family default
8584 \family default
8584 and LazyPython by Nathan Gray
8585 and LazyPython by Nathan Gray
8585 \family typewriter
8586 \family typewriter
8586 <n8gray-AT-caltech.edu>
8587 <n8gray-AT-caltech.edu>
8587 \family default
8588 \family default
8588 .
8589 .
8589 For all IPython-related requests, please contact Fernando.
8590 For all IPython-related requests, please contact Fernando.
8590
8591
8591 \layout Standard
8592 \layout Standard
8592
8593
8593 As of late 2005, the following developers have joined the core team:
8594 As of late 2005, the following developers have joined the core team:
8594 \layout List
8595 \layout List
8595 \labelwidthstring 00.00.0000
8596 \labelwidthstring 00.00.0000
8596
8597
8597 Robert\SpecialChar ~
8598 Robert\SpecialChar ~
8598 Kern
8599 Kern
8599 \family typewriter
8600 \family typewriter
8600 <rkern-AT-enthought.com>
8601 <rkern-AT-enthought.com>
8601 \family default
8602 \family default
8602 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8603 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8603 ve notebooks (XML documents) and graphical interface.
8604 ve notebooks (XML documents) and graphical interface.
8604 This project was awarded to the students Tzanko Matev
8605 This project was awarded to the students Tzanko Matev
8605 \family typewriter
8606 \family typewriter
8606 <tsanko-AT-gmail.com>
8607 <tsanko-AT-gmail.com>
8607 \family default
8608 \family default
8608 and Toni Alatalo
8609 and Toni Alatalo
8609 \family typewriter
8610 \family typewriter
8610 <antont-AT-an.org>
8611 <antont-AT-an.org>
8611 \layout List
8612 \layout List
8612 \labelwidthstring 00.00.0000
8613 \labelwidthstring 00.00.0000
8613
8614
8614 Brian\SpecialChar ~
8615 Brian\SpecialChar ~
8615 Granger
8616 Granger
8616 \family typewriter
8617 \family typewriter
8617 <bgranger-AT-scu.edu>
8618 <bgranger-AT-scu.edu>
8618 \family default
8619 \family default
8619 : extending IPython to allow support for interactive parallel computing.
8620 : extending IPython to allow support for interactive parallel computing.
8620 \layout Standard
8621 \layout Standard
8621
8622
8622 User or development help should be requested via the IPython mailing lists:
8623 User or development help should be requested via the IPython mailing lists:
8623 \layout Description
8624 \layout Description
8624
8625
8625 User\SpecialChar ~
8626 User\SpecialChar ~
8626 list:
8627 list:
8627 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8628 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8628
8629
8629 \end_inset
8630 \end_inset
8630
8631
8631
8632
8632 \layout Description
8633 \layout Description
8633
8634
8634 Developer's\SpecialChar ~
8635 Developer's\SpecialChar ~
8635 list:
8636 list:
8636 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8637 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8637
8638
8638 \end_inset
8639 \end_inset
8639
8640
8640
8641
8641 \layout Standard
8642 \layout Standard
8642
8643
8643 The IPython project is also very grateful to
8644 The IPython project is also very grateful to
8644 \begin_inset Foot
8645 \begin_inset Foot
8645 collapsed true
8646 collapsed true
8646
8647
8647 \layout Standard
8648 \layout Standard
8648
8649
8649 I've mangled email addresses to reduce spam, since the IPython manuals can
8650 I've mangled email addresses to reduce spam, since the IPython manuals can
8650 be accessed online.
8651 be accessed online.
8651 \end_inset
8652 \end_inset
8652
8653
8653 :
8654 :
8654 \layout Standard
8655 \layout Standard
8655
8656
8656 Bill Bumgarner
8657 Bill Bumgarner
8657 \family typewriter
8658 \family typewriter
8658 <bbum-AT-friday.com>
8659 <bbum-AT-friday.com>
8659 \family default
8660 \family default
8660 : for providing the DPyGetOpt module which gives very powerful and convenient
8661 : for providing the DPyGetOpt module which gives very powerful and convenient
8661 handling of command-line options (light years ahead of what Python 2.1.1's
8662 handling of command-line options (light years ahead of what Python 2.1.1's
8662 getopt module does).
8663 getopt module does).
8663 \layout Standard
8664 \layout Standard
8664
8665
8665 Ka-Ping Yee
8666 Ka-Ping Yee
8666 \family typewriter
8667 \family typewriter
8667 <ping-AT-lfw.org>
8668 <ping-AT-lfw.org>
8668 \family default
8669 \family default
8669 : for providing the Itpl module for convenient and powerful string interpolation
8670 : for providing the Itpl module for convenient and powerful string interpolation
8670 with a much nicer syntax than formatting through the '%' operator.
8671 with a much nicer syntax than formatting through the '%' operator.
8671 \layout Standard
8672 \layout Standard
8672
8673
8673 Arnd Bäcker
8674 Arnd Bäcker
8674 \family typewriter
8675 \family typewriter
8675 <baecker-AT-physik.tu-dresden.de>
8676 <baecker-AT-physik.tu-dresden.de>
8676 \family default
8677 \family default
8677 : for his many very useful suggestions and comments, and lots of help with
8678 : for his many very useful suggestions and comments, and lots of help with
8678 testing and documentation checking.
8679 testing and documentation checking.
8679 Many of IPython's newer features are a result of discussions with him (bugs
8680 Many of IPython's newer features are a result of discussions with him (bugs
8680 are still my fault, not his).
8681 are still my fault, not his).
8681 \layout Standard
8682 \layout Standard
8682
8683
8683 Obviously Guido van\SpecialChar ~
8684 Obviously Guido van\SpecialChar ~
8684 Rossum and the whole Python development team, that goes
8685 Rossum and the whole Python development team, that goes
8685 without saying.
8686 without saying.
8686 \layout Standard
8687 \layout Standard
8687
8688
8688 IPython's website is generously hosted at
8689 IPython's website is generously hosted at
8689 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8690 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8690
8691
8691 \end_inset
8692 \end_inset
8692
8693
8693 by Enthought (
8694 by Enthought (
8694 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8695 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8695
8696
8696 \end_inset
8697 \end_inset
8697
8698
8698 ).
8699 ).
8699 I am very grateful to them and all of the SciPy team for their contribution.
8700 I am very grateful to them and all of the SciPy team for their contribution.
8700 \layout Standard
8701 \layout Standard
8701
8702
8702
8703
8703 \begin_inset LatexCommand \label{figgins}
8704 \begin_inset LatexCommand \label{figgins}
8704
8705
8705 \end_inset
8706 \end_inset
8706
8707
8707 Fernando would also like to thank Stephen Figgins
8708 Fernando would also like to thank Stephen Figgins
8708 \family typewriter
8709 \family typewriter
8709 <fig-AT-monitor.net>
8710 <fig-AT-monitor.net>
8710 \family default
8711 \family default
8711 , an O'Reilly Python editor.
8712 , an O'Reilly Python editor.
8712 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8713 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8713 started.
8714 started.
8714 You can read it at:
8715 You can read it at:
8715 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8716 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8716
8717
8717 \end_inset
8718 \end_inset
8718
8719
8719 .
8720 .
8720 \layout Standard
8721 \layout Standard
8721
8722
8722 And last but not least, all the kind IPython users who have emailed new
8723 And last but not least, all the kind IPython users who have emailed new
8723 code, bug reports, fixes, comments and ideas.
8724 code, bug reports, fixes, comments and ideas.
8724 A brief list follows, please let me know if I have ommitted your name by
8725 A brief list follows, please let me know if I have ommitted your name by
8725 accident:
8726 accident:
8726 \layout List
8727 \layout List
8727 \labelwidthstring 00.00.0000
8728 \labelwidthstring 00.00.0000
8728
8729
8729 Jack\SpecialChar ~
8730 Jack\SpecialChar ~
8730 Moffit
8731 Moffit
8731 \family typewriter
8732 \family typewriter
8732 <jack-AT-xiph.org>
8733 <jack-AT-xiph.org>
8733 \family default
8734 \family default
8734 Bug fixes, including the infamous color problem.
8735 Bug fixes, including the infamous color problem.
8735 This bug alone caused many lost hours and frustration, many thanks to him
8736 This bug alone caused many lost hours and frustration, many thanks to him
8736 for the fix.
8737 for the fix.
8737 I've always been a fan of Ogg & friends, now I have one more reason to
8738 I've always been a fan of Ogg & friends, now I have one more reason to
8738 like these folks.
8739 like these folks.
8739 \newline
8740 \newline
8740 Jack is also contributing with Debian packaging and many other things.
8741 Jack is also contributing with Debian packaging and many other things.
8741 \layout List
8742 \layout List
8742 \labelwidthstring 00.00.0000
8743 \labelwidthstring 00.00.0000
8743
8744
8744 Alexander\SpecialChar ~
8745 Alexander\SpecialChar ~
8745 Schmolck
8746 Schmolck
8746 \family typewriter
8747 \family typewriter
8747 <a.schmolck-AT-gmx.net>
8748 <a.schmolck-AT-gmx.net>
8748 \family default
8749 \family default
8749 Emacs work, bug reports, bug fixes, ideas, lots more.
8750 Emacs work, bug reports, bug fixes, ideas, lots more.
8750 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8751 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8751 for IPython under (X)Emacs.
8752 for IPython under (X)Emacs.
8752 \layout List
8753 \layout List
8753 \labelwidthstring 00.00.0000
8754 \labelwidthstring 00.00.0000
8754
8755
8755 Andrea\SpecialChar ~
8756 Andrea\SpecialChar ~
8756 Riciputi
8757 Riciputi
8757 \family typewriter
8758 \family typewriter
8758 <andrea.riciputi-AT-libero.it>
8759 <andrea.riciputi-AT-libero.it>
8759 \family default
8760 \family default
8760 Mac OSX information, Fink package management.
8761 Mac OSX information, Fink package management.
8761 \layout List
8762 \layout List
8762 \labelwidthstring 00.00.0000
8763 \labelwidthstring 00.00.0000
8763
8764
8764 Gary\SpecialChar ~
8765 Gary\SpecialChar ~
8765 Bishop
8766 Bishop
8766 \family typewriter
8767 \family typewriter
8767 <gb-AT-cs.unc.edu>
8768 <gb-AT-cs.unc.edu>
8768 \family default
8769 \family default
8769 Bug reports, and patches to work around the exception handling idiosyncracies
8770 Bug reports, and patches to work around the exception handling idiosyncracies
8770 of WxPython.
8771 of WxPython.
8771 Readline and color support for Windows.
8772 Readline and color support for Windows.
8772 \layout List
8773 \layout List
8773 \labelwidthstring 00.00.0000
8774 \labelwidthstring 00.00.0000
8774
8775
8775 Jeffrey\SpecialChar ~
8776 Jeffrey\SpecialChar ~
8776 Collins
8777 Collins
8777 \family typewriter
8778 \family typewriter
8778 <Jeff.Collins-AT-vexcel.com>
8779 <Jeff.Collins-AT-vexcel.com>
8779 \family default
8780 \family default
8780 Bug reports.
8781 Bug reports.
8781 Much improved readline support, including fixes for Python 2.3.
8782 Much improved readline support, including fixes for Python 2.3.
8782 \layout List
8783 \layout List
8783 \labelwidthstring 00.00.0000
8784 \labelwidthstring 00.00.0000
8784
8785
8785 Dryice\SpecialChar ~
8786 Dryice\SpecialChar ~
8786 Liu
8787 Liu
8787 \family typewriter
8788 \family typewriter
8788 <dryice-AT-liu.com.cn>
8789 <dryice-AT-liu.com.cn>
8789 \family default
8790 \family default
8790 FreeBSD port.
8791 FreeBSD port.
8791 \layout List
8792 \layout List
8792 \labelwidthstring 00.00.0000
8793 \labelwidthstring 00.00.0000
8793
8794
8794 Mike\SpecialChar ~
8795 Mike\SpecialChar ~
8795 Heeter
8796 Heeter
8796 \family typewriter
8797 \family typewriter
8797 <korora-AT-SDF.LONESTAR.ORG>
8798 <korora-AT-SDF.LONESTAR.ORG>
8798 \layout List
8799 \layout List
8799 \labelwidthstring 00.00.0000
8800 \labelwidthstring 00.00.0000
8800
8801
8801 Christopher\SpecialChar ~
8802 Christopher\SpecialChar ~
8802 Hart
8803 Hart
8803 \family typewriter
8804 \family typewriter
8804 <hart-AT-caltech.edu>
8805 <hart-AT-caltech.edu>
8805 \family default
8806 \family default
8806 PDB integration.
8807 PDB integration.
8807 \layout List
8808 \layout List
8808 \labelwidthstring 00.00.0000
8809 \labelwidthstring 00.00.0000
8809
8810
8810 Milan\SpecialChar ~
8811 Milan\SpecialChar ~
8811 Zamazal
8812 Zamazal
8812 \family typewriter
8813 \family typewriter
8813 <pdm-AT-zamazal.org>
8814 <pdm-AT-zamazal.org>
8814 \family default
8815 \family default
8815 Emacs info.
8816 Emacs info.
8816 \layout List
8817 \layout List
8817 \labelwidthstring 00.00.0000
8818 \labelwidthstring 00.00.0000
8818
8819
8819 Philip\SpecialChar ~
8820 Philip\SpecialChar ~
8820 Hisley
8821 Hisley
8821 \family typewriter
8822 \family typewriter
8822 <compsys-AT-starpower.net>
8823 <compsys-AT-starpower.net>
8823 \layout List
8824 \layout List
8824 \labelwidthstring 00.00.0000
8825 \labelwidthstring 00.00.0000
8825
8826
8826 Holger\SpecialChar ~
8827 Holger\SpecialChar ~
8827 Krekel
8828 Krekel
8828 \family typewriter
8829 \family typewriter
8829 <pyth-AT-devel.trillke.net>
8830 <pyth-AT-devel.trillke.net>
8830 \family default
8831 \family default
8831 Tab completion, lots more.
8832 Tab completion, lots more.
8832 \layout List
8833 \layout List
8833 \labelwidthstring 00.00.0000
8834 \labelwidthstring 00.00.0000
8834
8835
8835 Robin\SpecialChar ~
8836 Robin\SpecialChar ~
8836 Siebler
8837 Siebler
8837 \family typewriter
8838 \family typewriter
8838 <robinsiebler-AT-starband.net>
8839 <robinsiebler-AT-starband.net>
8839 \layout List
8840 \layout List
8840 \labelwidthstring 00.00.0000
8841 \labelwidthstring 00.00.0000
8841
8842
8842 Ralf\SpecialChar ~
8843 Ralf\SpecialChar ~
8843 Ahlbrink
8844 Ahlbrink
8844 \family typewriter
8845 \family typewriter
8845 <ralf_ahlbrink-AT-web.de>
8846 <ralf_ahlbrink-AT-web.de>
8846 \layout List
8847 \layout List
8847 \labelwidthstring 00.00.0000
8848 \labelwidthstring 00.00.0000
8848
8849
8849 Thorsten\SpecialChar ~
8850 Thorsten\SpecialChar ~
8850 Kampe
8851 Kampe
8851 \family typewriter
8852 \family typewriter
8852 <thorsten-AT-thorstenkampe.de>
8853 <thorsten-AT-thorstenkampe.de>
8853 \layout List
8854 \layout List
8854 \labelwidthstring 00.00.0000
8855 \labelwidthstring 00.00.0000
8855
8856
8856 Fredrik\SpecialChar ~
8857 Fredrik\SpecialChar ~
8857 Kant
8858 Kant
8858 \family typewriter
8859 \family typewriter
8859 <fredrik.kant-AT-front.com>
8860 <fredrik.kant-AT-front.com>
8860 \family default
8861 \family default
8861 Windows setup.
8862 Windows setup.
8862 \layout List
8863 \layout List
8863 \labelwidthstring 00.00.0000
8864 \labelwidthstring 00.00.0000
8864
8865
8865 Syver\SpecialChar ~
8866 Syver\SpecialChar ~
8866 Enstad
8867 Enstad
8867 \family typewriter
8868 \family typewriter
8868 <syver-en-AT-online.no>
8869 <syver-en-AT-online.no>
8869 \family default
8870 \family default
8870 Windows setup.
8871 Windows setup.
8871 \layout List
8872 \layout List
8872 \labelwidthstring 00.00.0000
8873 \labelwidthstring 00.00.0000
8873
8874
8874 Richard
8875 Richard
8875 \family typewriter
8876 \family typewriter
8876 <rxe-AT-renre-europe.com>
8877 <rxe-AT-renre-europe.com>
8877 \family default
8878 \family default
8878 Global embedding.
8879 Global embedding.
8879 \layout List
8880 \layout List
8880 \labelwidthstring 00.00.0000
8881 \labelwidthstring 00.00.0000
8881
8882
8882 Hayden\SpecialChar ~
8883 Hayden\SpecialChar ~
8883 Callow
8884 Callow
8884 \family typewriter
8885 \family typewriter
8885 <h.callow-AT-elec.canterbury.ac.nz>
8886 <h.callow-AT-elec.canterbury.ac.nz>
8886 \family default
8887 \family default
8887 Gnuplot.py 1.6 compatibility.
8888 Gnuplot.py 1.6 compatibility.
8888 \layout List
8889 \layout List
8889 \labelwidthstring 00.00.0000
8890 \labelwidthstring 00.00.0000
8890
8891
8891 Leonardo\SpecialChar ~
8892 Leonardo\SpecialChar ~
8892 Santagada
8893 Santagada
8893 \family typewriter
8894 \family typewriter
8894 <retype-AT-terra.com.br>
8895 <retype-AT-terra.com.br>
8895 \family default
8896 \family default
8896 Fixes for Windows installation.
8897 Fixes for Windows installation.
8897 \layout List
8898 \layout List
8898 \labelwidthstring 00.00.0000
8899 \labelwidthstring 00.00.0000
8899
8900
8900 Christopher\SpecialChar ~
8901 Christopher\SpecialChar ~
8901 Armstrong
8902 Armstrong
8902 \family typewriter
8903 \family typewriter
8903 <radix-AT-twistedmatrix.com>
8904 <radix-AT-twistedmatrix.com>
8904 \family default
8905 \family default
8905 Bugfixes.
8906 Bugfixes.
8906 \layout List
8907 \layout List
8907 \labelwidthstring 00.00.0000
8908 \labelwidthstring 00.00.0000
8908
8909
8909 Francois\SpecialChar ~
8910 Francois\SpecialChar ~
8910 Pinard
8911 Pinard
8911 \family typewriter
8912 \family typewriter
8912 <pinard-AT-iro.umontreal.ca>
8913 <pinard-AT-iro.umontreal.ca>
8913 \family default
8914 \family default
8914 Code and documentation fixes.
8915 Code and documentation fixes.
8915 \layout List
8916 \layout List
8916 \labelwidthstring 00.00.0000
8917 \labelwidthstring 00.00.0000
8917
8918
8918 Cory\SpecialChar ~
8919 Cory\SpecialChar ~
8919 Dodt
8920 Dodt
8920 \family typewriter
8921 \family typewriter
8921 <cdodt-AT-fcoe.k12.ca.us>
8922 <cdodt-AT-fcoe.k12.ca.us>
8922 \family default
8923 \family default
8923 Bug reports and Windows ideas.
8924 Bug reports and Windows ideas.
8924 Patches for Windows installer.
8925 Patches for Windows installer.
8925 \layout List
8926 \layout List
8926 \labelwidthstring 00.00.0000
8927 \labelwidthstring 00.00.0000
8927
8928
8928 Olivier\SpecialChar ~
8929 Olivier\SpecialChar ~
8929 Aubert
8930 Aubert
8930 \family typewriter
8931 \family typewriter
8931 <oaubert-AT-bat710.univ-lyon1.fr>
8932 <oaubert-AT-bat710.univ-lyon1.fr>
8932 \family default
8933 \family default
8933 New magics.
8934 New magics.
8934 \layout List
8935 \layout List
8935 \labelwidthstring 00.00.0000
8936 \labelwidthstring 00.00.0000
8936
8937
8937 King\SpecialChar ~
8938 King\SpecialChar ~
8938 C.\SpecialChar ~
8939 C.\SpecialChar ~
8939 Shu
8940 Shu
8940 \family typewriter
8941 \family typewriter
8941 <kingshu-AT-myrealbox.com>
8942 <kingshu-AT-myrealbox.com>
8942 \family default
8943 \family default
8943 Autoindent patch.
8944 Autoindent patch.
8944 \layout List
8945 \layout List
8945 \labelwidthstring 00.00.0000
8946 \labelwidthstring 00.00.0000
8946
8947
8947 Chris\SpecialChar ~
8948 Chris\SpecialChar ~
8948 Drexler
8949 Drexler
8949 \family typewriter
8950 \family typewriter
8950 <chris-AT-ac-drexler.de>
8951 <chris-AT-ac-drexler.de>
8951 \family default
8952 \family default
8952 Readline packages for Win32/CygWin.
8953 Readline packages for Win32/CygWin.
8953 \layout List
8954 \layout List
8954 \labelwidthstring 00.00.0000
8955 \labelwidthstring 00.00.0000
8955
8956
8956 Gustavo\SpecialChar ~
8957 Gustavo\SpecialChar ~
8957 Córdova\SpecialChar ~
8958 Córdova\SpecialChar ~
8958 Avila
8959 Avila
8959 \family typewriter
8960 \family typewriter
8960 <gcordova-AT-sismex.com>
8961 <gcordova-AT-sismex.com>
8961 \family default
8962 \family default
8962 EvalDict code for nice, lightweight string interpolation.
8963 EvalDict code for nice, lightweight string interpolation.
8963 \layout List
8964 \layout List
8964 \labelwidthstring 00.00.0000
8965 \labelwidthstring 00.00.0000
8965
8966
8966 Kasper\SpecialChar ~
8967 Kasper\SpecialChar ~
8967 Souren
8968 Souren
8968 \family typewriter
8969 \family typewriter
8969 <Kasper.Souren-AT-ircam.fr>
8970 <Kasper.Souren-AT-ircam.fr>
8970 \family default
8971 \family default
8971 Bug reports, ideas.
8972 Bug reports, ideas.
8972 \layout List
8973 \layout List
8973 \labelwidthstring 00.00.0000
8974 \labelwidthstring 00.00.0000
8974
8975
8975 Gever\SpecialChar ~
8976 Gever\SpecialChar ~
8976 Tulley
8977 Tulley
8977 \family typewriter
8978 \family typewriter
8978 <gever-AT-helium.com>
8979 <gever-AT-helium.com>
8979 \family default
8980 \family default
8980 Code contributions.
8981 Code contributions.
8981 \layout List
8982 \layout List
8982 \labelwidthstring 00.00.0000
8983 \labelwidthstring 00.00.0000
8983
8984
8984 Ralf\SpecialChar ~
8985 Ralf\SpecialChar ~
8985 Schmitt
8986 Schmitt
8986 \family typewriter
8987 \family typewriter
8987 <ralf-AT-brainbot.com>
8988 <ralf-AT-brainbot.com>
8988 \family default
8989 \family default
8989 Bug reports & fixes.
8990 Bug reports & fixes.
8990 \layout List
8991 \layout List
8991 \labelwidthstring 00.00.0000
8992 \labelwidthstring 00.00.0000
8992
8993
8993 Oliver\SpecialChar ~
8994 Oliver\SpecialChar ~
8994 Sander
8995 Sander
8995 \family typewriter
8996 \family typewriter
8996 <osander-AT-gmx.de>
8997 <osander-AT-gmx.de>
8997 \family default
8998 \family default
8998 Bug reports.
8999 Bug reports.
8999 \layout List
9000 \layout List
9000 \labelwidthstring 00.00.0000
9001 \labelwidthstring 00.00.0000
9001
9002
9002 Rod\SpecialChar ~
9003 Rod\SpecialChar ~
9003 Holland
9004 Holland
9004 \family typewriter
9005 \family typewriter
9005 <rhh-AT-structurelabs.com>
9006 <rhh-AT-structurelabs.com>
9006 \family default
9007 \family default
9007 Bug reports and fixes to logging module.
9008 Bug reports and fixes to logging module.
9008 \layout List
9009 \layout List
9009 \labelwidthstring 00.00.0000
9010 \labelwidthstring 00.00.0000
9010
9011
9011 Daniel\SpecialChar ~
9012 Daniel\SpecialChar ~
9012 'Dang'\SpecialChar ~
9013 'Dang'\SpecialChar ~
9013 Griffith
9014 Griffith
9014 \family typewriter
9015 \family typewriter
9015 <pythondev-dang-AT-lazytwinacres.net>
9016 <pythondev-dang-AT-lazytwinacres.net>
9016 \family default
9017 \family default
9017 Fixes, enhancement suggestions for system shell use.
9018 Fixes, enhancement suggestions for system shell use.
9018 \layout List
9019 \layout List
9019 \labelwidthstring 00.00.0000
9020 \labelwidthstring 00.00.0000
9020
9021
9021 Viktor\SpecialChar ~
9022 Viktor\SpecialChar ~
9022 Ransmayr
9023 Ransmayr
9023 \family typewriter
9024 \family typewriter
9024 <viktor.ransmayr-AT-t-online.de>
9025 <viktor.ransmayr-AT-t-online.de>
9025 \family default
9026 \family default
9026 Tests and reports on Windows installation issues.
9027 Tests and reports on Windows installation issues.
9027 Contributed a true Windows binary installer.
9028 Contributed a true Windows binary installer.
9028 \layout List
9029 \layout List
9029 \labelwidthstring 00.00.0000
9030 \labelwidthstring 00.00.0000
9030
9031
9031 Mike\SpecialChar ~
9032 Mike\SpecialChar ~
9032 Salib
9033 Salib
9033 \family typewriter
9034 \family typewriter
9034 <msalib-AT-mit.edu>
9035 <msalib-AT-mit.edu>
9035 \family default
9036 \family default
9036 Help fixing a subtle bug related to traceback printing.
9037 Help fixing a subtle bug related to traceback printing.
9037 \layout List
9038 \layout List
9038 \labelwidthstring 00.00.0000
9039 \labelwidthstring 00.00.0000
9039
9040
9040 W.J.\SpecialChar ~
9041 W.J.\SpecialChar ~
9041 van\SpecialChar ~
9042 van\SpecialChar ~
9042 der\SpecialChar ~
9043 der\SpecialChar ~
9043 Laan
9044 Laan
9044 \family typewriter
9045 \family typewriter
9045 <gnufnork-AT-hetdigitalegat.nl>
9046 <gnufnork-AT-hetdigitalegat.nl>
9046 \family default
9047 \family default
9047 Bash-like prompt specials.
9048 Bash-like prompt specials.
9048 \layout List
9049 \layout List
9049 \labelwidthstring 00.00.0000
9050 \labelwidthstring 00.00.0000
9050
9051
9051 Ville\SpecialChar ~
9052 Ville\SpecialChar ~
9052 Vainio
9053 Vainio
9053 \family typewriter
9054 \family typewriter
9054 <vivainio-AT-kolumbus.fi>
9055 <vivainio-AT-kolumbus.fi>
9055 \family default
9056 \family default
9056 Bugfixes and suggestions.
9057 Bugfixes and suggestions.
9057 Excellent patches for many new features.
9058 Excellent patches for many new features.
9058 \layout List
9059 \layout List
9059 \labelwidthstring 00.00.0000
9060 \labelwidthstring 00.00.0000
9060
9061
9061 Antoon\SpecialChar ~
9062 Antoon\SpecialChar ~
9062 Pardon
9063 Pardon
9063 \family typewriter
9064 \family typewriter
9064 <Antoon.Pardon-AT-rece.vub.ac.be>
9065 <Antoon.Pardon-AT-rece.vub.ac.be>
9065 \family default
9066 \family default
9066 Critical fix for the multithreaded IPython.
9067 Critical fix for the multithreaded IPython.
9067 \layout List
9068 \layout List
9068 \labelwidthstring 00.00.0000
9069 \labelwidthstring 00.00.0000
9069
9070
9070 John\SpecialChar ~
9071 John\SpecialChar ~
9071 Hunter
9072 Hunter
9072 \family typewriter
9073 \family typewriter
9073 <jdhunter-AT-nitace.bsd.uchicago.edu>
9074 <jdhunter-AT-nitace.bsd.uchicago.edu>
9074 \family default
9075 \family default
9075 Matplotlib author, helped with all the development of support for matplotlib
9076 Matplotlib author, helped with all the development of support for matplotlib
9076 in IPyhton, including making necessary changes to matplotlib itself.
9077 in IPyhton, including making necessary changes to matplotlib itself.
9077 \layout List
9078 \layout List
9078 \labelwidthstring 00.00.0000
9079 \labelwidthstring 00.00.0000
9079
9080
9080 Matthew\SpecialChar ~
9081 Matthew\SpecialChar ~
9081 Arnison
9082 Arnison
9082 \family typewriter
9083 \family typewriter
9083 <maffew-AT-cat.org.au>
9084 <maffew-AT-cat.org.au>
9084 \family default
9085 \family default
9085 Bug reports, `
9086 Bug reports, `
9086 \family typewriter
9087 \family typewriter
9087 %run -d
9088 %run -d
9088 \family default
9089 \family default
9089 ' idea.
9090 ' idea.
9090 \layout List
9091 \layout List
9091 \labelwidthstring 00.00.0000
9092 \labelwidthstring 00.00.0000
9092
9093
9093 Prabhu\SpecialChar ~
9094 Prabhu\SpecialChar ~
9094 Ramachandran
9095 Ramachandran
9095 \family typewriter
9096 \family typewriter
9096 <prabhu_r-AT-users.sourceforge.net>
9097 <prabhu_r-AT-users.sourceforge.net>
9097 \family default
9098 \family default
9098 Help with (X)Emacs support, threading patches, ideas...
9099 Help with (X)Emacs support, threading patches, ideas...
9099 \layout List
9100 \layout List
9100 \labelwidthstring 00.00.0000
9101 \labelwidthstring 00.00.0000
9101
9102
9102 Norbert\SpecialChar ~
9103 Norbert\SpecialChar ~
9103 Tretkowski
9104 Tretkowski
9104 \family typewriter
9105 \family typewriter
9105 <tretkowski-AT-inittab.de>
9106 <tretkowski-AT-inittab.de>
9106 \family default
9107 \family default
9107 help with Debian packaging and distribution.
9108 help with Debian packaging and distribution.
9108 \layout List
9109 \layout List
9109 \labelwidthstring 00.00.0000
9110 \labelwidthstring 00.00.0000
9110
9111
9111 George\SpecialChar ~
9112 George\SpecialChar ~
9112 Sakkis <
9113 Sakkis <
9113 \family typewriter
9114 \family typewriter
9114 gsakkis-AT-eden.rutgers.edu>
9115 gsakkis-AT-eden.rutgers.edu>
9115 \family default
9116 \family default
9116 New matcher for tab-completing named arguments of user-defined functions.
9117 New matcher for tab-completing named arguments of user-defined functions.
9117 \layout List
9118 \layout List
9118 \labelwidthstring 00.00.0000
9119 \labelwidthstring 00.00.0000
9119
9120
9120 J�rgen\SpecialChar ~
9121 J�rgen\SpecialChar ~
9121 Stenarson
9122 Stenarson
9122 \family typewriter
9123 \family typewriter
9123 <jorgen.stenarson-AT-bostream.nu>
9124 <jorgen.stenarson-AT-bostream.nu>
9124 \family default
9125 \family default
9125 Wildcard support implementation for searching namespaces.
9126 Wildcard support implementation for searching namespaces.
9126 \layout List
9127 \layout List
9127 \labelwidthstring 00.00.0000
9128 \labelwidthstring 00.00.0000
9128
9129
9129 Vivian\SpecialChar ~
9130 Vivian\SpecialChar ~
9130 De\SpecialChar ~
9131 De\SpecialChar ~
9131 Smedt
9132 Smedt
9132 \family typewriter
9133 \family typewriter
9133 <vivian-AT-vdesmedt.com>
9134 <vivian-AT-vdesmedt.com>
9134 \family default
9135 \family default
9135 Debugger enhancements, so that when pdb is activated from within IPython,
9136 Debugger enhancements, so that when pdb is activated from within IPython,
9136 coloring, tab completion and other features continue to work seamlessly.
9137 coloring, tab completion and other features continue to work seamlessly.
9137 \layout List
9138 \layout List
9138 \labelwidthstring 00.00.0000
9139 \labelwidthstring 00.00.0000
9139
9140
9140 Scott\SpecialChar ~
9141 Scott\SpecialChar ~
9141 Tsai
9142 Tsai
9142 \family typewriter
9143 \family typewriter
9143 <scottt958-AT-yahoo.com.tw>
9144 <scottt958-AT-yahoo.com.tw>
9144 \family default
9145 \family default
9145 Support for automatic editor invocation on syntax errors (see
9146 Support for automatic editor invocation on syntax errors (see
9146 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9147 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9147
9148
9148 \end_inset
9149 \end_inset
9149
9150
9150 ).
9151 ).
9151 \the_end
9152 \the_end
General Comments 0
You need to be logged in to leave comments. Login now