##// END OF EJS Templates
New system for interactively running scripts. After a submission by Ken...
fperez -
Show More
@@ -0,0 +1,276 b''
1 #!/usr/bin/env python
2 """Module for interactively running scripts.
3
4 This module implements classes for interactively running scripts written for
5 any system with a prompt which can be matched by a regexp suitable for
6 pexpect. It can be used to run as if they had been typed up interactively, an
7 arbitrary series of commands for the target system.
8
9 The module includes classes ready for IPython (with the default prompts),
10 plain Python and SAGE, but making a new one is trivial. To see how to use it,
11 simply run the module as a script:
12
13 ./irunner.py --help
14
15
16 This is an extension of Ken Schutte <kschutte-AT-csail.mit.edu>'s script
17 contributed on the ipython-user list:
18
19 http://scipy.net/pipermail/ipython-user/2006-May/001705.html
20
21
22 NOTES:
23
24 - This module requires pexpect, available in most linux distros, or which can
25 be downloaded from
26
27 http://pexpect.sourceforge.net
28
29 - Because pexpect only works under Unix or Windows-Cygwin, this has the same
30 limitations. This means that it will NOT work under native windows Python.
31 """
32
33 # Stdlib imports
34 import optparse
35 import sys
36
37 # Third-party modules.
38 import pexpect
39
40 # Global usage strings, to avoid indentation issues when typing it below.
41 USAGE = """
42 Interactive script runner, type: %s
43
44 runner [opts] script_name
45 """
46
47 # The generic runner class
48 class InteractiveRunner(object):
49 """Class to run a sequence of commands through an interactive program."""
50
51 def __init__(self,program,prompts,args=None):
52 """Construct a runner.
53
54 Inputs:
55
56 - program: command to execute the given program.
57
58 - prompts: a list of patterns to match as valid prompts, in the
59 format used by pexpect. This basically means that it can be either
60 a string (to be compiled as a regular expression) or a list of such
61 (it must be a true list, as pexpect does type checks).
62
63 If more than one prompt is given, the first is treated as the main
64 program prompt and the others as 'continuation' prompts, like
65 python's. This means that blank lines in the input source are
66 ommitted when the first prompt is matched, but are NOT ommitted when
67 the continuation one matches, since this is how python signals the
68 end of multiline input interactively.
69
70 Optional inputs:
71
72 - args(None): optional list of strings to pass as arguments to the
73 child program.
74 """
75
76 self.program = program
77 self.prompts = prompts
78 if args is None: args = []
79 self.args = args
80
81 def run_file(self,fname,interact=False):
82 """Run the given file interactively.
83
84 Inputs:
85
86 -fname: name of the file to execute.
87
88 See the run_source docstring for the meaning of the optional
89 arguments."""
90
91 fobj = open(fname,'r')
92 try:
93 self.run_source(fobj,interact)
94 finally:
95 fobj.close()
96
97 def run_source(self,source,interact=False):
98 """Run the given source code interactively.
99
100 Inputs:
101
102 - source: a string of code to be executed, or an open file object we
103 can iterate over.
104
105 Optional inputs:
106
107 - interact(False): if true, start to interact with the running
108 program at the end of the script. Otherwise, just exit.
109 """
110
111 # if the source is a string, chop it up in lines so we can iterate
112 # over it just as if it were an open file.
113 if not isinstance(source,file):
114 source = source.splitlines(True)
115
116 # grab the true write method of stdout, in case anything later
117 # reassigns sys.stdout, so that we really are writing to the true
118 # stdout and not to something else.
119 write = sys.stdout.write
120
121 c = pexpect.spawn(self.program,self.args,timeout=None)
122
123 prompts = c.compile_pattern_list(self.prompts[0])
124 prompts = c.compile_pattern_list(self.prompts)
125
126 prompt_idx = c.expect_list(prompts)
127 # Flag whether the script ends normally or not, to know whether we can
128 # do anything further with the underlying process.
129 end_normal = True
130 for cmd in source:
131 # skip blank lines for all matches to the 'main' prompt, while the
132 # secondary prompts do not
133 if prompt_idx==0 and cmd.isspace():
134 continue
135
136 write(c.after)
137 c.send(cmd)
138 try:
139 prompt_idx = c.expect_list(prompts)
140 except pexpect.EOF:
141 # this will happen if the child dies unexpectedly
142 write(c.before)
143 end_normal = False
144 break
145 write(c.before)
146
147 if isinstance(source,file):
148 source.close()
149
150 if end_normal:
151 if interact:
152 c.send('\n')
153 print '<< Starting interactive mode >>',
154 try:
155 c.interact()
156 except OSError:
157 # This is what fires when the child stops. Simply print a
158 # newline so the system prompt is alingned. The extra
159 # space is there to make sure it gets printed, otherwise
160 # OS buffering sometimes just suppresses it.
161 write(' \n')
162 sys.stdout.flush()
163 else:
164 c.close()
165 else:
166 if interact:
167 e="Further interaction is not possible: child process is dead."
168 print >> sys.stderr, e
169
170 def main(self,argv=None):
171 """Run as a command-line script."""
172
173 parser = optparse.OptionParser(usage=USAGE % self.__class__.__name__)
174 newopt = parser.add_option
175 newopt('-i','--interact',action='store_true',default=False,
176 help='Interact with the program after the script is run.')
177
178 opts,args = parser.parse_args(argv)
179
180 if len(args) != 1:
181 print >> sys.stderr,"You must supply exactly one file to run."
182 sys.exit(1)
183
184 self.run_file(args[0],opts.interact)
185
186
187 # Specific runners for particular programs
188 class IPythonRunner(InteractiveRunner):
189 """Interactive IPython runner.
190
191 This initalizes IPython in 'nocolor' mode for simplicity. This lets us
192 avoid having to write a regexp that matches ANSI sequences, though pexpect
193 does support them. If anyone contributes patches for ANSI color support,
194 they will be welcome.
195
196 It also sets the prompts manually, since the prompt regexps for
197 pexpect need to be matched to the actual prompts, so user-customized
198 prompts would break this.
199 """
200
201 def __init__(self,program = 'ipython',args=None):
202 """New runner, optionally passing the ipython command to use."""
203
204 args0 = ['-colors','NoColor',
205 '-pi1','In [\\#]: ',
206 '-pi2',' .\\D.: ']
207 if args is None: args = args0
208 else: args = args0 + args
209 prompts = [r'In \[\d+\]: ',r' \.*: ']
210 InteractiveRunner.__init__(self,program,prompts,args)
211
212
213 class PythonRunner(InteractiveRunner):
214 """Interactive Python runner."""
215
216 def __init__(self,program='python',args=None):
217 """New runner, optionally passing the python command to use."""
218
219 prompts = [r'>>> ',r'\.\.\. ']
220 InteractiveRunner.__init__(self,program,prompts,args)
221
222
223 class SAGERunner(InteractiveRunner):
224 """Interactive SAGE runner.
225
226 XXX - This class is currently untested, meant for feedback from the SAGE
227 team. """
228
229 def __init__(self,program='sage',args=None):
230 """New runner, optionally passing the sage command to use."""
231 print 'XXX - This class is currently untested!!!'
232 print 'It is a placeholder, meant for feedback from the SAGE team.'
233
234 prompts = ['sage: ',r'\s*\.\.\. ']
235 InteractiveRunner.__init__(self,program,prompts,args)
236
237 # Global usage string, to avoid indentation issues if typed in a function def.
238 MAIN_USAGE = """
239 %prog [options] file_to_run
240
241 This is an interface to the various interactive runners available in this
242 module. If you want to pass specific options to one of the runners, you need
243 to first terminate the main options with a '--', and then provide the runner's
244 options. For example:
245
246 irunner.py --python -- --help
247
248 will pass --help to the python runner. Similarly,
249
250 irunner.py --ipython -- --log test.log script.ipy
251
252 will run the script.ipy file under the IPython runner, logging all output into
253 the test.log file.
254 """
255
256 def main():
257 """Run as a command-line script."""
258
259 parser = optparse.OptionParser(usage=MAIN_USAGE)
260 newopt = parser.add_option
261 parser.set_defaults(mode='ipython')
262 newopt('--ipython',action='store_const',dest='mode',const='ipython',
263 help='IPython interactive runner (default).')
264 newopt('--python',action='store_const',dest='mode',const='python',
265 help='Python interactive runner.')
266 newopt('--sage',action='store_const',dest='mode',const='sage',
267 help='SAGE interactive runner - UNTESTED.')
268
269 opts,args = parser.parse_args()
270 runners = dict(ipython=IPythonRunner,
271 python=PythonRunner,
272 sage=SAGERunner)
273 runners[opts.mode]().main(args)
274
275 if __name__ == '__main__':
276 main()
@@ -0,0 +1,156 b''
1 #!/usr/bin/env python
2 """Test suite for the irunner module.
3
4 Not the most elegant or fine-grained, but it does cover at least the bulk
5 functionality."""
6
7 # Global to make tests extra verbose and help debugging
8 VERBOSE = True
9
10 # stdlib imports
11 import cStringIO as StringIO
12 import unittest
13
14 # IPython imports
15 from IPython import irunner
16 from IPython.OutputTrap import OutputTrap
17
18 # Testing code begins
19 class RunnerTestCase(unittest.TestCase):
20
21 def _test_runner(self,runner,source,output):
22 """Test that a given runner's input/output match."""
23
24 log = OutputTrap(out_head='',quiet_out=True)
25 log.trap_out()
26 runner.run_source(source)
27 log.release_out()
28 out = log.summary_out()
29 # this output contains nasty \r\n lineends, and the initial ipython
30 # banner. clean it up for comparison
31 output_l = output.split()
32 out_l = out.split()
33 mismatch = 0
34 for n in range(len(output_l)):
35 ol1 = output_l[n].strip()
36 ol2 = out_l[n].strip()
37 if ol1 != ol2:
38 mismatch += 1
39 if VERBOSE:
40 print '<<< line %s does not match:' % n
41 print repr(ol1)
42 print repr(ol2)
43 print '>>>'
44 self.assert_(mismatch==0,'Number of mismatched lines: %s' %
45 mismatch)
46
47 def testIPython(self):
48 """Test the IPython runner."""
49 source = """
50 print 'hello, this is python'
51
52 # some more code
53 x=1;y=2
54 x+y**2
55
56 # An example of autocall functionality
57 from math import *
58 autocall 1
59 cos pi
60 autocall 0
61 cos pi
62 cos(pi)
63
64 for i in range(5):
65 print i,
66
67 print "that's all folks!"
68
69 %Exit
70 """
71 output = """\
72 In [1]: print 'hello, this is python'
73 hello, this is python
74
75 In [2]: # some more code
76
77 In [3]: x=1;y=2
78
79 In [4]: x+y**2
80 Out[4]: 5
81
82 In [5]: # An example of autocall functionality
83
84 In [6]: from math import *
85
86 In [7]: autocall 1
87 Automatic calling is: Smart
88
89 In [8]: cos pi
90 ------> cos(pi)
91 Out[8]: -1.0
92
93 In [9]: autocall 0
94 Automatic calling is: OFF
95
96 In [10]: cos pi
97 ------------------------------------------------------------
98 File "<ipython console>", line 1
99 cos pi
100 ^
101 SyntaxError: invalid syntax
102
103
104 In [11]: cos(pi)
105 Out[11]: -1.0
106
107 In [12]: for i in range(5):
108 ....: print i,
109 ....:
110 0 1 2 3 4
111
112 In [13]: print "that's all folks!"
113 that's all folks!
114
115 In [14]: %Exit"""
116 runner = irunner.IPythonRunner()
117 self._test_runner(runner,source,output)
118
119 def testPython(self):
120 """Test the Python runner."""
121 runner = irunner.PythonRunner()
122 source = """
123 print 'hello, this is python'
124
125 # some more code
126 x=1;y=2
127 x+y**2
128
129 from math import *
130 cos(pi)
131
132 for i in range(5):
133 print i,
134
135 print "that's all folks!"
136 """
137 output = """\
138 >>> print 'hello, this is python'
139 hello, this is python
140 >>> # some more code
141 ... x=1;y=2
142 >>> x+y**2
143 5
144 >>> from math import *
145 >>> cos(pi)
146 -1.0
147 >>> for i in range(5):
148 ... print i,
149 ...
150 0 1 2 3 4
151 >>> print "that's all folks!"
152 that's all folks!"""
153 self._test_runner(runner,source,output)
154
155 if __name__ == '__main__':
156 unittest.main()
@@ -1,2300 +1,2299 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 IPython -- An enhanced Interactive Python
4 4
5 5 Requires Python 2.3 or newer.
6 6
7 7 This file contains all the classes and helper functions specific to IPython.
8 8
9 $Id: iplib.py 1329 2006-05-26 07:52:45Z fperez $
9 $Id: iplib.py 1332 2006-05-30 01:41:28Z fperez $
10 10 """
11 11
12 12 #*****************************************************************************
13 13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
15 15 #
16 16 # Distributed under the terms of the BSD License. The full license is in
17 17 # the file COPYING, distributed as part of this software.
18 18 #
19 19 # Note: this code originally subclassed code.InteractiveConsole from the
20 20 # Python standard library. Over time, all of that class has been copied
21 21 # verbatim here for modifications which could not be accomplished by
22 22 # subclassing. At this point, there are no dependencies at all on the code
23 23 # module anymore (it is not even imported). The Python License (sec. 2)
24 24 # allows for this, but it's always nice to acknowledge credit where credit is
25 25 # due.
26 26 #*****************************************************************************
27 27
28 28 #****************************************************************************
29 29 # Modules and globals
30 30
31 31 from IPython import Release
32 32 __author__ = '%s <%s>\n%s <%s>' % \
33 33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
34 34 __license__ = Release.license
35 35 __version__ = Release.version
36 36
37 37 # Python standard modules
38 38 import __main__
39 39 import __builtin__
40 40 import StringIO
41 41 import bdb
42 42 import cPickle as pickle
43 43 import codeop
44 44 import exceptions
45 45 import glob
46 46 import inspect
47 47 import keyword
48 48 import new
49 49 import os
50 50 import pdb
51 51 import pydoc
52 52 import re
53 53 import shutil
54 54 import string
55 55 import sys
56 56 import tempfile
57 57 import traceback
58 58 import types
59 59 import pickleshare
60 60
61 61 from pprint import pprint, pformat
62 62
63 63 # IPython's own modules
64 64 import IPython
65 65 from IPython import OInspect,PyColorize,ultraTB
66 66 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
67 67 from IPython.FakeModule import FakeModule
68 68 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
69 69 from IPython.Logger import Logger
70 70 from IPython.Magic import Magic
71 71 from IPython.Prompts import CachedOutput
72 72 from IPython.ipstruct import Struct
73 73 from IPython.background_jobs import BackgroundJobManager
74 74 from IPython.usage import cmd_line_usage,interactive_usage
75 75 from IPython.genutils import *
76 76 import IPython.ipapi
77 77
78 78 # Globals
79 79
80 80 # store the builtin raw_input globally, and use this always, in case user code
81 81 # overwrites it (like wx.py.PyShell does)
82 82 raw_input_original = raw_input
83 83
84 84 # compiled regexps for autoindent management
85 85 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
86 86
87 87
88 88 #****************************************************************************
89 89 # Some utility function definitions
90 90
91 91 ini_spaces_re = re.compile(r'^(\s+)')
92 92
93 93 def num_ini_spaces(strng):
94 94 """Return the number of initial spaces in a string"""
95 95
96 96 ini_spaces = ini_spaces_re.match(strng)
97 97 if ini_spaces:
98 98 return ini_spaces.end()
99 99 else:
100 100 return 0
101 101
102 102 def softspace(file, newvalue):
103 103 """Copied from code.py, to remove the dependency"""
104 104
105 105 oldvalue = 0
106 106 try:
107 107 oldvalue = file.softspace
108 108 except AttributeError:
109 109 pass
110 110 try:
111 111 file.softspace = newvalue
112 112 except (AttributeError, TypeError):
113 113 # "attribute-less object" or "read-only attributes"
114 114 pass
115 115 return oldvalue
116 116
117 117
118 118 #****************************************************************************
119 119 # Local use exceptions
120 120 class SpaceInInput(exceptions.Exception): pass
121 121
122 122
123 123 #****************************************************************************
124 124 # Local use classes
125 125 class Bunch: pass
126 126
127 127 class Undefined: pass
128 128
129 129 class InputList(list):
130 130 """Class to store user input.
131 131
132 132 It's basically a list, but slices return a string instead of a list, thus
133 133 allowing things like (assuming 'In' is an instance):
134 134
135 135 exec In[4:7]
136 136
137 137 or
138 138
139 139 exec In[5:9] + In[14] + In[21:25]"""
140 140
141 141 def __getslice__(self,i,j):
142 142 return ''.join(list.__getslice__(self,i,j))
143 143
144 144 class SyntaxTB(ultraTB.ListTB):
145 145 """Extension which holds some state: the last exception value"""
146 146
147 147 def __init__(self,color_scheme = 'NoColor'):
148 148 ultraTB.ListTB.__init__(self,color_scheme)
149 149 self.last_syntax_error = None
150 150
151 151 def __call__(self, etype, value, elist):
152 152 self.last_syntax_error = value
153 153 ultraTB.ListTB.__call__(self,etype,value,elist)
154 154
155 155 def clear_err_state(self):
156 156 """Return the current error state and clear it"""
157 157 e = self.last_syntax_error
158 158 self.last_syntax_error = None
159 159 return e
160 160
161 161 #****************************************************************************
162 162 # Main IPython class
163 163
164 164 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
165 165 # until a full rewrite is made. I've cleaned all cross-class uses of
166 166 # attributes and methods, but too much user code out there relies on the
167 167 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
168 168 #
169 169 # But at least now, all the pieces have been separated and we could, in
170 170 # principle, stop using the mixin. This will ease the transition to the
171 171 # chainsaw branch.
172 172
173 173 # For reference, the following is the list of 'self.foo' uses in the Magic
174 174 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
175 175 # class, to prevent clashes.
176 176
177 177 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
178 178 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
179 179 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
180 180 # 'self.value']
181 181
182 182 class InteractiveShell(object,Magic):
183 183 """An enhanced console for Python."""
184 184
185 185 # class attribute to indicate whether the class supports threads or not.
186 186 # Subclasses with thread support should override this as needed.
187 187 isthreaded = False
188 188
189 189 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
190 190 user_ns = None,user_global_ns=None,banner2='',
191 191 custom_exceptions=((),None),embedded=False):
192 192
193
194 193 # log system
195 194 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
196 195
197 196 # some minimal strict typechecks. For some core data structures, I
198 197 # want actual basic python types, not just anything that looks like
199 198 # one. This is especially true for namespaces.
200 199 for ns in (user_ns,user_global_ns):
201 200 if ns is not None and type(ns) != types.DictType:
202 201 raise TypeError,'namespace must be a dictionary'
203 202
204 203 # Job manager (for jobs run as background threads)
205 204 self.jobs = BackgroundJobManager()
206 205
207 206 # Store the actual shell's name
208 207 self.name = name
209 208
210 209 # We need to know whether the instance is meant for embedding, since
211 210 # global/local namespaces need to be handled differently in that case
212 211 self.embedded = embedded
213 212
214 213 # command compiler
215 214 self.compile = codeop.CommandCompiler()
216 215
217 216 # User input buffer
218 217 self.buffer = []
219 218
220 219 # Default name given in compilation of code
221 220 self.filename = '<ipython console>'
222 221
223 222 # Make an empty namespace, which extension writers can rely on both
224 223 # existing and NEVER being used by ipython itself. This gives them a
225 224 # convenient location for storing additional information and state
226 225 # their extensions may require, without fear of collisions with other
227 226 # ipython names that may develop later.
228 227 self.meta = Struct()
229 228
230 229 # Create the namespace where the user will operate. user_ns is
231 230 # normally the only one used, and it is passed to the exec calls as
232 231 # the locals argument. But we do carry a user_global_ns namespace
233 232 # given as the exec 'globals' argument, This is useful in embedding
234 233 # situations where the ipython shell opens in a context where the
235 234 # distinction between locals and globals is meaningful.
236 235
237 236 # FIXME. For some strange reason, __builtins__ is showing up at user
238 237 # level as a dict instead of a module. This is a manual fix, but I
239 238 # should really track down where the problem is coming from. Alex
240 239 # Schmolck reported this problem first.
241 240
242 241 # A useful post by Alex Martelli on this topic:
243 242 # Re: inconsistent value from __builtins__
244 243 # Von: Alex Martelli <aleaxit@yahoo.com>
245 244 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
246 245 # Gruppen: comp.lang.python
247 246
248 247 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
249 248 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
250 249 # > <type 'dict'>
251 250 # > >>> print type(__builtins__)
252 251 # > <type 'module'>
253 252 # > Is this difference in return value intentional?
254 253
255 254 # Well, it's documented that '__builtins__' can be either a dictionary
256 255 # or a module, and it's been that way for a long time. Whether it's
257 256 # intentional (or sensible), I don't know. In any case, the idea is
258 257 # that if you need to access the built-in namespace directly, you
259 258 # should start with "import __builtin__" (note, no 's') which will
260 259 # definitely give you a module. Yeah, it's somewhat confusing:-(.
261 260
262 261 # These routines return properly built dicts as needed by the rest of
263 262 # the code, and can also be used by extension writers to generate
264 263 # properly initialized namespaces.
265 264 user_ns = IPython.ipapi.make_user_ns(user_ns)
266 265 user_global_ns = IPython.ipapi.make_user_global_ns(user_global_ns)
267 266
268 267 # Assign namespaces
269 268 # This is the namespace where all normal user variables live
270 269 self.user_ns = user_ns
271 270 # Embedded instances require a separate namespace for globals.
272 271 # Normally this one is unused by non-embedded instances.
273 272 self.user_global_ns = user_global_ns
274 273 # A namespace to keep track of internal data structures to prevent
275 274 # them from cluttering user-visible stuff. Will be updated later
276 275 self.internal_ns = {}
277 276
278 277 # Namespace of system aliases. Each entry in the alias
279 278 # table must be a 2-tuple of the form (N,name), where N is the number
280 279 # of positional arguments of the alias.
281 280 self.alias_table = {}
282 281
283 282 # A table holding all the namespaces IPython deals with, so that
284 283 # introspection facilities can search easily.
285 284 self.ns_table = {'user':user_ns,
286 285 'user_global':user_global_ns,
287 286 'alias':self.alias_table,
288 287 'internal':self.internal_ns,
289 288 'builtin':__builtin__.__dict__
290 289 }
291 290
292 291 # The user namespace MUST have a pointer to the shell itself.
293 292 self.user_ns[name] = self
294 293
295 294 # We need to insert into sys.modules something that looks like a
296 295 # module but which accesses the IPython namespace, for shelve and
297 296 # pickle to work interactively. Normally they rely on getting
298 297 # everything out of __main__, but for embedding purposes each IPython
299 298 # instance has its own private namespace, so we can't go shoving
300 299 # everything into __main__.
301 300
302 301 # note, however, that we should only do this for non-embedded
303 302 # ipythons, which really mimic the __main__.__dict__ with their own
304 303 # namespace. Embedded instances, on the other hand, should not do
305 304 # this because they need to manage the user local/global namespaces
306 305 # only, but they live within a 'normal' __main__ (meaning, they
307 306 # shouldn't overtake the execution environment of the script they're
308 307 # embedded in).
309 308
310 309 if not embedded:
311 310 try:
312 311 main_name = self.user_ns['__name__']
313 312 except KeyError:
314 313 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
315 314 else:
316 315 #print "pickle hack in place" # dbg
317 316 #print 'main_name:',main_name # dbg
318 317 sys.modules[main_name] = FakeModule(self.user_ns)
319 318
320 319 # List of input with multi-line handling.
321 320 # Fill its zero entry, user counter starts at 1
322 321 self.input_hist = InputList(['\n'])
323 322 # This one will hold the 'raw' input history, without any
324 323 # pre-processing. This will allow users to retrieve the input just as
325 324 # it was exactly typed in by the user, with %hist -r.
326 325 self.input_hist_raw = InputList(['\n'])
327 326
328 327 # list of visited directories
329 328 try:
330 329 self.dir_hist = [os.getcwd()]
331 330 except IOError, e:
332 331 self.dir_hist = []
333 332
334 333 # dict of output history
335 334 self.output_hist = {}
336 335
337 336 # dict of things NOT to alias (keywords, builtins and some magics)
338 337 no_alias = {}
339 338 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
340 339 for key in keyword.kwlist + no_alias_magics:
341 340 no_alias[key] = 1
342 341 no_alias.update(__builtin__.__dict__)
343 342 self.no_alias = no_alias
344 343
345 344 # make global variables for user access to these
346 345 self.user_ns['_ih'] = self.input_hist
347 346 self.user_ns['_oh'] = self.output_hist
348 347 self.user_ns['_dh'] = self.dir_hist
349 348
350 349 # user aliases to input and output histories
351 350 self.user_ns['In'] = self.input_hist
352 351 self.user_ns['Out'] = self.output_hist
353 352
354 353 # Object variable to store code object waiting execution. This is
355 354 # used mainly by the multithreaded shells, but it can come in handy in
356 355 # other situations. No need to use a Queue here, since it's a single
357 356 # item which gets cleared once run.
358 357 self.code_to_run = None
359 358
360 359 # escapes for automatic behavior on the command line
361 360 self.ESC_SHELL = '!'
362 361 self.ESC_HELP = '?'
363 362 self.ESC_MAGIC = '%'
364 363 self.ESC_QUOTE = ','
365 364 self.ESC_QUOTE2 = ';'
366 365 self.ESC_PAREN = '/'
367 366
368 367 # And their associated handlers
369 368 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
370 369 self.ESC_QUOTE : self.handle_auto,
371 370 self.ESC_QUOTE2 : self.handle_auto,
372 371 self.ESC_MAGIC : self.handle_magic,
373 372 self.ESC_HELP : self.handle_help,
374 373 self.ESC_SHELL : self.handle_shell_escape,
375 374 }
376 375
377 376 # class initializations
378 377 Magic.__init__(self,self)
379 378
380 379 # Python source parser/formatter for syntax highlighting
381 380 pyformat = PyColorize.Parser().format
382 381 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
383 382
384 383 # hooks holds pointers used for user-side customizations
385 384 self.hooks = Struct()
386 385
387 386 # Set all default hooks, defined in the IPython.hooks module.
388 387 hooks = IPython.hooks
389 388 for hook_name in hooks.__all__:
390 389 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
391 390 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
392 391 #print "bound hook",hook_name
393 392
394 393 # Flag to mark unconditional exit
395 394 self.exit_now = False
396 395
397 396 self.usage_min = """\
398 397 An enhanced console for Python.
399 398 Some of its features are:
400 399 - Readline support if the readline library is present.
401 400 - Tab completion in the local namespace.
402 401 - Logging of input, see command-line options.
403 402 - System shell escape via ! , eg !ls.
404 403 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
405 404 - Keeps track of locally defined variables via %who, %whos.
406 405 - Show object information with a ? eg ?x or x? (use ?? for more info).
407 406 """
408 407 if usage: self.usage = usage
409 408 else: self.usage = self.usage_min
410 409
411 410 # Storage
412 411 self.rc = rc # This will hold all configuration information
413 412 self.pager = 'less'
414 413 # temporary files used for various purposes. Deleted at exit.
415 414 self.tempfiles = []
416 415
417 416 # Keep track of readline usage (later set by init_readline)
418 417 self.has_readline = False
419 418
420 419 # template for logfile headers. It gets resolved at runtime by the
421 420 # logstart method.
422 421 self.loghead_tpl = \
423 422 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
424 423 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
425 424 #log# opts = %s
426 425 #log# args = %s
427 426 #log# It is safe to make manual edits below here.
428 427 #log#-----------------------------------------------------------------------
429 428 """
430 429 # for pushd/popd management
431 430 try:
432 431 self.home_dir = get_home_dir()
433 432 except HomeDirError,msg:
434 433 fatal(msg)
435 434
436 435 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
437 436
438 437 # Functions to call the underlying shell.
439 438
440 439 # utility to expand user variables via Itpl
441 440 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
442 441 self.user_ns))
443 442 # The first is similar to os.system, but it doesn't return a value,
444 443 # and it allows interpolation of variables in the user's namespace.
445 444 self.system = lambda cmd: shell(self.var_expand(cmd),
446 445 header='IPython system call: ',
447 446 verbose=self.rc.system_verbose)
448 447 # These are for getoutput and getoutputerror:
449 448 self.getoutput = lambda cmd: \
450 449 getoutput(self.var_expand(cmd),
451 450 header='IPython system call: ',
452 451 verbose=self.rc.system_verbose)
453 452 self.getoutputerror = lambda cmd: \
454 453 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
455 454 self.user_ns)),
456 455 header='IPython system call: ',
457 456 verbose=self.rc.system_verbose)
458 457
459 458 # RegExp for splitting line contents into pre-char//first
460 459 # word-method//rest. For clarity, each group in on one line.
461 460
462 461 # WARNING: update the regexp if the above escapes are changed, as they
463 462 # are hardwired in.
464 463
465 464 # Don't get carried away with trying to make the autocalling catch too
466 465 # much: it's better to be conservative rather than to trigger hidden
467 466 # evals() somewhere and end up causing side effects.
468 467
469 468 self.line_split = re.compile(r'^([\s*,;/])'
470 469 r'([\?\w\.]+\w*\s*)'
471 470 r'(\(?.*$)')
472 471
473 472 # Original re, keep around for a while in case changes break something
474 473 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
475 474 # r'(\s*[\?\w\.]+\w*\s*)'
476 475 # r'(\(?.*$)')
477 476
478 477 # RegExp to identify potential function names
479 478 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
480 479
481 480 # RegExp to exclude strings with this start from autocalling. In
482 481 # particular, all binary operators should be excluded, so that if foo
483 482 # is callable, foo OP bar doesn't become foo(OP bar), which is
484 483 # invalid. The characters '!=()' don't need to be checked for, as the
485 484 # _prefilter routine explicitely does so, to catch direct calls and
486 485 # rebindings of existing names.
487 486
488 487 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
489 488 # it affects the rest of the group in square brackets.
490 489 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
491 490 '|^is |^not |^in |^and |^or ')
492 491
493 492 # try to catch also methods for stuff in lists/tuples/dicts: off
494 493 # (experimental). For this to work, the line_split regexp would need
495 494 # to be modified so it wouldn't break things at '['. That line is
496 495 # nasty enough that I shouldn't change it until I can test it _well_.
497 496 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
498 497
499 498 # keep track of where we started running (mainly for crash post-mortem)
500 499 self.starting_dir = os.getcwd()
501 500
502 501 # Various switches which can be set
503 502 self.CACHELENGTH = 5000 # this is cheap, it's just text
504 503 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
505 504 self.banner2 = banner2
506 505
507 506 # TraceBack handlers:
508 507
509 508 # Syntax error handler.
510 509 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
511 510
512 511 # The interactive one is initialized with an offset, meaning we always
513 512 # want to remove the topmost item in the traceback, which is our own
514 513 # internal code. Valid modes: ['Plain','Context','Verbose']
515 514 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
516 515 color_scheme='NoColor',
517 516 tb_offset = 1)
518 517
519 518 # IPython itself shouldn't crash. This will produce a detailed
520 519 # post-mortem if it does. But we only install the crash handler for
521 520 # non-threaded shells, the threaded ones use a normal verbose reporter
522 521 # and lose the crash handler. This is because exceptions in the main
523 522 # thread (such as in GUI code) propagate directly to sys.excepthook,
524 523 # and there's no point in printing crash dumps for every user exception.
525 524 if self.isthreaded:
526 525 sys.excepthook = ultraTB.FormattedTB()
527 526 else:
528 527 from IPython import CrashHandler
529 528 sys.excepthook = CrashHandler.CrashHandler(self)
530 529
531 530 # The instance will store a pointer to this, so that runtime code
532 531 # (such as magics) can access it. This is because during the
533 532 # read-eval loop, it gets temporarily overwritten (to deal with GUI
534 533 # frameworks).
535 534 self.sys_excepthook = sys.excepthook
536 535
537 536 # and add any custom exception handlers the user may have specified
538 537 self.set_custom_exc(*custom_exceptions)
539 538
540 539 # indentation management
541 540 self.autoindent = False
542 541 self.indent_current_nsp = 0
543 542
544 543 # Make some aliases automatically
545 544 # Prepare list of shell aliases to auto-define
546 545 if os.name == 'posix':
547 546 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
548 547 'mv mv -i','rm rm -i','cp cp -i',
549 548 'cat cat','less less','clear clear',
550 549 # a better ls
551 550 'ls ls -F',
552 551 # long ls
553 552 'll ls -lF',
554 553 # color ls
555 554 'lc ls -F -o --color',
556 555 # ls normal files only
557 556 'lf ls -F -o --color %l | grep ^-',
558 557 # ls symbolic links
559 558 'lk ls -F -o --color %l | grep ^l',
560 559 # directories or links to directories,
561 560 'ldir ls -F -o --color %l | grep /$',
562 561 # things which are executable
563 562 'lx ls -F -o --color %l | grep ^-..x',
564 563 )
565 564 elif os.name in ['nt','dos']:
566 565 auto_alias = ('dir dir /on', 'ls dir /on',
567 566 'ddir dir /ad /on', 'ldir dir /ad /on',
568 567 'mkdir mkdir','rmdir rmdir','echo echo',
569 568 'ren ren','cls cls','copy copy')
570 569 else:
571 570 auto_alias = ()
572 571 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
573 572 # Call the actual (public) initializer
574 573 self.init_auto_alias()
575 574
576 575 # Produce a public API instance
577 576 self.api = IPython.ipapi.IPApi(self)
578 577
579 578 # track which builtins we add, so we can clean up later
580 579 self.builtins_added = {}
581 580 # This method will add the necessary builtins for operation, but
582 581 # tracking what it did via the builtins_added dict.
583 582 self.add_builtins()
584 583
585 584 # end __init__
586 585
587 586 def pre_config_initialization(self):
588 587 """Pre-configuration init method
589 588
590 589 This is called before the configuration files are processed to
591 590 prepare the services the config files might need.
592 591
593 592 self.rc already has reasonable default values at this point.
594 593 """
595 594 rc = self.rc
596 595
597 596 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
598 597
599 598 def post_config_initialization(self):
600 599 """Post configuration init method
601 600
602 601 This is called after the configuration files have been processed to
603 602 'finalize' the initialization."""
604 603
605 604 rc = self.rc
606 605
607 606 # Object inspector
608 607 self.inspector = OInspect.Inspector(OInspect.InspectColors,
609 608 PyColorize.ANSICodeColors,
610 609 'NoColor',
611 610 rc.object_info_string_level)
612 611
613 612 # Load readline proper
614 613 if rc.readline:
615 614 self.init_readline()
616 615
617 616 # local shortcut, this is used a LOT
618 617 self.log = self.logger.log
619 618
620 619 # Initialize cache, set in/out prompts and printing system
621 620 self.outputcache = CachedOutput(self,
622 621 rc.cache_size,
623 622 rc.pprint,
624 623 input_sep = rc.separate_in,
625 624 output_sep = rc.separate_out,
626 625 output_sep2 = rc.separate_out2,
627 626 ps1 = rc.prompt_in1,
628 627 ps2 = rc.prompt_in2,
629 628 ps_out = rc.prompt_out,
630 629 pad_left = rc.prompts_pad_left)
631 630
632 631 # user may have over-ridden the default print hook:
633 632 try:
634 633 self.outputcache.__class__.display = self.hooks.display
635 634 except AttributeError:
636 635 pass
637 636
638 637 # I don't like assigning globally to sys, because it means when embedding
639 638 # instances, each embedded instance overrides the previous choice. But
640 639 # sys.displayhook seems to be called internally by exec, so I don't see a
641 640 # way around it.
642 641 sys.displayhook = self.outputcache
643 642
644 643 # Set user colors (don't do it in the constructor above so that it
645 644 # doesn't crash if colors option is invalid)
646 645 self.magic_colors(rc.colors)
647 646
648 647 # Set calling of pdb on exceptions
649 648 self.call_pdb = rc.pdb
650 649
651 650 # Load user aliases
652 651 for alias in rc.alias:
653 652 self.magic_alias(alias)
654 653 self.hooks.late_startup_hook()
655 654
656 655 for batchfile in [path(arg) for arg in self.rc.args
657 656 if arg.lower().endswith('.ipy')]:
658 657 if not batchfile.isfile():
659 658 print "No such batch file:", batchfile
660 659 continue
661 660 self.api.runlines(batchfile.text())
662 661
663 662 def add_builtins(self):
664 663 """Store ipython references into the builtin namespace.
665 664
666 665 Some parts of ipython operate via builtins injected here, which hold a
667 666 reference to IPython itself."""
668 667
669 668 # TODO: deprecate all except _ip; 'jobs' should be installed
670 669 # by an extension and the rest are under _ip, ipalias is redundant
671 670 builtins_new = dict(__IPYTHON__ = self,
672 671 ip_set_hook = self.set_hook,
673 672 jobs = self.jobs,
674 673 ipmagic = self.ipmagic,
675 674 ipalias = self.ipalias,
676 675 ipsystem = self.ipsystem,
677 676 _ip = self.api
678 677 )
679 678 for biname,bival in builtins_new.items():
680 679 try:
681 680 # store the orignal value so we can restore it
682 681 self.builtins_added[biname] = __builtin__.__dict__[biname]
683 682 except KeyError:
684 683 # or mark that it wasn't defined, and we'll just delete it at
685 684 # cleanup
686 685 self.builtins_added[biname] = Undefined
687 686 __builtin__.__dict__[biname] = bival
688 687
689 688 # Keep in the builtins a flag for when IPython is active. We set it
690 689 # with setdefault so that multiple nested IPythons don't clobber one
691 690 # another. Each will increase its value by one upon being activated,
692 691 # which also gives us a way to determine the nesting level.
693 692 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
694 693
695 694 def clean_builtins(self):
696 695 """Remove any builtins which might have been added by add_builtins, or
697 696 restore overwritten ones to their previous values."""
698 697 for biname,bival in self.builtins_added.items():
699 698 if bival is Undefined:
700 699 del __builtin__.__dict__[biname]
701 700 else:
702 701 __builtin__.__dict__[biname] = bival
703 702 self.builtins_added.clear()
704 703
705 704 def set_hook(self,name,hook, priority = 50):
706 705 """set_hook(name,hook) -> sets an internal IPython hook.
707 706
708 707 IPython exposes some of its internal API as user-modifiable hooks. By
709 708 adding your function to one of these hooks, you can modify IPython's
710 709 behavior to call at runtime your own routines."""
711 710
712 711 # At some point in the future, this should validate the hook before it
713 712 # accepts it. Probably at least check that the hook takes the number
714 713 # of args it's supposed to.
715 714 dp = getattr(self.hooks, name, None)
716 715 if name not in IPython.hooks.__all__:
717 716 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
718 717 if not dp:
719 718 dp = IPython.hooks.CommandChainDispatcher()
720 719
721 720 f = new.instancemethod(hook,self,self.__class__)
722 721 try:
723 722 dp.add(f,priority)
724 723 except AttributeError:
725 724 # it was not commandchain, plain old func - replace
726 725 dp = f
727 726
728 727 setattr(self.hooks,name, dp)
729 728
730 729
731 730 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
732 731
733 732 def set_custom_exc(self,exc_tuple,handler):
734 733 """set_custom_exc(exc_tuple,handler)
735 734
736 735 Set a custom exception handler, which will be called if any of the
737 736 exceptions in exc_tuple occur in the mainloop (specifically, in the
738 737 runcode() method.
739 738
740 739 Inputs:
741 740
742 741 - exc_tuple: a *tuple* of valid exceptions to call the defined
743 742 handler for. It is very important that you use a tuple, and NOT A
744 743 LIST here, because of the way Python's except statement works. If
745 744 you only want to trap a single exception, use a singleton tuple:
746 745
747 746 exc_tuple == (MyCustomException,)
748 747
749 748 - handler: this must be defined as a function with the following
750 749 basic interface: def my_handler(self,etype,value,tb).
751 750
752 751 This will be made into an instance method (via new.instancemethod)
753 752 of IPython itself, and it will be called if any of the exceptions
754 753 listed in the exc_tuple are caught. If the handler is None, an
755 754 internal basic one is used, which just prints basic info.
756 755
757 756 WARNING: by putting in your own exception handler into IPython's main
758 757 execution loop, you run a very good chance of nasty crashes. This
759 758 facility should only be used if you really know what you are doing."""
760 759
761 760 assert type(exc_tuple)==type(()) , \
762 761 "The custom exceptions must be given AS A TUPLE."
763 762
764 763 def dummy_handler(self,etype,value,tb):
765 764 print '*** Simple custom exception handler ***'
766 765 print 'Exception type :',etype
767 766 print 'Exception value:',value
768 767 print 'Traceback :',tb
769 768 print 'Source code :','\n'.join(self.buffer)
770 769
771 770 if handler is None: handler = dummy_handler
772 771
773 772 self.CustomTB = new.instancemethod(handler,self,self.__class__)
774 773 self.custom_exceptions = exc_tuple
775 774
776 775 def set_custom_completer(self,completer,pos=0):
777 776 """set_custom_completer(completer,pos=0)
778 777
779 778 Adds a new custom completer function.
780 779
781 780 The position argument (defaults to 0) is the index in the completers
782 781 list where you want the completer to be inserted."""
783 782
784 783 newcomp = new.instancemethod(completer,self.Completer,
785 784 self.Completer.__class__)
786 785 self.Completer.matchers.insert(pos,newcomp)
787 786
788 787 def _get_call_pdb(self):
789 788 return self._call_pdb
790 789
791 790 def _set_call_pdb(self,val):
792 791
793 792 if val not in (0,1,False,True):
794 793 raise ValueError,'new call_pdb value must be boolean'
795 794
796 795 # store value in instance
797 796 self._call_pdb = val
798 797
799 798 # notify the actual exception handlers
800 799 self.InteractiveTB.call_pdb = val
801 800 if self.isthreaded:
802 801 try:
803 802 self.sys_excepthook.call_pdb = val
804 803 except:
805 804 warn('Failed to activate pdb for threaded exception handler')
806 805
807 806 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
808 807 'Control auto-activation of pdb at exceptions')
809 808
810 809
811 810 # These special functions get installed in the builtin namespace, to
812 811 # provide programmatic (pure python) access to magics, aliases and system
813 812 # calls. This is important for logging, user scripting, and more.
814 813
815 814 # We are basically exposing, via normal python functions, the three
816 815 # mechanisms in which ipython offers special call modes (magics for
817 816 # internal control, aliases for direct system access via pre-selected
818 817 # names, and !cmd for calling arbitrary system commands).
819 818
820 819 def ipmagic(self,arg_s):
821 820 """Call a magic function by name.
822 821
823 822 Input: a string containing the name of the magic function to call and any
824 823 additional arguments to be passed to the magic.
825 824
826 825 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
827 826 prompt:
828 827
829 828 In[1]: %name -opt foo bar
830 829
831 830 To call a magic without arguments, simply use ipmagic('name').
832 831
833 832 This provides a proper Python function to call IPython's magics in any
834 833 valid Python code you can type at the interpreter, including loops and
835 834 compound statements. It is added by IPython to the Python builtin
836 835 namespace upon initialization."""
837 836
838 837 args = arg_s.split(' ',1)
839 838 magic_name = args[0]
840 839 magic_name = magic_name.lstrip(self.ESC_MAGIC)
841 840
842 841 try:
843 842 magic_args = args[1]
844 843 except IndexError:
845 844 magic_args = ''
846 845 fn = getattr(self,'magic_'+magic_name,None)
847 846 if fn is None:
848 847 error("Magic function `%s` not found." % magic_name)
849 848 else:
850 849 magic_args = self.var_expand(magic_args)
851 850 return fn(magic_args)
852 851
853 852 def ipalias(self,arg_s):
854 853 """Call an alias by name.
855 854
856 855 Input: a string containing the name of the alias to call and any
857 856 additional arguments to be passed to the magic.
858 857
859 858 ipalias('name -opt foo bar') is equivalent to typing at the ipython
860 859 prompt:
861 860
862 861 In[1]: name -opt foo bar
863 862
864 863 To call an alias without arguments, simply use ipalias('name').
865 864
866 865 This provides a proper Python function to call IPython's aliases in any
867 866 valid Python code you can type at the interpreter, including loops and
868 867 compound statements. It is added by IPython to the Python builtin
869 868 namespace upon initialization."""
870 869
871 870 args = arg_s.split(' ',1)
872 871 alias_name = args[0]
873 872 try:
874 873 alias_args = args[1]
875 874 except IndexError:
876 875 alias_args = ''
877 876 if alias_name in self.alias_table:
878 877 self.call_alias(alias_name,alias_args)
879 878 else:
880 879 error("Alias `%s` not found." % alias_name)
881 880
882 881 def ipsystem(self,arg_s):
883 882 """Make a system call, using IPython."""
884 883
885 884 self.system(arg_s)
886 885
887 886 def complete(self,text):
888 887 """Return a sorted list of all possible completions on text.
889 888
890 889 Inputs:
891 890
892 891 - text: a string of text to be completed on.
893 892
894 893 This is a wrapper around the completion mechanism, similar to what
895 894 readline does at the command line when the TAB key is hit. By
896 895 exposing it as a method, it can be used by other non-readline
897 896 environments (such as GUIs) for text completion.
898 897
899 898 Simple usage example:
900 899
901 900 In [1]: x = 'hello'
902 901
903 902 In [2]: __IP.complete('x.l')
904 903 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
905 904
906 905 complete = self.Completer.complete
907 906 state = 0
908 907 # use a dict so we get unique keys, since ipyhton's multiple
909 908 # completers can return duplicates.
910 909 comps = {}
911 910 while True:
912 911 newcomp = complete(text,state)
913 912 if newcomp is None:
914 913 break
915 914 comps[newcomp] = 1
916 915 state += 1
917 916 outcomps = comps.keys()
918 917 outcomps.sort()
919 918 return outcomps
920 919
921 920 def set_completer_frame(self, frame=None):
922 921 if frame:
923 922 self.Completer.namespace = frame.f_locals
924 923 self.Completer.global_namespace = frame.f_globals
925 924 else:
926 925 self.Completer.namespace = self.user_ns
927 926 self.Completer.global_namespace = self.user_global_ns
928 927
929 928 def init_auto_alias(self):
930 929 """Define some aliases automatically.
931 930
932 931 These are ALL parameter-less aliases"""
933 932
934 933 for alias,cmd in self.auto_alias:
935 934 self.alias_table[alias] = (0,cmd)
936 935
937 936 def alias_table_validate(self,verbose=0):
938 937 """Update information about the alias table.
939 938
940 939 In particular, make sure no Python keywords/builtins are in it."""
941 940
942 941 no_alias = self.no_alias
943 942 for k in self.alias_table.keys():
944 943 if k in no_alias:
945 944 del self.alias_table[k]
946 945 if verbose:
947 946 print ("Deleting alias <%s>, it's a Python "
948 947 "keyword or builtin." % k)
949 948
950 949 def set_autoindent(self,value=None):
951 950 """Set the autoindent flag, checking for readline support.
952 951
953 952 If called with no arguments, it acts as a toggle."""
954 953
955 954 if not self.has_readline:
956 955 if os.name == 'posix':
957 956 warn("The auto-indent feature requires the readline library")
958 957 self.autoindent = 0
959 958 return
960 959 if value is None:
961 960 self.autoindent = not self.autoindent
962 961 else:
963 962 self.autoindent = value
964 963
965 964 def rc_set_toggle(self,rc_field,value=None):
966 965 """Set or toggle a field in IPython's rc config. structure.
967 966
968 967 If called with no arguments, it acts as a toggle.
969 968
970 969 If called with a non-existent field, the resulting AttributeError
971 970 exception will propagate out."""
972 971
973 972 rc_val = getattr(self.rc,rc_field)
974 973 if value is None:
975 974 value = not rc_val
976 975 setattr(self.rc,rc_field,value)
977 976
978 977 def user_setup(self,ipythondir,rc_suffix,mode='install'):
979 978 """Install the user configuration directory.
980 979
981 980 Can be called when running for the first time or to upgrade the user's
982 981 .ipython/ directory with the mode parameter. Valid modes are 'install'
983 982 and 'upgrade'."""
984 983
985 984 def wait():
986 985 try:
987 986 raw_input("Please press <RETURN> to start IPython.")
988 987 except EOFError:
989 988 print >> Term.cout
990 989 print '*'*70
991 990
992 991 cwd = os.getcwd() # remember where we started
993 992 glb = glob.glob
994 993 print '*'*70
995 994 if mode == 'install':
996 995 print \
997 996 """Welcome to IPython. I will try to create a personal configuration directory
998 997 where you can customize many aspects of IPython's functionality in:\n"""
999 998 else:
1000 999 print 'I am going to upgrade your configuration in:'
1001 1000
1002 1001 print ipythondir
1003 1002
1004 1003 rcdirend = os.path.join('IPython','UserConfig')
1005 1004 cfg = lambda d: os.path.join(d,rcdirend)
1006 1005 try:
1007 1006 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1008 1007 except IOError:
1009 1008 warning = """
1010 1009 Installation error. IPython's directory was not found.
1011 1010
1012 1011 Check the following:
1013 1012
1014 1013 The ipython/IPython directory should be in a directory belonging to your
1015 1014 PYTHONPATH environment variable (that is, it should be in a directory
1016 1015 belonging to sys.path). You can copy it explicitly there or just link to it.
1017 1016
1018 1017 IPython will proceed with builtin defaults.
1019 1018 """
1020 1019 warn(warning)
1021 1020 wait()
1022 1021 return
1023 1022
1024 1023 if mode == 'install':
1025 1024 try:
1026 1025 shutil.copytree(rcdir,ipythondir)
1027 1026 os.chdir(ipythondir)
1028 1027 rc_files = glb("ipythonrc*")
1029 1028 for rc_file in rc_files:
1030 1029 os.rename(rc_file,rc_file+rc_suffix)
1031 1030 except:
1032 1031 warning = """
1033 1032
1034 1033 There was a problem with the installation:
1035 1034 %s
1036 1035 Try to correct it or contact the developers if you think it's a bug.
1037 1036 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1038 1037 warn(warning)
1039 1038 wait()
1040 1039 return
1041 1040
1042 1041 elif mode == 'upgrade':
1043 1042 try:
1044 1043 os.chdir(ipythondir)
1045 1044 except:
1046 1045 print """
1047 1046 Can not upgrade: changing to directory %s failed. Details:
1048 1047 %s
1049 1048 """ % (ipythondir,sys.exc_info()[1])
1050 1049 wait()
1051 1050 return
1052 1051 else:
1053 1052 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1054 1053 for new_full_path in sources:
1055 1054 new_filename = os.path.basename(new_full_path)
1056 1055 if new_filename.startswith('ipythonrc'):
1057 1056 new_filename = new_filename + rc_suffix
1058 1057 # The config directory should only contain files, skip any
1059 1058 # directories which may be there (like CVS)
1060 1059 if os.path.isdir(new_full_path):
1061 1060 continue
1062 1061 if os.path.exists(new_filename):
1063 1062 old_file = new_filename+'.old'
1064 1063 if os.path.exists(old_file):
1065 1064 os.remove(old_file)
1066 1065 os.rename(new_filename,old_file)
1067 1066 shutil.copy(new_full_path,new_filename)
1068 1067 else:
1069 1068 raise ValueError,'unrecognized mode for install:',`mode`
1070 1069
1071 1070 # Fix line-endings to those native to each platform in the config
1072 1071 # directory.
1073 1072 try:
1074 1073 os.chdir(ipythondir)
1075 1074 except:
1076 1075 print """
1077 1076 Problem: changing to directory %s failed.
1078 1077 Details:
1079 1078 %s
1080 1079
1081 1080 Some configuration files may have incorrect line endings. This should not
1082 1081 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1083 1082 wait()
1084 1083 else:
1085 1084 for fname in glb('ipythonrc*'):
1086 1085 try:
1087 1086 native_line_ends(fname,backup=0)
1088 1087 except IOError:
1089 1088 pass
1090 1089
1091 1090 if mode == 'install':
1092 1091 print """
1093 1092 Successful installation!
1094 1093
1095 1094 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1096 1095 IPython manual (there are both HTML and PDF versions supplied with the
1097 1096 distribution) to make sure that your system environment is properly configured
1098 1097 to take advantage of IPython's features.
1099 1098
1100 1099 Important note: the configuration system has changed! The old system is
1101 1100 still in place, but its setting may be partly overridden by the settings in
1102 1101 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1103 1102 if some of the new settings bother you.
1104 1103
1105 1104 """
1106 1105 else:
1107 1106 print """
1108 1107 Successful upgrade!
1109 1108
1110 1109 All files in your directory:
1111 1110 %(ipythondir)s
1112 1111 which would have been overwritten by the upgrade were backed up with a .old
1113 1112 extension. If you had made particular customizations in those files you may
1114 1113 want to merge them back into the new files.""" % locals()
1115 1114 wait()
1116 1115 os.chdir(cwd)
1117 1116 # end user_setup()
1118 1117
1119 1118 def atexit_operations(self):
1120 1119 """This will be executed at the time of exit.
1121 1120
1122 1121 Saving of persistent data should be performed here. """
1123 1122
1124 1123 #print '*** IPython exit cleanup ***' # dbg
1125 1124 # input history
1126 1125 self.savehist()
1127 1126
1128 1127 # Cleanup all tempfiles left around
1129 1128 for tfile in self.tempfiles:
1130 1129 try:
1131 1130 os.unlink(tfile)
1132 1131 except OSError:
1133 1132 pass
1134 1133
1135 1134 # save the "persistent data" catch-all dictionary
1136 1135 self.hooks.shutdown_hook()
1137 1136
1138 1137 def savehist(self):
1139 1138 """Save input history to a file (via readline library)."""
1140 1139 try:
1141 1140 self.readline.write_history_file(self.histfile)
1142 1141 except:
1143 1142 print 'Unable to save IPython command history to file: ' + \
1144 1143 `self.histfile`
1145 1144
1146 1145 def pre_readline(self):
1147 1146 """readline hook to be used at the start of each line.
1148 1147
1149 1148 Currently it handles auto-indent only."""
1150 1149
1151 1150 #debugx('self.indent_current_nsp','pre_readline:')
1152 1151 self.readline.insert_text(self.indent_current_str())
1153 1152
1154 1153 def init_readline(self):
1155 1154 """Command history completion/saving/reloading."""
1156 1155
1157 1156 import IPython.rlineimpl as readline
1158 1157 if not readline.have_readline:
1159 1158 self.has_readline = 0
1160 1159 self.readline = None
1161 1160 # no point in bugging windows users with this every time:
1162 1161 warn('Readline services not available on this platform.')
1163 1162 else:
1164 1163 sys.modules['readline'] = readline
1165 1164 import atexit
1166 1165 from IPython.completer import IPCompleter
1167 1166 self.Completer = IPCompleter(self,
1168 1167 self.user_ns,
1169 1168 self.user_global_ns,
1170 1169 self.rc.readline_omit__names,
1171 1170 self.alias_table)
1172 1171
1173 1172 # Platform-specific configuration
1174 1173 if os.name == 'nt':
1175 1174 self.readline_startup_hook = readline.set_pre_input_hook
1176 1175 else:
1177 1176 self.readline_startup_hook = readline.set_startup_hook
1178 1177
1179 1178 # Load user's initrc file (readline config)
1180 1179 inputrc_name = os.environ.get('INPUTRC')
1181 1180 if inputrc_name is None:
1182 1181 home_dir = get_home_dir()
1183 1182 if home_dir is not None:
1184 1183 inputrc_name = os.path.join(home_dir,'.inputrc')
1185 1184 if os.path.isfile(inputrc_name):
1186 1185 try:
1187 1186 readline.read_init_file(inputrc_name)
1188 1187 except:
1189 1188 warn('Problems reading readline initialization file <%s>'
1190 1189 % inputrc_name)
1191 1190
1192 1191 self.has_readline = 1
1193 1192 self.readline = readline
1194 1193 # save this in sys so embedded copies can restore it properly
1195 1194 sys.ipcompleter = self.Completer.complete
1196 1195 readline.set_completer(self.Completer.complete)
1197 1196
1198 1197 # Configure readline according to user's prefs
1199 1198 for rlcommand in self.rc.readline_parse_and_bind:
1200 1199 readline.parse_and_bind(rlcommand)
1201 1200
1202 1201 # remove some chars from the delimiters list
1203 1202 delims = readline.get_completer_delims()
1204 1203 delims = delims.translate(string._idmap,
1205 1204 self.rc.readline_remove_delims)
1206 1205 readline.set_completer_delims(delims)
1207 1206 # otherwise we end up with a monster history after a while:
1208 1207 readline.set_history_length(1000)
1209 1208 try:
1210 1209 #print '*** Reading readline history' # dbg
1211 1210 readline.read_history_file(self.histfile)
1212 1211 except IOError:
1213 1212 pass # It doesn't exist yet.
1214 1213
1215 1214 atexit.register(self.atexit_operations)
1216 1215 del atexit
1217 1216
1218 1217 # Configure auto-indent for all platforms
1219 1218 self.set_autoindent(self.rc.autoindent)
1220 1219
1221 1220 def _should_recompile(self,e):
1222 1221 """Utility routine for edit_syntax_error"""
1223 1222
1224 1223 if e.filename in ('<ipython console>','<input>','<string>',
1225 1224 '<console>','<BackgroundJob compilation>',
1226 1225 None):
1227 1226
1228 1227 return False
1229 1228 try:
1230 1229 if (self.rc.autoedit_syntax and
1231 1230 not ask_yes_no('Return to editor to correct syntax error? '
1232 1231 '[Y/n] ','y')):
1233 1232 return False
1234 1233 except EOFError:
1235 1234 return False
1236 1235
1237 1236 def int0(x):
1238 1237 try:
1239 1238 return int(x)
1240 1239 except TypeError:
1241 1240 return 0
1242 1241 # always pass integer line and offset values to editor hook
1243 1242 self.hooks.fix_error_editor(e.filename,
1244 1243 int0(e.lineno),int0(e.offset),e.msg)
1245 1244 return True
1246 1245
1247 1246 def edit_syntax_error(self):
1248 1247 """The bottom half of the syntax error handler called in the main loop.
1249 1248
1250 1249 Loop until syntax error is fixed or user cancels.
1251 1250 """
1252 1251
1253 1252 while self.SyntaxTB.last_syntax_error:
1254 1253 # copy and clear last_syntax_error
1255 1254 err = self.SyntaxTB.clear_err_state()
1256 1255 if not self._should_recompile(err):
1257 1256 return
1258 1257 try:
1259 1258 # may set last_syntax_error again if a SyntaxError is raised
1260 1259 self.safe_execfile(err.filename,self.shell.user_ns)
1261 1260 except:
1262 1261 self.showtraceback()
1263 1262 else:
1264 1263 try:
1265 1264 f = file(err.filename)
1266 1265 try:
1267 1266 sys.displayhook(f.read())
1268 1267 finally:
1269 1268 f.close()
1270 1269 except:
1271 1270 self.showtraceback()
1272 1271
1273 1272 def showsyntaxerror(self, filename=None):
1274 1273 """Display the syntax error that just occurred.
1275 1274
1276 1275 This doesn't display a stack trace because there isn't one.
1277 1276
1278 1277 If a filename is given, it is stuffed in the exception instead
1279 1278 of what was there before (because Python's parser always uses
1280 1279 "<string>" when reading from a string).
1281 1280 """
1282 1281 etype, value, last_traceback = sys.exc_info()
1283 1282
1284 1283 # See note about these variables in showtraceback() below
1285 1284 sys.last_type = etype
1286 1285 sys.last_value = value
1287 1286 sys.last_traceback = last_traceback
1288 1287
1289 1288 if filename and etype is SyntaxError:
1290 1289 # Work hard to stuff the correct filename in the exception
1291 1290 try:
1292 1291 msg, (dummy_filename, lineno, offset, line) = value
1293 1292 except:
1294 1293 # Not the format we expect; leave it alone
1295 1294 pass
1296 1295 else:
1297 1296 # Stuff in the right filename
1298 1297 try:
1299 1298 # Assume SyntaxError is a class exception
1300 1299 value = SyntaxError(msg, (filename, lineno, offset, line))
1301 1300 except:
1302 1301 # If that failed, assume SyntaxError is a string
1303 1302 value = msg, (filename, lineno, offset, line)
1304 1303 self.SyntaxTB(etype,value,[])
1305 1304
1306 1305 def debugger(self):
1307 1306 """Call the pdb debugger."""
1308 1307
1309 1308 if not self.rc.pdb:
1310 1309 return
1311 1310 pdb.pm()
1312 1311
1313 1312 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1314 1313 """Display the exception that just occurred.
1315 1314
1316 1315 If nothing is known about the exception, this is the method which
1317 1316 should be used throughout the code for presenting user tracebacks,
1318 1317 rather than directly invoking the InteractiveTB object.
1319 1318
1320 1319 A specific showsyntaxerror() also exists, but this method can take
1321 1320 care of calling it if needed, so unless you are explicitly catching a
1322 1321 SyntaxError exception, don't try to analyze the stack manually and
1323 1322 simply call this method."""
1324 1323
1325 1324 # Though this won't be called by syntax errors in the input line,
1326 1325 # there may be SyntaxError cases whith imported code.
1327 1326 if exc_tuple is None:
1328 1327 etype, value, tb = sys.exc_info()
1329 1328 else:
1330 1329 etype, value, tb = exc_tuple
1331 1330 if etype is SyntaxError:
1332 1331 self.showsyntaxerror(filename)
1333 1332 else:
1334 1333 # WARNING: these variables are somewhat deprecated and not
1335 1334 # necessarily safe to use in a threaded environment, but tools
1336 1335 # like pdb depend on their existence, so let's set them. If we
1337 1336 # find problems in the field, we'll need to revisit their use.
1338 1337 sys.last_type = etype
1339 1338 sys.last_value = value
1340 1339 sys.last_traceback = tb
1341 1340
1342 1341 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1343 1342 if self.InteractiveTB.call_pdb and self.has_readline:
1344 1343 # pdb mucks up readline, fix it back
1345 1344 self.readline.set_completer(self.Completer.complete)
1346 1345
1347 1346 def mainloop(self,banner=None):
1348 1347 """Creates the local namespace and starts the mainloop.
1349 1348
1350 1349 If an optional banner argument is given, it will override the
1351 1350 internally created default banner."""
1352 1351
1353 1352 if self.rc.c: # Emulate Python's -c option
1354 1353 self.exec_init_cmd()
1355 1354 if banner is None:
1356 1355 if not self.rc.banner:
1357 1356 banner = ''
1358 1357 # banner is string? Use it directly!
1359 1358 elif isinstance(self.rc.banner,basestring):
1360 1359 banner = self.rc.banner
1361 1360 else:
1362 1361 banner = self.BANNER+self.banner2
1363 1362
1364 1363 self.interact(banner)
1365 1364
1366 1365 def exec_init_cmd(self):
1367 1366 """Execute a command given at the command line.
1368 1367
1369 1368 This emulates Python's -c option."""
1370 1369
1371 1370 #sys.argv = ['-c']
1372 1371 self.push(self.rc.c)
1373 1372
1374 1373 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1375 1374 """Embeds IPython into a running python program.
1376 1375
1377 1376 Input:
1378 1377
1379 1378 - header: An optional header message can be specified.
1380 1379
1381 1380 - local_ns, global_ns: working namespaces. If given as None, the
1382 1381 IPython-initialized one is updated with __main__.__dict__, so that
1383 1382 program variables become visible but user-specific configuration
1384 1383 remains possible.
1385 1384
1386 1385 - stack_depth: specifies how many levels in the stack to go to
1387 1386 looking for namespaces (when local_ns and global_ns are None). This
1388 1387 allows an intermediate caller to make sure that this function gets
1389 1388 the namespace from the intended level in the stack. By default (0)
1390 1389 it will get its locals and globals from the immediate caller.
1391 1390
1392 1391 Warning: it's possible to use this in a program which is being run by
1393 1392 IPython itself (via %run), but some funny things will happen (a few
1394 1393 globals get overwritten). In the future this will be cleaned up, as
1395 1394 there is no fundamental reason why it can't work perfectly."""
1396 1395
1397 1396 # Get locals and globals from caller
1398 1397 if local_ns is None or global_ns is None:
1399 1398 call_frame = sys._getframe(stack_depth).f_back
1400 1399
1401 1400 if local_ns is None:
1402 1401 local_ns = call_frame.f_locals
1403 1402 if global_ns is None:
1404 1403 global_ns = call_frame.f_globals
1405 1404
1406 1405 # Update namespaces and fire up interpreter
1407 1406
1408 1407 # The global one is easy, we can just throw it in
1409 1408 self.user_global_ns = global_ns
1410 1409
1411 1410 # but the user/local one is tricky: ipython needs it to store internal
1412 1411 # data, but we also need the locals. We'll copy locals in the user
1413 1412 # one, but will track what got copied so we can delete them at exit.
1414 1413 # This is so that a later embedded call doesn't see locals from a
1415 1414 # previous call (which most likely existed in a separate scope).
1416 1415 local_varnames = local_ns.keys()
1417 1416 self.user_ns.update(local_ns)
1418 1417
1419 1418 # Patch for global embedding to make sure that things don't overwrite
1420 1419 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1421 1420 # FIXME. Test this a bit more carefully (the if.. is new)
1422 1421 if local_ns is None and global_ns is None:
1423 1422 self.user_global_ns.update(__main__.__dict__)
1424 1423
1425 1424 # make sure the tab-completer has the correct frame information, so it
1426 1425 # actually completes using the frame's locals/globals
1427 1426 self.set_completer_frame()
1428 1427
1429 1428 # before activating the interactive mode, we need to make sure that
1430 1429 # all names in the builtin namespace needed by ipython point to
1431 1430 # ourselves, and not to other instances.
1432 1431 self.add_builtins()
1433 1432
1434 1433 self.interact(header)
1435 1434
1436 1435 # now, purge out the user namespace from anything we might have added
1437 1436 # from the caller's local namespace
1438 1437 delvar = self.user_ns.pop
1439 1438 for var in local_varnames:
1440 1439 delvar(var,None)
1441 1440 # and clean builtins we may have overridden
1442 1441 self.clean_builtins()
1443 1442
1444 1443 def interact(self, banner=None):
1445 1444 """Closely emulate the interactive Python console.
1446 1445
1447 1446 The optional banner argument specify the banner to print
1448 1447 before the first interaction; by default it prints a banner
1449 1448 similar to the one printed by the real Python interpreter,
1450 1449 followed by the current class name in parentheses (so as not
1451 1450 to confuse this with the real interpreter -- since it's so
1452 1451 close!).
1453 1452
1454 1453 """
1455 1454 cprt = 'Type "copyright", "credits" or "license" for more information.'
1456 1455 if banner is None:
1457 1456 self.write("Python %s on %s\n%s\n(%s)\n" %
1458 1457 (sys.version, sys.platform, cprt,
1459 1458 self.__class__.__name__))
1460 1459 else:
1461 1460 self.write(banner)
1462 1461
1463 1462 more = 0
1464 1463
1465 1464 # Mark activity in the builtins
1466 1465 __builtin__.__dict__['__IPYTHON__active'] += 1
1467 1466
1468 1467 # exit_now is set by a call to %Exit or %Quit
1469 1468 self.exit_now = False
1470 1469 while not self.exit_now:
1471 1470 if more:
1472 1471 prompt = self.outputcache.prompt2
1473 1472 if self.autoindent:
1474 1473 self.readline_startup_hook(self.pre_readline)
1475 1474 else:
1476 1475 prompt = self.outputcache.prompt1
1477 1476 try:
1478 1477 line = self.raw_input(prompt,more)
1479 1478 if self.autoindent:
1480 1479 self.readline_startup_hook(None)
1481 1480 except KeyboardInterrupt:
1482 1481 self.write('\nKeyboardInterrupt\n')
1483 1482 self.resetbuffer()
1484 1483 # keep cache in sync with the prompt counter:
1485 1484 self.outputcache.prompt_count -= 1
1486 1485
1487 1486 if self.autoindent:
1488 1487 self.indent_current_nsp = 0
1489 1488 more = 0
1490 1489 except EOFError:
1491 1490 if self.autoindent:
1492 1491 self.readline_startup_hook(None)
1493 1492 self.write('\n')
1494 1493 self.exit()
1495 1494 except bdb.BdbQuit:
1496 1495 warn('The Python debugger has exited with a BdbQuit exception.\n'
1497 1496 'Because of how pdb handles the stack, it is impossible\n'
1498 1497 'for IPython to properly format this particular exception.\n'
1499 1498 'IPython will resume normal operation.')
1500 1499 except:
1501 1500 # exceptions here are VERY RARE, but they can be triggered
1502 1501 # asynchronously by signal handlers, for example.
1503 1502 self.showtraceback()
1504 1503 else:
1505 1504 more = self.push(line)
1506 1505 if (self.SyntaxTB.last_syntax_error and
1507 1506 self.rc.autoedit_syntax):
1508 1507 self.edit_syntax_error()
1509 1508
1510 1509 # We are off again...
1511 1510 __builtin__.__dict__['__IPYTHON__active'] -= 1
1512 1511
1513 1512 def excepthook(self, etype, value, tb):
1514 1513 """One more defense for GUI apps that call sys.excepthook.
1515 1514
1516 1515 GUI frameworks like wxPython trap exceptions and call
1517 1516 sys.excepthook themselves. I guess this is a feature that
1518 1517 enables them to keep running after exceptions that would
1519 1518 otherwise kill their mainloop. This is a bother for IPython
1520 1519 which excepts to catch all of the program exceptions with a try:
1521 1520 except: statement.
1522 1521
1523 1522 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1524 1523 any app directly invokes sys.excepthook, it will look to the user like
1525 1524 IPython crashed. In order to work around this, we can disable the
1526 1525 CrashHandler and replace it with this excepthook instead, which prints a
1527 1526 regular traceback using our InteractiveTB. In this fashion, apps which
1528 1527 call sys.excepthook will generate a regular-looking exception from
1529 1528 IPython, and the CrashHandler will only be triggered by real IPython
1530 1529 crashes.
1531 1530
1532 1531 This hook should be used sparingly, only in places which are not likely
1533 1532 to be true IPython errors.
1534 1533 """
1535 1534 self.showtraceback((etype,value,tb),tb_offset=0)
1536 1535
1537 1536 def transform_alias(self, alias,rest=''):
1538 1537 """ Transform alias to system command string
1539 1538
1540 1539 """
1541 1540 nargs,cmd = self.alias_table[alias]
1542 1541 if ' ' in cmd and os.path.isfile(cmd):
1543 1542 cmd = '"%s"' % cmd
1544 1543
1545 1544 # Expand the %l special to be the user's input line
1546 1545 if cmd.find('%l') >= 0:
1547 1546 cmd = cmd.replace('%l',rest)
1548 1547 rest = ''
1549 1548 if nargs==0:
1550 1549 # Simple, argument-less aliases
1551 1550 cmd = '%s %s' % (cmd,rest)
1552 1551 else:
1553 1552 # Handle aliases with positional arguments
1554 1553 args = rest.split(None,nargs)
1555 1554 if len(args)< nargs:
1556 1555 error('Alias <%s> requires %s arguments, %s given.' %
1557 1556 (alias,nargs,len(args)))
1558 1557 return None
1559 1558 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1560 1559 # Now call the macro, evaluating in the user's namespace
1561 1560
1562 1561 return cmd
1563 1562
1564 1563 def call_alias(self,alias,rest=''):
1565 1564 """Call an alias given its name and the rest of the line.
1566 1565
1567 1566 This is only used to provide backwards compatibility for users of
1568 1567 ipalias(), use of which is not recommended for anymore."""
1569 1568
1570 1569 # Now call the macro, evaluating in the user's namespace
1571 1570 cmd = self.transform_alias(alias, rest)
1572 1571 try:
1573 1572 self.system(cmd)
1574 1573 except:
1575 1574 self.showtraceback()
1576 1575
1577 1576 def indent_current_str(self):
1578 1577 """return the current level of indentation as a string"""
1579 1578 return self.indent_current_nsp * ' '
1580 1579
1581 1580 def autoindent_update(self,line):
1582 1581 """Keep track of the indent level."""
1583 1582
1584 1583 #debugx('line')
1585 1584 #debugx('self.indent_current_nsp')
1586 1585 if self.autoindent:
1587 1586 if line:
1588 1587 inisp = num_ini_spaces(line)
1589 1588 if inisp < self.indent_current_nsp:
1590 1589 self.indent_current_nsp = inisp
1591 1590
1592 1591 if line[-1] == ':':
1593 1592 self.indent_current_nsp += 4
1594 1593 elif dedent_re.match(line):
1595 1594 self.indent_current_nsp -= 4
1596 1595 else:
1597 1596 self.indent_current_nsp = 0
1598 1597
1599 1598 def runlines(self,lines):
1600 1599 """Run a string of one or more lines of source.
1601 1600
1602 1601 This method is capable of running a string containing multiple source
1603 1602 lines, as if they had been entered at the IPython prompt. Since it
1604 1603 exposes IPython's processing machinery, the given strings can contain
1605 1604 magic calls (%magic), special shell access (!cmd), etc."""
1606 1605
1607 1606 # We must start with a clean buffer, in case this is run from an
1608 1607 # interactive IPython session (via a magic, for example).
1609 1608 self.resetbuffer()
1610 1609 lines = lines.split('\n')
1611 1610 more = 0
1612 1611 for line in lines:
1613 1612 # skip blank lines so we don't mess up the prompt counter, but do
1614 1613 # NOT skip even a blank line if we are in a code block (more is
1615 1614 # true)
1616 1615 if line or more:
1617 1616 more = self.push(self.prefilter(line,more))
1618 1617 # IPython's runsource returns None if there was an error
1619 1618 # compiling the code. This allows us to stop processing right
1620 1619 # away, so the user gets the error message at the right place.
1621 1620 if more is None:
1622 1621 break
1623 1622 # final newline in case the input didn't have it, so that the code
1624 1623 # actually does get executed
1625 1624 if more:
1626 1625 self.push('\n')
1627 1626
1628 1627 def runsource(self, source, filename='<input>', symbol='single'):
1629 1628 """Compile and run some source in the interpreter.
1630 1629
1631 1630 Arguments are as for compile_command().
1632 1631
1633 1632 One several things can happen:
1634 1633
1635 1634 1) The input is incorrect; compile_command() raised an
1636 1635 exception (SyntaxError or OverflowError). A syntax traceback
1637 1636 will be printed by calling the showsyntaxerror() method.
1638 1637
1639 1638 2) The input is incomplete, and more input is required;
1640 1639 compile_command() returned None. Nothing happens.
1641 1640
1642 1641 3) The input is complete; compile_command() returned a code
1643 1642 object. The code is executed by calling self.runcode() (which
1644 1643 also handles run-time exceptions, except for SystemExit).
1645 1644
1646 1645 The return value is:
1647 1646
1648 1647 - True in case 2
1649 1648
1650 1649 - False in the other cases, unless an exception is raised, where
1651 1650 None is returned instead. This can be used by external callers to
1652 1651 know whether to continue feeding input or not.
1653 1652
1654 1653 The return value can be used to decide whether to use sys.ps1 or
1655 1654 sys.ps2 to prompt the next line."""
1656 1655
1657 1656 try:
1658 1657 code = self.compile(source,filename,symbol)
1659 1658 except (OverflowError, SyntaxError, ValueError):
1660 1659 # Case 1
1661 1660 self.showsyntaxerror(filename)
1662 1661 return None
1663 1662
1664 1663 if code is None:
1665 1664 # Case 2
1666 1665 return True
1667 1666
1668 1667 # Case 3
1669 1668 # We store the code object so that threaded shells and
1670 1669 # custom exception handlers can access all this info if needed.
1671 1670 # The source corresponding to this can be obtained from the
1672 1671 # buffer attribute as '\n'.join(self.buffer).
1673 1672 self.code_to_run = code
1674 1673 # now actually execute the code object
1675 1674 if self.runcode(code) == 0:
1676 1675 return False
1677 1676 else:
1678 1677 return None
1679 1678
1680 1679 def runcode(self,code_obj):
1681 1680 """Execute a code object.
1682 1681
1683 1682 When an exception occurs, self.showtraceback() is called to display a
1684 1683 traceback.
1685 1684
1686 1685 Return value: a flag indicating whether the code to be run completed
1687 1686 successfully:
1688 1687
1689 1688 - 0: successful execution.
1690 1689 - 1: an error occurred.
1691 1690 """
1692 1691
1693 1692 # Set our own excepthook in case the user code tries to call it
1694 1693 # directly, so that the IPython crash handler doesn't get triggered
1695 1694 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1696 1695
1697 1696 # we save the original sys.excepthook in the instance, in case config
1698 1697 # code (such as magics) needs access to it.
1699 1698 self.sys_excepthook = old_excepthook
1700 1699 outflag = 1 # happens in more places, so it's easier as default
1701 1700 try:
1702 1701 try:
1703 1702 # Embedded instances require separate global/local namespaces
1704 1703 # so they can see both the surrounding (local) namespace and
1705 1704 # the module-level globals when called inside another function.
1706 1705 if self.embedded:
1707 1706 exec code_obj in self.user_global_ns, self.user_ns
1708 1707 # Normal (non-embedded) instances should only have a single
1709 1708 # namespace for user code execution, otherwise functions won't
1710 1709 # see interactive top-level globals.
1711 1710 else:
1712 1711 exec code_obj in self.user_ns
1713 1712 finally:
1714 1713 # Reset our crash handler in place
1715 1714 sys.excepthook = old_excepthook
1716 1715 except SystemExit:
1717 1716 self.resetbuffer()
1718 1717 self.showtraceback()
1719 1718 warn("Type exit or quit to exit IPython "
1720 1719 "(%Exit or %Quit do so unconditionally).",level=1)
1721 1720 except self.custom_exceptions:
1722 1721 etype,value,tb = sys.exc_info()
1723 1722 self.CustomTB(etype,value,tb)
1724 1723 except:
1725 1724 self.showtraceback()
1726 1725 else:
1727 1726 outflag = 0
1728 1727 if softspace(sys.stdout, 0):
1729 1728 print
1730 1729 # Flush out code object which has been run (and source)
1731 1730 self.code_to_run = None
1732 1731 return outflag
1733 1732
1734 1733 def push(self, line):
1735 1734 """Push a line to the interpreter.
1736 1735
1737 1736 The line should not have a trailing newline; it may have
1738 1737 internal newlines. The line is appended to a buffer and the
1739 1738 interpreter's runsource() method is called with the
1740 1739 concatenated contents of the buffer as source. If this
1741 1740 indicates that the command was executed or invalid, the buffer
1742 1741 is reset; otherwise, the command is incomplete, and the buffer
1743 1742 is left as it was after the line was appended. The return
1744 1743 value is 1 if more input is required, 0 if the line was dealt
1745 1744 with in some way (this is the same as runsource()).
1746 1745 """
1747 1746
1748 1747 # autoindent management should be done here, and not in the
1749 1748 # interactive loop, since that one is only seen by keyboard input. We
1750 1749 # need this done correctly even for code run via runlines (which uses
1751 1750 # push).
1752 1751
1753 1752 #print 'push line: <%s>' % line # dbg
1754 1753 self.autoindent_update(line)
1755 1754
1756 1755 self.buffer.append(line)
1757 1756 more = self.runsource('\n'.join(self.buffer), self.filename)
1758 1757 if not more:
1759 1758 self.resetbuffer()
1760 1759 return more
1761 1760
1762 1761 def resetbuffer(self):
1763 1762 """Reset the input buffer."""
1764 1763 self.buffer[:] = []
1765 1764
1766 1765 def raw_input(self,prompt='',continue_prompt=False):
1767 1766 """Write a prompt and read a line.
1768 1767
1769 1768 The returned line does not include the trailing newline.
1770 1769 When the user enters the EOF key sequence, EOFError is raised.
1771 1770
1772 1771 Optional inputs:
1773 1772
1774 1773 - prompt(''): a string to be printed to prompt the user.
1775 1774
1776 1775 - continue_prompt(False): whether this line is the first one or a
1777 1776 continuation in a sequence of inputs.
1778 1777 """
1779 1778
1780 1779 line = raw_input_original(prompt)
1781 1780
1782 1781 # Try to be reasonably smart about not re-indenting pasted input more
1783 1782 # than necessary. We do this by trimming out the auto-indent initial
1784 1783 # spaces, if the user's actual input started itself with whitespace.
1785 1784 #debugx('self.buffer[-1]')
1786 1785
1787 1786 if self.autoindent:
1788 1787 if num_ini_spaces(line) > self.indent_current_nsp:
1789 1788 line = line[self.indent_current_nsp:]
1790 1789 self.indent_current_nsp = 0
1791 1790
1792 1791 # store the unfiltered input before the user has any chance to modify
1793 1792 # it.
1794 1793 if line.strip():
1795 1794 if continue_prompt:
1796 1795 self.input_hist_raw[-1] += '%s\n' % line
1797 1796 else:
1798 1797 self.input_hist_raw.append('%s\n' % line)
1799 1798
1800 1799 try:
1801 1800 lineout = self.prefilter(line,continue_prompt)
1802 1801 except:
1803 1802 # blanket except, in case a user-defined prefilter crashes, so it
1804 1803 # can't take all of ipython with it.
1805 1804 self.showtraceback()
1806 1805 return lineout
1807 1806
1808 1807 def split_user_input(self,line):
1809 1808 """Split user input into pre-char, function part and rest."""
1810 1809
1811 1810 lsplit = self.line_split.match(line)
1812 1811 if lsplit is None: # no regexp match returns None
1813 1812 try:
1814 1813 iFun,theRest = line.split(None,1)
1815 1814 except ValueError:
1816 1815 iFun,theRest = line,''
1817 1816 pre = re.match('^(\s*)(.*)',line).groups()[0]
1818 1817 else:
1819 1818 pre,iFun,theRest = lsplit.groups()
1820 1819
1821 1820 #print 'line:<%s>' % line # dbg
1822 1821 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1823 1822 return pre,iFun.strip(),theRest
1824 1823
1825 1824 def _prefilter(self, line, continue_prompt):
1826 1825 """Calls different preprocessors, depending on the form of line."""
1827 1826
1828 1827 # All handlers *must* return a value, even if it's blank ('').
1829 1828
1830 1829 # Lines are NOT logged here. Handlers should process the line as
1831 1830 # needed, update the cache AND log it (so that the input cache array
1832 1831 # stays synced).
1833 1832
1834 1833 # This function is _very_ delicate, and since it's also the one which
1835 1834 # determines IPython's response to user input, it must be as efficient
1836 1835 # as possible. For this reason it has _many_ returns in it, trying
1837 1836 # always to exit as quickly as it can figure out what it needs to do.
1838 1837
1839 1838 # This function is the main responsible for maintaining IPython's
1840 1839 # behavior respectful of Python's semantics. So be _very_ careful if
1841 1840 # making changes to anything here.
1842 1841
1843 1842 #.....................................................................
1844 1843 # Code begins
1845 1844
1846 1845 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1847 1846
1848 1847 # save the line away in case we crash, so the post-mortem handler can
1849 1848 # record it
1850 1849 self._last_input_line = line
1851 1850
1852 1851 #print '***line: <%s>' % line # dbg
1853 1852
1854 1853 # the input history needs to track even empty lines
1855 1854 stripped = line.strip()
1856 1855
1857 1856 if not stripped:
1858 1857 if not continue_prompt:
1859 1858 self.outputcache.prompt_count -= 1
1860 1859 return self.handle_normal(line,continue_prompt)
1861 1860 #return self.handle_normal('',continue_prompt)
1862 1861
1863 1862 # print '***cont',continue_prompt # dbg
1864 1863 # special handlers are only allowed for single line statements
1865 1864 if continue_prompt and not self.rc.multi_line_specials:
1866 1865 return self.handle_normal(line,continue_prompt)
1867 1866
1868 1867
1869 1868 # For the rest, we need the structure of the input
1870 1869 pre,iFun,theRest = self.split_user_input(line)
1871 1870
1872 1871 # See whether any pre-existing handler can take care of it
1873 1872
1874 1873 rewritten = self.hooks.input_prefilter(stripped)
1875 1874 if rewritten != stripped: # ok, some prefilter did something
1876 1875 rewritten = pre + rewritten # add indentation
1877 1876 return self.handle_normal(rewritten)
1878 1877
1879 1878 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1880 1879
1881 1880 # First check for explicit escapes in the last/first character
1882 1881 handler = None
1883 1882 if line[-1] == self.ESC_HELP:
1884 1883 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1885 1884 if handler is None:
1886 1885 # look at the first character of iFun, NOT of line, so we skip
1887 1886 # leading whitespace in multiline input
1888 1887 handler = self.esc_handlers.get(iFun[0:1])
1889 1888 if handler is not None:
1890 1889 return handler(line,continue_prompt,pre,iFun,theRest)
1891 1890 # Emacs ipython-mode tags certain input lines
1892 1891 if line.endswith('# PYTHON-MODE'):
1893 1892 return self.handle_emacs(line,continue_prompt)
1894 1893
1895 1894 # Next, check if we can automatically execute this thing
1896 1895
1897 1896 # Allow ! in multi-line statements if multi_line_specials is on:
1898 1897 if continue_prompt and self.rc.multi_line_specials and \
1899 1898 iFun.startswith(self.ESC_SHELL):
1900 1899 return self.handle_shell_escape(line,continue_prompt,
1901 1900 pre=pre,iFun=iFun,
1902 1901 theRest=theRest)
1903 1902
1904 1903 # Let's try to find if the input line is a magic fn
1905 1904 oinfo = None
1906 1905 if hasattr(self,'magic_'+iFun):
1907 1906 # WARNING: _ofind uses getattr(), so it can consume generators and
1908 1907 # cause other side effects.
1909 1908 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1910 1909 if oinfo['ismagic']:
1911 1910 # Be careful not to call magics when a variable assignment is
1912 1911 # being made (ls='hi', for example)
1913 1912 if self.rc.automagic and \
1914 1913 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1915 1914 (self.rc.multi_line_specials or not continue_prompt):
1916 1915 return self.handle_magic(line,continue_prompt,
1917 1916 pre,iFun,theRest)
1918 1917 else:
1919 1918 return self.handle_normal(line,continue_prompt)
1920 1919
1921 1920 # If the rest of the line begins with an (in)equality, assginment or
1922 1921 # function call, we should not call _ofind but simply execute it.
1923 1922 # This avoids spurious geattr() accesses on objects upon assignment.
1924 1923 #
1925 1924 # It also allows users to assign to either alias or magic names true
1926 1925 # python variables (the magic/alias systems always take second seat to
1927 1926 # true python code).
1928 1927 if theRest and theRest[0] in '!=()':
1929 1928 return self.handle_normal(line,continue_prompt)
1930 1929
1931 1930 if oinfo is None:
1932 1931 # let's try to ensure that _oinfo is ONLY called when autocall is
1933 1932 # on. Since it has inevitable potential side effects, at least
1934 1933 # having autocall off should be a guarantee to the user that no
1935 1934 # weird things will happen.
1936 1935
1937 1936 if self.rc.autocall:
1938 1937 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1939 1938 else:
1940 1939 # in this case, all that's left is either an alias or
1941 1940 # processing the line normally.
1942 1941 if iFun in self.alias_table:
1943 1942 # if autocall is off, by not running _ofind we won't know
1944 1943 # whether the given name may also exist in one of the
1945 1944 # user's namespace. At this point, it's best to do a
1946 1945 # quick check just to be sure that we don't let aliases
1947 1946 # shadow variables.
1948 1947 head = iFun.split('.',1)[0]
1949 1948 if head in self.user_ns or head in self.internal_ns \
1950 1949 or head in __builtin__.__dict__:
1951 1950 return self.handle_normal(line,continue_prompt)
1952 1951 else:
1953 1952 return self.handle_alias(line,continue_prompt,
1954 1953 pre,iFun,theRest)
1955 1954
1956 1955 else:
1957 1956 return self.handle_normal(line,continue_prompt)
1958 1957
1959 1958 if not oinfo['found']:
1960 1959 return self.handle_normal(line,continue_prompt)
1961 1960 else:
1962 1961 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1963 1962 if oinfo['isalias']:
1964 1963 return self.handle_alias(line,continue_prompt,
1965 1964 pre,iFun,theRest)
1966 1965
1967 1966 if (self.rc.autocall
1968 1967 and
1969 1968 (
1970 1969 #only consider exclusion re if not "," or ";" autoquoting
1971 1970 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
1972 1971 or pre == self.ESC_PAREN) or
1973 1972 (not self.re_exclude_auto.match(theRest)))
1974 1973 and
1975 1974 self.re_fun_name.match(iFun) and
1976 1975 callable(oinfo['obj'])) :
1977 1976 #print 'going auto' # dbg
1978 1977 return self.handle_auto(line,continue_prompt,
1979 1978 pre,iFun,theRest,oinfo['obj'])
1980 1979 else:
1981 1980 #print 'was callable?', callable(oinfo['obj']) # dbg
1982 1981 return self.handle_normal(line,continue_prompt)
1983 1982
1984 1983 # If we get here, we have a normal Python line. Log and return.
1985 1984 return self.handle_normal(line,continue_prompt)
1986 1985
1987 1986 def _prefilter_dumb(self, line, continue_prompt):
1988 1987 """simple prefilter function, for debugging"""
1989 1988 return self.handle_normal(line,continue_prompt)
1990 1989
1991 1990 # Set the default prefilter() function (this can be user-overridden)
1992 1991 prefilter = _prefilter
1993 1992
1994 1993 def handle_normal(self,line,continue_prompt=None,
1995 1994 pre=None,iFun=None,theRest=None):
1996 1995 """Handle normal input lines. Use as a template for handlers."""
1997 1996
1998 1997 # With autoindent on, we need some way to exit the input loop, and I
1999 1998 # don't want to force the user to have to backspace all the way to
2000 1999 # clear the line. The rule will be in this case, that either two
2001 2000 # lines of pure whitespace in a row, or a line of pure whitespace but
2002 2001 # of a size different to the indent level, will exit the input loop.
2003 2002
2004 2003 if (continue_prompt and self.autoindent and line.isspace() and
2005 2004 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2006 2005 (self.buffer[-1]).isspace() )):
2007 2006 line = ''
2008 2007
2009 2008 self.log(line,continue_prompt)
2010 2009 return line
2011 2010
2012 2011 def handle_alias(self,line,continue_prompt=None,
2013 2012 pre=None,iFun=None,theRest=None):
2014 2013 """Handle alias input lines. """
2015 2014
2016 2015 # pre is needed, because it carries the leading whitespace. Otherwise
2017 2016 # aliases won't work in indented sections.
2018 2017 transformed = self.transform_alias(iFun, theRest)
2019 2018 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2020 2019 self.log(line_out,continue_prompt)
2021 2020 return line_out
2022 2021
2023 2022 def handle_shell_escape(self, line, continue_prompt=None,
2024 2023 pre=None,iFun=None,theRest=None):
2025 2024 """Execute the line in a shell, empty return value"""
2026 2025
2027 2026 #print 'line in :', `line` # dbg
2028 2027 # Example of a special handler. Others follow a similar pattern.
2029 2028 if line.lstrip().startswith('!!'):
2030 2029 # rewrite iFun/theRest to properly hold the call to %sx and
2031 2030 # the actual command to be executed, so handle_magic can work
2032 2031 # correctly
2033 2032 theRest = '%s %s' % (iFun[2:],theRest)
2034 2033 iFun = 'sx'
2035 2034 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2036 2035 line.lstrip()[2:]),
2037 2036 continue_prompt,pre,iFun,theRest)
2038 2037 else:
2039 2038 cmd=line.lstrip().lstrip('!')
2040 2039 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2041 2040 # update cache/log and return
2042 2041 self.log(line_out,continue_prompt)
2043 2042 return line_out
2044 2043
2045 2044 def handle_magic(self, line, continue_prompt=None,
2046 2045 pre=None,iFun=None,theRest=None):
2047 2046 """Execute magic functions."""
2048 2047
2049 2048
2050 2049 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2051 2050 self.log(cmd,continue_prompt)
2052 2051 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2053 2052 return cmd
2054 2053
2055 2054 def handle_auto(self, line, continue_prompt=None,
2056 2055 pre=None,iFun=None,theRest=None,obj=None):
2057 2056 """Hande lines which can be auto-executed, quoting if requested."""
2058 2057
2059 2058 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2060 2059
2061 2060 # This should only be active for single-line input!
2062 2061 if continue_prompt:
2063 2062 self.log(line,continue_prompt)
2064 2063 return line
2065 2064
2066 2065 auto_rewrite = True
2067 2066
2068 2067 if pre == self.ESC_QUOTE:
2069 2068 # Auto-quote splitting on whitespace
2070 2069 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2071 2070 elif pre == self.ESC_QUOTE2:
2072 2071 # Auto-quote whole string
2073 2072 newcmd = '%s("%s")' % (iFun,theRest)
2074 2073 elif pre == self.ESC_PAREN:
2075 2074 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2076 2075 else:
2077 2076 # Auto-paren.
2078 2077 # We only apply it to argument-less calls if the autocall
2079 2078 # parameter is set to 2. We only need to check that autocall is <
2080 2079 # 2, since this function isn't called unless it's at least 1.
2081 2080 if not theRest and (self.rc.autocall < 2):
2082 2081 newcmd = '%s %s' % (iFun,theRest)
2083 2082 auto_rewrite = False
2084 2083 else:
2085 2084 if theRest.startswith('['):
2086 2085 if hasattr(obj,'__getitem__'):
2087 2086 # Don't autocall in this case: item access for an object
2088 2087 # which is BOTH callable and implements __getitem__.
2089 2088 newcmd = '%s %s' % (iFun,theRest)
2090 2089 auto_rewrite = False
2091 2090 else:
2092 2091 # if the object doesn't support [] access, go ahead and
2093 2092 # autocall
2094 2093 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2095 2094 elif theRest.endswith(';'):
2096 2095 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2097 2096 else:
2098 2097 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2099 2098
2100 2099 if auto_rewrite:
2101 2100 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2102 2101 # log what is now valid Python, not the actual user input (without the
2103 2102 # final newline)
2104 2103 self.log(newcmd,continue_prompt)
2105 2104 return newcmd
2106 2105
2107 2106 def handle_help(self, line, continue_prompt=None,
2108 2107 pre=None,iFun=None,theRest=None):
2109 2108 """Try to get some help for the object.
2110 2109
2111 2110 obj? or ?obj -> basic information.
2112 2111 obj?? or ??obj -> more details.
2113 2112 """
2114 2113
2115 2114 # We need to make sure that we don't process lines which would be
2116 2115 # otherwise valid python, such as "x=1 # what?"
2117 2116 try:
2118 2117 codeop.compile_command(line)
2119 2118 except SyntaxError:
2120 2119 # We should only handle as help stuff which is NOT valid syntax
2121 2120 if line[0]==self.ESC_HELP:
2122 2121 line = line[1:]
2123 2122 elif line[-1]==self.ESC_HELP:
2124 2123 line = line[:-1]
2125 2124 self.log('#?'+line)
2126 2125 if line:
2127 2126 self.magic_pinfo(line)
2128 2127 else:
2129 2128 page(self.usage,screen_lines=self.rc.screen_length)
2130 2129 return '' # Empty string is needed here!
2131 2130 except:
2132 2131 # Pass any other exceptions through to the normal handler
2133 2132 return self.handle_normal(line,continue_prompt)
2134 2133 else:
2135 2134 # If the code compiles ok, we should handle it normally
2136 2135 return self.handle_normal(line,continue_prompt)
2137 2136
2138 2137 def getapi(self):
2139 2138 """ Get an IPApi object for this shell instance
2140 2139
2141 2140 Getting an IPApi object is always preferable to accessing the shell
2142 2141 directly, but this holds true especially for extensions.
2143 2142
2144 2143 It should always be possible to implement an extension with IPApi
2145 2144 alone. If not, contact maintainer to request an addition.
2146 2145
2147 2146 """
2148 2147 return self.api
2149 2148
2150 2149 def handle_emacs(self,line,continue_prompt=None,
2151 2150 pre=None,iFun=None,theRest=None):
2152 2151 """Handle input lines marked by python-mode."""
2153 2152
2154 2153 # Currently, nothing is done. Later more functionality can be added
2155 2154 # here if needed.
2156 2155
2157 2156 # The input cache shouldn't be updated
2158 2157
2159 2158 return line
2160 2159
2161 2160 def mktempfile(self,data=None):
2162 2161 """Make a new tempfile and return its filename.
2163 2162
2164 2163 This makes a call to tempfile.mktemp, but it registers the created
2165 2164 filename internally so ipython cleans it up at exit time.
2166 2165
2167 2166 Optional inputs:
2168 2167
2169 2168 - data(None): if data is given, it gets written out to the temp file
2170 2169 immediately, and the file is closed again."""
2171 2170
2172 2171 filename = tempfile.mktemp('.py','ipython_edit_')
2173 2172 self.tempfiles.append(filename)
2174 2173
2175 2174 if data:
2176 2175 tmp_file = open(filename,'w')
2177 2176 tmp_file.write(data)
2178 2177 tmp_file.close()
2179 2178 return filename
2180 2179
2181 2180 def write(self,data):
2182 2181 """Write a string to the default output"""
2183 2182 Term.cout.write(data)
2184 2183
2185 2184 def write_err(self,data):
2186 2185 """Write a string to the default error output"""
2187 2186 Term.cerr.write(data)
2188 2187
2189 2188 def exit(self):
2190 2189 """Handle interactive exit.
2191 2190
2192 2191 This method sets the exit_now attribute."""
2193 2192
2194 2193 if self.rc.confirm_exit:
2195 2194 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2196 2195 self.exit_now = True
2197 2196 else:
2198 2197 self.exit_now = True
2199 2198 return self.exit_now
2200 2199
2201 2200 def safe_execfile(self,fname,*where,**kw):
2202 2201 fname = os.path.expanduser(fname)
2203 2202
2204 2203 # find things also in current directory
2205 2204 dname = os.path.dirname(fname)
2206 2205 if not sys.path.count(dname):
2207 2206 sys.path.append(dname)
2208 2207
2209 2208 try:
2210 2209 xfile = open(fname)
2211 2210 except:
2212 2211 print >> Term.cerr, \
2213 2212 'Could not open file <%s> for safe execution.' % fname
2214 2213 return None
2215 2214
2216 2215 kw.setdefault('islog',0)
2217 2216 kw.setdefault('quiet',1)
2218 2217 kw.setdefault('exit_ignore',0)
2219 2218 first = xfile.readline()
2220 2219 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2221 2220 xfile.close()
2222 2221 # line by line execution
2223 2222 if first.startswith(loghead) or kw['islog']:
2224 2223 print 'Loading log file <%s> one line at a time...' % fname
2225 2224 if kw['quiet']:
2226 2225 stdout_save = sys.stdout
2227 2226 sys.stdout = StringIO.StringIO()
2228 2227 try:
2229 2228 globs,locs = where[0:2]
2230 2229 except:
2231 2230 try:
2232 2231 globs = locs = where[0]
2233 2232 except:
2234 2233 globs = locs = globals()
2235 2234 badblocks = []
2236 2235
2237 2236 # we also need to identify indented blocks of code when replaying
2238 2237 # logs and put them together before passing them to an exec
2239 2238 # statement. This takes a bit of regexp and look-ahead work in the
2240 2239 # file. It's easiest if we swallow the whole thing in memory
2241 2240 # first, and manually walk through the lines list moving the
2242 2241 # counter ourselves.
2243 2242 indent_re = re.compile('\s+\S')
2244 2243 xfile = open(fname)
2245 2244 filelines = xfile.readlines()
2246 2245 xfile.close()
2247 2246 nlines = len(filelines)
2248 2247 lnum = 0
2249 2248 while lnum < nlines:
2250 2249 line = filelines[lnum]
2251 2250 lnum += 1
2252 2251 # don't re-insert logger status info into cache
2253 2252 if line.startswith('#log#'):
2254 2253 continue
2255 2254 else:
2256 2255 # build a block of code (maybe a single line) for execution
2257 2256 block = line
2258 2257 try:
2259 2258 next = filelines[lnum] # lnum has already incremented
2260 2259 except:
2261 2260 next = None
2262 2261 while next and indent_re.match(next):
2263 2262 block += next
2264 2263 lnum += 1
2265 2264 try:
2266 2265 next = filelines[lnum]
2267 2266 except:
2268 2267 next = None
2269 2268 # now execute the block of one or more lines
2270 2269 try:
2271 2270 exec block in globs,locs
2272 2271 except SystemExit:
2273 2272 pass
2274 2273 except:
2275 2274 badblocks.append(block.rstrip())
2276 2275 if kw['quiet']: # restore stdout
2277 2276 sys.stdout.close()
2278 2277 sys.stdout = stdout_save
2279 2278 print 'Finished replaying log file <%s>' % fname
2280 2279 if badblocks:
2281 2280 print >> sys.stderr, ('\nThe following lines/blocks in file '
2282 2281 '<%s> reported errors:' % fname)
2283 2282
2284 2283 for badline in badblocks:
2285 2284 print >> sys.stderr, badline
2286 2285 else: # regular file execution
2287 2286 try:
2288 2287 execfile(fname,*where)
2289 2288 except SyntaxError:
2290 2289 self.showsyntaxerror()
2291 2290 warn('Failure executing file: <%s>' % fname)
2292 2291 except SystemExit,status:
2293 2292 if not kw['exit_ignore']:
2294 2293 self.showtraceback()
2295 2294 warn('Failure executing file: <%s>' % fname)
2296 2295 except:
2297 2296 self.showtraceback()
2298 2297 warn('Failure executing file: <%s>' % fname)
2299 2298
2300 2299 #************************* end of file <iplib.py> *****************************
@@ -1,641 +1,641 b''
1 1 # -*- coding: utf-8 -*-
2 2 #*****************************************************************************
3 3 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
4 4 #
5 5 # Distributed under the terms of the BSD License. The full license is in
6 6 # the file COPYING, distributed as part of this software.
7 7 #*****************************************************************************
8 8
9 # $Id: usage.py 1301 2006-05-15 17:21:55Z vivainio $
9 # $Id: usage.py 1332 2006-05-30 01:41:28Z fperez $
10 10
11 11 from IPython import Release
12 12 __author__ = '%s <%s>' % Release.authors['Fernando']
13 13 __license__ = Release.license
14 14 __version__ = Release.version
15 15
16 16 __doc__ = """
17 17 IPython -- An enhanced Interactive Python
18 18 =========================================
19 19
20 20 A Python shell with automatic history (input and output), dynamic object
21 21 introspection, easier configuration, command completion, access to the system
22 22 shell and more.
23 23
24 24 IPython can also be embedded in running programs. See EMBEDDING below.
25 25
26 26
27 27 USAGE
28 28 ipython [options] files
29 29
30 30 If invoked with no options, it executes all the files listed in
31 31 sequence and drops you into the interpreter while still acknowledging
32 32 any options you may have set in your ipythonrc file. This behavior is
33 33 different from standard Python, which when called as python -i will
34 34 only execute one file and will ignore your configuration setup.
35 35
36 36 Please note that some of the configuration options are not available at
37 37 the command line, simply because they are not practical here. Look into
38 38 your ipythonrc configuration file for details on those. This file
39 39 typically installed in the $HOME/.ipython directory.
40 40
41 41 For Windows users, $HOME resolves to C:\\Documents and
42 42 Settings\\YourUserName in most instances, and _ipython is used instead
43 43 of .ipython, since some Win32 programs have problems with dotted names
44 44 in directories.
45 45
46 46 In the rest of this text, we will refer to this directory as
47 47 IPYTHONDIR.
48 48
49 49
50 50 SPECIAL THREADING OPTIONS
51 51 The following special options are ONLY valid at the beginning of the
52 52 command line, and not later. This is because they control the initial-
53 53 ization of ipython itself, before the normal option-handling mechanism
54 54 is active.
55 55
56 56 -gthread, -qthread, -wthread, -pylab
57 57
58 58 Only ONE of these can be given, and it can only be given as the
59 59 first option passed to IPython (it will have no effect in any
60 60 other position). They provide threading support for the GTK, QT
61 61 and WXWidgets toolkits, and for the matplotlib library.
62 62
63 63 With any of the first three options, IPython starts running a
64 64 separate thread for the graphical toolkit's operation, so that
65 65 you can open and control graphical elements from within an
66 66 IPython command line, without blocking. All three provide
67 67 essentially the same functionality, respectively for GTK, QT and
68 68 WXWidgets (via their Python interfaces).
69 69
70 70 Note that with -wthread, you can additionally use the -wxversion
71 71 option to request a specific version of wx to be used. This
72 72 requires that you have the 'wxversion' Python module installed,
73 73 which is part of recent wxPython distributions.
74 74
75 75 If -pylab is given, IPython loads special support for the mat-
76 76 plotlib library (http://matplotlib.sourceforge.net), allowing
77 77 interactive usage of any of its backends as defined in the
78 78 user's .matplotlibrc file. It automatically activates GTK, QT
79 79 or WX threading for IPyhton if the choice of matplotlib backend
80 80 requires it. It also modifies the %run command to correctly
81 81 execute (without blocking) any matplotlib-based script which
82 82 calls show() at the end.
83 83
84 84 -tk The -g/q/wthread options, and -pylab (if matplotlib is
85 85 configured to use GTK, QT or WX), will normally block Tk
86 86 graphical interfaces. This means that when GTK, QT or WX
87 87 threading is active, any attempt to open a Tk GUI will result in
88 88 a dead window, and possibly cause the Python interpreter to
89 89 crash. An extra option, -tk, is available to address this
90 90 issue. It can ONLY be given as a SECOND option after any of the
91 91 above (-gthread, -qthread, -wthread or -pylab).
92 92
93 93 If -tk is given, IPython will try to coordinate Tk threading
94 94 with GTK, QT or WX. This is however potentially unreliable, and
95 95 you will have to test on your platform and Python configuration
96 96 to determine whether it works for you. Debian users have
97 97 reported success, apparently due to the fact that Debian builds
98 98 all of Tcl, Tk, Tkinter and Python with pthreads support. Under
99 99 other Linux environments (such as Fedora Core 2/3), this option
100 100 has caused random crashes and lockups of the Python interpreter.
101 101 Under other operating systems (Mac OSX and Windows), you'll need
102 102 to try it to find out, since currently no user reports are
103 103 available.
104 104
105 105 There is unfortunately no way for IPython to determine at run-
106 106 time whether -tk will work reliably or not, so you will need to
107 107 do some experiments before relying on it for regular work.
108 108
109 109 A WARNING ABOUT SIGNALS AND THREADS
110 110
111 111 When any of the thread systems (GTK, QT or WX) are active, either
112 112 directly or via -pylab with a threaded backend, it is impossible to
113 113 interrupt long-running Python code via Ctrl-C. IPython can not pass
114 114 the KeyboardInterrupt exception (or the underlying SIGINT) across
115 115 threads, so any long-running process started from IPython will run to
116 116 completion, or will have to be killed via an external (OS-based)
117 117 mechanism.
118 118
119 119 To the best of my knowledge, this limitation is imposed by the Python
120 120 interpreter itself, and it comes from the difficulty of writing
121 121 portable signal/threaded code. If any user is an expert on this topic
122 122 and can suggest a better solution, I would love to hear about it. In
123 123 the IPython sources, look at the Shell.py module, and in particular at
124 124 the runcode() method.
125 125
126 126 REGULAR OPTIONS
127 127 After the above threading options have been given, regular options can
128 128 follow in any order. All options can be abbreviated to their shortest
129 129 non-ambiguous form and are case-sensitive. One or two dashes can be
130 130 used. Some options have an alternate short form, indicated after a |.
131 131
132 132 Most options can also be set from your ipythonrc configuration file.
133 133 See the provided examples for assistance. Options given on the comman-
134 134 dline override the values set in the ipythonrc file.
135 135
136 136 All options with a [no] prepended can be specified in negated form
137 137 (using -nooption instead of -option) to turn the feature off.
138 138
139 139 -h, --help
140 140 Show summary of options.
141 141
142 142 -pylab This can only be given as the first option passed to IPython (it
143 143 will have no effect in any other position). It adds special sup-
144 144 port for the matplotlib library (http://matplotlib.source-
145 145 forge.net), allowing interactive usage of any of its backends as
146 146 defined in the user's .matplotlibrc file. It automatically
147 147 activates GTK or WX threading for IPyhton if the choice of mat-
148 148 plotlib backend requires it. It also modifies the @run command
149 149 to correctly execute (without blocking) any matplotlib-based
150 150 script which calls show() at the end.
151 151
152 152 -autocall <val>
153 153 Make IPython automatically call any callable object even if you
154 154 didn't type explicit parentheses. For example, 'str 43' becomes
155 155 'str(43)' automatically. The value can be '0' to disable the
156 156 feature, '1' for 'smart' autocall, where it is not applied if
157 157 there are no more arguments on the line, and '2' for 'full'
158 158 autocall, where all callable objects are automatically called
159 159 (even if no arguments are present). The default is '1'.
160 160
161 161 -[no]autoindent
162 162 Turn automatic indentation on/off.
163 163
164 164 -[no]automagic
165 165 Make magic commands automatic (without needing their first char-
166 166 acter to be %). Type %magic at the IPython prompt for more
167 167 information.
168 168
169 169 -[no]autoedit_syntax
170 170 When a syntax error occurs after editing a file, automatically
171 171 open the file to the trouble causing line for convenient fixing.
172 172
173 173 -[no]banner
174 174 Print the intial information banner (default on).
175 175
176 176 -c <command>
177 177 Execute the given command string, and set sys.argv to ['c'].
178 178 This is similar to the -c option in the normal Python inter-
179 179 preter.
180 180
181 181 -cache_size|cs <n>
182 182 Size of the output cache (maximum number of entries to hold in
183 183 memory). The default is 1000, you can change it permanently in
184 184 your config file. Setting it to 0 completely disables the
185 185 caching system, and the minimum value accepted is 20 (if you
186 186 provide a value less than 20, it is reset to 0 and a warning is
187 187 issued). This limit is defined because otherwise you'll spend
188 188 more time re-flushing a too small cache than working.
189 189
190 190 -classic|cl
191 191 Gives IPython a similar feel to the classic Python prompt.
192 192
193 193 -colors <scheme>
194 194 Color scheme for prompts and exception reporting. Currently
195 195 implemented: NoColor, Linux, and LightBG.
196 196
197 197 -[no]color_info
198 198 IPython can display information about objects via a set of func-
199 199 tions, and optionally can use colors for this, syntax highlight-
200 200 ing source code and various other elements. However, because
201 201 this information is passed through a pager (like 'less') and
202 202 many pagers get confused with color codes, this option is off by
203 203 default. You can test it and turn it on permanently in your
204 204 ipythonrc file if it works for you. As a reference, the 'less'
205 205 pager supplied with Mandrake 8.2 works ok, but that in RedHat
206 206 7.2 doesn't.
207 207
208 208 Test it and turn it on permanently if it works with your system.
209 209 The magic function @color_info allows you to toggle this inter-
210 210 actively for testing.
211 211
212 212 -[no]confirm_exit
213 213 Set to confirm when you try to exit IPython with an EOF (Con-
214 214 trol-D in Unix, Control-Z/Enter in Windows). Note that using the
215 215 magic functions @Exit or @Quit you can force a direct exit,
216 216 bypassing any confirmation.
217 217
218 218 -[no]debug
219 219 Show information about the loading process. Very useful to pin
220 220 down problems with your configuration files or to get details
221 221 about session restores.
222 222
223 223 -[no]deep_reload
224 224 IPython can use the deep_reload module which reloads changes in
225 225 modules recursively (it replaces the reload() function, so you
226 226 don't need to change anything to use it). deep_reload() forces a
227 227 full reload of modules whose code may have changed, which the
228 228 default reload() function does not.
229 229
230 230 When deep_reload is off, IPython will use the normal reload(),
231 231 but deep_reload will still be available as dreload(). This fea-
232 232 ture is off by default [which means that you have both normal
233 233 reload() and dreload()].
234 234
235 235 -editor <name>
236 236 Which editor to use with the @edit command. By default, IPython
237 237 will honor your EDITOR environment variable (if not set, vi is
238 238 the Unix default and notepad the Windows one). Since this editor
239 239 is invoked on the fly by IPython and is meant for editing small
240 240 code snippets, you may want to use a small, lightweight editor
241 241 here (in case your default EDITOR is something like Emacs).
242 242
243 243 -ipythondir <name>
244 244 The name of your IPython configuration directory IPYTHONDIR.
245 245 This can also be specified through the environment variable
246 246 IPYTHONDIR.
247 247
248 248 -log|l Generate a log file of all input. The file is named
249 249 ipython_log.py in your current directory (which prevents logs
250 250 from multiple IPython sessions from trampling each other). You
251 251 can use this to later restore a session by loading your logfile
252 252 as a file to be executed with option -logplay (see below).
253 253
254 254 -logfile|lf
255 255 Specify the name of your logfile.
256 256
257 257 -logplay|lp
258 258 Replay a previous log. For restoring a session as close as pos-
259 259 sible to the state you left it in, use this option (don't just
260 260 run the logfile). With -logplay, IPython will try to reconstruct
261 261 the previous working environment in full, not just execute the
262 262 commands in the logfile.
263 263 When a session is restored, logging is automatically turned on
264 264 again with the name of the logfile it was invoked with (it is
265 265 read from the log header). So once you've turned logging on for
266 266 a session, you can quit IPython and reload it as many times as
267 267 you want and it will continue to log its history and restore
268 268 from the beginning every time.
269 269
270 270 Caveats: there are limitations in this option. The history vari-
271 271 ables _i*,_* and _dh don't get restored properly. In the future
272 272 we will try to implement full session saving by writing and
273 273 retrieving a failed because of inherent limitations of Python's
274 274 Pickle module, so this may have to wait.
275 275
276 276 -[no]messages
277 277 Print messages which IPython collects about its startup process
278 278 (default on).
279 279
280 280 -[no]pdb
281 281 Automatically call the pdb debugger after every uncaught excep-
282 282 tion. If you are used to debugging using pdb, this puts you
283 283 automatically inside of it after any call (either in IPython or
284 284 in code called by it) which triggers an exception which goes
285 285 uncaught.
286 286
287 287 -[no]pprint
288 288 IPython can optionally use the pprint (pretty printer) module
289 289 for displaying results. pprint tends to give a nicer display of
290 290 nested data structures. If you like it, you can turn it on per-
291 291 manently in your config file (default off).
292 292
293 293 -profile|p <name>
294 294 Assume that your config file is ipythonrc-<name> (looks in cur-
295 295 rent dir first, then in IPYTHONDIR). This is a quick way to keep
296 296 and load multiple config files for different tasks, especially
297 297 if you use the include option of config files. You can keep a
298 298 basic IPYTHONDIR/ipythonrc file and then have other 'profiles'
299 299 which include this one and load extra things for particular
300 300 tasks. For example:
301 301
302 302 1) $HOME/.ipython/ipythonrc : load basic things you always want.
303 303 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math-
304 304 related modules.
305 305 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
306 306 plotting modules.
307 307
308 308 Since it is possible to create an endless loop by having circu-
309 309 lar file inclusions, IPython will stop if it reaches 15 recur-
310 310 sive inclusions.
311 311
312 312 -prompt_in1|pi1 <string>
313 313 Specify the string used for input prompts. Note that if you are
314 314 using numbered prompts, the number is represented with a '\#' in
315 315 the string. Don't forget to quote strings with spaces embedded
316 in them. Default: 'In [\#]:'.
316 in them. Default: 'In [\#]: '.
317 317
318 318 Most bash-like escapes can be used to customize IPython's
319 319 prompts, as well as a few additional ones which are IPython-spe-
320 320 cific. All valid prompt escapes are described in detail in the
321 321 Customization section of the IPython HTML/PDF manual.
322 322
323 323 -prompt_in2|pi2 <string>
324 Similar to the previous option, but used for the continuation
325 prompts. The special sequence '\D' is similar to '\#', but with
326 all digits replaced dots (so you can have your continuation
327 prompt aligned with your input prompt). Default: ' .\D.:'
324 Similar to the previous option, but used for the continuation
325 prompts. The special sequence '\D' is similar to '\#', but with
326 all digits replaced dots (so you can have your continuation
327 prompt aligned with your input prompt). Default: ' .\D.: '
328 328 (note three spaces at the start for alignment with 'In [\#]').
329 329
330 330 -prompt_out|po <string>
331 331 String used for output prompts, also uses numbers like
332 332 prompt_in1. Default: 'Out[\#]:'.
333 333
334 334 -quick Start in bare bones mode (no config file loaded).
335 335
336 336 -rcfile <name>
337 337 Name of your IPython resource configuration file. normally
338 338 IPython loads ipythonrc (from current directory) or
339 339 IPYTHONDIR/ipythonrc. If the loading of your config file fails,
340 340 IPython starts with a bare bones configuration (no modules
341 341 loaded at all).
342 342
343 343 -[no]readline
344 344 Use the readline library, which is needed to support name com-
345 345 pletion and command history, among other things. It is enabled
346 346 by default, but may cause problems for users of X/Emacs in
347 347 Python comint or shell buffers.
348 348
349 349 Note that emacs 'eterm' buffers (opened with M-x term) support
350 350 IPython's readline and syntax coloring fine, only 'emacs' (M-x
351 351 shell and C-c !) buffers do not.
352 352
353 353 -screen_length|sl <n>
354 354 Number of lines of your screen. This is used to control print-
355 355 ing of very long strings. Strings longer than this number of
356 356 lines will be sent through a pager instead of directly printed.
357 357
358 358 The default value for this is 0, which means IPython will auto-
359 359 detect your screen size every time it needs to print certain
360 360 potentially long strings (this doesn't change the behavior of
361 361 the 'print' keyword, it's only triggered internally). If for
362 362 some reason this isn't working well (it needs curses support),
363 363 specify it yourself. Otherwise don't change the default.
364 364
365 365 -separate_in|si <string>
366 366 Separator before input prompts. Default '0.
367 367
368 368 -separate_out|so <string>
369 369 Separator before output prompts. Default: 0 (nothing).
370 370
371 371 -separate_out2|so2 <string>
372 372 Separator after output prompts. Default: 0 (nothing).
373 373
374 374 -nosep Shorthand for '-separate_in 0 -separate_out 0 -separate_out2 0'.
375 375 Simply removes all input/output separators.
376 376
377 377 -upgrade
378 378 Allows you to upgrade your IPYTHONDIR configuration when you
379 379 install a new version of IPython. Since new versions may
380 380 include new command lines options or example files, this copies
381 381 updated ipythonrc-type files. However, it backs up (with a .old
382 382 extension) all files which it overwrites so that you can merge
383 383 back any custimizations you might have in your personal files.
384 384
385 385 -Version
386 386 Print version information and exit.
387 387
388 388 -wxversion <string>
389 389 Select a specific version of wxPython (used in conjunction with
390 390 -wthread). Requires the wxversion module, part of recent
391 391 wxPython distributions.
392 392
393 393 -xmode <modename>
394 394 Mode for exception reporting. The valid modes are Plain, Con-
395 395 text, and Verbose.
396 396
397 397 - Plain: similar to python's normal traceback printing.
398 398
399 399 - Context: prints 5 lines of context source code around each
400 400 line in the traceback.
401 401
402 402 - Verbose: similar to Context, but additionally prints the vari-
403 403 ables currently visible where the exception happened (shortening
404 404 their strings if too long). This can potentially be very slow,
405 405 if you happen to have a huge data structure whose string repre-
406 406 sentation is complex to compute. Your computer may appear to
407 407 freeze for a while with cpu usage at 100%. If this occurs, you
408 408 can cancel the traceback with Ctrl-C (maybe hitting it more than
409 409 once).
410 410
411 411
412 412 EMBEDDING
413 413 It is possible to start an IPython instance inside your own Python pro-
414 414 grams. In the documentation example files there are some illustrations
415 415 on how to do this.
416 416
417 417 This feature allows you to evalutate dynamically the state of your
418 418 code, operate with your variables, analyze them, etc. Note however
419 419 that any changes you make to values while in the shell do NOT propagate
420 420 back to the running code, so it is safe to modify your values because
421 421 you won't break your code in bizarre ways by doing so.
422 422 """
423 423
424 424 cmd_line_usage = __doc__
425 425
426 426 #---------------------------------------------------------------------------
427 427 interactive_usage = """
428 428 IPython -- An enhanced Interactive Python
429 429 =========================================
430 430
431 431 IPython offers a combination of convenient shell features, special commands
432 432 and a history mechanism for both input (command history) and output (results
433 433 caching, similar to Mathematica). It is intended to be a fully compatible
434 434 replacement for the standard Python interpreter, while offering vastly
435 435 improved functionality and flexibility.
436 436
437 437 At your system command line, type 'ipython -help' to see the command line
438 438 options available. This document only describes interactive features.
439 439
440 440 Warning: IPython relies on the existence of a global variable called __IP which
441 441 controls the shell itself. If you redefine __IP to anything, bizarre behavior
442 442 will quickly occur.
443 443
444 444 MAIN FEATURES
445 445
446 446 * Access to the standard Python help. As of Python 2.1, a help system is
447 447 available with access to object docstrings and the Python manuals. Simply
448 448 type 'help' (no quotes) to access it.
449 449
450 450 * Magic commands: type %magic for information on the magic subsystem.
451 451
452 452 * System command aliases, via the %alias command or the ipythonrc config file.
453 453
454 454 * Dynamic object information:
455 455
456 456 Typing ?word or word? prints detailed information about an object. If
457 457 certain strings in the object are too long (docstrings, code, etc.) they get
458 458 snipped in the center for brevity.
459 459
460 460 Typing ??word or word?? gives access to the full information without
461 461 snipping long strings. Long strings are sent to the screen through the less
462 462 pager if longer than the screen, printed otherwise.
463 463
464 464 The ?/?? system gives access to the full source code for any object (if
465 465 available), shows function prototypes and other useful information.
466 466
467 467 If you just want to see an object's docstring, type '%pdoc object' (without
468 468 quotes, and without % if you have automagic on).
469 469
470 470 Both %pdoc and ?/?? give you access to documentation even on things which are
471 471 not explicitely defined. Try for example typing {}.get? or after import os,
472 472 type os.path.abspath??. The magic functions %pdef, %source and %file operate
473 473 similarly.
474 474
475 475 * Completion in the local namespace, by typing TAB at the prompt.
476 476
477 477 At any time, hitting tab will complete any available python commands or
478 478 variable names, and show you a list of the possible completions if there's
479 479 no unambiguous one. It will also complete filenames in the current directory.
480 480
481 481 This feature requires the readline and rlcomplete modules, so it won't work
482 482 if your Python lacks readline support (such as under Windows).
483 483
484 484 * Search previous command history in two ways (also requires readline):
485 485
486 486 - Start typing, and then use Ctrl-p (previous,up) and Ctrl-n (next,down) to
487 487 search through only the history items that match what you've typed so
488 488 far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like
489 489 normal arrow keys.
490 490
491 491 - Hit Ctrl-r: opens a search prompt. Begin typing and the system searches
492 492 your history for lines that match what you've typed so far, completing as
493 493 much as it can.
494 494
495 495 * Persistent command history across sessions (readline required).
496 496
497 497 * Logging of input with the ability to save and restore a working session.
498 498
499 499 * System escape with !. Typing !ls will run 'ls' in the current directory.
500 500
501 501 * The reload command does a 'deep' reload of a module: changes made to the
502 502 module since you imported will actually be available without having to exit.
503 503
504 504 * Verbose and colored exception traceback printouts. See the magic xmode and
505 505 xcolor functions for details (just type %magic).
506 506
507 507 * Input caching system:
508 508
509 509 IPython offers numbered prompts (In/Out) with input and output caching. All
510 510 input is saved and can be retrieved as variables (besides the usual arrow
511 511 key recall).
512 512
513 513 The following GLOBAL variables always exist (so don't overwrite them!):
514 514 _i: stores previous input.
515 515 _ii: next previous.
516 516 _iii: next-next previous.
517 517 _ih : a list of all input _ih[n] is the input from line n.
518 518
519 519 Additionally, global variables named _i<n> are dynamically created (<n>
520 520 being the prompt counter), such that _i<n> == _ih[<n>]
521 521
522 522 For example, what you typed at prompt 14 is available as _i14 and _ih[14].
523 523
524 524 You can create macros which contain multiple input lines from this history,
525 525 for later re-execution, with the %macro function.
526 526
527 527 The history function %hist allows you to see any part of your input history
528 528 by printing a range of the _i variables. Note that inputs which contain
529 529 magic functions (%) appear in the history with a prepended comment. This is
530 530 because they aren't really valid Python code, so you can't exec them.
531 531
532 532 * Output caching system:
533 533
534 534 For output that is returned from actions, a system similar to the input
535 535 cache exists but using _ instead of _i. Only actions that produce a result
536 536 (NOT assignments, for example) are cached. If you are familiar with
537 537 Mathematica, IPython's _ variables behave exactly like Mathematica's %
538 538 variables.
539 539
540 540 The following GLOBAL variables always exist (so don't overwrite them!):
541 541 _ (one underscore): previous output.
542 542 __ (two underscores): next previous.
543 543 ___ (three underscores): next-next previous.
544 544
545 545 Global variables named _<n> are dynamically created (<n> being the prompt
546 546 counter), such that the result of output <n> is always available as _<n>.
547 547
548 548 Finally, a global dictionary named _oh exists with entries for all lines
549 549 which generated output.
550 550
551 551 * Directory history:
552 552
553 553 Your history of visited directories is kept in the global list _dh, and the
554 554 magic %cd command can be used to go to any entry in that list.
555 555
556 556 * Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython)
557 557
558 558 1. Auto-parentheses
559 559 Callable objects (i.e. functions, methods, etc) can be invoked like
560 560 this (notice the commas between the arguments):
561 561 >>> callable_ob arg1, arg2, arg3
562 562 and the input will be translated to this:
563 563 --> callable_ob(arg1, arg2, arg3)
564 564 You can force auto-parentheses by using '/' as the first character
565 565 of a line. For example:
566 566 >>> /globals # becomes 'globals()'
567 567 Note that the '/' MUST be the first character on the line! This
568 568 won't work:
569 569 >>> print /globals # syntax error
570 570
571 571 In most cases the automatic algorithm should work, so you should
572 572 rarely need to explicitly invoke /. One notable exception is if you
573 573 are trying to call a function with a list of tuples as arguments (the
574 574 parenthesis will confuse IPython):
575 575 In [1]: zip (1,2,3),(4,5,6) # won't work
576 576 but this will work:
577 577 In [2]: /zip (1,2,3),(4,5,6)
578 578 ------> zip ((1,2,3),(4,5,6))
579 579 Out[2]= [(1, 4), (2, 5), (3, 6)]
580 580
581 581 IPython tells you that it has altered your command line by
582 582 displaying the new command line preceded by -->. e.g.:
583 583 In [18]: callable list
584 584 -------> callable (list)
585 585
586 586 2. Auto-Quoting
587 587 You can force auto-quoting of a function's arguments by using ',' as
588 588 the first character of a line. For example:
589 589 >>> ,my_function /home/me # becomes my_function("/home/me")
590 590
591 591 If you use ';' instead, the whole argument is quoted as a single
592 592 string (while ',' splits on whitespace):
593 593 >>> ,my_function a b c # becomes my_function("a","b","c")
594 594 >>> ;my_function a b c # becomes my_function("a b c")
595 595
596 596 Note that the ',' MUST be the first character on the line! This
597 597 won't work:
598 598 >>> x = ,my_function /home/me # syntax error
599 599 """
600 600
601 601 quick_reference = r"""
602 602 IPython -- An enhanced Interactive Python - Quick Reference Card
603 603 ================================================================
604 604
605 605 obj?, obj??, ?obj,??obj : Get help, or more help for object
606 606 ?os.p* : List names in os starting with p
607 607
608 608 Example magic:
609 609
610 610 %alias d ls -F : 'd' is now an alias for 'ls -F'
611 611 alias d ls -F : Works if 'alias' not a python name
612 612 alist = %alias : Get list of aliases to 'alist'
613 613
614 614 System commands:
615 615
616 616 !cp a.txt b/ : System command escape, calls os.system()
617 617 cp a.txt b/ : after %rehashx, most system commands work without !
618 618 cp ${f}.txt $bar : Variable expansion in magics and system commands
619 619 files = !ls /usr : Capture sytem command output
620 620 files.s, files.l, files.n: "a b c", ['a','b','c'], 'a\nb\nc'
621 621 cd /usr/share : Obvious, also 'cd d:\home\_ipython' works
622 622
623 623 History:
624 624
625 625 _i, _ii, _iii : Previous, next previous, next next previous input
626 626 _ih[4], _ih[2:5] : Input history line 4, lines 2-4
627 627 _, __, ___ : previous, next previous, next next previous output
628 628 _dh : Directory history
629 629 _oh : Output history
630 630 %hist : Command history
631 631
632 632 Autocall:
633 633
634 634 f 1,2 : f(1,2)
635 635 /f 1,2 : f(1,2) (forced autoparen)
636 636 ,f 1 2 : f("1","2")
637 637 ;f 1 2 : f("1 2")
638 638
639 639 """
640 640
641 641
@@ -1,5457 +1,5469 b''
1 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/irunner.py: New module to run scripts as if manually
4 typed into an interactive environment, based on pexpect. After a
5 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
6 ipython-user list. Simple unittests in the tests/ directory.
7
8 * tools/release: add Will Maier, OpenBSD port maintainer, to
9 recepients list. We are now officially part of the OpenBSD ports:
10 http://www.openbsd.org/ports.html ! Many thanks to Will for the
11 work.
12
1 13 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
2 14
3 15 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
4 16 so that it doesn't break tkinter apps.
5 17
6 18 * IPython/iplib.py (_prefilter): fix bug where aliases would
7 19 shadow variables when autocall was fully off. Reported by SAGE
8 20 author William Stein.
9 21
10 22 * IPython/OInspect.py (Inspector.__init__): add a flag to control
11 23 at what detail level strings are computed when foo? is requested.
12 24 This allows users to ask for example that the string form of an
13 25 object is only computed when foo?? is called, or even never, by
14 26 setting the object_info_string_level >= 2 in the configuration
15 27 file. This new option has been added and documented. After a
16 28 request by SAGE to be able to control the printing of very large
17 29 objects more easily.
18 30
19 31 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
20 32
21 33 * IPython/ipmaker.py (make_IPython): remove the ipython call path
22 34 from sys.argv, to be 100% consistent with how Python itself works
23 35 (as seen for example with python -i file.py). After a bug report
24 36 by Jeffrey Collins.
25 37
26 38 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
27 39 nasty bug which was preventing custom namespaces with -pylab,
28 40 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
29 41 compatibility (long gone from mpl).
30 42
31 43 * IPython/ipapi.py (make_session): name change: create->make. We
32 44 use make in other places (ipmaker,...), it's shorter and easier to
33 45 type and say, etc. I'm trying to clean things before 0.7.2 so
34 46 that I can keep things stable wrt to ipapi in the chainsaw branch.
35 47
36 48 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
37 49 python-mode recognizes our debugger mode. Add support for
38 50 autoindent inside (X)emacs. After a patch sent in by Jin Liu
39 51 <m.liu.jin-AT-gmail.com> originally written by
40 52 doxgen-AT-newsmth.net (with minor modifications for xemacs
41 53 compatibility)
42 54
43 55 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
44 56 tracebacks when walking the stack so that the stack tracking system
45 57 in emacs' python-mode can identify the frames correctly.
46 58
47 59 * IPython/ipmaker.py (make_IPython): make the internal (and
48 60 default config) autoedit_syntax value false by default. Too many
49 61 users have complained to me (both on and off-list) about problems
50 62 with this option being on by default, so I'm making it default to
51 63 off. It can still be enabled by anyone via the usual mechanisms.
52 64
53 65 * IPython/completer.py (Completer.attr_matches): add support for
54 66 PyCrust-style _getAttributeNames magic method. Patch contributed
55 67 by <mscott-AT-goldenspud.com>. Closes #50.
56 68
57 69 * IPython/iplib.py (InteractiveShell.__init__): remove the
58 70 deletion of exit/quit from __builtin__, which can break
59 71 third-party tools like the Zope debugging console. The
60 72 %exit/%quit magics remain. In general, it's probably a good idea
61 73 not to delete anything from __builtin__, since we never know what
62 74 that will break. In any case, python now (for 2.5) will support
63 75 'real' exit/quit, so this issue is moot. Closes #55.
64 76
65 77 * IPython/genutils.py (with_obj): rename the 'with' function to
66 78 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
67 79 becomes a language keyword. Closes #53.
68 80
69 81 * IPython/FakeModule.py (FakeModule.__init__): add a proper
70 82 __file__ attribute to this so it fools more things into thinking
71 83 it is a real module. Closes #59.
72 84
73 85 * IPython/Magic.py (magic_edit): add -n option to open the editor
74 86 at a specific line number. After a patch by Stefan van der Walt.
75 87
76 88 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
77 89
78 90 * IPython/iplib.py (edit_syntax_error): fix crash when for some
79 91 reason the file could not be opened. After automatic crash
80 92 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
81 93 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
82 94 (_should_recompile): Don't fire editor if using %bg, since there
83 95 is no file in the first place. From the same report as above.
84 96 (raw_input): protect against faulty third-party prefilters. After
85 97 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
86 98 while running under SAGE.
87 99
88 100 2006-05-23 Ville Vainio <vivainio@gmail.com>
89 101
90 102 * ipapi.py: Stripped down ip.to_user_ns() to work only as
91 103 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
92 104 now returns None (again), unless dummy is specifically allowed by
93 105 ipapi.get(allow_dummy=True).
94 106
95 107 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
96 108
97 109 * IPython: remove all 2.2-compatibility objects and hacks from
98 110 everywhere, since we only support 2.3 at this point. Docs
99 111 updated.
100 112
101 113 * IPython/ipapi.py (IPApi.__init__): Clean up of all getters.
102 114 Anything requiring extra validation can be turned into a Python
103 115 property in the future. I used a property for the db one b/c
104 116 there was a nasty circularity problem with the initialization
105 117 order, which right now I don't have time to clean up.
106 118
107 119 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
108 120 another locking bug reported by Jorgen. I'm not 100% sure though,
109 121 so more testing is needed...
110 122
111 123 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
112 124
113 125 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
114 126 local variables from any routine in user code (typically executed
115 127 with %run) directly into the interactive namespace. Very useful
116 128 when doing complex debugging.
117 129 (IPythonNotRunning): Changed the default None object to a dummy
118 130 whose attributes can be queried as well as called without
119 131 exploding, to ease writing code which works transparently both in
120 132 and out of ipython and uses some of this API.
121 133
122 134 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
123 135
124 136 * IPython/hooks.py (result_display): Fix the fact that our display
125 137 hook was using str() instead of repr(), as the default python
126 138 console does. This had gone unnoticed b/c it only happened if
127 139 %Pprint was off, but the inconsistency was there.
128 140
129 141 2006-05-15 Ville Vainio <vivainio@gmail.com>
130 142
131 143 * Oinspect.py: Only show docstring for nonexisting/binary files
132 144 when doing object??, closing ticket #62
133 145
134 146 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
135 147
136 148 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
137 149 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
138 150 was being released in a routine which hadn't checked if it had
139 151 been the one to acquire it.
140 152
141 153 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
142 154
143 155 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
144 156
145 157 2006-04-11 Ville Vainio <vivainio@gmail.com>
146 158
147 159 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
148 160 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
149 161 prefilters, allowing stuff like magics and aliases in the file.
150 162
151 163 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
152 164 added. Supported now are "%clear in" and "%clear out" (clear input and
153 165 output history, respectively). Also fixed CachedOutput.flush to
154 166 properly flush the output cache.
155 167
156 168 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
157 169 half-success (and fail explicitly).
158 170
159 171 2006-03-28 Ville Vainio <vivainio@gmail.com>
160 172
161 173 * iplib.py: Fix quoting of aliases so that only argless ones
162 174 are quoted
163 175
164 176 2006-03-28 Ville Vainio <vivainio@gmail.com>
165 177
166 178 * iplib.py: Quote aliases with spaces in the name.
167 179 "c:\program files\blah\bin" is now legal alias target.
168 180
169 181 * ext_rehashdir.py: Space no longer allowed as arg
170 182 separator, since space is legal in path names.
171 183
172 184 2006-03-16 Ville Vainio <vivainio@gmail.com>
173 185
174 186 * upgrade_dir.py: Take path.py from Extensions, correcting
175 187 %upgrade magic
176 188
177 189 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
178 190
179 191 * hooks.py: Only enclose editor binary in quotes if legal and
180 192 necessary (space in the name, and is an existing file). Fixes a bug
181 193 reported by Zachary Pincus.
182 194
183 195 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
184 196
185 197 * Manual: thanks to a tip on proper color handling for Emacs, by
186 198 Eric J Haywiser <ejh1-AT-MIT.EDU>.
187 199
188 200 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
189 201 by applying the provided patch. Thanks to Liu Jin
190 202 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
191 203 XEmacs/Linux, I'm trusting the submitter that it actually helps
192 204 under win32/GNU Emacs. Will revisit if any problems are reported.
193 205
194 206 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
195 207
196 208 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
197 209 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
198 210
199 211 2006-03-12 Ville Vainio <vivainio@gmail.com>
200 212
201 213 * Magic.py (magic_timeit): Added %timeit magic, contributed by
202 214 Torsten Marek.
203 215
204 216 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
205 217
206 218 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
207 219 line ranges works again.
208 220
209 221 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
210 222
211 223 * IPython/iplib.py (showtraceback): add back sys.last_traceback
212 224 and friends, after a discussion with Zach Pincus on ipython-user.
213 225 I'm not 100% sure, but after thinking aobut it quite a bit, it may
214 226 be OK. Testing with the multithreaded shells didn't reveal any
215 227 problems, but let's keep an eye out.
216 228
217 229 In the process, I fixed a few things which were calling
218 230 self.InteractiveTB() directly (like safe_execfile), which is a
219 231 mistake: ALL exception reporting should be done by calling
220 232 self.showtraceback(), which handles state and tab-completion and
221 233 more.
222 234
223 235 2006-03-01 Ville Vainio <vivainio@gmail.com>
224 236
225 237 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
226 238 To use, do "from ipipe import *".
227 239
228 240 2006-02-24 Ville Vainio <vivainio@gmail.com>
229 241
230 242 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
231 243 "cleanly" and safely than the older upgrade mechanism.
232 244
233 245 2006-02-21 Ville Vainio <vivainio@gmail.com>
234 246
235 247 * Magic.py: %save works again.
236 248
237 249 2006-02-15 Ville Vainio <vivainio@gmail.com>
238 250
239 251 * Magic.py: %Pprint works again
240 252
241 253 * Extensions/ipy_sane_defaults.py: Provide everything provided
242 254 in default ipythonrc, to make it possible to have a completely empty
243 255 ipythonrc (and thus completely rc-file free configuration)
244 256
245 257
246 258 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
247 259
248 260 * IPython/hooks.py (editor): quote the call to the editor command,
249 261 to allow commands with spaces in them. Problem noted by watching
250 262 Ian Oswald's video about textpad under win32 at
251 263 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
252 264
253 265 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
254 266 describing magics (we haven't used @ for a loong time).
255 267
256 268 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
257 269 contributed by marienz to close
258 270 http://www.scipy.net/roundup/ipython/issue53.
259 271
260 272 2006-02-10 Ville Vainio <vivainio@gmail.com>
261 273
262 274 * genutils.py: getoutput now works in win32 too
263 275
264 276 * completer.py: alias and magic completion only invoked
265 277 at the first "item" in the line, to avoid "cd %store"
266 278 nonsense.
267 279
268 280 2006-02-09 Ville Vainio <vivainio@gmail.com>
269 281
270 282 * test/*: Added a unit testing framework (finally).
271 283 '%run runtests.py' to run test_*.
272 284
273 285 * ipapi.py: Exposed runlines and set_custom_exc
274 286
275 287 2006-02-07 Ville Vainio <vivainio@gmail.com>
276 288
277 289 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
278 290 instead use "f(1 2)" as before.
279 291
280 292 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
281 293
282 294 * IPython/demo.py (IPythonDemo): Add new classes to the demo
283 295 facilities, for demos processed by the IPython input filter
284 296 (IPythonDemo), and for running a script one-line-at-a-time as a
285 297 demo, both for pure Python (LineDemo) and for IPython-processed
286 298 input (IPythonLineDemo). After a request by Dave Kohel, from the
287 299 SAGE team.
288 300 (Demo.edit): added and edit() method to the demo objects, to edit
289 301 the in-memory copy of the last executed block.
290 302
291 303 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
292 304 processing to %edit, %macro and %save. These commands can now be
293 305 invoked on the unprocessed input as it was typed by the user
294 306 (without any prefilters applied). After requests by the SAGE team
295 307 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
296 308
297 309 2006-02-01 Ville Vainio <vivainio@gmail.com>
298 310
299 311 * setup.py, eggsetup.py: easy_install ipython==dev works
300 312 correctly now (on Linux)
301 313
302 314 * ipy_user_conf,ipmaker: user config changes, removed spurious
303 315 warnings
304 316
305 317 * iplib: if rc.banner is string, use it as is.
306 318
307 319 * Magic: %pycat accepts a string argument and pages it's contents.
308 320
309 321
310 322 2006-01-30 Ville Vainio <vivainio@gmail.com>
311 323
312 324 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
313 325 Now %store and bookmarks work through PickleShare, meaning that
314 326 concurrent access is possible and all ipython sessions see the
315 327 same database situation all the time, instead of snapshot of
316 328 the situation when the session was started. Hence, %bookmark
317 329 results are immediately accessible from othes sessions. The database
318 330 is also available for use by user extensions. See:
319 331 http://www.python.org/pypi/pickleshare
320 332
321 333 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
322 334
323 335 * aliases can now be %store'd
324 336
325 337 * path.py move to Extensions so that pickleshare does not need
326 338 IPython-specific import. Extensions added to pythonpath right
327 339 at __init__.
328 340
329 341 * iplib.py: ipalias deprecated/redundant; aliases are converted and
330 342 called with _ip.system and the pre-transformed command string.
331 343
332 344 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
333 345
334 346 * IPython/iplib.py (interact): Fix that we were not catching
335 347 KeyboardInterrupt exceptions properly. I'm not quite sure why the
336 348 logic here had to change, but it's fixed now.
337 349
338 350 2006-01-29 Ville Vainio <vivainio@gmail.com>
339 351
340 352 * iplib.py: Try to import pyreadline on Windows.
341 353
342 354 2006-01-27 Ville Vainio <vivainio@gmail.com>
343 355
344 356 * iplib.py: Expose ipapi as _ip in builtin namespace.
345 357 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
346 358 and ip_set_hook (-> _ip.set_hook) redundant. % and !
347 359 syntax now produce _ip.* variant of the commands.
348 360
349 361 * "_ip.options().autoedit_syntax = 2" automatically throws
350 362 user to editor for syntax error correction without prompting.
351 363
352 364 2006-01-27 Ville Vainio <vivainio@gmail.com>
353 365
354 366 * ipmaker.py: Give "realistic" sys.argv for scripts (without
355 367 'ipython' at argv[0]) executed through command line.
356 368 NOTE: this DEPRECATES calling ipython with multiple scripts
357 369 ("ipython a.py b.py c.py")
358 370
359 371 * iplib.py, hooks.py: Added configurable input prefilter,
360 372 named 'input_prefilter'. See ext_rescapture.py for example
361 373 usage.
362 374
363 375 * ext_rescapture.py, Magic.py: Better system command output capture
364 376 through 'var = !ls' (deprecates user-visible %sc). Same notation
365 377 applies for magics, 'var = %alias' assigns alias list to var.
366 378
367 379 * ipapi.py: added meta() for accessing extension-usable data store.
368 380
369 381 * iplib.py: added InteractiveShell.getapi(). New magics should be
370 382 written doing self.getapi() instead of using the shell directly.
371 383
372 384 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
373 385 %store foo >> ~/myfoo.txt to store variables to files (in clean
374 386 textual form, not a restorable pickle).
375 387
376 388 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
377 389
378 390 * usage.py, Magic.py: added %quickref
379 391
380 392 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
381 393
382 394 * GetoptErrors when invoking magics etc. with wrong args
383 395 are now more helpful:
384 396 GetoptError: option -l not recognized (allowed: "qb" )
385 397
386 398 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
387 399
388 400 * IPython/demo.py (Demo.show): Flush stdout after each block, so
389 401 computationally intensive blocks don't appear to stall the demo.
390 402
391 403 2006-01-24 Ville Vainio <vivainio@gmail.com>
392 404
393 405 * iplib.py, hooks.py: 'result_display' hook can return a non-None
394 406 value to manipulate resulting history entry.
395 407
396 408 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
397 409 to instance methods of IPApi class, to make extending an embedded
398 410 IPython feasible. See ext_rehashdir.py for example usage.
399 411
400 412 * Merged 1071-1076 from banches/0.7.1
401 413
402 414
403 415 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
404 416
405 417 * tools/release (daystamp): Fix build tools to use the new
406 418 eggsetup.py script to build lightweight eggs.
407 419
408 420 * Applied changesets 1062 and 1064 before 0.7.1 release.
409 421
410 422 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
411 423 see the raw input history (without conversions like %ls ->
412 424 ipmagic("ls")). After a request from W. Stein, SAGE
413 425 (http://modular.ucsd.edu/sage) developer. This information is
414 426 stored in the input_hist_raw attribute of the IPython instance, so
415 427 developers can access it if needed (it's an InputList instance).
416 428
417 429 * Versionstring = 0.7.2.svn
418 430
419 431 * eggsetup.py: A separate script for constructing eggs, creates
420 432 proper launch scripts even on Windows (an .exe file in
421 433 \python24\scripts).
422 434
423 435 * ipapi.py: launch_new_instance, launch entry point needed for the
424 436 egg.
425 437
426 438 2006-01-23 Ville Vainio <vivainio@gmail.com>
427 439
428 440 * Added %cpaste magic for pasting python code
429 441
430 442 2006-01-22 Ville Vainio <vivainio@gmail.com>
431 443
432 444 * Merge from branches/0.7.1 into trunk, revs 1052-1057
433 445
434 446 * Versionstring = 0.7.2.svn
435 447
436 448 * eggsetup.py: A separate script for constructing eggs, creates
437 449 proper launch scripts even on Windows (an .exe file in
438 450 \python24\scripts).
439 451
440 452 * ipapi.py: launch_new_instance, launch entry point needed for the
441 453 egg.
442 454
443 455 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
444 456
445 457 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
446 458 %pfile foo would print the file for foo even if it was a binary.
447 459 Now, extensions '.so' and '.dll' are skipped.
448 460
449 461 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
450 462 bug, where macros would fail in all threaded modes. I'm not 100%
451 463 sure, so I'm going to put out an rc instead of making a release
452 464 today, and wait for feedback for at least a few days.
453 465
454 466 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
455 467 it...) the handling of pasting external code with autoindent on.
456 468 To get out of a multiline input, the rule will appear for most
457 469 users unchanged: two blank lines or change the indent level
458 470 proposed by IPython. But there is a twist now: you can
459 471 add/subtract only *one or two spaces*. If you add/subtract three
460 472 or more (unless you completely delete the line), IPython will
461 473 accept that line, and you'll need to enter a second one of pure
462 474 whitespace. I know it sounds complicated, but I can't find a
463 475 different solution that covers all the cases, with the right
464 476 heuristics. Hopefully in actual use, nobody will really notice
465 477 all these strange rules and things will 'just work'.
466 478
467 479 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
468 480
469 481 * IPython/iplib.py (interact): catch exceptions which can be
470 482 triggered asynchronously by signal handlers. Thanks to an
471 483 automatic crash report, submitted by Colin Kingsley
472 484 <tercel-AT-gentoo.org>.
473 485
474 486 2006-01-20 Ville Vainio <vivainio@gmail.com>
475 487
476 488 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
477 489 (%rehashdir, very useful, try it out) of how to extend ipython
478 490 with new magics. Also added Extensions dir to pythonpath to make
479 491 importing extensions easy.
480 492
481 493 * %store now complains when trying to store interactively declared
482 494 classes / instances of those classes.
483 495
484 496 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
485 497 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
486 498 if they exist, and ipy_user_conf.py with some defaults is created for
487 499 the user.
488 500
489 501 * Startup rehashing done by the config file, not InterpreterExec.
490 502 This means system commands are available even without selecting the
491 503 pysh profile. It's the sensible default after all.
492 504
493 505 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
494 506
495 507 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
496 508 multiline code with autoindent on working. But I am really not
497 509 sure, so this needs more testing. Will commit a debug-enabled
498 510 version for now, while I test it some more, so that Ville and
499 511 others may also catch any problems. Also made
500 512 self.indent_current_str() a method, to ensure that there's no
501 513 chance of the indent space count and the corresponding string
502 514 falling out of sync. All code needing the string should just call
503 515 the method.
504 516
505 517 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
506 518
507 519 * IPython/Magic.py (magic_edit): fix check for when users don't
508 520 save their output files, the try/except was in the wrong section.
509 521
510 522 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
511 523
512 524 * IPython/Magic.py (magic_run): fix __file__ global missing from
513 525 script's namespace when executed via %run. After a report by
514 526 Vivian.
515 527
516 528 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
517 529 when using python 2.4. The parent constructor changed in 2.4, and
518 530 we need to track it directly (we can't call it, as it messes up
519 531 readline and tab-completion inside our pdb would stop working).
520 532 After a bug report by R. Bernstein <rocky-AT-panix.com>.
521 533
522 534 2006-01-16 Ville Vainio <vivainio@gmail.com>
523 535
524 536 * Ipython/magic.py:Reverted back to old %edit functionality
525 537 that returns file contents on exit.
526 538
527 539 * IPython/path.py: Added Jason Orendorff's "path" module to
528 540 IPython tree, http://www.jorendorff.com/articles/python/path/.
529 541 You can get path objects conveniently through %sc, and !!, e.g.:
530 542 sc files=ls
531 543 for p in files.paths: # or files.p
532 544 print p,p.mtime
533 545
534 546 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
535 547 now work again without considering the exclusion regexp -
536 548 hence, things like ',foo my/path' turn to 'foo("my/path")'
537 549 instead of syntax error.
538 550
539 551
540 552 2006-01-14 Ville Vainio <vivainio@gmail.com>
541 553
542 554 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
543 555 ipapi decorators for python 2.4 users, options() provides access to rc
544 556 data.
545 557
546 558 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
547 559 as path separators (even on Linux ;-). Space character after
548 560 backslash (as yielded by tab completer) is still space;
549 561 "%cd long\ name" works as expected.
550 562
551 563 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
552 564 as "chain of command", with priority. API stays the same,
553 565 TryNext exception raised by a hook function signals that
554 566 current hook failed and next hook should try handling it, as
555 567 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
556 568 requested configurable display hook, which is now implemented.
557 569
558 570 2006-01-13 Ville Vainio <vivainio@gmail.com>
559 571
560 572 * IPython/platutils*.py: platform specific utility functions,
561 573 so far only set_term_title is implemented (change terminal
562 574 label in windowing systems). %cd now changes the title to
563 575 current dir.
564 576
565 577 * IPython/Release.py: Added myself to "authors" list,
566 578 had to create new files.
567 579
568 580 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
569 581 shell escape; not a known bug but had potential to be one in the
570 582 future.
571 583
572 584 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
573 585 extension API for IPython! See the module for usage example. Fix
574 586 OInspect for docstring-less magic functions.
575 587
576 588
577 589 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
578 590
579 591 * IPython/iplib.py (raw_input): temporarily deactivate all
580 592 attempts at allowing pasting of code with autoindent on. It
581 593 introduced bugs (reported by Prabhu) and I can't seem to find a
582 594 robust combination which works in all cases. Will have to revisit
583 595 later.
584 596
585 597 * IPython/genutils.py: remove isspace() function. We've dropped
586 598 2.2 compatibility, so it's OK to use the string method.
587 599
588 600 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
589 601
590 602 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
591 603 matching what NOT to autocall on, to include all python binary
592 604 operators (including things like 'and', 'or', 'is' and 'in').
593 605 Prompted by a bug report on 'foo & bar', but I realized we had
594 606 many more potential bug cases with other operators. The regexp is
595 607 self.re_exclude_auto, it's fairly commented.
596 608
597 609 2006-01-12 Ville Vainio <vivainio@gmail.com>
598 610
599 611 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
600 612 Prettified and hardened string/backslash quoting with ipsystem(),
601 613 ipalias() and ipmagic(). Now even \ characters are passed to
602 614 %magics, !shell escapes and aliases exactly as they are in the
603 615 ipython command line. Should improve backslash experience,
604 616 particularly in Windows (path delimiter for some commands that
605 617 won't understand '/'), but Unix benefits as well (regexps). %cd
606 618 magic still doesn't support backslash path delimiters, though. Also
607 619 deleted all pretense of supporting multiline command strings in
608 620 !system or %magic commands. Thanks to Jerry McRae for suggestions.
609 621
610 622 * doc/build_doc_instructions.txt added. Documentation on how to
611 623 use doc/update_manual.py, added yesterday. Both files contributed
612 624 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
613 625 doc/*.sh for deprecation at a later date.
614 626
615 627 * /ipython.py Added ipython.py to root directory for
616 628 zero-installation (tar xzvf ipython.tgz; cd ipython; python
617 629 ipython.py) and development convenience (no need to kee doing
618 630 "setup.py install" between changes).
619 631
620 632 * Made ! and !! shell escapes work (again) in multiline expressions:
621 633 if 1:
622 634 !ls
623 635 !!ls
624 636
625 637 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
626 638
627 639 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
628 640 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
629 641 module in case-insensitive installation. Was causing crashes
630 642 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
631 643
632 644 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
633 645 <marienz-AT-gentoo.org>, closes
634 646 http://www.scipy.net/roundup/ipython/issue51.
635 647
636 648 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
637 649
638 650 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
639 651 problem of excessive CPU usage under *nix and keyboard lag under
640 652 win32.
641 653
642 654 2006-01-10 *** Released version 0.7.0
643 655
644 656 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
645 657
646 658 * IPython/Release.py (revision): tag version number to 0.7.0,
647 659 ready for release.
648 660
649 661 * IPython/Magic.py (magic_edit): Add print statement to %edit so
650 662 it informs the user of the name of the temp. file used. This can
651 663 help if you decide later to reuse that same file, so you know
652 664 where to copy the info from.
653 665
654 666 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
655 667
656 668 * setup_bdist_egg.py: little script to build an egg. Added
657 669 support in the release tools as well.
658 670
659 671 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
660 672
661 673 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
662 674 version selection (new -wxversion command line and ipythonrc
663 675 parameter). Patch contributed by Arnd Baecker
664 676 <arnd.baecker-AT-web.de>.
665 677
666 678 * IPython/iplib.py (embed_mainloop): fix tab-completion in
667 679 embedded instances, for variables defined at the interactive
668 680 prompt of the embedded ipython. Reported by Arnd.
669 681
670 682 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
671 683 it can be used as a (stateful) toggle, or with a direct parameter.
672 684
673 685 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
674 686 could be triggered in certain cases and cause the traceback
675 687 printer not to work.
676 688
677 689 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
678 690
679 691 * IPython/iplib.py (_should_recompile): Small fix, closes
680 692 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
681 693
682 694 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
683 695
684 696 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
685 697 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
686 698 Moad for help with tracking it down.
687 699
688 700 * IPython/iplib.py (handle_auto): fix autocall handling for
689 701 objects which support BOTH __getitem__ and __call__ (so that f [x]
690 702 is left alone, instead of becoming f([x]) automatically).
691 703
692 704 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
693 705 Ville's patch.
694 706
695 707 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
696 708
697 709 * IPython/iplib.py (handle_auto): changed autocall semantics to
698 710 include 'smart' mode, where the autocall transformation is NOT
699 711 applied if there are no arguments on the line. This allows you to
700 712 just type 'foo' if foo is a callable to see its internal form,
701 713 instead of having it called with no arguments (typically a
702 714 mistake). The old 'full' autocall still exists: for that, you
703 715 need to set the 'autocall' parameter to 2 in your ipythonrc file.
704 716
705 717 * IPython/completer.py (Completer.attr_matches): add
706 718 tab-completion support for Enthoughts' traits. After a report by
707 719 Arnd and a patch by Prabhu.
708 720
709 721 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
710 722
711 723 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
712 724 Schmolck's patch to fix inspect.getinnerframes().
713 725
714 726 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
715 727 for embedded instances, regarding handling of namespaces and items
716 728 added to the __builtin__ one. Multiple embedded instances and
717 729 recursive embeddings should work better now (though I'm not sure
718 730 I've got all the corner cases fixed, that code is a bit of a brain
719 731 twister).
720 732
721 733 * IPython/Magic.py (magic_edit): added support to edit in-memory
722 734 macros (automatically creates the necessary temp files). %edit
723 735 also doesn't return the file contents anymore, it's just noise.
724 736
725 737 * IPython/completer.py (Completer.attr_matches): revert change to
726 738 complete only on attributes listed in __all__. I realized it
727 739 cripples the tab-completion system as a tool for exploring the
728 740 internals of unknown libraries (it renders any non-__all__
729 741 attribute off-limits). I got bit by this when trying to see
730 742 something inside the dis module.
731 743
732 744 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
733 745
734 746 * IPython/iplib.py (InteractiveShell.__init__): add .meta
735 747 namespace for users and extension writers to hold data in. This
736 748 follows the discussion in
737 749 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
738 750
739 751 * IPython/completer.py (IPCompleter.complete): small patch to help
740 752 tab-completion under Emacs, after a suggestion by John Barnard
741 753 <barnarj-AT-ccf.org>.
742 754
743 755 * IPython/Magic.py (Magic.extract_input_slices): added support for
744 756 the slice notation in magics to use N-M to represent numbers N...M
745 757 (closed endpoints). This is used by %macro and %save.
746 758
747 759 * IPython/completer.py (Completer.attr_matches): for modules which
748 760 define __all__, complete only on those. After a patch by Jeffrey
749 761 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
750 762 speed up this routine.
751 763
752 764 * IPython/Logger.py (Logger.log): fix a history handling bug. I
753 765 don't know if this is the end of it, but the behavior now is
754 766 certainly much more correct. Note that coupled with macros,
755 767 slightly surprising (at first) behavior may occur: a macro will in
756 768 general expand to multiple lines of input, so upon exiting, the
757 769 in/out counters will both be bumped by the corresponding amount
758 770 (as if the macro's contents had been typed interactively). Typing
759 771 %hist will reveal the intermediate (silently processed) lines.
760 772
761 773 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
762 774 pickle to fail (%run was overwriting __main__ and not restoring
763 775 it, but pickle relies on __main__ to operate).
764 776
765 777 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
766 778 using properties, but forgot to make the main InteractiveShell
767 779 class a new-style class. Properties fail silently, and
768 780 misteriously, with old-style class (getters work, but
769 781 setters don't do anything).
770 782
771 783 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
772 784
773 785 * IPython/Magic.py (magic_history): fix history reporting bug (I
774 786 know some nasties are still there, I just can't seem to find a
775 787 reproducible test case to track them down; the input history is
776 788 falling out of sync...)
777 789
778 790 * IPython/iplib.py (handle_shell_escape): fix bug where both
779 791 aliases and system accesses where broken for indented code (such
780 792 as loops).
781 793
782 794 * IPython/genutils.py (shell): fix small but critical bug for
783 795 win32 system access.
784 796
785 797 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
786 798
787 799 * IPython/iplib.py (showtraceback): remove use of the
788 800 sys.last_{type/value/traceback} structures, which are non
789 801 thread-safe.
790 802 (_prefilter): change control flow to ensure that we NEVER
791 803 introspect objects when autocall is off. This will guarantee that
792 804 having an input line of the form 'x.y', where access to attribute
793 805 'y' has side effects, doesn't trigger the side effect TWICE. It
794 806 is important to note that, with autocall on, these side effects
795 807 can still happen.
796 808 (ipsystem): new builtin, to complete the ip{magic/alias/system}
797 809 trio. IPython offers these three kinds of special calls which are
798 810 not python code, and it's a good thing to have their call method
799 811 be accessible as pure python functions (not just special syntax at
800 812 the command line). It gives us a better internal implementation
801 813 structure, as well as exposing these for user scripting more
802 814 cleanly.
803 815
804 816 * IPython/macro.py (Macro.__init__): moved macros to a standalone
805 817 file. Now that they'll be more likely to be used with the
806 818 persistance system (%store), I want to make sure their module path
807 819 doesn't change in the future, so that we don't break things for
808 820 users' persisted data.
809 821
810 822 * IPython/iplib.py (autoindent_update): move indentation
811 823 management into the _text_ processing loop, not the keyboard
812 824 interactive one. This is necessary to correctly process non-typed
813 825 multiline input (such as macros).
814 826
815 827 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
816 828 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
817 829 which was producing problems in the resulting manual.
818 830 (magic_whos): improve reporting of instances (show their class,
819 831 instead of simply printing 'instance' which isn't terribly
820 832 informative).
821 833
822 834 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
823 835 (minor mods) to support network shares under win32.
824 836
825 837 * IPython/winconsole.py (get_console_size): add new winconsole
826 838 module and fixes to page_dumb() to improve its behavior under
827 839 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
828 840
829 841 * IPython/Magic.py (Macro): simplified Macro class to just
830 842 subclass list. We've had only 2.2 compatibility for a very long
831 843 time, yet I was still avoiding subclassing the builtin types. No
832 844 more (I'm also starting to use properties, though I won't shift to
833 845 2.3-specific features quite yet).
834 846 (magic_store): added Ville's patch for lightweight variable
835 847 persistence, after a request on the user list by Matt Wilkie
836 848 <maphew-AT-gmail.com>. The new %store magic's docstring has full
837 849 details.
838 850
839 851 * IPython/iplib.py (InteractiveShell.post_config_initialization):
840 852 changed the default logfile name from 'ipython.log' to
841 853 'ipython_log.py'. These logs are real python files, and now that
842 854 we have much better multiline support, people are more likely to
843 855 want to use them as such. Might as well name them correctly.
844 856
845 857 * IPython/Magic.py: substantial cleanup. While we can't stop
846 858 using magics as mixins, due to the existing customizations 'out
847 859 there' which rely on the mixin naming conventions, at least I
848 860 cleaned out all cross-class name usage. So once we are OK with
849 861 breaking compatibility, the two systems can be separated.
850 862
851 863 * IPython/Logger.py: major cleanup. This one is NOT a mixin
852 864 anymore, and the class is a fair bit less hideous as well. New
853 865 features were also introduced: timestamping of input, and logging
854 866 of output results. These are user-visible with the -t and -o
855 867 options to %logstart. Closes
856 868 http://www.scipy.net/roundup/ipython/issue11 and a request by
857 869 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
858 870
859 871 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
860 872
861 873 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
862 874 better hadnle backslashes in paths. See the thread 'More Windows
863 875 questions part 2 - \/ characters revisited' on the iypthon user
864 876 list:
865 877 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
866 878
867 879 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
868 880
869 881 (InteractiveShell.__init__): change threaded shells to not use the
870 882 ipython crash handler. This was causing more problems than not,
871 883 as exceptions in the main thread (GUI code, typically) would
872 884 always show up as a 'crash', when they really weren't.
873 885
874 886 The colors and exception mode commands (%colors/%xmode) have been
875 887 synchronized to also take this into account, so users can get
876 888 verbose exceptions for their threaded code as well. I also added
877 889 support for activating pdb inside this exception handler as well,
878 890 so now GUI authors can use IPython's enhanced pdb at runtime.
879 891
880 892 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
881 893 true by default, and add it to the shipped ipythonrc file. Since
882 894 this asks the user before proceeding, I think it's OK to make it
883 895 true by default.
884 896
885 897 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
886 898 of the previous special-casing of input in the eval loop. I think
887 899 this is cleaner, as they really are commands and shouldn't have
888 900 a special role in the middle of the core code.
889 901
890 902 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
891 903
892 904 * IPython/iplib.py (edit_syntax_error): added support for
893 905 automatically reopening the editor if the file had a syntax error
894 906 in it. Thanks to scottt who provided the patch at:
895 907 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
896 908 version committed).
897 909
898 910 * IPython/iplib.py (handle_normal): add suport for multi-line
899 911 input with emtpy lines. This fixes
900 912 http://www.scipy.net/roundup/ipython/issue43 and a similar
901 913 discussion on the user list.
902 914
903 915 WARNING: a behavior change is necessarily introduced to support
904 916 blank lines: now a single blank line with whitespace does NOT
905 917 break the input loop, which means that when autoindent is on, by
906 918 default hitting return on the next (indented) line does NOT exit.
907 919
908 920 Instead, to exit a multiline input you can either have:
909 921
910 922 - TWO whitespace lines (just hit return again), or
911 923 - a single whitespace line of a different length than provided
912 924 by the autoindent (add or remove a space).
913 925
914 926 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
915 927 module to better organize all readline-related functionality.
916 928 I've deleted FlexCompleter and put all completion clases here.
917 929
918 930 * IPython/iplib.py (raw_input): improve indentation management.
919 931 It is now possible to paste indented code with autoindent on, and
920 932 the code is interpreted correctly (though it still looks bad on
921 933 screen, due to the line-oriented nature of ipython).
922 934 (MagicCompleter.complete): change behavior so that a TAB key on an
923 935 otherwise empty line actually inserts a tab, instead of completing
924 936 on the entire global namespace. This makes it easier to use the
925 937 TAB key for indentation. After a request by Hans Meine
926 938 <hans_meine-AT-gmx.net>
927 939 (_prefilter): add support so that typing plain 'exit' or 'quit'
928 940 does a sensible thing. Originally I tried to deviate as little as
929 941 possible from the default python behavior, but even that one may
930 942 change in this direction (thread on python-dev to that effect).
931 943 Regardless, ipython should do the right thing even if CPython's
932 944 '>>>' prompt doesn't.
933 945 (InteractiveShell): removed subclassing code.InteractiveConsole
934 946 class. By now we'd overridden just about all of its methods: I've
935 947 copied the remaining two over, and now ipython is a standalone
936 948 class. This will provide a clearer picture for the chainsaw
937 949 branch refactoring.
938 950
939 951 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
940 952
941 953 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
942 954 failures for objects which break when dir() is called on them.
943 955
944 956 * IPython/FlexCompleter.py (Completer.__init__): Added support for
945 957 distinct local and global namespaces in the completer API. This
946 958 change allows us top properly handle completion with distinct
947 959 scopes, including in embedded instances (this had never really
948 960 worked correctly).
949 961
950 962 Note: this introduces a change in the constructor for
951 963 MagicCompleter, as a new global_namespace parameter is now the
952 964 second argument (the others were bumped one position).
953 965
954 966 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
955 967
956 968 * IPython/iplib.py (embed_mainloop): fix tab-completion in
957 969 embedded instances (which can be done now thanks to Vivian's
958 970 frame-handling fixes for pdb).
959 971 (InteractiveShell.__init__): Fix namespace handling problem in
960 972 embedded instances. We were overwriting __main__ unconditionally,
961 973 and this should only be done for 'full' (non-embedded) IPython;
962 974 embedded instances must respect the caller's __main__. Thanks to
963 975 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
964 976
965 977 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
966 978
967 979 * setup.py: added download_url to setup(). This registers the
968 980 download address at PyPI, which is not only useful to humans
969 981 browsing the site, but is also picked up by setuptools (the Eggs
970 982 machinery). Thanks to Ville and R. Kern for the info/discussion
971 983 on this.
972 984
973 985 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
974 986
975 987 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
976 988 This brings a lot of nice functionality to the pdb mode, which now
977 989 has tab-completion, syntax highlighting, and better stack handling
978 990 than before. Many thanks to Vivian De Smedt
979 991 <vivian-AT-vdesmedt.com> for the original patches.
980 992
981 993 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
982 994
983 995 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
984 996 sequence to consistently accept the banner argument. The
985 997 inconsistency was tripping SAGE, thanks to Gary Zablackis
986 998 <gzabl-AT-yahoo.com> for the report.
987 999
988 1000 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
989 1001
990 1002 * IPython/iplib.py (InteractiveShell.post_config_initialization):
991 1003 Fix bug where a naked 'alias' call in the ipythonrc file would
992 1004 cause a crash. Bug reported by Jorgen Stenarson.
993 1005
994 1006 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
995 1007
996 1008 * IPython/ipmaker.py (make_IPython): cleanups which should improve
997 1009 startup time.
998 1010
999 1011 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1000 1012 instances had introduced a bug with globals in normal code. Now
1001 1013 it's working in all cases.
1002 1014
1003 1015 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1004 1016 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1005 1017 has been introduced to set the default case sensitivity of the
1006 1018 searches. Users can still select either mode at runtime on a
1007 1019 per-search basis.
1008 1020
1009 1021 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1010 1022
1011 1023 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1012 1024 attributes in wildcard searches for subclasses. Modified version
1013 1025 of a patch by Jorgen.
1014 1026
1015 1027 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1016 1028
1017 1029 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1018 1030 embedded instances. I added a user_global_ns attribute to the
1019 1031 InteractiveShell class to handle this.
1020 1032
1021 1033 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1022 1034
1023 1035 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1024 1036 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1025 1037 (reported under win32, but may happen also in other platforms).
1026 1038 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1027 1039
1028 1040 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1029 1041
1030 1042 * IPython/Magic.py (magic_psearch): new support for wildcard
1031 1043 patterns. Now, typing ?a*b will list all names which begin with a
1032 1044 and end in b, for example. The %psearch magic has full
1033 1045 docstrings. Many thanks to JΓΆrgen Stenarson
1034 1046 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1035 1047 implementing this functionality.
1036 1048
1037 1049 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1038 1050
1039 1051 * Manual: fixed long-standing annoyance of double-dashes (as in
1040 1052 --prefix=~, for example) being stripped in the HTML version. This
1041 1053 is a latex2html bug, but a workaround was provided. Many thanks
1042 1054 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1043 1055 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1044 1056 rolling. This seemingly small issue had tripped a number of users
1045 1057 when first installing, so I'm glad to see it gone.
1046 1058
1047 1059 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1048 1060
1049 1061 * IPython/Extensions/numeric_formats.py: fix missing import,
1050 1062 reported by Stephen Walton.
1051 1063
1052 1064 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1053 1065
1054 1066 * IPython/demo.py: finish demo module, fully documented now.
1055 1067
1056 1068 * IPython/genutils.py (file_read): simple little utility to read a
1057 1069 file and ensure it's closed afterwards.
1058 1070
1059 1071 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
1060 1072
1061 1073 * IPython/demo.py (Demo.__init__): added support for individually
1062 1074 tagging blocks for automatic execution.
1063 1075
1064 1076 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
1065 1077 syntax-highlighted python sources, requested by John.
1066 1078
1067 1079 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
1068 1080
1069 1081 * IPython/demo.py (Demo.again): fix bug where again() blocks after
1070 1082 finishing.
1071 1083
1072 1084 * IPython/genutils.py (shlex_split): moved from Magic to here,
1073 1085 where all 2.2 compatibility stuff lives. I needed it for demo.py.
1074 1086
1075 1087 * IPython/demo.py (Demo.__init__): added support for silent
1076 1088 blocks, improved marks as regexps, docstrings written.
1077 1089 (Demo.__init__): better docstring, added support for sys.argv.
1078 1090
1079 1091 * IPython/genutils.py (marquee): little utility used by the demo
1080 1092 code, handy in general.
1081 1093
1082 1094 * IPython/demo.py (Demo.__init__): new class for interactive
1083 1095 demos. Not documented yet, I just wrote it in a hurry for
1084 1096 scipy'05. Will docstring later.
1085 1097
1086 1098 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
1087 1099
1088 1100 * IPython/Shell.py (sigint_handler): Drastic simplification which
1089 1101 also seems to make Ctrl-C work correctly across threads! This is
1090 1102 so simple, that I can't beleive I'd missed it before. Needs more
1091 1103 testing, though.
1092 1104 (KBINT): Never mind, revert changes. I'm sure I'd tried something
1093 1105 like this before...
1094 1106
1095 1107 * IPython/genutils.py (get_home_dir): add protection against
1096 1108 non-dirs in win32 registry.
1097 1109
1098 1110 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
1099 1111 bug where dict was mutated while iterating (pysh crash).
1100 1112
1101 1113 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
1102 1114
1103 1115 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
1104 1116 spurious newlines added by this routine. After a report by
1105 1117 F. Mantegazza.
1106 1118
1107 1119 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
1108 1120
1109 1121 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
1110 1122 calls. These were a leftover from the GTK 1.x days, and can cause
1111 1123 problems in certain cases (after a report by John Hunter).
1112 1124
1113 1125 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
1114 1126 os.getcwd() fails at init time. Thanks to patch from David Remahl
1115 1127 <chmod007-AT-mac.com>.
1116 1128 (InteractiveShell.__init__): prevent certain special magics from
1117 1129 being shadowed by aliases. Closes
1118 1130 http://www.scipy.net/roundup/ipython/issue41.
1119 1131
1120 1132 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
1121 1133
1122 1134 * IPython/iplib.py (InteractiveShell.complete): Added new
1123 1135 top-level completion method to expose the completion mechanism
1124 1136 beyond readline-based environments.
1125 1137
1126 1138 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
1127 1139
1128 1140 * tools/ipsvnc (svnversion): fix svnversion capture.
1129 1141
1130 1142 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
1131 1143 attribute to self, which was missing. Before, it was set by a
1132 1144 routine which in certain cases wasn't being called, so the
1133 1145 instance could end up missing the attribute. This caused a crash.
1134 1146 Closes http://www.scipy.net/roundup/ipython/issue40.
1135 1147
1136 1148 2005-08-16 Fernando Perez <fperez@colorado.edu>
1137 1149
1138 1150 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
1139 1151 contains non-string attribute. Closes
1140 1152 http://www.scipy.net/roundup/ipython/issue38.
1141 1153
1142 1154 2005-08-14 Fernando Perez <fperez@colorado.edu>
1143 1155
1144 1156 * tools/ipsvnc: Minor improvements, to add changeset info.
1145 1157
1146 1158 2005-08-12 Fernando Perez <fperez@colorado.edu>
1147 1159
1148 1160 * IPython/iplib.py (runsource): remove self.code_to_run_src
1149 1161 attribute. I realized this is nothing more than
1150 1162 '\n'.join(self.buffer), and having the same data in two different
1151 1163 places is just asking for synchronization bugs. This may impact
1152 1164 people who have custom exception handlers, so I need to warn
1153 1165 ipython-dev about it (F. Mantegazza may use them).
1154 1166
1155 1167 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
1156 1168
1157 1169 * IPython/genutils.py: fix 2.2 compatibility (generators)
1158 1170
1159 1171 2005-07-18 Fernando Perez <fperez@colorado.edu>
1160 1172
1161 1173 * IPython/genutils.py (get_home_dir): fix to help users with
1162 1174 invalid $HOME under win32.
1163 1175
1164 1176 2005-07-17 Fernando Perez <fperez@colorado.edu>
1165 1177
1166 1178 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
1167 1179 some old hacks and clean up a bit other routines; code should be
1168 1180 simpler and a bit faster.
1169 1181
1170 1182 * IPython/iplib.py (interact): removed some last-resort attempts
1171 1183 to survive broken stdout/stderr. That code was only making it
1172 1184 harder to abstract out the i/o (necessary for gui integration),
1173 1185 and the crashes it could prevent were extremely rare in practice
1174 1186 (besides being fully user-induced in a pretty violent manner).
1175 1187
1176 1188 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
1177 1189 Nothing major yet, but the code is simpler to read; this should
1178 1190 make it easier to do more serious modifications in the future.
1179 1191
1180 1192 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
1181 1193 which broke in .15 (thanks to a report by Ville).
1182 1194
1183 1195 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
1184 1196 be quite correct, I know next to nothing about unicode). This
1185 1197 will allow unicode strings to be used in prompts, amongst other
1186 1198 cases. It also will prevent ipython from crashing when unicode
1187 1199 shows up unexpectedly in many places. If ascii encoding fails, we
1188 1200 assume utf_8. Currently the encoding is not a user-visible
1189 1201 setting, though it could be made so if there is demand for it.
1190 1202
1191 1203 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
1192 1204
1193 1205 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
1194 1206
1195 1207 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
1196 1208
1197 1209 * IPython/genutils.py: Add 2.2 compatibility here, so all other
1198 1210 code can work transparently for 2.2/2.3.
1199 1211
1200 1212 2005-07-16 Fernando Perez <fperez@colorado.edu>
1201 1213
1202 1214 * IPython/ultraTB.py (ExceptionColors): Make a global variable
1203 1215 out of the color scheme table used for coloring exception
1204 1216 tracebacks. This allows user code to add new schemes at runtime.
1205 1217 This is a minimally modified version of the patch at
1206 1218 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
1207 1219 for the contribution.
1208 1220
1209 1221 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
1210 1222 slightly modified version of the patch in
1211 1223 http://www.scipy.net/roundup/ipython/issue34, which also allows me
1212 1224 to remove the previous try/except solution (which was costlier).
1213 1225 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
1214 1226
1215 1227 2005-06-08 Fernando Perez <fperez@colorado.edu>
1216 1228
1217 1229 * IPython/iplib.py (write/write_err): Add methods to abstract all
1218 1230 I/O a bit more.
1219 1231
1220 1232 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
1221 1233 warning, reported by Aric Hagberg, fix by JD Hunter.
1222 1234
1223 1235 2005-06-02 *** Released version 0.6.15
1224 1236
1225 1237 2005-06-01 Fernando Perez <fperez@colorado.edu>
1226 1238
1227 1239 * IPython/iplib.py (MagicCompleter.file_matches): Fix
1228 1240 tab-completion of filenames within open-quoted strings. Note that
1229 1241 this requires that in ~/.ipython/ipythonrc, users change the
1230 1242 readline delimiters configuration to read:
1231 1243
1232 1244 readline_remove_delims -/~
1233 1245
1234 1246
1235 1247 2005-05-31 *** Released version 0.6.14
1236 1248
1237 1249 2005-05-29 Fernando Perez <fperez@colorado.edu>
1238 1250
1239 1251 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
1240 1252 with files not on the filesystem. Reported by Eliyahu Sandler
1241 1253 <eli@gondolin.net>
1242 1254
1243 1255 2005-05-22 Fernando Perez <fperez@colorado.edu>
1244 1256
1245 1257 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
1246 1258 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
1247 1259
1248 1260 2005-05-19 Fernando Perez <fperez@colorado.edu>
1249 1261
1250 1262 * IPython/iplib.py (safe_execfile): close a file which could be
1251 1263 left open (causing problems in win32, which locks open files).
1252 1264 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
1253 1265
1254 1266 2005-05-18 Fernando Perez <fperez@colorado.edu>
1255 1267
1256 1268 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
1257 1269 keyword arguments correctly to safe_execfile().
1258 1270
1259 1271 2005-05-13 Fernando Perez <fperez@colorado.edu>
1260 1272
1261 1273 * ipython.1: Added info about Qt to manpage, and threads warning
1262 1274 to usage page (invoked with --help).
1263 1275
1264 1276 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
1265 1277 new matcher (it goes at the end of the priority list) to do
1266 1278 tab-completion on named function arguments. Submitted by George
1267 1279 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
1268 1280 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
1269 1281 for more details.
1270 1282
1271 1283 * IPython/Magic.py (magic_run): Added new -e flag to ignore
1272 1284 SystemExit exceptions in the script being run. Thanks to a report
1273 1285 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
1274 1286 producing very annoying behavior when running unit tests.
1275 1287
1276 1288 2005-05-12 Fernando Perez <fperez@colorado.edu>
1277 1289
1278 1290 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
1279 1291 which I'd broken (again) due to a changed regexp. In the process,
1280 1292 added ';' as an escape to auto-quote the whole line without
1281 1293 splitting its arguments. Thanks to a report by Jerry McRae
1282 1294 <qrs0xyc02-AT-sneakemail.com>.
1283 1295
1284 1296 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
1285 1297 possible crashes caused by a TokenError. Reported by Ed Schofield
1286 1298 <schofield-AT-ftw.at>.
1287 1299
1288 1300 2005-05-06 Fernando Perez <fperez@colorado.edu>
1289 1301
1290 1302 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
1291 1303
1292 1304 2005-04-29 Fernando Perez <fperez@colorado.edu>
1293 1305
1294 1306 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
1295 1307 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
1296 1308 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
1297 1309 which provides support for Qt interactive usage (similar to the
1298 1310 existing one for WX and GTK). This had been often requested.
1299 1311
1300 1312 2005-04-14 *** Released version 0.6.13
1301 1313
1302 1314 2005-04-08 Fernando Perez <fperez@colorado.edu>
1303 1315
1304 1316 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
1305 1317 from _ofind, which gets called on almost every input line. Now,
1306 1318 we only try to get docstrings if they are actually going to be
1307 1319 used (the overhead of fetching unnecessary docstrings can be
1308 1320 noticeable for certain objects, such as Pyro proxies).
1309 1321
1310 1322 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
1311 1323 for completers. For some reason I had been passing them the state
1312 1324 variable, which completers never actually need, and was in
1313 1325 conflict with the rlcompleter API. Custom completers ONLY need to
1314 1326 take the text parameter.
1315 1327
1316 1328 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
1317 1329 work correctly in pysh. I've also moved all the logic which used
1318 1330 to be in pysh.py here, which will prevent problems with future
1319 1331 upgrades. However, this time I must warn users to update their
1320 1332 pysh profile to include the line
1321 1333
1322 1334 import_all IPython.Extensions.InterpreterExec
1323 1335
1324 1336 because otherwise things won't work for them. They MUST also
1325 1337 delete pysh.py and the line
1326 1338
1327 1339 execfile pysh.py
1328 1340
1329 1341 from their ipythonrc-pysh.
1330 1342
1331 1343 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
1332 1344 robust in the face of objects whose dir() returns non-strings
1333 1345 (which it shouldn't, but some broken libs like ITK do). Thanks to
1334 1346 a patch by John Hunter (implemented differently, though). Also
1335 1347 minor improvements by using .extend instead of + on lists.
1336 1348
1337 1349 * pysh.py:
1338 1350
1339 1351 2005-04-06 Fernando Perez <fperez@colorado.edu>
1340 1352
1341 1353 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
1342 1354 by default, so that all users benefit from it. Those who don't
1343 1355 want it can still turn it off.
1344 1356
1345 1357 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
1346 1358 config file, I'd forgotten about this, so users were getting it
1347 1359 off by default.
1348 1360
1349 1361 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
1350 1362 consistency. Now magics can be called in multiline statements,
1351 1363 and python variables can be expanded in magic calls via $var.
1352 1364 This makes the magic system behave just like aliases or !system
1353 1365 calls.
1354 1366
1355 1367 2005-03-28 Fernando Perez <fperez@colorado.edu>
1356 1368
1357 1369 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
1358 1370 expensive string additions for building command. Add support for
1359 1371 trailing ';' when autocall is used.
1360 1372
1361 1373 2005-03-26 Fernando Perez <fperez@colorado.edu>
1362 1374
1363 1375 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
1364 1376 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
1365 1377 ipython.el robust against prompts with any number of spaces
1366 1378 (including 0) after the ':' character.
1367 1379
1368 1380 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
1369 1381 continuation prompt, which misled users to think the line was
1370 1382 already indented. Closes debian Bug#300847, reported to me by
1371 1383 Norbert Tretkowski <tretkowski-AT-inittab.de>.
1372 1384
1373 1385 2005-03-23 Fernando Perez <fperez@colorado.edu>
1374 1386
1375 1387 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
1376 1388 properly aligned if they have embedded newlines.
1377 1389
1378 1390 * IPython/iplib.py (runlines): Add a public method to expose
1379 1391 IPython's code execution machinery, so that users can run strings
1380 1392 as if they had been typed at the prompt interactively.
1381 1393 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
1382 1394 methods which can call the system shell, but with python variable
1383 1395 expansion. The three such methods are: __IPYTHON__.system,
1384 1396 .getoutput and .getoutputerror. These need to be documented in a
1385 1397 'public API' section (to be written) of the manual.
1386 1398
1387 1399 2005-03-20 Fernando Perez <fperez@colorado.edu>
1388 1400
1389 1401 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
1390 1402 for custom exception handling. This is quite powerful, and it
1391 1403 allows for user-installable exception handlers which can trap
1392 1404 custom exceptions at runtime and treat them separately from
1393 1405 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1394 1406 Mantegazza <mantegazza-AT-ill.fr>.
1395 1407 (InteractiveShell.set_custom_completer): public API function to
1396 1408 add new completers at runtime.
1397 1409
1398 1410 2005-03-19 Fernando Perez <fperez@colorado.edu>
1399 1411
1400 1412 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1401 1413 allow objects which provide their docstrings via non-standard
1402 1414 mechanisms (like Pyro proxies) to still be inspected by ipython's
1403 1415 ? system.
1404 1416
1405 1417 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1406 1418 automatic capture system. I tried quite hard to make it work
1407 1419 reliably, and simply failed. I tried many combinations with the
1408 1420 subprocess module, but eventually nothing worked in all needed
1409 1421 cases (not blocking stdin for the child, duplicating stdout
1410 1422 without blocking, etc). The new %sc/%sx still do capture to these
1411 1423 magical list/string objects which make shell use much more
1412 1424 conveninent, so not all is lost.
1413 1425
1414 1426 XXX - FIX MANUAL for the change above!
1415 1427
1416 1428 (runsource): I copied code.py's runsource() into ipython to modify
1417 1429 it a bit. Now the code object and source to be executed are
1418 1430 stored in ipython. This makes this info accessible to third-party
1419 1431 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
1420 1432 Mantegazza <mantegazza-AT-ill.fr>.
1421 1433
1422 1434 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
1423 1435 history-search via readline (like C-p/C-n). I'd wanted this for a
1424 1436 long time, but only recently found out how to do it. For users
1425 1437 who already have their ipythonrc files made and want this, just
1426 1438 add:
1427 1439
1428 1440 readline_parse_and_bind "\e[A": history-search-backward
1429 1441 readline_parse_and_bind "\e[B": history-search-forward
1430 1442
1431 1443 2005-03-18 Fernando Perez <fperez@colorado.edu>
1432 1444
1433 1445 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
1434 1446 LSString and SList classes which allow transparent conversions
1435 1447 between list mode and whitespace-separated string.
1436 1448 (magic_r): Fix recursion problem in %r.
1437 1449
1438 1450 * IPython/genutils.py (LSString): New class to be used for
1439 1451 automatic storage of the results of all alias/system calls in _o
1440 1452 and _e (stdout/err). These provide a .l/.list attribute which
1441 1453 does automatic splitting on newlines. This means that for most
1442 1454 uses, you'll never need to do capturing of output with %sc/%sx
1443 1455 anymore, since ipython keeps this always done for you. Note that
1444 1456 only the LAST results are stored, the _o/e variables are
1445 1457 overwritten on each call. If you need to save their contents
1446 1458 further, simply bind them to any other name.
1447 1459
1448 1460 2005-03-17 Fernando Perez <fperez@colorado.edu>
1449 1461
1450 1462 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
1451 1463 prompt namespace handling.
1452 1464
1453 1465 2005-03-16 Fernando Perez <fperez@colorado.edu>
1454 1466
1455 1467 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
1456 1468 classic prompts to be '>>> ' (final space was missing, and it
1457 1469 trips the emacs python mode).
1458 1470 (BasePrompt.__str__): Added safe support for dynamic prompt
1459 1471 strings. Now you can set your prompt string to be '$x', and the
1460 1472 value of x will be printed from your interactive namespace. The
1461 1473 interpolation syntax includes the full Itpl support, so
1462 1474 ${foo()+x+bar()} is a valid prompt string now, and the function
1463 1475 calls will be made at runtime.
1464 1476
1465 1477 2005-03-15 Fernando Perez <fperez@colorado.edu>
1466 1478
1467 1479 * IPython/Magic.py (magic_history): renamed %hist to %history, to
1468 1480 avoid name clashes in pylab. %hist still works, it just forwards
1469 1481 the call to %history.
1470 1482
1471 1483 2005-03-02 *** Released version 0.6.12
1472 1484
1473 1485 2005-03-02 Fernando Perez <fperez@colorado.edu>
1474 1486
1475 1487 * IPython/iplib.py (handle_magic): log magic calls properly as
1476 1488 ipmagic() function calls.
1477 1489
1478 1490 * IPython/Magic.py (magic_time): Improved %time to support
1479 1491 statements and provide wall-clock as well as CPU time.
1480 1492
1481 1493 2005-02-27 Fernando Perez <fperez@colorado.edu>
1482 1494
1483 1495 * IPython/hooks.py: New hooks module, to expose user-modifiable
1484 1496 IPython functionality in a clean manner. For now only the editor
1485 1497 hook is actually written, and other thigns which I intend to turn
1486 1498 into proper hooks aren't yet there. The display and prefilter
1487 1499 stuff, for example, should be hooks. But at least now the
1488 1500 framework is in place, and the rest can be moved here with more
1489 1501 time later. IPython had had a .hooks variable for a long time for
1490 1502 this purpose, but I'd never actually used it for anything.
1491 1503
1492 1504 2005-02-26 Fernando Perez <fperez@colorado.edu>
1493 1505
1494 1506 * IPython/ipmaker.py (make_IPython): make the default ipython
1495 1507 directory be called _ipython under win32, to follow more the
1496 1508 naming peculiarities of that platform (where buggy software like
1497 1509 Visual Sourcesafe breaks with .named directories). Reported by
1498 1510 Ville Vainio.
1499 1511
1500 1512 2005-02-23 Fernando Perez <fperez@colorado.edu>
1501 1513
1502 1514 * IPython/iplib.py (InteractiveShell.__init__): removed a few
1503 1515 auto_aliases for win32 which were causing problems. Users can
1504 1516 define the ones they personally like.
1505 1517
1506 1518 2005-02-21 Fernando Perez <fperez@colorado.edu>
1507 1519
1508 1520 * IPython/Magic.py (magic_time): new magic to time execution of
1509 1521 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
1510 1522
1511 1523 2005-02-19 Fernando Perez <fperez@colorado.edu>
1512 1524
1513 1525 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
1514 1526 into keys (for prompts, for example).
1515 1527
1516 1528 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
1517 1529 prompts in case users want them. This introduces a small behavior
1518 1530 change: ipython does not automatically add a space to all prompts
1519 1531 anymore. To get the old prompts with a space, users should add it
1520 1532 manually to their ipythonrc file, so for example prompt_in1 should
1521 1533 now read 'In [\#]: ' instead of 'In [\#]:'.
1522 1534 (BasePrompt.__init__): New option prompts_pad_left (only in rc
1523 1535 file) to control left-padding of secondary prompts.
1524 1536
1525 1537 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
1526 1538 the profiler can't be imported. Fix for Debian, which removed
1527 1539 profile.py because of License issues. I applied a slightly
1528 1540 modified version of the original Debian patch at
1529 1541 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
1530 1542
1531 1543 2005-02-17 Fernando Perez <fperez@colorado.edu>
1532 1544
1533 1545 * IPython/genutils.py (native_line_ends): Fix bug which would
1534 1546 cause improper line-ends under win32 b/c I was not opening files
1535 1547 in binary mode. Bug report and fix thanks to Ville.
1536 1548
1537 1549 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
1538 1550 trying to catch spurious foo[1] autocalls. My fix actually broke
1539 1551 ',/' autoquote/call with explicit escape (bad regexp).
1540 1552
1541 1553 2005-02-15 *** Released version 0.6.11
1542 1554
1543 1555 2005-02-14 Fernando Perez <fperez@colorado.edu>
1544 1556
1545 1557 * IPython/background_jobs.py: New background job management
1546 1558 subsystem. This is implemented via a new set of classes, and
1547 1559 IPython now provides a builtin 'jobs' object for background job
1548 1560 execution. A convenience %bg magic serves as a lightweight
1549 1561 frontend for starting the more common type of calls. This was
1550 1562 inspired by discussions with B. Granger and the BackgroundCommand
1551 1563 class described in the book Python Scripting for Computational
1552 1564 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
1553 1565 (although ultimately no code from this text was used, as IPython's
1554 1566 system is a separate implementation).
1555 1567
1556 1568 * IPython/iplib.py (MagicCompleter.python_matches): add new option
1557 1569 to control the completion of single/double underscore names
1558 1570 separately. As documented in the example ipytonrc file, the
1559 1571 readline_omit__names variable can now be set to 2, to omit even
1560 1572 single underscore names. Thanks to a patch by Brian Wong
1561 1573 <BrianWong-AT-AirgoNetworks.Com>.
1562 1574 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
1563 1575 be autocalled as foo([1]) if foo were callable. A problem for
1564 1576 things which are both callable and implement __getitem__.
1565 1577 (init_readline): Fix autoindentation for win32. Thanks to a patch
1566 1578 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
1567 1579
1568 1580 2005-02-12 Fernando Perez <fperez@colorado.edu>
1569 1581
1570 1582 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
1571 1583 which I had written long ago to sort out user error messages which
1572 1584 may occur during startup. This seemed like a good idea initially,
1573 1585 but it has proven a disaster in retrospect. I don't want to
1574 1586 change much code for now, so my fix is to set the internal 'debug'
1575 1587 flag to true everywhere, whose only job was precisely to control
1576 1588 this subsystem. This closes issue 28 (as well as avoiding all
1577 1589 sorts of strange hangups which occur from time to time).
1578 1590
1579 1591 2005-02-07 Fernando Perez <fperez@colorado.edu>
1580 1592
1581 1593 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1582 1594 previous call produced a syntax error.
1583 1595
1584 1596 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1585 1597 classes without constructor.
1586 1598
1587 1599 2005-02-06 Fernando Perez <fperez@colorado.edu>
1588 1600
1589 1601 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1590 1602 completions with the results of each matcher, so we return results
1591 1603 to the user from all namespaces. This breaks with ipython
1592 1604 tradition, but I think it's a nicer behavior. Now you get all
1593 1605 possible completions listed, from all possible namespaces (python,
1594 1606 filesystem, magics...) After a request by John Hunter
1595 1607 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1596 1608
1597 1609 2005-02-05 Fernando Perez <fperez@colorado.edu>
1598 1610
1599 1611 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1600 1612 the call had quote characters in it (the quotes were stripped).
1601 1613
1602 1614 2005-01-31 Fernando Perez <fperez@colorado.edu>
1603 1615
1604 1616 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1605 1617 Itpl.itpl() to make the code more robust against psyco
1606 1618 optimizations.
1607 1619
1608 1620 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1609 1621 of causing an exception. Quicker, cleaner.
1610 1622
1611 1623 2005-01-28 Fernando Perez <fperez@colorado.edu>
1612 1624
1613 1625 * scripts/ipython_win_post_install.py (install): hardcode
1614 1626 sys.prefix+'python.exe' as the executable path. It turns out that
1615 1627 during the post-installation run, sys.executable resolves to the
1616 1628 name of the binary installer! I should report this as a distutils
1617 1629 bug, I think. I updated the .10 release with this tiny fix, to
1618 1630 avoid annoying the lists further.
1619 1631
1620 1632 2005-01-27 *** Released version 0.6.10
1621 1633
1622 1634 2005-01-27 Fernando Perez <fperez@colorado.edu>
1623 1635
1624 1636 * IPython/numutils.py (norm): Added 'inf' as optional name for
1625 1637 L-infinity norm, included references to mathworld.com for vector
1626 1638 norm definitions.
1627 1639 (amin/amax): added amin/amax for array min/max. Similar to what
1628 1640 pylab ships with after the recent reorganization of names.
1629 1641 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1630 1642
1631 1643 * ipython.el: committed Alex's recent fixes and improvements.
1632 1644 Tested with python-mode from CVS, and it looks excellent. Since
1633 1645 python-mode hasn't released anything in a while, I'm temporarily
1634 1646 putting a copy of today's CVS (v 4.70) of python-mode in:
1635 1647 http://ipython.scipy.org/tmp/python-mode.el
1636 1648
1637 1649 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1638 1650 sys.executable for the executable name, instead of assuming it's
1639 1651 called 'python.exe' (the post-installer would have produced broken
1640 1652 setups on systems with a differently named python binary).
1641 1653
1642 1654 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1643 1655 references to os.linesep, to make the code more
1644 1656 platform-independent. This is also part of the win32 coloring
1645 1657 fixes.
1646 1658
1647 1659 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1648 1660 lines, which actually cause coloring bugs because the length of
1649 1661 the line is very difficult to correctly compute with embedded
1650 1662 escapes. This was the source of all the coloring problems under
1651 1663 Win32. I think that _finally_, Win32 users have a properly
1652 1664 working ipython in all respects. This would never have happened
1653 1665 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1654 1666
1655 1667 2005-01-26 *** Released version 0.6.9
1656 1668
1657 1669 2005-01-25 Fernando Perez <fperez@colorado.edu>
1658 1670
1659 1671 * setup.py: finally, we have a true Windows installer, thanks to
1660 1672 the excellent work of Viktor Ransmayr
1661 1673 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1662 1674 Windows users. The setup routine is quite a bit cleaner thanks to
1663 1675 this, and the post-install script uses the proper functions to
1664 1676 allow a clean de-installation using the standard Windows Control
1665 1677 Panel.
1666 1678
1667 1679 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1668 1680 environment variable under all OSes (including win32) if
1669 1681 available. This will give consistency to win32 users who have set
1670 1682 this variable for any reason. If os.environ['HOME'] fails, the
1671 1683 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1672 1684
1673 1685 2005-01-24 Fernando Perez <fperez@colorado.edu>
1674 1686
1675 1687 * IPython/numutils.py (empty_like): add empty_like(), similar to
1676 1688 zeros_like() but taking advantage of the new empty() Numeric routine.
1677 1689
1678 1690 2005-01-23 *** Released version 0.6.8
1679 1691
1680 1692 2005-01-22 Fernando Perez <fperez@colorado.edu>
1681 1693
1682 1694 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1683 1695 automatic show() calls. After discussing things with JDH, it
1684 1696 turns out there are too many corner cases where this can go wrong.
1685 1697 It's best not to try to be 'too smart', and simply have ipython
1686 1698 reproduce as much as possible the default behavior of a normal
1687 1699 python shell.
1688 1700
1689 1701 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1690 1702 line-splitting regexp and _prefilter() to avoid calling getattr()
1691 1703 on assignments. This closes
1692 1704 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1693 1705 readline uses getattr(), so a simple <TAB> keypress is still
1694 1706 enough to trigger getattr() calls on an object.
1695 1707
1696 1708 2005-01-21 Fernando Perez <fperez@colorado.edu>
1697 1709
1698 1710 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1699 1711 docstring under pylab so it doesn't mask the original.
1700 1712
1701 1713 2005-01-21 *** Released version 0.6.7
1702 1714
1703 1715 2005-01-21 Fernando Perez <fperez@colorado.edu>
1704 1716
1705 1717 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1706 1718 signal handling for win32 users in multithreaded mode.
1707 1719
1708 1720 2005-01-17 Fernando Perez <fperez@colorado.edu>
1709 1721
1710 1722 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1711 1723 instances with no __init__. After a crash report by Norbert Nemec
1712 1724 <Norbert-AT-nemec-online.de>.
1713 1725
1714 1726 2005-01-14 Fernando Perez <fperez@colorado.edu>
1715 1727
1716 1728 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1717 1729 names for verbose exceptions, when multiple dotted names and the
1718 1730 'parent' object were present on the same line.
1719 1731
1720 1732 2005-01-11 Fernando Perez <fperez@colorado.edu>
1721 1733
1722 1734 * IPython/genutils.py (flag_calls): new utility to trap and flag
1723 1735 calls in functions. I need it to clean up matplotlib support.
1724 1736 Also removed some deprecated code in genutils.
1725 1737
1726 1738 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1727 1739 that matplotlib scripts called with %run, which don't call show()
1728 1740 themselves, still have their plotting windows open.
1729 1741
1730 1742 2005-01-05 Fernando Perez <fperez@colorado.edu>
1731 1743
1732 1744 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1733 1745 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1734 1746
1735 1747 2004-12-19 Fernando Perez <fperez@colorado.edu>
1736 1748
1737 1749 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1738 1750 parent_runcode, which was an eyesore. The same result can be
1739 1751 obtained with Python's regular superclass mechanisms.
1740 1752
1741 1753 2004-12-17 Fernando Perez <fperez@colorado.edu>
1742 1754
1743 1755 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1744 1756 reported by Prabhu.
1745 1757 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1746 1758 sys.stderr) instead of explicitly calling sys.stderr. This helps
1747 1759 maintain our I/O abstractions clean, for future GUI embeddings.
1748 1760
1749 1761 * IPython/genutils.py (info): added new utility for sys.stderr
1750 1762 unified info message handling (thin wrapper around warn()).
1751 1763
1752 1764 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1753 1765 composite (dotted) names on verbose exceptions.
1754 1766 (VerboseTB.nullrepr): harden against another kind of errors which
1755 1767 Python's inspect module can trigger, and which were crashing
1756 1768 IPython. Thanks to a report by Marco Lombardi
1757 1769 <mlombard-AT-ma010192.hq.eso.org>.
1758 1770
1759 1771 2004-12-13 *** Released version 0.6.6
1760 1772
1761 1773 2004-12-12 Fernando Perez <fperez@colorado.edu>
1762 1774
1763 1775 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1764 1776 generated by pygtk upon initialization if it was built without
1765 1777 threads (for matplotlib users). After a crash reported by
1766 1778 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1767 1779
1768 1780 * IPython/ipmaker.py (make_IPython): fix small bug in the
1769 1781 import_some parameter for multiple imports.
1770 1782
1771 1783 * IPython/iplib.py (ipmagic): simplified the interface of
1772 1784 ipmagic() to take a single string argument, just as it would be
1773 1785 typed at the IPython cmd line.
1774 1786 (ipalias): Added new ipalias() with an interface identical to
1775 1787 ipmagic(). This completes exposing a pure python interface to the
1776 1788 alias and magic system, which can be used in loops or more complex
1777 1789 code where IPython's automatic line mangling is not active.
1778 1790
1779 1791 * IPython/genutils.py (timing): changed interface of timing to
1780 1792 simply run code once, which is the most common case. timings()
1781 1793 remains unchanged, for the cases where you want multiple runs.
1782 1794
1783 1795 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1784 1796 bug where Python2.2 crashes with exec'ing code which does not end
1785 1797 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1786 1798 before.
1787 1799
1788 1800 2004-12-10 Fernando Perez <fperez@colorado.edu>
1789 1801
1790 1802 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1791 1803 -t to -T, to accomodate the new -t flag in %run (the %run and
1792 1804 %prun options are kind of intermixed, and it's not easy to change
1793 1805 this with the limitations of python's getopt).
1794 1806
1795 1807 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1796 1808 the execution of scripts. It's not as fine-tuned as timeit.py,
1797 1809 but it works from inside ipython (and under 2.2, which lacks
1798 1810 timeit.py). Optionally a number of runs > 1 can be given for
1799 1811 timing very short-running code.
1800 1812
1801 1813 * IPython/genutils.py (uniq_stable): new routine which returns a
1802 1814 list of unique elements in any iterable, but in stable order of
1803 1815 appearance. I needed this for the ultraTB fixes, and it's a handy
1804 1816 utility.
1805 1817
1806 1818 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1807 1819 dotted names in Verbose exceptions. This had been broken since
1808 1820 the very start, now x.y will properly be printed in a Verbose
1809 1821 traceback, instead of x being shown and y appearing always as an
1810 1822 'undefined global'. Getting this to work was a bit tricky,
1811 1823 because by default python tokenizers are stateless. Saved by
1812 1824 python's ability to easily add a bit of state to an arbitrary
1813 1825 function (without needing to build a full-blown callable object).
1814 1826
1815 1827 Also big cleanup of this code, which had horrendous runtime
1816 1828 lookups of zillions of attributes for colorization. Moved all
1817 1829 this code into a few templates, which make it cleaner and quicker.
1818 1830
1819 1831 Printout quality was also improved for Verbose exceptions: one
1820 1832 variable per line, and memory addresses are printed (this can be
1821 1833 quite handy in nasty debugging situations, which is what Verbose
1822 1834 is for).
1823 1835
1824 1836 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1825 1837 the command line as scripts to be loaded by embedded instances.
1826 1838 Doing so has the potential for an infinite recursion if there are
1827 1839 exceptions thrown in the process. This fixes a strange crash
1828 1840 reported by Philippe MULLER <muller-AT-irit.fr>.
1829 1841
1830 1842 2004-12-09 Fernando Perez <fperez@colorado.edu>
1831 1843
1832 1844 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1833 1845 to reflect new names in matplotlib, which now expose the
1834 1846 matlab-compatible interface via a pylab module instead of the
1835 1847 'matlab' name. The new code is backwards compatible, so users of
1836 1848 all matplotlib versions are OK. Patch by J. Hunter.
1837 1849
1838 1850 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1839 1851 of __init__ docstrings for instances (class docstrings are already
1840 1852 automatically printed). Instances with customized docstrings
1841 1853 (indep. of the class) are also recognized and all 3 separate
1842 1854 docstrings are printed (instance, class, constructor). After some
1843 1855 comments/suggestions by J. Hunter.
1844 1856
1845 1857 2004-12-05 Fernando Perez <fperez@colorado.edu>
1846 1858
1847 1859 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1848 1860 warnings when tab-completion fails and triggers an exception.
1849 1861
1850 1862 2004-12-03 Fernando Perez <fperez@colorado.edu>
1851 1863
1852 1864 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1853 1865 be triggered when using 'run -p'. An incorrect option flag was
1854 1866 being set ('d' instead of 'D').
1855 1867 (manpage): fix missing escaped \- sign.
1856 1868
1857 1869 2004-11-30 *** Released version 0.6.5
1858 1870
1859 1871 2004-11-30 Fernando Perez <fperez@colorado.edu>
1860 1872
1861 1873 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1862 1874 setting with -d option.
1863 1875
1864 1876 * setup.py (docfiles): Fix problem where the doc glob I was using
1865 1877 was COMPLETELY BROKEN. It was giving the right files by pure
1866 1878 accident, but failed once I tried to include ipython.el. Note:
1867 1879 glob() does NOT allow you to do exclusion on multiple endings!
1868 1880
1869 1881 2004-11-29 Fernando Perez <fperez@colorado.edu>
1870 1882
1871 1883 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1872 1884 the manpage as the source. Better formatting & consistency.
1873 1885
1874 1886 * IPython/Magic.py (magic_run): Added new -d option, to run
1875 1887 scripts under the control of the python pdb debugger. Note that
1876 1888 this required changing the %prun option -d to -D, to avoid a clash
1877 1889 (since %run must pass options to %prun, and getopt is too dumb to
1878 1890 handle options with string values with embedded spaces). Thanks
1879 1891 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1880 1892 (magic_who_ls): added type matching to %who and %whos, so that one
1881 1893 can filter their output to only include variables of certain
1882 1894 types. Another suggestion by Matthew.
1883 1895 (magic_whos): Added memory summaries in kb and Mb for arrays.
1884 1896 (magic_who): Improve formatting (break lines every 9 vars).
1885 1897
1886 1898 2004-11-28 Fernando Perez <fperez@colorado.edu>
1887 1899
1888 1900 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1889 1901 cache when empty lines were present.
1890 1902
1891 1903 2004-11-24 Fernando Perez <fperez@colorado.edu>
1892 1904
1893 1905 * IPython/usage.py (__doc__): document the re-activated threading
1894 1906 options for WX and GTK.
1895 1907
1896 1908 2004-11-23 Fernando Perez <fperez@colorado.edu>
1897 1909
1898 1910 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1899 1911 the -wthread and -gthread options, along with a new -tk one to try
1900 1912 and coordinate Tk threading with wx/gtk. The tk support is very
1901 1913 platform dependent, since it seems to require Tcl and Tk to be
1902 1914 built with threads (Fedora1/2 appears NOT to have it, but in
1903 1915 Prabhu's Debian boxes it works OK). But even with some Tk
1904 1916 limitations, this is a great improvement.
1905 1917
1906 1918 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1907 1919 info in user prompts. Patch by Prabhu.
1908 1920
1909 1921 2004-11-18 Fernando Perez <fperez@colorado.edu>
1910 1922
1911 1923 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1912 1924 EOFErrors and bail, to avoid infinite loops if a non-terminating
1913 1925 file is fed into ipython. Patch submitted in issue 19 by user,
1914 1926 many thanks.
1915 1927
1916 1928 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1917 1929 autoquote/parens in continuation prompts, which can cause lots of
1918 1930 problems. Closes roundup issue 20.
1919 1931
1920 1932 2004-11-17 Fernando Perez <fperez@colorado.edu>
1921 1933
1922 1934 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1923 1935 reported as debian bug #280505. I'm not sure my local changelog
1924 1936 entry has the proper debian format (Jack?).
1925 1937
1926 1938 2004-11-08 *** Released version 0.6.4
1927 1939
1928 1940 2004-11-08 Fernando Perez <fperez@colorado.edu>
1929 1941
1930 1942 * IPython/iplib.py (init_readline): Fix exit message for Windows
1931 1943 when readline is active. Thanks to a report by Eric Jones
1932 1944 <eric-AT-enthought.com>.
1933 1945
1934 1946 2004-11-07 Fernando Perez <fperez@colorado.edu>
1935 1947
1936 1948 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1937 1949 sometimes seen by win2k/cygwin users.
1938 1950
1939 1951 2004-11-06 Fernando Perez <fperez@colorado.edu>
1940 1952
1941 1953 * IPython/iplib.py (interact): Change the handling of %Exit from
1942 1954 trying to propagate a SystemExit to an internal ipython flag.
1943 1955 This is less elegant than using Python's exception mechanism, but
1944 1956 I can't get that to work reliably with threads, so under -pylab
1945 1957 %Exit was hanging IPython. Cross-thread exception handling is
1946 1958 really a bitch. Thaks to a bug report by Stephen Walton
1947 1959 <stephen.walton-AT-csun.edu>.
1948 1960
1949 1961 2004-11-04 Fernando Perez <fperez@colorado.edu>
1950 1962
1951 1963 * IPython/iplib.py (raw_input_original): store a pointer to the
1952 1964 true raw_input to harden against code which can modify it
1953 1965 (wx.py.PyShell does this and would otherwise crash ipython).
1954 1966 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1955 1967
1956 1968 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1957 1969 Ctrl-C problem, which does not mess up the input line.
1958 1970
1959 1971 2004-11-03 Fernando Perez <fperez@colorado.edu>
1960 1972
1961 1973 * IPython/Release.py: Changed licensing to BSD, in all files.
1962 1974 (name): lowercase name for tarball/RPM release.
1963 1975
1964 1976 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1965 1977 use throughout ipython.
1966 1978
1967 1979 * IPython/Magic.py (Magic._ofind): Switch to using the new
1968 1980 OInspect.getdoc() function.
1969 1981
1970 1982 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1971 1983 of the line currently being canceled via Ctrl-C. It's extremely
1972 1984 ugly, but I don't know how to do it better (the problem is one of
1973 1985 handling cross-thread exceptions).
1974 1986
1975 1987 2004-10-28 Fernando Perez <fperez@colorado.edu>
1976 1988
1977 1989 * IPython/Shell.py (signal_handler): add signal handlers to trap
1978 1990 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1979 1991 report by Francesc Alted.
1980 1992
1981 1993 2004-10-21 Fernando Perez <fperez@colorado.edu>
1982 1994
1983 1995 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1984 1996 to % for pysh syntax extensions.
1985 1997
1986 1998 2004-10-09 Fernando Perez <fperez@colorado.edu>
1987 1999
1988 2000 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1989 2001 arrays to print a more useful summary, without calling str(arr).
1990 2002 This avoids the problem of extremely lengthy computations which
1991 2003 occur if arr is large, and appear to the user as a system lockup
1992 2004 with 100% cpu activity. After a suggestion by Kristian Sandberg
1993 2005 <Kristian.Sandberg@colorado.edu>.
1994 2006 (Magic.__init__): fix bug in global magic escapes not being
1995 2007 correctly set.
1996 2008
1997 2009 2004-10-08 Fernando Perez <fperez@colorado.edu>
1998 2010
1999 2011 * IPython/Magic.py (__license__): change to absolute imports of
2000 2012 ipython's own internal packages, to start adapting to the absolute
2001 2013 import requirement of PEP-328.
2002 2014
2003 2015 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2004 2016 files, and standardize author/license marks through the Release
2005 2017 module instead of having per/file stuff (except for files with
2006 2018 particular licenses, like the MIT/PSF-licensed codes).
2007 2019
2008 2020 * IPython/Debugger.py: remove dead code for python 2.1
2009 2021
2010 2022 2004-10-04 Fernando Perez <fperez@colorado.edu>
2011 2023
2012 2024 * IPython/iplib.py (ipmagic): New function for accessing magics
2013 2025 via a normal python function call.
2014 2026
2015 2027 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2016 2028 from '@' to '%', to accomodate the new @decorator syntax of python
2017 2029 2.4.
2018 2030
2019 2031 2004-09-29 Fernando Perez <fperez@colorado.edu>
2020 2032
2021 2033 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2022 2034 matplotlib.use to prevent running scripts which try to switch
2023 2035 interactive backends from within ipython. This will just crash
2024 2036 the python interpreter, so we can't allow it (but a detailed error
2025 2037 is given to the user).
2026 2038
2027 2039 2004-09-28 Fernando Perez <fperez@colorado.edu>
2028 2040
2029 2041 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2030 2042 matplotlib-related fixes so that using @run with non-matplotlib
2031 2043 scripts doesn't pop up spurious plot windows. This requires
2032 2044 matplotlib >= 0.63, where I had to make some changes as well.
2033 2045
2034 2046 * IPython/ipmaker.py (make_IPython): update version requirement to
2035 2047 python 2.2.
2036 2048
2037 2049 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2038 2050 banner arg for embedded customization.
2039 2051
2040 2052 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2041 2053 explicit uses of __IP as the IPython's instance name. Now things
2042 2054 are properly handled via the shell.name value. The actual code
2043 2055 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2044 2056 is much better than before. I'll clean things completely when the
2045 2057 magic stuff gets a real overhaul.
2046 2058
2047 2059 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2048 2060 minor changes to debian dir.
2049 2061
2050 2062 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2051 2063 pointer to the shell itself in the interactive namespace even when
2052 2064 a user-supplied dict is provided. This is needed for embedding
2053 2065 purposes (found by tests with Michel Sanner).
2054 2066
2055 2067 2004-09-27 Fernando Perez <fperez@colorado.edu>
2056 2068
2057 2069 * IPython/UserConfig/ipythonrc: remove []{} from
2058 2070 readline_remove_delims, so that things like [modname.<TAB> do
2059 2071 proper completion. This disables [].TAB, but that's a less common
2060 2072 case than module names in list comprehensions, for example.
2061 2073 Thanks to a report by Andrea Riciputi.
2062 2074
2063 2075 2004-09-09 Fernando Perez <fperez@colorado.edu>
2064 2076
2065 2077 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
2066 2078 blocking problems in win32 and osx. Fix by John.
2067 2079
2068 2080 2004-09-08 Fernando Perez <fperez@colorado.edu>
2069 2081
2070 2082 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
2071 2083 for Win32 and OSX. Fix by John Hunter.
2072 2084
2073 2085 2004-08-30 *** Released version 0.6.3
2074 2086
2075 2087 2004-08-30 Fernando Perez <fperez@colorado.edu>
2076 2088
2077 2089 * setup.py (isfile): Add manpages to list of dependent files to be
2078 2090 updated.
2079 2091
2080 2092 2004-08-27 Fernando Perez <fperez@colorado.edu>
2081 2093
2082 2094 * IPython/Shell.py (start): I've disabled -wthread and -gthread
2083 2095 for now. They don't really work with standalone WX/GTK code
2084 2096 (though matplotlib IS working fine with both of those backends).
2085 2097 This will neeed much more testing. I disabled most things with
2086 2098 comments, so turning it back on later should be pretty easy.
2087 2099
2088 2100 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
2089 2101 autocalling of expressions like r'foo', by modifying the line
2090 2102 split regexp. Closes
2091 2103 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
2092 2104 Riley <ipythonbugs-AT-sabi.net>.
2093 2105 (InteractiveShell.mainloop): honor --nobanner with banner
2094 2106 extensions.
2095 2107
2096 2108 * IPython/Shell.py: Significant refactoring of all classes, so
2097 2109 that we can really support ALL matplotlib backends and threading
2098 2110 models (John spotted a bug with Tk which required this). Now we
2099 2111 should support single-threaded, WX-threads and GTK-threads, both
2100 2112 for generic code and for matplotlib.
2101 2113
2102 2114 * IPython/ipmaker.py (__call__): Changed -mpthread option to
2103 2115 -pylab, to simplify things for users. Will also remove the pylab
2104 2116 profile, since now all of matplotlib configuration is directly
2105 2117 handled here. This also reduces startup time.
2106 2118
2107 2119 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
2108 2120 shell wasn't being correctly called. Also in IPShellWX.
2109 2121
2110 2122 * IPython/iplib.py (InteractiveShell.__init__): Added option to
2111 2123 fine-tune banner.
2112 2124
2113 2125 * IPython/numutils.py (spike): Deprecate these spike functions,
2114 2126 delete (long deprecated) gnuplot_exec handler.
2115 2127
2116 2128 2004-08-26 Fernando Perez <fperez@colorado.edu>
2117 2129
2118 2130 * ipython.1: Update for threading options, plus some others which
2119 2131 were missing.
2120 2132
2121 2133 * IPython/ipmaker.py (__call__): Added -wthread option for
2122 2134 wxpython thread handling. Make sure threading options are only
2123 2135 valid at the command line.
2124 2136
2125 2137 * scripts/ipython: moved shell selection into a factory function
2126 2138 in Shell.py, to keep the starter script to a minimum.
2127 2139
2128 2140 2004-08-25 Fernando Perez <fperez@colorado.edu>
2129 2141
2130 2142 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
2131 2143 John. Along with some recent changes he made to matplotlib, the
2132 2144 next versions of both systems should work very well together.
2133 2145
2134 2146 2004-08-24 Fernando Perez <fperez@colorado.edu>
2135 2147
2136 2148 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
2137 2149 tried to switch the profiling to using hotshot, but I'm getting
2138 2150 strange errors from prof.runctx() there. I may be misreading the
2139 2151 docs, but it looks weird. For now the profiling code will
2140 2152 continue to use the standard profiler.
2141 2153
2142 2154 2004-08-23 Fernando Perez <fperez@colorado.edu>
2143 2155
2144 2156 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
2145 2157 threaded shell, by John Hunter. It's not quite ready yet, but
2146 2158 close.
2147 2159
2148 2160 2004-08-22 Fernando Perez <fperez@colorado.edu>
2149 2161
2150 2162 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
2151 2163 in Magic and ultraTB.
2152 2164
2153 2165 * ipython.1: document threading options in manpage.
2154 2166
2155 2167 * scripts/ipython: Changed name of -thread option to -gthread,
2156 2168 since this is GTK specific. I want to leave the door open for a
2157 2169 -wthread option for WX, which will most likely be necessary. This
2158 2170 change affects usage and ipmaker as well.
2159 2171
2160 2172 * IPython/Shell.py (matplotlib_shell): Add a factory function to
2161 2173 handle the matplotlib shell issues. Code by John Hunter
2162 2174 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2163 2175 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
2164 2176 broken (and disabled for end users) for now, but it puts the
2165 2177 infrastructure in place.
2166 2178
2167 2179 2004-08-21 Fernando Perez <fperez@colorado.edu>
2168 2180
2169 2181 * ipythonrc-pylab: Add matplotlib support.
2170 2182
2171 2183 * matplotlib_config.py: new files for matplotlib support, part of
2172 2184 the pylab profile.
2173 2185
2174 2186 * IPython/usage.py (__doc__): documented the threading options.
2175 2187
2176 2188 2004-08-20 Fernando Perez <fperez@colorado.edu>
2177 2189
2178 2190 * ipython: Modified the main calling routine to handle the -thread
2179 2191 and -mpthread options. This needs to be done as a top-level hack,
2180 2192 because it determines which class to instantiate for IPython
2181 2193 itself.
2182 2194
2183 2195 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
2184 2196 classes to support multithreaded GTK operation without blocking,
2185 2197 and matplotlib with all backends. This is a lot of still very
2186 2198 experimental code, and threads are tricky. So it may still have a
2187 2199 few rough edges... This code owes a lot to
2188 2200 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
2189 2201 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
2190 2202 to John Hunter for all the matplotlib work.
2191 2203
2192 2204 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
2193 2205 options for gtk thread and matplotlib support.
2194 2206
2195 2207 2004-08-16 Fernando Perez <fperez@colorado.edu>
2196 2208
2197 2209 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
2198 2210 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
2199 2211 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
2200 2212
2201 2213 2004-08-11 Fernando Perez <fperez@colorado.edu>
2202 2214
2203 2215 * setup.py (isfile): Fix build so documentation gets updated for
2204 2216 rpms (it was only done for .tgz builds).
2205 2217
2206 2218 2004-08-10 Fernando Perez <fperez@colorado.edu>
2207 2219
2208 2220 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
2209 2221
2210 2222 * iplib.py : Silence syntax error exceptions in tab-completion.
2211 2223
2212 2224 2004-08-05 Fernando Perez <fperez@colorado.edu>
2213 2225
2214 2226 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
2215 2227 'color off' mark for continuation prompts. This was causing long
2216 2228 continuation lines to mis-wrap.
2217 2229
2218 2230 2004-08-01 Fernando Perez <fperez@colorado.edu>
2219 2231
2220 2232 * IPython/ipmaker.py (make_IPython): Allow the shell class used
2221 2233 for building ipython to be a parameter. All this is necessary
2222 2234 right now to have a multithreaded version, but this insane
2223 2235 non-design will be cleaned up soon. For now, it's a hack that
2224 2236 works.
2225 2237
2226 2238 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
2227 2239 args in various places. No bugs so far, but it's a dangerous
2228 2240 practice.
2229 2241
2230 2242 2004-07-31 Fernando Perez <fperez@colorado.edu>
2231 2243
2232 2244 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
2233 2245 fix completion of files with dots in their names under most
2234 2246 profiles (pysh was OK because the completion order is different).
2235 2247
2236 2248 2004-07-27 Fernando Perez <fperez@colorado.edu>
2237 2249
2238 2250 * IPython/iplib.py (InteractiveShell.__init__): build dict of
2239 2251 keywords manually, b/c the one in keyword.py was removed in python
2240 2252 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
2241 2253 This is NOT a bug under python 2.3 and earlier.
2242 2254
2243 2255 2004-07-26 Fernando Perez <fperez@colorado.edu>
2244 2256
2245 2257 * IPython/ultraTB.py (VerboseTB.text): Add another
2246 2258 linecache.checkcache() call to try to prevent inspect.py from
2247 2259 crashing under python 2.3. I think this fixes
2248 2260 http://www.scipy.net/roundup/ipython/issue17.
2249 2261
2250 2262 2004-07-26 *** Released version 0.6.2
2251 2263
2252 2264 2004-07-26 Fernando Perez <fperez@colorado.edu>
2253 2265
2254 2266 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
2255 2267 fail for any number.
2256 2268 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
2257 2269 empty bookmarks.
2258 2270
2259 2271 2004-07-26 *** Released version 0.6.1
2260 2272
2261 2273 2004-07-26 Fernando Perez <fperez@colorado.edu>
2262 2274
2263 2275 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
2264 2276
2265 2277 * IPython/iplib.py (protect_filename): Applied Ville's patch for
2266 2278 escaping '()[]{}' in filenames.
2267 2279
2268 2280 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
2269 2281 Python 2.2 users who lack a proper shlex.split.
2270 2282
2271 2283 2004-07-19 Fernando Perez <fperez@colorado.edu>
2272 2284
2273 2285 * IPython/iplib.py (InteractiveShell.init_readline): Add support
2274 2286 for reading readline's init file. I follow the normal chain:
2275 2287 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
2276 2288 report by Mike Heeter. This closes
2277 2289 http://www.scipy.net/roundup/ipython/issue16.
2278 2290
2279 2291 2004-07-18 Fernando Perez <fperez@colorado.edu>
2280 2292
2281 2293 * IPython/iplib.py (__init__): Add better handling of '\' under
2282 2294 Win32 for filenames. After a patch by Ville.
2283 2295
2284 2296 2004-07-17 Fernando Perez <fperez@colorado.edu>
2285 2297
2286 2298 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2287 2299 autocalling would be triggered for 'foo is bar' if foo is
2288 2300 callable. I also cleaned up the autocall detection code to use a
2289 2301 regexp, which is faster. Bug reported by Alexander Schmolck.
2290 2302
2291 2303 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
2292 2304 '?' in them would confuse the help system. Reported by Alex
2293 2305 Schmolck.
2294 2306
2295 2307 2004-07-16 Fernando Perez <fperez@colorado.edu>
2296 2308
2297 2309 * IPython/GnuplotInteractive.py (__all__): added plot2.
2298 2310
2299 2311 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
2300 2312 plotting dictionaries, lists or tuples of 1d arrays.
2301 2313
2302 2314 * IPython/Magic.py (Magic.magic_hist): small clenaups and
2303 2315 optimizations.
2304 2316
2305 2317 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
2306 2318 the information which was there from Janko's original IPP code:
2307 2319
2308 2320 03.05.99 20:53 porto.ifm.uni-kiel.de
2309 2321 --Started changelog.
2310 2322 --make clear do what it say it does
2311 2323 --added pretty output of lines from inputcache
2312 2324 --Made Logger a mixin class, simplifies handling of switches
2313 2325 --Added own completer class. .string<TAB> expands to last history
2314 2326 line which starts with string. The new expansion is also present
2315 2327 with Ctrl-r from the readline library. But this shows, who this
2316 2328 can be done for other cases.
2317 2329 --Added convention that all shell functions should accept a
2318 2330 parameter_string This opens the door for different behaviour for
2319 2331 each function. @cd is a good example of this.
2320 2332
2321 2333 04.05.99 12:12 porto.ifm.uni-kiel.de
2322 2334 --added logfile rotation
2323 2335 --added new mainloop method which freezes first the namespace
2324 2336
2325 2337 07.05.99 21:24 porto.ifm.uni-kiel.de
2326 2338 --added the docreader classes. Now there is a help system.
2327 2339 -This is only a first try. Currently it's not easy to put new
2328 2340 stuff in the indices. But this is the way to go. Info would be
2329 2341 better, but HTML is every where and not everybody has an info
2330 2342 system installed and it's not so easy to change html-docs to info.
2331 2343 --added global logfile option
2332 2344 --there is now a hook for object inspection method pinfo needs to
2333 2345 be provided for this. Can be reached by two '??'.
2334 2346
2335 2347 08.05.99 20:51 porto.ifm.uni-kiel.de
2336 2348 --added a README
2337 2349 --bug in rc file. Something has changed so functions in the rc
2338 2350 file need to reference the shell and not self. Not clear if it's a
2339 2351 bug or feature.
2340 2352 --changed rc file for new behavior
2341 2353
2342 2354 2004-07-15 Fernando Perez <fperez@colorado.edu>
2343 2355
2344 2356 * IPython/Logger.py (Logger.log): fixed recent bug where the input
2345 2357 cache was falling out of sync in bizarre manners when multi-line
2346 2358 input was present. Minor optimizations and cleanup.
2347 2359
2348 2360 (Logger): Remove old Changelog info for cleanup. This is the
2349 2361 information which was there from Janko's original code:
2350 2362
2351 2363 Changes to Logger: - made the default log filename a parameter
2352 2364
2353 2365 - put a check for lines beginning with !@? in log(). Needed
2354 2366 (even if the handlers properly log their lines) for mid-session
2355 2367 logging activation to work properly. Without this, lines logged
2356 2368 in mid session, which get read from the cache, would end up
2357 2369 'bare' (with !@? in the open) in the log. Now they are caught
2358 2370 and prepended with a #.
2359 2371
2360 2372 * IPython/iplib.py (InteractiveShell.init_readline): added check
2361 2373 in case MagicCompleter fails to be defined, so we don't crash.
2362 2374
2363 2375 2004-07-13 Fernando Perez <fperez@colorado.edu>
2364 2376
2365 2377 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
2366 2378 of EPS if the requested filename ends in '.eps'.
2367 2379
2368 2380 2004-07-04 Fernando Perez <fperez@colorado.edu>
2369 2381
2370 2382 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
2371 2383 escaping of quotes when calling the shell.
2372 2384
2373 2385 2004-07-02 Fernando Perez <fperez@colorado.edu>
2374 2386
2375 2387 * IPython/Prompts.py (CachedOutput.update): Fix problem with
2376 2388 gettext not working because we were clobbering '_'. Fixes
2377 2389 http://www.scipy.net/roundup/ipython/issue6.
2378 2390
2379 2391 2004-07-01 Fernando Perez <fperez@colorado.edu>
2380 2392
2381 2393 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
2382 2394 into @cd. Patch by Ville.
2383 2395
2384 2396 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2385 2397 new function to store things after ipmaker runs. Patch by Ville.
2386 2398 Eventually this will go away once ipmaker is removed and the class
2387 2399 gets cleaned up, but for now it's ok. Key functionality here is
2388 2400 the addition of the persistent storage mechanism, a dict for
2389 2401 keeping data across sessions (for now just bookmarks, but more can
2390 2402 be implemented later).
2391 2403
2392 2404 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2393 2405 persistent across sections. Patch by Ville, I modified it
2394 2406 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2395 2407 added a '-l' option to list all bookmarks.
2396 2408
2397 2409 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2398 2410 center for cleanup. Registered with atexit.register(). I moved
2399 2411 here the old exit_cleanup(). After a patch by Ville.
2400 2412
2401 2413 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2402 2414 characters in the hacked shlex_split for python 2.2.
2403 2415
2404 2416 * IPython/iplib.py (file_matches): more fixes to filenames with
2405 2417 whitespace in them. It's not perfect, but limitations in python's
2406 2418 readline make it impossible to go further.
2407 2419
2408 2420 2004-06-29 Fernando Perez <fperez@colorado.edu>
2409 2421
2410 2422 * IPython/iplib.py (file_matches): escape whitespace correctly in
2411 2423 filename completions. Bug reported by Ville.
2412 2424
2413 2425 2004-06-28 Fernando Perez <fperez@colorado.edu>
2414 2426
2415 2427 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
2416 2428 the history file will be called 'history-PROFNAME' (or just
2417 2429 'history' if no profile is loaded). I was getting annoyed at
2418 2430 getting my Numerical work history clobbered by pysh sessions.
2419 2431
2420 2432 * IPython/iplib.py (InteractiveShell.__init__): Internal
2421 2433 getoutputerror() function so that we can honor the system_verbose
2422 2434 flag for _all_ system calls. I also added escaping of #
2423 2435 characters here to avoid confusing Itpl.
2424 2436
2425 2437 * IPython/Magic.py (shlex_split): removed call to shell in
2426 2438 parse_options and replaced it with shlex.split(). The annoying
2427 2439 part was that in Python 2.2, shlex.split() doesn't exist, so I had
2428 2440 to backport it from 2.3, with several frail hacks (the shlex
2429 2441 module is rather limited in 2.2). Thanks to a suggestion by Ville
2430 2442 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
2431 2443 problem.
2432 2444
2433 2445 (Magic.magic_system_verbose): new toggle to print the actual
2434 2446 system calls made by ipython. Mainly for debugging purposes.
2435 2447
2436 2448 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
2437 2449 doesn't support persistence. Reported (and fix suggested) by
2438 2450 Travis Caldwell <travis_caldwell2000@yahoo.com>.
2439 2451
2440 2452 2004-06-26 Fernando Perez <fperez@colorado.edu>
2441 2453
2442 2454 * IPython/Logger.py (Logger.log): fix to handle correctly empty
2443 2455 continue prompts.
2444 2456
2445 2457 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
2446 2458 function (basically a big docstring) and a few more things here to
2447 2459 speedup startup. pysh.py is now very lightweight. We want because
2448 2460 it gets execfile'd, while InterpreterExec gets imported, so
2449 2461 byte-compilation saves time.
2450 2462
2451 2463 2004-06-25 Fernando Perez <fperez@colorado.edu>
2452 2464
2453 2465 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
2454 2466 -NUM', which was recently broken.
2455 2467
2456 2468 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
2457 2469 in multi-line input (but not !!, which doesn't make sense there).
2458 2470
2459 2471 * IPython/UserConfig/ipythonrc: made autoindent on by default.
2460 2472 It's just too useful, and people can turn it off in the less
2461 2473 common cases where it's a problem.
2462 2474
2463 2475 2004-06-24 Fernando Perez <fperez@colorado.edu>
2464 2476
2465 2477 * IPython/iplib.py (InteractiveShell._prefilter): big change -
2466 2478 special syntaxes (like alias calling) is now allied in multi-line
2467 2479 input. This is still _very_ experimental, but it's necessary for
2468 2480 efficient shell usage combining python looping syntax with system
2469 2481 calls. For now it's restricted to aliases, I don't think it
2470 2482 really even makes sense to have this for magics.
2471 2483
2472 2484 2004-06-23 Fernando Perez <fperez@colorado.edu>
2473 2485
2474 2486 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
2475 2487 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
2476 2488
2477 2489 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
2478 2490 extensions under Windows (after code sent by Gary Bishop). The
2479 2491 extensions considered 'executable' are stored in IPython's rc
2480 2492 structure as win_exec_ext.
2481 2493
2482 2494 * IPython/genutils.py (shell): new function, like system() but
2483 2495 without return value. Very useful for interactive shell work.
2484 2496
2485 2497 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
2486 2498 delete aliases.
2487 2499
2488 2500 * IPython/iplib.py (InteractiveShell.alias_table_update): make
2489 2501 sure that the alias table doesn't contain python keywords.
2490 2502
2491 2503 2004-06-21 Fernando Perez <fperez@colorado.edu>
2492 2504
2493 2505 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
2494 2506 non-existent items are found in $PATH. Reported by Thorsten.
2495 2507
2496 2508 2004-06-20 Fernando Perez <fperez@colorado.edu>
2497 2509
2498 2510 * IPython/iplib.py (complete): modified the completer so that the
2499 2511 order of priorities can be easily changed at runtime.
2500 2512
2501 2513 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
2502 2514 Modified to auto-execute all lines beginning with '~', '/' or '.'.
2503 2515
2504 2516 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
2505 2517 expand Python variables prepended with $ in all system calls. The
2506 2518 same was done to InteractiveShell.handle_shell_escape. Now all
2507 2519 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
2508 2520 expansion of python variables and expressions according to the
2509 2521 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
2510 2522
2511 2523 Though PEP-215 has been rejected, a similar (but simpler) one
2512 2524 seems like it will go into Python 2.4, PEP-292 -
2513 2525 http://www.python.org/peps/pep-0292.html.
2514 2526
2515 2527 I'll keep the full syntax of PEP-215, since IPython has since the
2516 2528 start used Ka-Ping Yee's reference implementation discussed there
2517 2529 (Itpl), and I actually like the powerful semantics it offers.
2518 2530
2519 2531 In order to access normal shell variables, the $ has to be escaped
2520 2532 via an extra $. For example:
2521 2533
2522 2534 In [7]: PATH='a python variable'
2523 2535
2524 2536 In [8]: !echo $PATH
2525 2537 a python variable
2526 2538
2527 2539 In [9]: !echo $$PATH
2528 2540 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2529 2541
2530 2542 (Magic.parse_options): escape $ so the shell doesn't evaluate
2531 2543 things prematurely.
2532 2544
2533 2545 * IPython/iplib.py (InteractiveShell.call_alias): added the
2534 2546 ability for aliases to expand python variables via $.
2535 2547
2536 2548 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
2537 2549 system, now there's a @rehash/@rehashx pair of magics. These work
2538 2550 like the csh rehash command, and can be invoked at any time. They
2539 2551 build a table of aliases to everything in the user's $PATH
2540 2552 (@rehash uses everything, @rehashx is slower but only adds
2541 2553 executable files). With this, the pysh.py-based shell profile can
2542 2554 now simply call rehash upon startup, and full access to all
2543 2555 programs in the user's path is obtained.
2544 2556
2545 2557 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
2546 2558 functionality is now fully in place. I removed the old dynamic
2547 2559 code generation based approach, in favor of a much lighter one
2548 2560 based on a simple dict. The advantage is that this allows me to
2549 2561 now have thousands of aliases with negligible cost (unthinkable
2550 2562 with the old system).
2551 2563
2552 2564 2004-06-19 Fernando Perez <fperez@colorado.edu>
2553 2565
2554 2566 * IPython/iplib.py (__init__): extended MagicCompleter class to
2555 2567 also complete (last in priority) on user aliases.
2556 2568
2557 2569 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
2558 2570 call to eval.
2559 2571 (ItplNS.__init__): Added a new class which functions like Itpl,
2560 2572 but allows configuring the namespace for the evaluation to occur
2561 2573 in.
2562 2574
2563 2575 2004-06-18 Fernando Perez <fperez@colorado.edu>
2564 2576
2565 2577 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
2566 2578 better message when 'exit' or 'quit' are typed (a common newbie
2567 2579 confusion).
2568 2580
2569 2581 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
2570 2582 check for Windows users.
2571 2583
2572 2584 * IPython/iplib.py (InteractiveShell.user_setup): removed
2573 2585 disabling of colors for Windows. I'll test at runtime and issue a
2574 2586 warning if Gary's readline isn't found, as to nudge users to
2575 2587 download it.
2576 2588
2577 2589 2004-06-16 Fernando Perez <fperez@colorado.edu>
2578 2590
2579 2591 * IPython/genutils.py (Stream.__init__): changed to print errors
2580 2592 to sys.stderr. I had a circular dependency here. Now it's
2581 2593 possible to run ipython as IDLE's shell (consider this pre-alpha,
2582 2594 since true stdout things end up in the starting terminal instead
2583 2595 of IDLE's out).
2584 2596
2585 2597 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2586 2598 users who haven't # updated their prompt_in2 definitions. Remove
2587 2599 eventually.
2588 2600 (multiple_replace): added credit to original ASPN recipe.
2589 2601
2590 2602 2004-06-15 Fernando Perez <fperez@colorado.edu>
2591 2603
2592 2604 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2593 2605 list of auto-defined aliases.
2594 2606
2595 2607 2004-06-13 Fernando Perez <fperez@colorado.edu>
2596 2608
2597 2609 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2598 2610 install was really requested (so setup.py can be used for other
2599 2611 things under Windows).
2600 2612
2601 2613 2004-06-10 Fernando Perez <fperez@colorado.edu>
2602 2614
2603 2615 * IPython/Logger.py (Logger.create_log): Manually remove any old
2604 2616 backup, since os.remove may fail under Windows. Fixes bug
2605 2617 reported by Thorsten.
2606 2618
2607 2619 2004-06-09 Fernando Perez <fperez@colorado.edu>
2608 2620
2609 2621 * examples/example-embed.py: fixed all references to %n (replaced
2610 2622 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2611 2623 for all examples and the manual as well.
2612 2624
2613 2625 2004-06-08 Fernando Perez <fperez@colorado.edu>
2614 2626
2615 2627 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2616 2628 alignment and color management. All 3 prompt subsystems now
2617 2629 inherit from BasePrompt.
2618 2630
2619 2631 * tools/release: updates for windows installer build and tag rpms
2620 2632 with python version (since paths are fixed).
2621 2633
2622 2634 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2623 2635 which will become eventually obsolete. Also fixed the default
2624 2636 prompt_in2 to use \D, so at least new users start with the correct
2625 2637 defaults.
2626 2638 WARNING: Users with existing ipythonrc files will need to apply
2627 2639 this fix manually!
2628 2640
2629 2641 * setup.py: make windows installer (.exe). This is finally the
2630 2642 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2631 2643 which I hadn't included because it required Python 2.3 (or recent
2632 2644 distutils).
2633 2645
2634 2646 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2635 2647 usage of new '\D' escape.
2636 2648
2637 2649 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2638 2650 lacks os.getuid())
2639 2651 (CachedOutput.set_colors): Added the ability to turn coloring
2640 2652 on/off with @colors even for manually defined prompt colors. It
2641 2653 uses a nasty global, but it works safely and via the generic color
2642 2654 handling mechanism.
2643 2655 (Prompt2.__init__): Introduced new escape '\D' for continuation
2644 2656 prompts. It represents the counter ('\#') as dots.
2645 2657 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2646 2658 need to update their ipythonrc files and replace '%n' with '\D' in
2647 2659 their prompt_in2 settings everywhere. Sorry, but there's
2648 2660 otherwise no clean way to get all prompts to properly align. The
2649 2661 ipythonrc shipped with IPython has been updated.
2650 2662
2651 2663 2004-06-07 Fernando Perez <fperez@colorado.edu>
2652 2664
2653 2665 * setup.py (isfile): Pass local_icons option to latex2html, so the
2654 2666 resulting HTML file is self-contained. Thanks to
2655 2667 dryice-AT-liu.com.cn for the tip.
2656 2668
2657 2669 * pysh.py: I created a new profile 'shell', which implements a
2658 2670 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2659 2671 system shell, nor will it become one anytime soon. It's mainly
2660 2672 meant to illustrate the use of the new flexible bash-like prompts.
2661 2673 I guess it could be used by hardy souls for true shell management,
2662 2674 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2663 2675 profile. This uses the InterpreterExec extension provided by
2664 2676 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2665 2677
2666 2678 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2667 2679 auto-align itself with the length of the previous input prompt
2668 2680 (taking into account the invisible color escapes).
2669 2681 (CachedOutput.__init__): Large restructuring of this class. Now
2670 2682 all three prompts (primary1, primary2, output) are proper objects,
2671 2683 managed by the 'parent' CachedOutput class. The code is still a
2672 2684 bit hackish (all prompts share state via a pointer to the cache),
2673 2685 but it's overall far cleaner than before.
2674 2686
2675 2687 * IPython/genutils.py (getoutputerror): modified to add verbose,
2676 2688 debug and header options. This makes the interface of all getout*
2677 2689 functions uniform.
2678 2690 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2679 2691
2680 2692 * IPython/Magic.py (Magic.default_option): added a function to
2681 2693 allow registering default options for any magic command. This
2682 2694 makes it easy to have profiles which customize the magics globally
2683 2695 for a certain use. The values set through this function are
2684 2696 picked up by the parse_options() method, which all magics should
2685 2697 use to parse their options.
2686 2698
2687 2699 * IPython/genutils.py (warn): modified the warnings framework to
2688 2700 use the Term I/O class. I'm trying to slowly unify all of
2689 2701 IPython's I/O operations to pass through Term.
2690 2702
2691 2703 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2692 2704 the secondary prompt to correctly match the length of the primary
2693 2705 one for any prompt. Now multi-line code will properly line up
2694 2706 even for path dependent prompts, such as the new ones available
2695 2707 via the prompt_specials.
2696 2708
2697 2709 2004-06-06 Fernando Perez <fperez@colorado.edu>
2698 2710
2699 2711 * IPython/Prompts.py (prompt_specials): Added the ability to have
2700 2712 bash-like special sequences in the prompts, which get
2701 2713 automatically expanded. Things like hostname, current working
2702 2714 directory and username are implemented already, but it's easy to
2703 2715 add more in the future. Thanks to a patch by W.J. van der Laan
2704 2716 <gnufnork-AT-hetdigitalegat.nl>
2705 2717 (prompt_specials): Added color support for prompt strings, so
2706 2718 users can define arbitrary color setups for their prompts.
2707 2719
2708 2720 2004-06-05 Fernando Perez <fperez@colorado.edu>
2709 2721
2710 2722 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2711 2723 code to load Gary Bishop's readline and configure it
2712 2724 automatically. Thanks to Gary for help on this.
2713 2725
2714 2726 2004-06-01 Fernando Perez <fperez@colorado.edu>
2715 2727
2716 2728 * IPython/Logger.py (Logger.create_log): fix bug for logging
2717 2729 with no filename (previous fix was incomplete).
2718 2730
2719 2731 2004-05-25 Fernando Perez <fperez@colorado.edu>
2720 2732
2721 2733 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2722 2734 parens would get passed to the shell.
2723 2735
2724 2736 2004-05-20 Fernando Perez <fperez@colorado.edu>
2725 2737
2726 2738 * IPython/Magic.py (Magic.magic_prun): changed default profile
2727 2739 sort order to 'time' (the more common profiling need).
2728 2740
2729 2741 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2730 2742 so that source code shown is guaranteed in sync with the file on
2731 2743 disk (also changed in psource). Similar fix to the one for
2732 2744 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2733 2745 <yann.ledu-AT-noos.fr>.
2734 2746
2735 2747 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2736 2748 with a single option would not be correctly parsed. Closes
2737 2749 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2738 2750 introduced in 0.6.0 (on 2004-05-06).
2739 2751
2740 2752 2004-05-13 *** Released version 0.6.0
2741 2753
2742 2754 2004-05-13 Fernando Perez <fperez@colorado.edu>
2743 2755
2744 2756 * debian/: Added debian/ directory to CVS, so that debian support
2745 2757 is publicly accessible. The debian package is maintained by Jack
2746 2758 Moffit <jack-AT-xiph.org>.
2747 2759
2748 2760 * Documentation: included the notes about an ipython-based system
2749 2761 shell (the hypothetical 'pysh') into the new_design.pdf document,
2750 2762 so that these ideas get distributed to users along with the
2751 2763 official documentation.
2752 2764
2753 2765 2004-05-10 Fernando Perez <fperez@colorado.edu>
2754 2766
2755 2767 * IPython/Logger.py (Logger.create_log): fix recently introduced
2756 2768 bug (misindented line) where logstart would fail when not given an
2757 2769 explicit filename.
2758 2770
2759 2771 2004-05-09 Fernando Perez <fperez@colorado.edu>
2760 2772
2761 2773 * IPython/Magic.py (Magic.parse_options): skip system call when
2762 2774 there are no options to look for. Faster, cleaner for the common
2763 2775 case.
2764 2776
2765 2777 * Documentation: many updates to the manual: describing Windows
2766 2778 support better, Gnuplot updates, credits, misc small stuff. Also
2767 2779 updated the new_design doc a bit.
2768 2780
2769 2781 2004-05-06 *** Released version 0.6.0.rc1
2770 2782
2771 2783 2004-05-06 Fernando Perez <fperez@colorado.edu>
2772 2784
2773 2785 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2774 2786 operations to use the vastly more efficient list/''.join() method.
2775 2787 (FormattedTB.text): Fix
2776 2788 http://www.scipy.net/roundup/ipython/issue12 - exception source
2777 2789 extract not updated after reload. Thanks to Mike Salib
2778 2790 <msalib-AT-mit.edu> for pinning the source of the problem.
2779 2791 Fortunately, the solution works inside ipython and doesn't require
2780 2792 any changes to python proper.
2781 2793
2782 2794 * IPython/Magic.py (Magic.parse_options): Improved to process the
2783 2795 argument list as a true shell would (by actually using the
2784 2796 underlying system shell). This way, all @magics automatically get
2785 2797 shell expansion for variables. Thanks to a comment by Alex
2786 2798 Schmolck.
2787 2799
2788 2800 2004-04-04 Fernando Perez <fperez@colorado.edu>
2789 2801
2790 2802 * IPython/iplib.py (InteractiveShell.interact): Added a special
2791 2803 trap for a debugger quit exception, which is basically impossible
2792 2804 to handle by normal mechanisms, given what pdb does to the stack.
2793 2805 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2794 2806
2795 2807 2004-04-03 Fernando Perez <fperez@colorado.edu>
2796 2808
2797 2809 * IPython/genutils.py (Term): Standardized the names of the Term
2798 2810 class streams to cin/cout/cerr, following C++ naming conventions
2799 2811 (I can't use in/out/err because 'in' is not a valid attribute
2800 2812 name).
2801 2813
2802 2814 * IPython/iplib.py (InteractiveShell.interact): don't increment
2803 2815 the prompt if there's no user input. By Daniel 'Dang' Griffith
2804 2816 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2805 2817 Francois Pinard.
2806 2818
2807 2819 2004-04-02 Fernando Perez <fperez@colorado.edu>
2808 2820
2809 2821 * IPython/genutils.py (Stream.__init__): Modified to survive at
2810 2822 least importing in contexts where stdin/out/err aren't true file
2811 2823 objects, such as PyCrust (they lack fileno() and mode). However,
2812 2824 the recovery facilities which rely on these things existing will
2813 2825 not work.
2814 2826
2815 2827 2004-04-01 Fernando Perez <fperez@colorado.edu>
2816 2828
2817 2829 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2818 2830 use the new getoutputerror() function, so it properly
2819 2831 distinguishes stdout/err.
2820 2832
2821 2833 * IPython/genutils.py (getoutputerror): added a function to
2822 2834 capture separately the standard output and error of a command.
2823 2835 After a comment from dang on the mailing lists. This code is
2824 2836 basically a modified version of commands.getstatusoutput(), from
2825 2837 the standard library.
2826 2838
2827 2839 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2828 2840 '!!' as a special syntax (shorthand) to access @sx.
2829 2841
2830 2842 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2831 2843 command and return its output as a list split on '\n'.
2832 2844
2833 2845 2004-03-31 Fernando Perez <fperez@colorado.edu>
2834 2846
2835 2847 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2836 2848 method to dictionaries used as FakeModule instances if they lack
2837 2849 it. At least pydoc in python2.3 breaks for runtime-defined
2838 2850 functions without this hack. At some point I need to _really_
2839 2851 understand what FakeModule is doing, because it's a gross hack.
2840 2852 But it solves Arnd's problem for now...
2841 2853
2842 2854 2004-02-27 Fernando Perez <fperez@colorado.edu>
2843 2855
2844 2856 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2845 2857 mode would behave erratically. Also increased the number of
2846 2858 possible logs in rotate mod to 999. Thanks to Rod Holland
2847 2859 <rhh@StructureLABS.com> for the report and fixes.
2848 2860
2849 2861 2004-02-26 Fernando Perez <fperez@colorado.edu>
2850 2862
2851 2863 * IPython/genutils.py (page): Check that the curses module really
2852 2864 has the initscr attribute before trying to use it. For some
2853 2865 reason, the Solaris curses module is missing this. I think this
2854 2866 should be considered a Solaris python bug, but I'm not sure.
2855 2867
2856 2868 2004-01-17 Fernando Perez <fperez@colorado.edu>
2857 2869
2858 2870 * IPython/genutils.py (Stream.__init__): Changes to try to make
2859 2871 ipython robust against stdin/out/err being closed by the user.
2860 2872 This is 'user error' (and blocks a normal python session, at least
2861 2873 the stdout case). However, Ipython should be able to survive such
2862 2874 instances of abuse as gracefully as possible. To simplify the
2863 2875 coding and maintain compatibility with Gary Bishop's Term
2864 2876 contributions, I've made use of classmethods for this. I think
2865 2877 this introduces a dependency on python 2.2.
2866 2878
2867 2879 2004-01-13 Fernando Perez <fperez@colorado.edu>
2868 2880
2869 2881 * IPython/numutils.py (exp_safe): simplified the code a bit and
2870 2882 removed the need for importing the kinds module altogether.
2871 2883
2872 2884 2004-01-06 Fernando Perez <fperez@colorado.edu>
2873 2885
2874 2886 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2875 2887 a magic function instead, after some community feedback. No
2876 2888 special syntax will exist for it, but its name is deliberately
2877 2889 very short.
2878 2890
2879 2891 2003-12-20 Fernando Perez <fperez@colorado.edu>
2880 2892
2881 2893 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2882 2894 new functionality, to automagically assign the result of a shell
2883 2895 command to a variable. I'll solicit some community feedback on
2884 2896 this before making it permanent.
2885 2897
2886 2898 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2887 2899 requested about callables for which inspect couldn't obtain a
2888 2900 proper argspec. Thanks to a crash report sent by Etienne
2889 2901 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2890 2902
2891 2903 2003-12-09 Fernando Perez <fperez@colorado.edu>
2892 2904
2893 2905 * IPython/genutils.py (page): patch for the pager to work across
2894 2906 various versions of Windows. By Gary Bishop.
2895 2907
2896 2908 2003-12-04 Fernando Perez <fperez@colorado.edu>
2897 2909
2898 2910 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2899 2911 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2900 2912 While I tested this and it looks ok, there may still be corner
2901 2913 cases I've missed.
2902 2914
2903 2915 2003-12-01 Fernando Perez <fperez@colorado.edu>
2904 2916
2905 2917 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2906 2918 where a line like 'p,q=1,2' would fail because the automagic
2907 2919 system would be triggered for @p.
2908 2920
2909 2921 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2910 2922 cleanups, code unmodified.
2911 2923
2912 2924 * IPython/genutils.py (Term): added a class for IPython to handle
2913 2925 output. In most cases it will just be a proxy for stdout/err, but
2914 2926 having this allows modifications to be made for some platforms,
2915 2927 such as handling color escapes under Windows. All of this code
2916 2928 was contributed by Gary Bishop, with minor modifications by me.
2917 2929 The actual changes affect many files.
2918 2930
2919 2931 2003-11-30 Fernando Perez <fperez@colorado.edu>
2920 2932
2921 2933 * IPython/iplib.py (file_matches): new completion code, courtesy
2922 2934 of Jeff Collins. This enables filename completion again under
2923 2935 python 2.3, which disabled it at the C level.
2924 2936
2925 2937 2003-11-11 Fernando Perez <fperez@colorado.edu>
2926 2938
2927 2939 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2928 2940 for Numeric.array(map(...)), but often convenient.
2929 2941
2930 2942 2003-11-05 Fernando Perez <fperez@colorado.edu>
2931 2943
2932 2944 * IPython/numutils.py (frange): Changed a call from int() to
2933 2945 int(round()) to prevent a problem reported with arange() in the
2934 2946 numpy list.
2935 2947
2936 2948 2003-10-06 Fernando Perez <fperez@colorado.edu>
2937 2949
2938 2950 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2939 2951 prevent crashes if sys lacks an argv attribute (it happens with
2940 2952 embedded interpreters which build a bare-bones sys module).
2941 2953 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2942 2954
2943 2955 2003-09-24 Fernando Perez <fperez@colorado.edu>
2944 2956
2945 2957 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2946 2958 to protect against poorly written user objects where __getattr__
2947 2959 raises exceptions other than AttributeError. Thanks to a bug
2948 2960 report by Oliver Sander <osander-AT-gmx.de>.
2949 2961
2950 2962 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2951 2963 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2952 2964
2953 2965 2003-09-09 Fernando Perez <fperez@colorado.edu>
2954 2966
2955 2967 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2956 2968 unpacking a list whith a callable as first element would
2957 2969 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2958 2970 Collins.
2959 2971
2960 2972 2003-08-25 *** Released version 0.5.0
2961 2973
2962 2974 2003-08-22 Fernando Perez <fperez@colorado.edu>
2963 2975
2964 2976 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2965 2977 improperly defined user exceptions. Thanks to feedback from Mark
2966 2978 Russell <mrussell-AT-verio.net>.
2967 2979
2968 2980 2003-08-20 Fernando Perez <fperez@colorado.edu>
2969 2981
2970 2982 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2971 2983 printing so that it would print multi-line string forms starting
2972 2984 with a new line. This way the formatting is better respected for
2973 2985 objects which work hard to make nice string forms.
2974 2986
2975 2987 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2976 2988 autocall would overtake data access for objects with both
2977 2989 __getitem__ and __call__.
2978 2990
2979 2991 2003-08-19 *** Released version 0.5.0-rc1
2980 2992
2981 2993 2003-08-19 Fernando Perez <fperez@colorado.edu>
2982 2994
2983 2995 * IPython/deep_reload.py (load_tail): single tiny change here
2984 2996 seems to fix the long-standing bug of dreload() failing to work
2985 2997 for dotted names. But this module is pretty tricky, so I may have
2986 2998 missed some subtlety. Needs more testing!.
2987 2999
2988 3000 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2989 3001 exceptions which have badly implemented __str__ methods.
2990 3002 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2991 3003 which I've been getting reports about from Python 2.3 users. I
2992 3004 wish I had a simple test case to reproduce the problem, so I could
2993 3005 either write a cleaner workaround or file a bug report if
2994 3006 necessary.
2995 3007
2996 3008 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2997 3009 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2998 3010 a bug report by Tjabo Kloppenburg.
2999 3011
3000 3012 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3001 3013 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3002 3014 seems rather unstable. Thanks to a bug report by Tjabo
3003 3015 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3004 3016
3005 3017 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3006 3018 this out soon because of the critical fixes in the inner loop for
3007 3019 generators.
3008 3020
3009 3021 * IPython/Magic.py (Magic.getargspec): removed. This (and
3010 3022 _get_def) have been obsoleted by OInspect for a long time, I
3011 3023 hadn't noticed that they were dead code.
3012 3024 (Magic._ofind): restored _ofind functionality for a few literals
3013 3025 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3014 3026 for things like "hello".capitalize?, since that would require a
3015 3027 potentially dangerous eval() again.
3016 3028
3017 3029 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3018 3030 logic a bit more to clean up the escapes handling and minimize the
3019 3031 use of _ofind to only necessary cases. The interactive 'feel' of
3020 3032 IPython should have improved quite a bit with the changes in
3021 3033 _prefilter and _ofind (besides being far safer than before).
3022 3034
3023 3035 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3024 3036 obscure, never reported). Edit would fail to find the object to
3025 3037 edit under some circumstances.
3026 3038 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3027 3039 which were causing double-calling of generators. Those eval calls
3028 3040 were _very_ dangerous, since code with side effects could be
3029 3041 triggered. As they say, 'eval is evil'... These were the
3030 3042 nastiest evals in IPython. Besides, _ofind is now far simpler,
3031 3043 and it should also be quite a bit faster. Its use of inspect is
3032 3044 also safer, so perhaps some of the inspect-related crashes I've
3033 3045 seen lately with Python 2.3 might be taken care of. That will
3034 3046 need more testing.
3035 3047
3036 3048 2003-08-17 Fernando Perez <fperez@colorado.edu>
3037 3049
3038 3050 * IPython/iplib.py (InteractiveShell._prefilter): significant
3039 3051 simplifications to the logic for handling user escapes. Faster
3040 3052 and simpler code.
3041 3053
3042 3054 2003-08-14 Fernando Perez <fperez@colorado.edu>
3043 3055
3044 3056 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3045 3057 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3046 3058 but it should be quite a bit faster. And the recursive version
3047 3059 generated O(log N) intermediate storage for all rank>1 arrays,
3048 3060 even if they were contiguous.
3049 3061 (l1norm): Added this function.
3050 3062 (norm): Added this function for arbitrary norms (including
3051 3063 l-infinity). l1 and l2 are still special cases for convenience
3052 3064 and speed.
3053 3065
3054 3066 2003-08-03 Fernando Perez <fperez@colorado.edu>
3055 3067
3056 3068 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
3057 3069 exceptions, which now raise PendingDeprecationWarnings in Python
3058 3070 2.3. There were some in Magic and some in Gnuplot2.
3059 3071
3060 3072 2003-06-30 Fernando Perez <fperez@colorado.edu>
3061 3073
3062 3074 * IPython/genutils.py (page): modified to call curses only for
3063 3075 terminals where TERM=='xterm'. After problems under many other
3064 3076 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
3065 3077
3066 3078 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
3067 3079 would be triggered when readline was absent. This was just an old
3068 3080 debugging statement I'd forgotten to take out.
3069 3081
3070 3082 2003-06-20 Fernando Perez <fperez@colorado.edu>
3071 3083
3072 3084 * IPython/genutils.py (clock): modified to return only user time
3073 3085 (not counting system time), after a discussion on scipy. While
3074 3086 system time may be a useful quantity occasionally, it may much
3075 3087 more easily be skewed by occasional swapping or other similar
3076 3088 activity.
3077 3089
3078 3090 2003-06-05 Fernando Perez <fperez@colorado.edu>
3079 3091
3080 3092 * IPython/numutils.py (identity): new function, for building
3081 3093 arbitrary rank Kronecker deltas (mostly backwards compatible with
3082 3094 Numeric.identity)
3083 3095
3084 3096 2003-06-03 Fernando Perez <fperez@colorado.edu>
3085 3097
3086 3098 * IPython/iplib.py (InteractiveShell.handle_magic): protect
3087 3099 arguments passed to magics with spaces, to allow trailing '\' to
3088 3100 work normally (mainly for Windows users).
3089 3101
3090 3102 2003-05-29 Fernando Perez <fperez@colorado.edu>
3091 3103
3092 3104 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
3093 3105 instead of pydoc.help. This fixes a bizarre behavior where
3094 3106 printing '%s' % locals() would trigger the help system. Now
3095 3107 ipython behaves like normal python does.
3096 3108
3097 3109 Note that if one does 'from pydoc import help', the bizarre
3098 3110 behavior returns, but this will also happen in normal python, so
3099 3111 it's not an ipython bug anymore (it has to do with how pydoc.help
3100 3112 is implemented).
3101 3113
3102 3114 2003-05-22 Fernando Perez <fperez@colorado.edu>
3103 3115
3104 3116 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
3105 3117 return [] instead of None when nothing matches, also match to end
3106 3118 of line. Patch by Gary Bishop.
3107 3119
3108 3120 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
3109 3121 protection as before, for files passed on the command line. This
3110 3122 prevents the CrashHandler from kicking in if user files call into
3111 3123 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
3112 3124 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
3113 3125
3114 3126 2003-05-20 *** Released version 0.4.0
3115 3127
3116 3128 2003-05-20 Fernando Perez <fperez@colorado.edu>
3117 3129
3118 3130 * setup.py: added support for manpages. It's a bit hackish b/c of
3119 3131 a bug in the way the bdist_rpm distutils target handles gzipped
3120 3132 manpages, but it works. After a patch by Jack.
3121 3133
3122 3134 2003-05-19 Fernando Perez <fperez@colorado.edu>
3123 3135
3124 3136 * IPython/numutils.py: added a mockup of the kinds module, since
3125 3137 it was recently removed from Numeric. This way, numutils will
3126 3138 work for all users even if they are missing kinds.
3127 3139
3128 3140 * IPython/Magic.py (Magic._ofind): Harden against an inspect
3129 3141 failure, which can occur with SWIG-wrapped extensions. After a
3130 3142 crash report from Prabhu.
3131 3143
3132 3144 2003-05-16 Fernando Perez <fperez@colorado.edu>
3133 3145
3134 3146 * IPython/iplib.py (InteractiveShell.excepthook): New method to
3135 3147 protect ipython from user code which may call directly
3136 3148 sys.excepthook (this looks like an ipython crash to the user, even
3137 3149 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3138 3150 This is especially important to help users of WxWindows, but may
3139 3151 also be useful in other cases.
3140 3152
3141 3153 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
3142 3154 an optional tb_offset to be specified, and to preserve exception
3143 3155 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3144 3156
3145 3157 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
3146 3158
3147 3159 2003-05-15 Fernando Perez <fperez@colorado.edu>
3148 3160
3149 3161 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
3150 3162 installing for a new user under Windows.
3151 3163
3152 3164 2003-05-12 Fernando Perez <fperez@colorado.edu>
3153 3165
3154 3166 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
3155 3167 handler for Emacs comint-based lines. Currently it doesn't do
3156 3168 much (but importantly, it doesn't update the history cache). In
3157 3169 the future it may be expanded if Alex needs more functionality
3158 3170 there.
3159 3171
3160 3172 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
3161 3173 info to crash reports.
3162 3174
3163 3175 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
3164 3176 just like Python's -c. Also fixed crash with invalid -color
3165 3177 option value at startup. Thanks to Will French
3166 3178 <wfrench-AT-bestweb.net> for the bug report.
3167 3179
3168 3180 2003-05-09 Fernando Perez <fperez@colorado.edu>
3169 3181
3170 3182 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
3171 3183 to EvalDict (it's a mapping, after all) and simplified its code
3172 3184 quite a bit, after a nice discussion on c.l.py where Gustavo
3173 3185 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
3174 3186
3175 3187 2003-04-30 Fernando Perez <fperez@colorado.edu>
3176 3188
3177 3189 * IPython/genutils.py (timings_out): modified it to reduce its
3178 3190 overhead in the common reps==1 case.
3179 3191
3180 3192 2003-04-29 Fernando Perez <fperez@colorado.edu>
3181 3193
3182 3194 * IPython/genutils.py (timings_out): Modified to use the resource
3183 3195 module, which avoids the wraparound problems of time.clock().
3184 3196
3185 3197 2003-04-17 *** Released version 0.2.15pre4
3186 3198
3187 3199 2003-04-17 Fernando Perez <fperez@colorado.edu>
3188 3200
3189 3201 * setup.py (scriptfiles): Split windows-specific stuff over to a
3190 3202 separate file, in an attempt to have a Windows GUI installer.
3191 3203 That didn't work, but part of the groundwork is done.
3192 3204
3193 3205 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
3194 3206 indent/unindent with 4 spaces. Particularly useful in combination
3195 3207 with the new auto-indent option.
3196 3208
3197 3209 2003-04-16 Fernando Perez <fperez@colorado.edu>
3198 3210
3199 3211 * IPython/Magic.py: various replacements of self.rc for
3200 3212 self.shell.rc. A lot more remains to be done to fully disentangle
3201 3213 this class from the main Shell class.
3202 3214
3203 3215 * IPython/GnuplotRuntime.py: added checks for mouse support so
3204 3216 that we don't try to enable it if the current gnuplot doesn't
3205 3217 really support it. Also added checks so that we don't try to
3206 3218 enable persist under Windows (where Gnuplot doesn't recognize the
3207 3219 option).
3208 3220
3209 3221 * IPython/iplib.py (InteractiveShell.interact): Added optional
3210 3222 auto-indenting code, after a patch by King C. Shu
3211 3223 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
3212 3224 get along well with pasting indented code. If I ever figure out
3213 3225 how to make that part go well, it will become on by default.
3214 3226
3215 3227 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
3216 3228 crash ipython if there was an unmatched '%' in the user's prompt
3217 3229 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3218 3230
3219 3231 * IPython/iplib.py (InteractiveShell.interact): removed the
3220 3232 ability to ask the user whether he wants to crash or not at the
3221 3233 'last line' exception handler. Calling functions at that point
3222 3234 changes the stack, and the error reports would have incorrect
3223 3235 tracebacks.
3224 3236
3225 3237 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
3226 3238 pass through a peger a pretty-printed form of any object. After a
3227 3239 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
3228 3240
3229 3241 2003-04-14 Fernando Perez <fperez@colorado.edu>
3230 3242
3231 3243 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
3232 3244 all files in ~ would be modified at first install (instead of
3233 3245 ~/.ipython). This could be potentially disastrous, as the
3234 3246 modification (make line-endings native) could damage binary files.
3235 3247
3236 3248 2003-04-10 Fernando Perez <fperez@colorado.edu>
3237 3249
3238 3250 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
3239 3251 handle only lines which are invalid python. This now means that
3240 3252 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
3241 3253 for the bug report.
3242 3254
3243 3255 2003-04-01 Fernando Perez <fperez@colorado.edu>
3244 3256
3245 3257 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
3246 3258 where failing to set sys.last_traceback would crash pdb.pm().
3247 3259 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
3248 3260 report.
3249 3261
3250 3262 2003-03-25 Fernando Perez <fperez@colorado.edu>
3251 3263
3252 3264 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
3253 3265 before printing it (it had a lot of spurious blank lines at the
3254 3266 end).
3255 3267
3256 3268 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
3257 3269 output would be sent 21 times! Obviously people don't use this
3258 3270 too often, or I would have heard about it.
3259 3271
3260 3272 2003-03-24 Fernando Perez <fperez@colorado.edu>
3261 3273
3262 3274 * setup.py (scriptfiles): renamed the data_files parameter from
3263 3275 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
3264 3276 for the patch.
3265 3277
3266 3278 2003-03-20 Fernando Perez <fperez@colorado.edu>
3267 3279
3268 3280 * IPython/genutils.py (error): added error() and fatal()
3269 3281 functions.
3270 3282
3271 3283 2003-03-18 *** Released version 0.2.15pre3
3272 3284
3273 3285 2003-03-18 Fernando Perez <fperez@colorado.edu>
3274 3286
3275 3287 * setupext/install_data_ext.py
3276 3288 (install_data_ext.initialize_options): Class contributed by Jack
3277 3289 Moffit for fixing the old distutils hack. He is sending this to
3278 3290 the distutils folks so in the future we may not need it as a
3279 3291 private fix.
3280 3292
3281 3293 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
3282 3294 changes for Debian packaging. See his patch for full details.
3283 3295 The old distutils hack of making the ipythonrc* files carry a
3284 3296 bogus .py extension is gone, at last. Examples were moved to a
3285 3297 separate subdir under doc/, and the separate executable scripts
3286 3298 now live in their own directory. Overall a great cleanup. The
3287 3299 manual was updated to use the new files, and setup.py has been
3288 3300 fixed for this setup.
3289 3301
3290 3302 * IPython/PyColorize.py (Parser.usage): made non-executable and
3291 3303 created a pycolor wrapper around it to be included as a script.
3292 3304
3293 3305 2003-03-12 *** Released version 0.2.15pre2
3294 3306
3295 3307 2003-03-12 Fernando Perez <fperez@colorado.edu>
3296 3308
3297 3309 * IPython/ColorANSI.py (make_color_table): Finally fixed the
3298 3310 long-standing problem with garbage characters in some terminals.
3299 3311 The issue was really that the \001 and \002 escapes must _only_ be
3300 3312 passed to input prompts (which call readline), but _never_ to
3301 3313 normal text to be printed on screen. I changed ColorANSI to have
3302 3314 two classes: TermColors and InputTermColors, each with the
3303 3315 appropriate escapes for input prompts or normal text. The code in
3304 3316 Prompts.py got slightly more complicated, but this very old and
3305 3317 annoying bug is finally fixed.
3306 3318
3307 3319 All the credit for nailing down the real origin of this problem
3308 3320 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
3309 3321 *Many* thanks to him for spending quite a bit of effort on this.
3310 3322
3311 3323 2003-03-05 *** Released version 0.2.15pre1
3312 3324
3313 3325 2003-03-03 Fernando Perez <fperez@colorado.edu>
3314 3326
3315 3327 * IPython/FakeModule.py: Moved the former _FakeModule to a
3316 3328 separate file, because it's also needed by Magic (to fix a similar
3317 3329 pickle-related issue in @run).
3318 3330
3319 3331 2003-03-02 Fernando Perez <fperez@colorado.edu>
3320 3332
3321 3333 * IPython/Magic.py (Magic.magic_autocall): new magic to control
3322 3334 the autocall option at runtime.
3323 3335 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
3324 3336 across Magic.py to start separating Magic from InteractiveShell.
3325 3337 (Magic._ofind): Fixed to return proper namespace for dotted
3326 3338 names. Before, a dotted name would always return 'not currently
3327 3339 defined', because it would find the 'parent'. s.x would be found,
3328 3340 but since 'x' isn't defined by itself, it would get confused.
3329 3341 (Magic.magic_run): Fixed pickling problems reported by Ralf
3330 3342 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
3331 3343 that I'd used when Mike Heeter reported similar issues at the
3332 3344 top-level, but now for @run. It boils down to injecting the
3333 3345 namespace where code is being executed with something that looks
3334 3346 enough like a module to fool pickle.dump(). Since a pickle stores
3335 3347 a named reference to the importing module, we need this for
3336 3348 pickles to save something sensible.
3337 3349
3338 3350 * IPython/ipmaker.py (make_IPython): added an autocall option.
3339 3351
3340 3352 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
3341 3353 the auto-eval code. Now autocalling is an option, and the code is
3342 3354 also vastly safer. There is no more eval() involved at all.
3343 3355
3344 3356 2003-03-01 Fernando Perez <fperez@colorado.edu>
3345 3357
3346 3358 * IPython/Magic.py (Magic._ofind): Changed interface to return a
3347 3359 dict with named keys instead of a tuple.
3348 3360
3349 3361 * IPython: Started using CVS for IPython as of 0.2.15pre1.
3350 3362
3351 3363 * setup.py (make_shortcut): Fixed message about directories
3352 3364 created during Windows installation (the directories were ok, just
3353 3365 the printed message was misleading). Thanks to Chris Liechti
3354 3366 <cliechti-AT-gmx.net> for the heads up.
3355 3367
3356 3368 2003-02-21 Fernando Perez <fperez@colorado.edu>
3357 3369
3358 3370 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
3359 3371 of ValueError exception when checking for auto-execution. This
3360 3372 one is raised by things like Numeric arrays arr.flat when the
3361 3373 array is non-contiguous.
3362 3374
3363 3375 2003-01-31 Fernando Perez <fperez@colorado.edu>
3364 3376
3365 3377 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
3366 3378 not return any value at all (even though the command would get
3367 3379 executed).
3368 3380 (xsys): Flush stdout right after printing the command to ensure
3369 3381 proper ordering of commands and command output in the total
3370 3382 output.
3371 3383 (SystemExec/xsys/bq): Switched the names of xsys/bq and
3372 3384 system/getoutput as defaults. The old ones are kept for
3373 3385 compatibility reasons, so no code which uses this library needs
3374 3386 changing.
3375 3387
3376 3388 2003-01-27 *** Released version 0.2.14
3377 3389
3378 3390 2003-01-25 Fernando Perez <fperez@colorado.edu>
3379 3391
3380 3392 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
3381 3393 functions defined in previous edit sessions could not be re-edited
3382 3394 (because the temp files were immediately removed). Now temp files
3383 3395 are removed only at IPython's exit.
3384 3396 (Magic.magic_run): Improved @run to perform shell-like expansions
3385 3397 on its arguments (~users and $VARS). With this, @run becomes more
3386 3398 like a normal command-line.
3387 3399
3388 3400 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
3389 3401 bugs related to embedding and cleaned up that code. A fairly
3390 3402 important one was the impossibility to access the global namespace
3391 3403 through the embedded IPython (only local variables were visible).
3392 3404
3393 3405 2003-01-14 Fernando Perez <fperez@colorado.edu>
3394 3406
3395 3407 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3396 3408 auto-calling to be a bit more conservative. Now it doesn't get
3397 3409 triggered if any of '!=()<>' are in the rest of the input line, to
3398 3410 allow comparing callables. Thanks to Alex for the heads up.
3399 3411
3400 3412 2003-01-07 Fernando Perez <fperez@colorado.edu>
3401 3413
3402 3414 * IPython/genutils.py (page): fixed estimation of the number of
3403 3415 lines in a string to be paged to simply count newlines. This
3404 3416 prevents over-guessing due to embedded escape sequences. A better
3405 3417 long-term solution would involve stripping out the control chars
3406 3418 for the count, but it's potentially so expensive I just don't
3407 3419 think it's worth doing.
3408 3420
3409 3421 2002-12-19 *** Released version 0.2.14pre50
3410 3422
3411 3423 2002-12-19 Fernando Perez <fperez@colorado.edu>
3412 3424
3413 3425 * tools/release (version): Changed release scripts to inform
3414 3426 Andrea and build a NEWS file with a list of recent changes.
3415 3427
3416 3428 * IPython/ColorANSI.py (__all__): changed terminal detection
3417 3429 code. Seems to work better for xterms without breaking
3418 3430 konsole. Will need more testing to determine if WinXP and Mac OSX
3419 3431 also work ok.
3420 3432
3421 3433 2002-12-18 *** Released version 0.2.14pre49
3422 3434
3423 3435 2002-12-18 Fernando Perez <fperez@colorado.edu>
3424 3436
3425 3437 * Docs: added new info about Mac OSX, from Andrea.
3426 3438
3427 3439 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
3428 3440 allow direct plotting of python strings whose format is the same
3429 3441 of gnuplot data files.
3430 3442
3431 3443 2002-12-16 Fernando Perez <fperez@colorado.edu>
3432 3444
3433 3445 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
3434 3446 value of exit question to be acknowledged.
3435 3447
3436 3448 2002-12-03 Fernando Perez <fperez@colorado.edu>
3437 3449
3438 3450 * IPython/ipmaker.py: removed generators, which had been added
3439 3451 by mistake in an earlier debugging run. This was causing trouble
3440 3452 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
3441 3453 for pointing this out.
3442 3454
3443 3455 2002-11-17 Fernando Perez <fperez@colorado.edu>
3444 3456
3445 3457 * Manual: updated the Gnuplot section.
3446 3458
3447 3459 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
3448 3460 a much better split of what goes in Runtime and what goes in
3449 3461 Interactive.
3450 3462
3451 3463 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
3452 3464 being imported from iplib.
3453 3465
3454 3466 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
3455 3467 for command-passing. Now the global Gnuplot instance is called
3456 3468 'gp' instead of 'g', which was really a far too fragile and
3457 3469 common name.
3458 3470
3459 3471 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
3460 3472 bounding boxes generated by Gnuplot for square plots.
3461 3473
3462 3474 * IPython/genutils.py (popkey): new function added. I should
3463 3475 suggest this on c.l.py as a dict method, it seems useful.
3464 3476
3465 3477 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
3466 3478 to transparently handle PostScript generation. MUCH better than
3467 3479 the previous plot_eps/replot_eps (which I removed now). The code
3468 3480 is also fairly clean and well documented now (including
3469 3481 docstrings).
3470 3482
3471 3483 2002-11-13 Fernando Perez <fperez@colorado.edu>
3472 3484
3473 3485 * IPython/Magic.py (Magic.magic_edit): fixed docstring
3474 3486 (inconsistent with options).
3475 3487
3476 3488 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
3477 3489 manually disabled, I don't know why. Fixed it.
3478 3490 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
3479 3491 eps output.
3480 3492
3481 3493 2002-11-12 Fernando Perez <fperez@colorado.edu>
3482 3494
3483 3495 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
3484 3496 don't propagate up to caller. Fixes crash reported by François
3485 3497 Pinard.
3486 3498
3487 3499 2002-11-09 Fernando Perez <fperez@colorado.edu>
3488 3500
3489 3501 * IPython/ipmaker.py (make_IPython): fixed problem with writing
3490 3502 history file for new users.
3491 3503 (make_IPython): fixed bug where initial install would leave the
3492 3504 user running in the .ipython dir.
3493 3505 (make_IPython): fixed bug where config dir .ipython would be
3494 3506 created regardless of the given -ipythondir option. Thanks to Cory
3495 3507 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
3496 3508
3497 3509 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
3498 3510 type confirmations. Will need to use it in all of IPython's code
3499 3511 consistently.
3500 3512
3501 3513 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
3502 3514 context to print 31 lines instead of the default 5. This will make
3503 3515 the crash reports extremely detailed in case the problem is in
3504 3516 libraries I don't have access to.
3505 3517
3506 3518 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
3507 3519 line of defense' code to still crash, but giving users fair
3508 3520 warning. I don't want internal errors to go unreported: if there's
3509 3521 an internal problem, IPython should crash and generate a full
3510 3522 report.
3511 3523
3512 3524 2002-11-08 Fernando Perez <fperez@colorado.edu>
3513 3525
3514 3526 * IPython/iplib.py (InteractiveShell.interact): added code to trap
3515 3527 otherwise uncaught exceptions which can appear if people set
3516 3528 sys.stdout to something badly broken. Thanks to a crash report
3517 3529 from henni-AT-mail.brainbot.com.
3518 3530
3519 3531 2002-11-04 Fernando Perez <fperez@colorado.edu>
3520 3532
3521 3533 * IPython/iplib.py (InteractiveShell.interact): added
3522 3534 __IPYTHON__active to the builtins. It's a flag which goes on when
3523 3535 the interaction starts and goes off again when it stops. This
3524 3536 allows embedding code to detect being inside IPython. Before this
3525 3537 was done via __IPYTHON__, but that only shows that an IPython
3526 3538 instance has been created.
3527 3539
3528 3540 * IPython/Magic.py (Magic.magic_env): I realized that in a
3529 3541 UserDict, instance.data holds the data as a normal dict. So I
3530 3542 modified @env to return os.environ.data instead of rebuilding a
3531 3543 dict by hand.
3532 3544
3533 3545 2002-11-02 Fernando Perez <fperez@colorado.edu>
3534 3546
3535 3547 * IPython/genutils.py (warn): changed so that level 1 prints no
3536 3548 header. Level 2 is now the default (with 'WARNING' header, as
3537 3549 before). I think I tracked all places where changes were needed in
3538 3550 IPython, but outside code using the old level numbering may have
3539 3551 broken.
3540 3552
3541 3553 * IPython/iplib.py (InteractiveShell.runcode): added this to
3542 3554 handle the tracebacks in SystemExit traps correctly. The previous
3543 3555 code (through interact) was printing more of the stack than
3544 3556 necessary, showing IPython internal code to the user.
3545 3557
3546 3558 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
3547 3559 default. Now that the default at the confirmation prompt is yes,
3548 3560 it's not so intrusive. François' argument that ipython sessions
3549 3561 tend to be complex enough not to lose them from an accidental C-d,
3550 3562 is a valid one.
3551 3563
3552 3564 * IPython/iplib.py (InteractiveShell.interact): added a
3553 3565 showtraceback() call to the SystemExit trap, and modified the exit
3554 3566 confirmation to have yes as the default.
3555 3567
3556 3568 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
3557 3569 this file. It's been gone from the code for a long time, this was
3558 3570 simply leftover junk.
3559 3571
3560 3572 2002-11-01 Fernando Perez <fperez@colorado.edu>
3561 3573
3562 3574 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
3563 3575 added. If set, IPython now traps EOF and asks for
3564 3576 confirmation. After a request by François Pinard.
3565 3577
3566 3578 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
3567 3579 of @abort, and with a new (better) mechanism for handling the
3568 3580 exceptions.
3569 3581
3570 3582 2002-10-27 Fernando Perez <fperez@colorado.edu>
3571 3583
3572 3584 * IPython/usage.py (__doc__): updated the --help information and
3573 3585 the ipythonrc file to indicate that -log generates
3574 3586 ./ipython.log. Also fixed the corresponding info in @logstart.
3575 3587 This and several other fixes in the manuals thanks to reports by
3576 3588 François Pinard <pinard-AT-iro.umontreal.ca>.
3577 3589
3578 3590 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3579 3591 refer to @logstart (instead of @log, which doesn't exist).
3580 3592
3581 3593 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3582 3594 AttributeError crash. Thanks to Christopher Armstrong
3583 3595 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3584 3596 introduced recently (in 0.2.14pre37) with the fix to the eval
3585 3597 problem mentioned below.
3586 3598
3587 3599 2002-10-17 Fernando Perez <fperez@colorado.edu>
3588 3600
3589 3601 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3590 3602 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3591 3603
3592 3604 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3593 3605 this function to fix a problem reported by Alex Schmolck. He saw
3594 3606 it with list comprehensions and generators, which were getting
3595 3607 called twice. The real problem was an 'eval' call in testing for
3596 3608 automagic which was evaluating the input line silently.
3597 3609
3598 3610 This is a potentially very nasty bug, if the input has side
3599 3611 effects which must not be repeated. The code is much cleaner now,
3600 3612 without any blanket 'except' left and with a regexp test for
3601 3613 actual function names.
3602 3614
3603 3615 But an eval remains, which I'm not fully comfortable with. I just
3604 3616 don't know how to find out if an expression could be a callable in
3605 3617 the user's namespace without doing an eval on the string. However
3606 3618 that string is now much more strictly checked so that no code
3607 3619 slips by, so the eval should only happen for things that can
3608 3620 really be only function/method names.
3609 3621
3610 3622 2002-10-15 Fernando Perez <fperez@colorado.edu>
3611 3623
3612 3624 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3613 3625 OSX information to main manual, removed README_Mac_OSX file from
3614 3626 distribution. Also updated credits for recent additions.
3615 3627
3616 3628 2002-10-10 Fernando Perez <fperez@colorado.edu>
3617 3629
3618 3630 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3619 3631 terminal-related issues. Many thanks to Andrea Riciputi
3620 3632 <andrea.riciputi-AT-libero.it> for writing it.
3621 3633
3622 3634 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3623 3635 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3624 3636
3625 3637 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3626 3638 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3627 3639 <syver-en-AT-online.no> who both submitted patches for this problem.
3628 3640
3629 3641 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3630 3642 global embedding to make sure that things don't overwrite user
3631 3643 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3632 3644
3633 3645 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3634 3646 compatibility. Thanks to Hayden Callow
3635 3647 <h.callow-AT-elec.canterbury.ac.nz>
3636 3648
3637 3649 2002-10-04 Fernando Perez <fperez@colorado.edu>
3638 3650
3639 3651 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3640 3652 Gnuplot.File objects.
3641 3653
3642 3654 2002-07-23 Fernando Perez <fperez@colorado.edu>
3643 3655
3644 3656 * IPython/genutils.py (timing): Added timings() and timing() for
3645 3657 quick access to the most commonly needed data, the execution
3646 3658 times. Old timing() renamed to timings_out().
3647 3659
3648 3660 2002-07-18 Fernando Perez <fperez@colorado.edu>
3649 3661
3650 3662 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3651 3663 bug with nested instances disrupting the parent's tab completion.
3652 3664
3653 3665 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3654 3666 all_completions code to begin the emacs integration.
3655 3667
3656 3668 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3657 3669 argument to allow titling individual arrays when plotting.
3658 3670
3659 3671 2002-07-15 Fernando Perez <fperez@colorado.edu>
3660 3672
3661 3673 * setup.py (make_shortcut): changed to retrieve the value of
3662 3674 'Program Files' directory from the registry (this value changes in
3663 3675 non-english versions of Windows). Thanks to Thomas Fanslau
3664 3676 <tfanslau-AT-gmx.de> for the report.
3665 3677
3666 3678 2002-07-10 Fernando Perez <fperez@colorado.edu>
3667 3679
3668 3680 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3669 3681 a bug in pdb, which crashes if a line with only whitespace is
3670 3682 entered. Bug report submitted to sourceforge.
3671 3683
3672 3684 2002-07-09 Fernando Perez <fperez@colorado.edu>
3673 3685
3674 3686 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3675 3687 reporting exceptions (it's a bug in inspect.py, I just set a
3676 3688 workaround).
3677 3689
3678 3690 2002-07-08 Fernando Perez <fperez@colorado.edu>
3679 3691
3680 3692 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3681 3693 __IPYTHON__ in __builtins__ to show up in user_ns.
3682 3694
3683 3695 2002-07-03 Fernando Perez <fperez@colorado.edu>
3684 3696
3685 3697 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3686 3698 name from @gp_set_instance to @gp_set_default.
3687 3699
3688 3700 * IPython/ipmaker.py (make_IPython): default editor value set to
3689 3701 '0' (a string), to match the rc file. Otherwise will crash when
3690 3702 .strip() is called on it.
3691 3703
3692 3704
3693 3705 2002-06-28 Fernando Perez <fperez@colorado.edu>
3694 3706
3695 3707 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3696 3708 of files in current directory when a file is executed via
3697 3709 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3698 3710
3699 3711 * setup.py (manfiles): fix for rpm builds, submitted by RA
3700 3712 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3701 3713
3702 3714 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3703 3715 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3704 3716 string!). A. Schmolck caught this one.
3705 3717
3706 3718 2002-06-27 Fernando Perez <fperez@colorado.edu>
3707 3719
3708 3720 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3709 3721 defined files at the cmd line. __name__ wasn't being set to
3710 3722 __main__.
3711 3723
3712 3724 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3713 3725 regular lists and tuples besides Numeric arrays.
3714 3726
3715 3727 * IPython/Prompts.py (CachedOutput.__call__): Added output
3716 3728 supression for input ending with ';'. Similar to Mathematica and
3717 3729 Matlab. The _* vars and Out[] list are still updated, just like
3718 3730 Mathematica behaves.
3719 3731
3720 3732 2002-06-25 Fernando Perez <fperez@colorado.edu>
3721 3733
3722 3734 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3723 3735 .ini extensions for profiels under Windows.
3724 3736
3725 3737 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3726 3738 string form. Fix contributed by Alexander Schmolck
3727 3739 <a.schmolck-AT-gmx.net>
3728 3740
3729 3741 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3730 3742 pre-configured Gnuplot instance.
3731 3743
3732 3744 2002-06-21 Fernando Perez <fperez@colorado.edu>
3733 3745
3734 3746 * IPython/numutils.py (exp_safe): new function, works around the
3735 3747 underflow problems in Numeric.
3736 3748 (log2): New fn. Safe log in base 2: returns exact integer answer
3737 3749 for exact integer powers of 2.
3738 3750
3739 3751 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3740 3752 properly.
3741 3753
3742 3754 2002-06-20 Fernando Perez <fperez@colorado.edu>
3743 3755
3744 3756 * IPython/genutils.py (timing): new function like
3745 3757 Mathematica's. Similar to time_test, but returns more info.
3746 3758
3747 3759 2002-06-18 Fernando Perez <fperez@colorado.edu>
3748 3760
3749 3761 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3750 3762 according to Mike Heeter's suggestions.
3751 3763
3752 3764 2002-06-16 Fernando Perez <fperez@colorado.edu>
3753 3765
3754 3766 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3755 3767 system. GnuplotMagic is gone as a user-directory option. New files
3756 3768 make it easier to use all the gnuplot stuff both from external
3757 3769 programs as well as from IPython. Had to rewrite part of
3758 3770 hardcopy() b/c of a strange bug: often the ps files simply don't
3759 3771 get created, and require a repeat of the command (often several
3760 3772 times).
3761 3773
3762 3774 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3763 3775 resolve output channel at call time, so that if sys.stderr has
3764 3776 been redirected by user this gets honored.
3765 3777
3766 3778 2002-06-13 Fernando Perez <fperez@colorado.edu>
3767 3779
3768 3780 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3769 3781 IPShell. Kept a copy with the old names to avoid breaking people's
3770 3782 embedded code.
3771 3783
3772 3784 * IPython/ipython: simplified it to the bare minimum after
3773 3785 Holger's suggestions. Added info about how to use it in
3774 3786 PYTHONSTARTUP.
3775 3787
3776 3788 * IPython/Shell.py (IPythonShell): changed the options passing
3777 3789 from a string with funky %s replacements to a straight list. Maybe
3778 3790 a bit more typing, but it follows sys.argv conventions, so there's
3779 3791 less special-casing to remember.
3780 3792
3781 3793 2002-06-12 Fernando Perez <fperez@colorado.edu>
3782 3794
3783 3795 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3784 3796 command. Thanks to a suggestion by Mike Heeter.
3785 3797 (Magic.magic_pfile): added behavior to look at filenames if given
3786 3798 arg is not a defined object.
3787 3799 (Magic.magic_save): New @save function to save code snippets. Also
3788 3800 a Mike Heeter idea.
3789 3801
3790 3802 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3791 3803 plot() and replot(). Much more convenient now, especially for
3792 3804 interactive use.
3793 3805
3794 3806 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3795 3807 filenames.
3796 3808
3797 3809 2002-06-02 Fernando Perez <fperez@colorado.edu>
3798 3810
3799 3811 * IPython/Struct.py (Struct.__init__): modified to admit
3800 3812 initialization via another struct.
3801 3813
3802 3814 * IPython/genutils.py (SystemExec.__init__): New stateful
3803 3815 interface to xsys and bq. Useful for writing system scripts.
3804 3816
3805 3817 2002-05-30 Fernando Perez <fperez@colorado.edu>
3806 3818
3807 3819 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3808 3820 documents. This will make the user download smaller (it's getting
3809 3821 too big).
3810 3822
3811 3823 2002-05-29 Fernando Perez <fperez@colorado.edu>
3812 3824
3813 3825 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3814 3826 fix problems with shelve and pickle. Seems to work, but I don't
3815 3827 know if corner cases break it. Thanks to Mike Heeter
3816 3828 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3817 3829
3818 3830 2002-05-24 Fernando Perez <fperez@colorado.edu>
3819 3831
3820 3832 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3821 3833 macros having broken.
3822 3834
3823 3835 2002-05-21 Fernando Perez <fperez@colorado.edu>
3824 3836
3825 3837 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3826 3838 introduced logging bug: all history before logging started was
3827 3839 being written one character per line! This came from the redesign
3828 3840 of the input history as a special list which slices to strings,
3829 3841 not to lists.
3830 3842
3831 3843 2002-05-20 Fernando Perez <fperez@colorado.edu>
3832 3844
3833 3845 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3834 3846 be an attribute of all classes in this module. The design of these
3835 3847 classes needs some serious overhauling.
3836 3848
3837 3849 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3838 3850 which was ignoring '_' in option names.
3839 3851
3840 3852 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3841 3853 'Verbose_novars' to 'Context' and made it the new default. It's a
3842 3854 bit more readable and also safer than verbose.
3843 3855
3844 3856 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3845 3857 triple-quoted strings.
3846 3858
3847 3859 * IPython/OInspect.py (__all__): new module exposing the object
3848 3860 introspection facilities. Now the corresponding magics are dummy
3849 3861 wrappers around this. Having this module will make it much easier
3850 3862 to put these functions into our modified pdb.
3851 3863 This new object inspector system uses the new colorizing module,
3852 3864 so source code and other things are nicely syntax highlighted.
3853 3865
3854 3866 2002-05-18 Fernando Perez <fperez@colorado.edu>
3855 3867
3856 3868 * IPython/ColorANSI.py: Split the coloring tools into a separate
3857 3869 module so I can use them in other code easier (they were part of
3858 3870 ultraTB).
3859 3871
3860 3872 2002-05-17 Fernando Perez <fperez@colorado.edu>
3861 3873
3862 3874 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3863 3875 fixed it to set the global 'g' also to the called instance, as
3864 3876 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3865 3877 user's 'g' variables).
3866 3878
3867 3879 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3868 3880 global variables (aliases to _ih,_oh) so that users which expect
3869 3881 In[5] or Out[7] to work aren't unpleasantly surprised.
3870 3882 (InputList.__getslice__): new class to allow executing slices of
3871 3883 input history directly. Very simple class, complements the use of
3872 3884 macros.
3873 3885
3874 3886 2002-05-16 Fernando Perez <fperez@colorado.edu>
3875 3887
3876 3888 * setup.py (docdirbase): make doc directory be just doc/IPython
3877 3889 without version numbers, it will reduce clutter for users.
3878 3890
3879 3891 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3880 3892 execfile call to prevent possible memory leak. See for details:
3881 3893 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3882 3894
3883 3895 2002-05-15 Fernando Perez <fperez@colorado.edu>
3884 3896
3885 3897 * IPython/Magic.py (Magic.magic_psource): made the object
3886 3898 introspection names be more standard: pdoc, pdef, pfile and
3887 3899 psource. They all print/page their output, and it makes
3888 3900 remembering them easier. Kept old names for compatibility as
3889 3901 aliases.
3890 3902
3891 3903 2002-05-14 Fernando Perez <fperez@colorado.edu>
3892 3904
3893 3905 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3894 3906 what the mouse problem was. The trick is to use gnuplot with temp
3895 3907 files and NOT with pipes (for data communication), because having
3896 3908 both pipes and the mouse on is bad news.
3897 3909
3898 3910 2002-05-13 Fernando Perez <fperez@colorado.edu>
3899 3911
3900 3912 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3901 3913 bug. Information would be reported about builtins even when
3902 3914 user-defined functions overrode them.
3903 3915
3904 3916 2002-05-11 Fernando Perez <fperez@colorado.edu>
3905 3917
3906 3918 * IPython/__init__.py (__all__): removed FlexCompleter from
3907 3919 __all__ so that things don't fail in platforms without readline.
3908 3920
3909 3921 2002-05-10 Fernando Perez <fperez@colorado.edu>
3910 3922
3911 3923 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3912 3924 it requires Numeric, effectively making Numeric a dependency for
3913 3925 IPython.
3914 3926
3915 3927 * Released 0.2.13
3916 3928
3917 3929 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3918 3930 profiler interface. Now all the major options from the profiler
3919 3931 module are directly supported in IPython, both for single
3920 3932 expressions (@prun) and for full programs (@run -p).
3921 3933
3922 3934 2002-05-09 Fernando Perez <fperez@colorado.edu>
3923 3935
3924 3936 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3925 3937 magic properly formatted for screen.
3926 3938
3927 3939 * setup.py (make_shortcut): Changed things to put pdf version in
3928 3940 doc/ instead of doc/manual (had to change lyxport a bit).
3929 3941
3930 3942 * IPython/Magic.py (Profile.string_stats): made profile runs go
3931 3943 through pager (they are long and a pager allows searching, saving,
3932 3944 etc.)
3933 3945
3934 3946 2002-05-08 Fernando Perez <fperez@colorado.edu>
3935 3947
3936 3948 * Released 0.2.12
3937 3949
3938 3950 2002-05-06 Fernando Perez <fperez@colorado.edu>
3939 3951
3940 3952 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3941 3953 introduced); 'hist n1 n2' was broken.
3942 3954 (Magic.magic_pdb): added optional on/off arguments to @pdb
3943 3955 (Magic.magic_run): added option -i to @run, which executes code in
3944 3956 the IPython namespace instead of a clean one. Also added @irun as
3945 3957 an alias to @run -i.
3946 3958
3947 3959 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3948 3960 fixed (it didn't really do anything, the namespaces were wrong).
3949 3961
3950 3962 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3951 3963
3952 3964 * IPython/__init__.py (__all__): Fixed package namespace, now
3953 3965 'import IPython' does give access to IPython.<all> as
3954 3966 expected. Also renamed __release__ to Release.
3955 3967
3956 3968 * IPython/Debugger.py (__license__): created new Pdb class which
3957 3969 functions like a drop-in for the normal pdb.Pdb but does NOT
3958 3970 import readline by default. This way it doesn't muck up IPython's
3959 3971 readline handling, and now tab-completion finally works in the
3960 3972 debugger -- sort of. It completes things globally visible, but the
3961 3973 completer doesn't track the stack as pdb walks it. That's a bit
3962 3974 tricky, and I'll have to implement it later.
3963 3975
3964 3976 2002-05-05 Fernando Perez <fperez@colorado.edu>
3965 3977
3966 3978 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3967 3979 magic docstrings when printed via ? (explicit \'s were being
3968 3980 printed).
3969 3981
3970 3982 * IPython/ipmaker.py (make_IPython): fixed namespace
3971 3983 identification bug. Now variables loaded via logs or command-line
3972 3984 files are recognized in the interactive namespace by @who.
3973 3985
3974 3986 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3975 3987 log replay system stemming from the string form of Structs.
3976 3988
3977 3989 * IPython/Magic.py (Macro.__init__): improved macros to properly
3978 3990 handle magic commands in them.
3979 3991 (Magic.magic_logstart): usernames are now expanded so 'logstart
3980 3992 ~/mylog' now works.
3981 3993
3982 3994 * IPython/iplib.py (complete): fixed bug where paths starting with
3983 3995 '/' would be completed as magic names.
3984 3996
3985 3997 2002-05-04 Fernando Perez <fperez@colorado.edu>
3986 3998
3987 3999 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3988 4000 allow running full programs under the profiler's control.
3989 4001
3990 4002 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3991 4003 mode to report exceptions verbosely but without formatting
3992 4004 variables. This addresses the issue of ipython 'freezing' (it's
3993 4005 not frozen, but caught in an expensive formatting loop) when huge
3994 4006 variables are in the context of an exception.
3995 4007 (VerboseTB.text): Added '--->' markers at line where exception was
3996 4008 triggered. Much clearer to read, especially in NoColor modes.
3997 4009
3998 4010 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3999 4011 implemented in reverse when changing to the new parse_options().
4000 4012
4001 4013 2002-05-03 Fernando Perez <fperez@colorado.edu>
4002 4014
4003 4015 * IPython/Magic.py (Magic.parse_options): new function so that
4004 4016 magics can parse options easier.
4005 4017 (Magic.magic_prun): new function similar to profile.run(),
4006 4018 suggested by Chris Hart.
4007 4019 (Magic.magic_cd): fixed behavior so that it only changes if
4008 4020 directory actually is in history.
4009 4021
4010 4022 * IPython/usage.py (__doc__): added information about potential
4011 4023 slowness of Verbose exception mode when there are huge data
4012 4024 structures to be formatted (thanks to Archie Paulson).
4013 4025
4014 4026 * IPython/ipmaker.py (make_IPython): Changed default logging
4015 4027 (when simply called with -log) to use curr_dir/ipython.log in
4016 4028 rotate mode. Fixed crash which was occuring with -log before
4017 4029 (thanks to Jim Boyle).
4018 4030
4019 4031 2002-05-01 Fernando Perez <fperez@colorado.edu>
4020 4032
4021 4033 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4022 4034 was nasty -- though somewhat of a corner case).
4023 4035
4024 4036 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4025 4037 text (was a bug).
4026 4038
4027 4039 2002-04-30 Fernando Perez <fperez@colorado.edu>
4028 4040
4029 4041 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4030 4042 a print after ^D or ^C from the user so that the In[] prompt
4031 4043 doesn't over-run the gnuplot one.
4032 4044
4033 4045 2002-04-29 Fernando Perez <fperez@colorado.edu>
4034 4046
4035 4047 * Released 0.2.10
4036 4048
4037 4049 * IPython/__release__.py (version): get date dynamically.
4038 4050
4039 4051 * Misc. documentation updates thanks to Arnd's comments. Also ran
4040 4052 a full spellcheck on the manual (hadn't been done in a while).
4041 4053
4042 4054 2002-04-27 Fernando Perez <fperez@colorado.edu>
4043 4055
4044 4056 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4045 4057 starting a log in mid-session would reset the input history list.
4046 4058
4047 4059 2002-04-26 Fernando Perez <fperez@colorado.edu>
4048 4060
4049 4061 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4050 4062 all files were being included in an update. Now anything in
4051 4063 UserConfig that matches [A-Za-z]*.py will go (this excludes
4052 4064 __init__.py)
4053 4065
4054 4066 2002-04-25 Fernando Perez <fperez@colorado.edu>
4055 4067
4056 4068 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
4057 4069 to __builtins__ so that any form of embedded or imported code can
4058 4070 test for being inside IPython.
4059 4071
4060 4072 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
4061 4073 changed to GnuplotMagic because it's now an importable module,
4062 4074 this makes the name follow that of the standard Gnuplot module.
4063 4075 GnuplotMagic can now be loaded at any time in mid-session.
4064 4076
4065 4077 2002-04-24 Fernando Perez <fperez@colorado.edu>
4066 4078
4067 4079 * IPython/numutils.py: removed SIUnits. It doesn't properly set
4068 4080 the globals (IPython has its own namespace) and the
4069 4081 PhysicalQuantity stuff is much better anyway.
4070 4082
4071 4083 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
4072 4084 embedding example to standard user directory for
4073 4085 distribution. Also put it in the manual.
4074 4086
4075 4087 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
4076 4088 instance as first argument (so it doesn't rely on some obscure
4077 4089 hidden global).
4078 4090
4079 4091 * IPython/UserConfig/ipythonrc.py: put () back in accepted
4080 4092 delimiters. While it prevents ().TAB from working, it allows
4081 4093 completions in open (... expressions. This is by far a more common
4082 4094 case.
4083 4095
4084 4096 2002-04-23 Fernando Perez <fperez@colorado.edu>
4085 4097
4086 4098 * IPython/Extensions/InterpreterPasteInput.py: new
4087 4099 syntax-processing module for pasting lines with >>> or ... at the
4088 4100 start.
4089 4101
4090 4102 * IPython/Extensions/PhysicalQ_Interactive.py
4091 4103 (PhysicalQuantityInteractive.__int__): fixed to work with either
4092 4104 Numeric or math.
4093 4105
4094 4106 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
4095 4107 provided profiles. Now we have:
4096 4108 -math -> math module as * and cmath with its own namespace.
4097 4109 -numeric -> Numeric as *, plus gnuplot & grace
4098 4110 -physics -> same as before
4099 4111
4100 4112 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
4101 4113 user-defined magics wouldn't be found by @magic if they were
4102 4114 defined as class methods. Also cleaned up the namespace search
4103 4115 logic and the string building (to use %s instead of many repeated
4104 4116 string adds).
4105 4117
4106 4118 * IPython/UserConfig/example-magic.py (magic_foo): updated example
4107 4119 of user-defined magics to operate with class methods (cleaner, in
4108 4120 line with the gnuplot code).
4109 4121
4110 4122 2002-04-22 Fernando Perez <fperez@colorado.edu>
4111 4123
4112 4124 * setup.py: updated dependency list so that manual is updated when
4113 4125 all included files change.
4114 4126
4115 4127 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
4116 4128 the delimiter removal option (the fix is ugly right now).
4117 4129
4118 4130 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
4119 4131 all of the math profile (quicker loading, no conflict between
4120 4132 g-9.8 and g-gnuplot).
4121 4133
4122 4134 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
4123 4135 name of post-mortem files to IPython_crash_report.txt.
4124 4136
4125 4137 * Cleanup/update of the docs. Added all the new readline info and
4126 4138 formatted all lists as 'real lists'.
4127 4139
4128 4140 * IPython/ipmaker.py (make_IPython): removed now-obsolete
4129 4141 tab-completion options, since the full readline parse_and_bind is
4130 4142 now accessible.
4131 4143
4132 4144 * IPython/iplib.py (InteractiveShell.init_readline): Changed
4133 4145 handling of readline options. Now users can specify any string to
4134 4146 be passed to parse_and_bind(), as well as the delimiters to be
4135 4147 removed.
4136 4148 (InteractiveShell.__init__): Added __name__ to the global
4137 4149 namespace so that things like Itpl which rely on its existence
4138 4150 don't crash.
4139 4151 (InteractiveShell._prefilter): Defined the default with a _ so
4140 4152 that prefilter() is easier to override, while the default one
4141 4153 remains available.
4142 4154
4143 4155 2002-04-18 Fernando Perez <fperez@colorado.edu>
4144 4156
4145 4157 * Added information about pdb in the docs.
4146 4158
4147 4159 2002-04-17 Fernando Perez <fperez@colorado.edu>
4148 4160
4149 4161 * IPython/ipmaker.py (make_IPython): added rc_override option to
4150 4162 allow passing config options at creation time which may override
4151 4163 anything set in the config files or command line. This is
4152 4164 particularly useful for configuring embedded instances.
4153 4165
4154 4166 2002-04-15 Fernando Perez <fperez@colorado.edu>
4155 4167
4156 4168 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
4157 4169 crash embedded instances because of the input cache falling out of
4158 4170 sync with the output counter.
4159 4171
4160 4172 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
4161 4173 mode which calls pdb after an uncaught exception in IPython itself.
4162 4174
4163 4175 2002-04-14 Fernando Perez <fperez@colorado.edu>
4164 4176
4165 4177 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
4166 4178 readline, fix it back after each call.
4167 4179
4168 4180 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
4169 4181 method to force all access via __call__(), which guarantees that
4170 4182 traceback references are properly deleted.
4171 4183
4172 4184 * IPython/Prompts.py (CachedOutput._display): minor fixes to
4173 4185 improve printing when pprint is in use.
4174 4186
4175 4187 2002-04-13 Fernando Perez <fperez@colorado.edu>
4176 4188
4177 4189 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
4178 4190 exceptions aren't caught anymore. If the user triggers one, he
4179 4191 should know why he's doing it and it should go all the way up,
4180 4192 just like any other exception. So now @abort will fully kill the
4181 4193 embedded interpreter and the embedding code (unless that happens
4182 4194 to catch SystemExit).
4183 4195
4184 4196 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
4185 4197 and a debugger() method to invoke the interactive pdb debugger
4186 4198 after printing exception information. Also added the corresponding
4187 4199 -pdb option and @pdb magic to control this feature, and updated
4188 4200 the docs. After a suggestion from Christopher Hart
4189 4201 (hart-AT-caltech.edu).
4190 4202
4191 4203 2002-04-12 Fernando Perez <fperez@colorado.edu>
4192 4204
4193 4205 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
4194 4206 the exception handlers defined by the user (not the CrashHandler)
4195 4207 so that user exceptions don't trigger an ipython bug report.
4196 4208
4197 4209 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
4198 4210 configurable (it should have always been so).
4199 4211
4200 4212 2002-03-26 Fernando Perez <fperez@colorado.edu>
4201 4213
4202 4214 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
4203 4215 and there to fix embedding namespace issues. This should all be
4204 4216 done in a more elegant way.
4205 4217
4206 4218 2002-03-25 Fernando Perez <fperez@colorado.edu>
4207 4219
4208 4220 * IPython/genutils.py (get_home_dir): Try to make it work under
4209 4221 win9x also.
4210 4222
4211 4223 2002-03-20 Fernando Perez <fperez@colorado.edu>
4212 4224
4213 4225 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
4214 4226 sys.displayhook untouched upon __init__.
4215 4227
4216 4228 2002-03-19 Fernando Perez <fperez@colorado.edu>
4217 4229
4218 4230 * Released 0.2.9 (for embedding bug, basically).
4219 4231
4220 4232 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
4221 4233 exceptions so that enclosing shell's state can be restored.
4222 4234
4223 4235 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
4224 4236 naming conventions in the .ipython/ dir.
4225 4237
4226 4238 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
4227 4239 from delimiters list so filenames with - in them get expanded.
4228 4240
4229 4241 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
4230 4242 sys.displayhook not being properly restored after an embedded call.
4231 4243
4232 4244 2002-03-18 Fernando Perez <fperez@colorado.edu>
4233 4245
4234 4246 * Released 0.2.8
4235 4247
4236 4248 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
4237 4249 some files weren't being included in a -upgrade.
4238 4250 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
4239 4251 on' so that the first tab completes.
4240 4252 (InteractiveShell.handle_magic): fixed bug with spaces around
4241 4253 quotes breaking many magic commands.
4242 4254
4243 4255 * setup.py: added note about ignoring the syntax error messages at
4244 4256 installation.
4245 4257
4246 4258 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
4247 4259 streamlining the gnuplot interface, now there's only one magic @gp.
4248 4260
4249 4261 2002-03-17 Fernando Perez <fperez@colorado.edu>
4250 4262
4251 4263 * IPython/UserConfig/magic_gnuplot.py: new name for the
4252 4264 example-magic_pm.py file. Much enhanced system, now with a shell
4253 4265 for communicating directly with gnuplot, one command at a time.
4254 4266
4255 4267 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
4256 4268 setting __name__=='__main__'.
4257 4269
4258 4270 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
4259 4271 mini-shell for accessing gnuplot from inside ipython. Should
4260 4272 extend it later for grace access too. Inspired by Arnd's
4261 4273 suggestion.
4262 4274
4263 4275 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
4264 4276 calling magic functions with () in their arguments. Thanks to Arnd
4265 4277 Baecker for pointing this to me.
4266 4278
4267 4279 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
4268 4280 infinitely for integer or complex arrays (only worked with floats).
4269 4281
4270 4282 2002-03-16 Fernando Perez <fperez@colorado.edu>
4271 4283
4272 4284 * setup.py: Merged setup and setup_windows into a single script
4273 4285 which properly handles things for windows users.
4274 4286
4275 4287 2002-03-15 Fernando Perez <fperez@colorado.edu>
4276 4288
4277 4289 * Big change to the manual: now the magics are all automatically
4278 4290 documented. This information is generated from their docstrings
4279 4291 and put in a latex file included by the manual lyx file. This way
4280 4292 we get always up to date information for the magics. The manual
4281 4293 now also has proper version information, also auto-synced.
4282 4294
4283 4295 For this to work, an undocumented --magic_docstrings option was added.
4284 4296
4285 4297 2002-03-13 Fernando Perez <fperez@colorado.edu>
4286 4298
4287 4299 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
4288 4300 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
4289 4301
4290 4302 2002-03-12 Fernando Perez <fperez@colorado.edu>
4291 4303
4292 4304 * IPython/ultraTB.py (TermColors): changed color escapes again to
4293 4305 fix the (old, reintroduced) line-wrapping bug. Basically, if
4294 4306 \001..\002 aren't given in the color escapes, lines get wrapped
4295 4307 weirdly. But giving those screws up old xterms and emacs terms. So
4296 4308 I added some logic for emacs terms to be ok, but I can't identify old
4297 4309 xterms separately ($TERM=='xterm' for many terminals, like konsole).
4298 4310
4299 4311 2002-03-10 Fernando Perez <fperez@colorado.edu>
4300 4312
4301 4313 * IPython/usage.py (__doc__): Various documentation cleanups and
4302 4314 updates, both in usage docstrings and in the manual.
4303 4315
4304 4316 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
4305 4317 handling of caching. Set minimum acceptabe value for having a
4306 4318 cache at 20 values.
4307 4319
4308 4320 * IPython/iplib.py (InteractiveShell.user_setup): moved the
4309 4321 install_first_time function to a method, renamed it and added an
4310 4322 'upgrade' mode. Now people can update their config directory with
4311 4323 a simple command line switch (-upgrade, also new).
4312 4324
4313 4325 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
4314 4326 @file (convenient for automagic users under Python >= 2.2).
4315 4327 Removed @files (it seemed more like a plural than an abbrev. of
4316 4328 'file show').
4317 4329
4318 4330 * IPython/iplib.py (install_first_time): Fixed crash if there were
4319 4331 backup files ('~') in .ipython/ install directory.
4320 4332
4321 4333 * IPython/ipmaker.py (make_IPython): fixes for new prompt
4322 4334 system. Things look fine, but these changes are fairly
4323 4335 intrusive. Test them for a few days.
4324 4336
4325 4337 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
4326 4338 the prompts system. Now all in/out prompt strings are user
4327 4339 controllable. This is particularly useful for embedding, as one
4328 4340 can tag embedded instances with particular prompts.
4329 4341
4330 4342 Also removed global use of sys.ps1/2, which now allows nested
4331 4343 embeddings without any problems. Added command-line options for
4332 4344 the prompt strings.
4333 4345
4334 4346 2002-03-08 Fernando Perez <fperez@colorado.edu>
4335 4347
4336 4348 * IPython/UserConfig/example-embed-short.py (ipshell): added
4337 4349 example file with the bare minimum code for embedding.
4338 4350
4339 4351 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
4340 4352 functionality for the embeddable shell to be activated/deactivated
4341 4353 either globally or at each call.
4342 4354
4343 4355 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
4344 4356 rewriting the prompt with '--->' for auto-inputs with proper
4345 4357 coloring. Now the previous UGLY hack in handle_auto() is gone, and
4346 4358 this is handled by the prompts class itself, as it should.
4347 4359
4348 4360 2002-03-05 Fernando Perez <fperez@colorado.edu>
4349 4361
4350 4362 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
4351 4363 @logstart to avoid name clashes with the math log function.
4352 4364
4353 4365 * Big updates to X/Emacs section of the manual.
4354 4366
4355 4367 * Removed ipython_emacs. Milan explained to me how to pass
4356 4368 arguments to ipython through Emacs. Some day I'm going to end up
4357 4369 learning some lisp...
4358 4370
4359 4371 2002-03-04 Fernando Perez <fperez@colorado.edu>
4360 4372
4361 4373 * IPython/ipython_emacs: Created script to be used as the
4362 4374 py-python-command Emacs variable so we can pass IPython
4363 4375 parameters. I can't figure out how to tell Emacs directly to pass
4364 4376 parameters to IPython, so a dummy shell script will do it.
4365 4377
4366 4378 Other enhancements made for things to work better under Emacs'
4367 4379 various types of terminals. Many thanks to Milan Zamazal
4368 4380 <pdm-AT-zamazal.org> for all the suggestions and pointers.
4369 4381
4370 4382 2002-03-01 Fernando Perez <fperez@colorado.edu>
4371 4383
4372 4384 * IPython/ipmaker.py (make_IPython): added a --readline! option so
4373 4385 that loading of readline is now optional. This gives better
4374 4386 control to emacs users.
4375 4387
4376 4388 * IPython/ultraTB.py (__date__): Modified color escape sequences
4377 4389 and now things work fine under xterm and in Emacs' term buffers
4378 4390 (though not shell ones). Well, in emacs you get colors, but all
4379 4391 seem to be 'light' colors (no difference between dark and light
4380 4392 ones). But the garbage chars are gone, and also in xterms. It
4381 4393 seems that now I'm using 'cleaner' ansi sequences.
4382 4394
4383 4395 2002-02-21 Fernando Perez <fperez@colorado.edu>
4384 4396
4385 4397 * Released 0.2.7 (mainly to publish the scoping fix).
4386 4398
4387 4399 * IPython/Logger.py (Logger.logstate): added. A corresponding
4388 4400 @logstate magic was created.
4389 4401
4390 4402 * IPython/Magic.py: fixed nested scoping problem under Python
4391 4403 2.1.x (automagic wasn't working).
4392 4404
4393 4405 2002-02-20 Fernando Perez <fperez@colorado.edu>
4394 4406
4395 4407 * Released 0.2.6.
4396 4408
4397 4409 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4398 4410 option so that logs can come out without any headers at all.
4399 4411
4400 4412 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4401 4413 SciPy.
4402 4414
4403 4415 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4404 4416 that embedded IPython calls don't require vars() to be explicitly
4405 4417 passed. Now they are extracted from the caller's frame (code
4406 4418 snatched from Eric Jones' weave). Added better documentation to
4407 4419 the section on embedding and the example file.
4408 4420
4409 4421 * IPython/genutils.py (page): Changed so that under emacs, it just
4410 4422 prints the string. You can then page up and down in the emacs
4411 4423 buffer itself. This is how the builtin help() works.
4412 4424
4413 4425 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
4414 4426 macro scoping: macros need to be executed in the user's namespace
4415 4427 to work as if they had been typed by the user.
4416 4428
4417 4429 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
4418 4430 execute automatically (no need to type 'exec...'). They then
4419 4431 behave like 'true macros'. The printing system was also modified
4420 4432 for this to work.
4421 4433
4422 4434 2002-02-19 Fernando Perez <fperez@colorado.edu>
4423 4435
4424 4436 * IPython/genutils.py (page_file): new function for paging files
4425 4437 in an OS-independent way. Also necessary for file viewing to work
4426 4438 well inside Emacs buffers.
4427 4439 (page): Added checks for being in an emacs buffer.
4428 4440 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
4429 4441 same bug in iplib.
4430 4442
4431 4443 2002-02-18 Fernando Perez <fperez@colorado.edu>
4432 4444
4433 4445 * IPython/iplib.py (InteractiveShell.init_readline): modified use
4434 4446 of readline so that IPython can work inside an Emacs buffer.
4435 4447
4436 4448 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
4437 4449 method signatures (they weren't really bugs, but it looks cleaner
4438 4450 and keeps PyChecker happy).
4439 4451
4440 4452 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
4441 4453 for implementing various user-defined hooks. Currently only
4442 4454 display is done.
4443 4455
4444 4456 * IPython/Prompts.py (CachedOutput._display): changed display
4445 4457 functions so that they can be dynamically changed by users easily.
4446 4458
4447 4459 * IPython/Extensions/numeric_formats.py (num_display): added an
4448 4460 extension for printing NumPy arrays in flexible manners. It
4449 4461 doesn't do anything yet, but all the structure is in
4450 4462 place. Ultimately the plan is to implement output format control
4451 4463 like in Octave.
4452 4464
4453 4465 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
4454 4466 methods are found at run-time by all the automatic machinery.
4455 4467
4456 4468 2002-02-17 Fernando Perez <fperez@colorado.edu>
4457 4469
4458 4470 * setup_Windows.py (make_shortcut): documented. Cleaned up the
4459 4471 whole file a little.
4460 4472
4461 4473 * ToDo: closed this document. Now there's a new_design.lyx
4462 4474 document for all new ideas. Added making a pdf of it for the
4463 4475 end-user distro.
4464 4476
4465 4477 * IPython/Logger.py (Logger.switch_log): Created this to replace
4466 4478 logon() and logoff(). It also fixes a nasty crash reported by
4467 4479 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
4468 4480
4469 4481 * IPython/iplib.py (complete): got auto-completion to work with
4470 4482 automagic (I had wanted this for a long time).
4471 4483
4472 4484 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
4473 4485 to @file, since file() is now a builtin and clashes with automagic
4474 4486 for @file.
4475 4487
4476 4488 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
4477 4489 of this was previously in iplib, which had grown to more than 2000
4478 4490 lines, way too long. No new functionality, but it makes managing
4479 4491 the code a bit easier.
4480 4492
4481 4493 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
4482 4494 information to crash reports.
4483 4495
4484 4496 2002-02-12 Fernando Perez <fperez@colorado.edu>
4485 4497
4486 4498 * Released 0.2.5.
4487 4499
4488 4500 2002-02-11 Fernando Perez <fperez@colorado.edu>
4489 4501
4490 4502 * Wrote a relatively complete Windows installer. It puts
4491 4503 everything in place, creates Start Menu entries and fixes the
4492 4504 color issues. Nothing fancy, but it works.
4493 4505
4494 4506 2002-02-10 Fernando Perez <fperez@colorado.edu>
4495 4507
4496 4508 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
4497 4509 os.path.expanduser() call so that we can type @run ~/myfile.py and
4498 4510 have thigs work as expected.
4499 4511
4500 4512 * IPython/genutils.py (page): fixed exception handling so things
4501 4513 work both in Unix and Windows correctly. Quitting a pager triggers
4502 4514 an IOError/broken pipe in Unix, and in windows not finding a pager
4503 4515 is also an IOError, so I had to actually look at the return value
4504 4516 of the exception, not just the exception itself. Should be ok now.
4505 4517
4506 4518 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
4507 4519 modified to allow case-insensitive color scheme changes.
4508 4520
4509 4521 2002-02-09 Fernando Perez <fperez@colorado.edu>
4510 4522
4511 4523 * IPython/genutils.py (native_line_ends): new function to leave
4512 4524 user config files with os-native line-endings.
4513 4525
4514 4526 * README and manual updates.
4515 4527
4516 4528 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
4517 4529 instead of StringType to catch Unicode strings.
4518 4530
4519 4531 * IPython/genutils.py (filefind): fixed bug for paths with
4520 4532 embedded spaces (very common in Windows).
4521 4533
4522 4534 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
4523 4535 files under Windows, so that they get automatically associated
4524 4536 with a text editor. Windows makes it a pain to handle
4525 4537 extension-less files.
4526 4538
4527 4539 * IPython/iplib.py (InteractiveShell.init_readline): Made the
4528 4540 warning about readline only occur for Posix. In Windows there's no
4529 4541 way to get readline, so why bother with the warning.
4530 4542
4531 4543 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
4532 4544 for __str__ instead of dir(self), since dir() changed in 2.2.
4533 4545
4534 4546 * Ported to Windows! Tested on XP, I suspect it should work fine
4535 4547 on NT/2000, but I don't think it will work on 98 et al. That
4536 4548 series of Windows is such a piece of junk anyway that I won't try
4537 4549 porting it there. The XP port was straightforward, showed a few
4538 4550 bugs here and there (fixed all), in particular some string
4539 4551 handling stuff which required considering Unicode strings (which
4540 4552 Windows uses). This is good, but hasn't been too tested :) No
4541 4553 fancy installer yet, I'll put a note in the manual so people at
4542 4554 least make manually a shortcut.
4543 4555
4544 4556 * IPython/iplib.py (Magic.magic_colors): Unified the color options
4545 4557 into a single one, "colors". This now controls both prompt and
4546 4558 exception color schemes, and can be changed both at startup
4547 4559 (either via command-line switches or via ipythonrc files) and at
4548 4560 runtime, with @colors.
4549 4561 (Magic.magic_run): renamed @prun to @run and removed the old
4550 4562 @run. The two were too similar to warrant keeping both.
4551 4563
4552 4564 2002-02-03 Fernando Perez <fperez@colorado.edu>
4553 4565
4554 4566 * IPython/iplib.py (install_first_time): Added comment on how to
4555 4567 configure the color options for first-time users. Put a <return>
4556 4568 request at the end so that small-terminal users get a chance to
4557 4569 read the startup info.
4558 4570
4559 4571 2002-01-23 Fernando Perez <fperez@colorado.edu>
4560 4572
4561 4573 * IPython/iplib.py (CachedOutput.update): Changed output memory
4562 4574 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
4563 4575 input history we still use _i. Did this b/c these variable are
4564 4576 very commonly used in interactive work, so the less we need to
4565 4577 type the better off we are.
4566 4578 (Magic.magic_prun): updated @prun to better handle the namespaces
4567 4579 the file will run in, including a fix for __name__ not being set
4568 4580 before.
4569 4581
4570 4582 2002-01-20 Fernando Perez <fperez@colorado.edu>
4571 4583
4572 4584 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
4573 4585 extra garbage for Python 2.2. Need to look more carefully into
4574 4586 this later.
4575 4587
4576 4588 2002-01-19 Fernando Perez <fperez@colorado.edu>
4577 4589
4578 4590 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4579 4591 display SyntaxError exceptions properly formatted when they occur
4580 4592 (they can be triggered by imported code).
4581 4593
4582 4594 2002-01-18 Fernando Perez <fperez@colorado.edu>
4583 4595
4584 4596 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4585 4597 SyntaxError exceptions are reported nicely formatted, instead of
4586 4598 spitting out only offset information as before.
4587 4599 (Magic.magic_prun): Added the @prun function for executing
4588 4600 programs with command line args inside IPython.
4589 4601
4590 4602 2002-01-16 Fernando Perez <fperez@colorado.edu>
4591 4603
4592 4604 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4593 4605 to *not* include the last item given in a range. This brings their
4594 4606 behavior in line with Python's slicing:
4595 4607 a[n1:n2] -> a[n1]...a[n2-1]
4596 4608 It may be a bit less convenient, but I prefer to stick to Python's
4597 4609 conventions *everywhere*, so users never have to wonder.
4598 4610 (Magic.magic_macro): Added @macro function to ease the creation of
4599 4611 macros.
4600 4612
4601 4613 2002-01-05 Fernando Perez <fperez@colorado.edu>
4602 4614
4603 4615 * Released 0.2.4.
4604 4616
4605 4617 * IPython/iplib.py (Magic.magic_pdef):
4606 4618 (InteractiveShell.safe_execfile): report magic lines and error
4607 4619 lines without line numbers so one can easily copy/paste them for
4608 4620 re-execution.
4609 4621
4610 4622 * Updated manual with recent changes.
4611 4623
4612 4624 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4613 4625 docstring printing when class? is called. Very handy for knowing
4614 4626 how to create class instances (as long as __init__ is well
4615 4627 documented, of course :)
4616 4628 (Magic.magic_doc): print both class and constructor docstrings.
4617 4629 (Magic.magic_pdef): give constructor info if passed a class and
4618 4630 __call__ info for callable object instances.
4619 4631
4620 4632 2002-01-04 Fernando Perez <fperez@colorado.edu>
4621 4633
4622 4634 * Made deep_reload() off by default. It doesn't always work
4623 4635 exactly as intended, so it's probably safer to have it off. It's
4624 4636 still available as dreload() anyway, so nothing is lost.
4625 4637
4626 4638 2002-01-02 Fernando Perez <fperez@colorado.edu>
4627 4639
4628 4640 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4629 4641 so I wanted an updated release).
4630 4642
4631 4643 2001-12-27 Fernando Perez <fperez@colorado.edu>
4632 4644
4633 4645 * IPython/iplib.py (InteractiveShell.interact): Added the original
4634 4646 code from 'code.py' for this module in order to change the
4635 4647 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4636 4648 the history cache would break when the user hit Ctrl-C, and
4637 4649 interact() offers no way to add any hooks to it.
4638 4650
4639 4651 2001-12-23 Fernando Perez <fperez@colorado.edu>
4640 4652
4641 4653 * setup.py: added check for 'MANIFEST' before trying to remove
4642 4654 it. Thanks to Sean Reifschneider.
4643 4655
4644 4656 2001-12-22 Fernando Perez <fperez@colorado.edu>
4645 4657
4646 4658 * Released 0.2.2.
4647 4659
4648 4660 * Finished (reasonably) writing the manual. Later will add the
4649 4661 python-standard navigation stylesheets, but for the time being
4650 4662 it's fairly complete. Distribution will include html and pdf
4651 4663 versions.
4652 4664
4653 4665 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4654 4666 (MayaVi author).
4655 4667
4656 4668 2001-12-21 Fernando Perez <fperez@colorado.edu>
4657 4669
4658 4670 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4659 4671 good public release, I think (with the manual and the distutils
4660 4672 installer). The manual can use some work, but that can go
4661 4673 slowly. Otherwise I think it's quite nice for end users. Next
4662 4674 summer, rewrite the guts of it...
4663 4675
4664 4676 * Changed format of ipythonrc files to use whitespace as the
4665 4677 separator instead of an explicit '='. Cleaner.
4666 4678
4667 4679 2001-12-20 Fernando Perez <fperez@colorado.edu>
4668 4680
4669 4681 * Started a manual in LyX. For now it's just a quick merge of the
4670 4682 various internal docstrings and READMEs. Later it may grow into a
4671 4683 nice, full-blown manual.
4672 4684
4673 4685 * Set up a distutils based installer. Installation should now be
4674 4686 trivially simple for end-users.
4675 4687
4676 4688 2001-12-11 Fernando Perez <fperez@colorado.edu>
4677 4689
4678 4690 * Released 0.2.0. First public release, announced it at
4679 4691 comp.lang.python. From now on, just bugfixes...
4680 4692
4681 4693 * Went through all the files, set copyright/license notices and
4682 4694 cleaned up things. Ready for release.
4683 4695
4684 4696 2001-12-10 Fernando Perez <fperez@colorado.edu>
4685 4697
4686 4698 * Changed the first-time installer not to use tarfiles. It's more
4687 4699 robust now and less unix-dependent. Also makes it easier for
4688 4700 people to later upgrade versions.
4689 4701
4690 4702 * Changed @exit to @abort to reflect the fact that it's pretty
4691 4703 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4692 4704 becomes significant only when IPyhton is embedded: in that case,
4693 4705 C-D closes IPython only, but @abort kills the enclosing program
4694 4706 too (unless it had called IPython inside a try catching
4695 4707 SystemExit).
4696 4708
4697 4709 * Created Shell module which exposes the actuall IPython Shell
4698 4710 classes, currently the normal and the embeddable one. This at
4699 4711 least offers a stable interface we won't need to change when
4700 4712 (later) the internals are rewritten. That rewrite will be confined
4701 4713 to iplib and ipmaker, but the Shell interface should remain as is.
4702 4714
4703 4715 * Added embed module which offers an embeddable IPShell object,
4704 4716 useful to fire up IPython *inside* a running program. Great for
4705 4717 debugging or dynamical data analysis.
4706 4718
4707 4719 2001-12-08 Fernando Perez <fperez@colorado.edu>
4708 4720
4709 4721 * Fixed small bug preventing seeing info from methods of defined
4710 4722 objects (incorrect namespace in _ofind()).
4711 4723
4712 4724 * Documentation cleanup. Moved the main usage docstrings to a
4713 4725 separate file, usage.py (cleaner to maintain, and hopefully in the
4714 4726 future some perlpod-like way of producing interactive, man and
4715 4727 html docs out of it will be found).
4716 4728
4717 4729 * Added @profile to see your profile at any time.
4718 4730
4719 4731 * Added @p as an alias for 'print'. It's especially convenient if
4720 4732 using automagic ('p x' prints x).
4721 4733
4722 4734 * Small cleanups and fixes after a pychecker run.
4723 4735
4724 4736 * Changed the @cd command to handle @cd - and @cd -<n> for
4725 4737 visiting any directory in _dh.
4726 4738
4727 4739 * Introduced _dh, a history of visited directories. @dhist prints
4728 4740 it out with numbers.
4729 4741
4730 4742 2001-12-07 Fernando Perez <fperez@colorado.edu>
4731 4743
4732 4744 * Released 0.1.22
4733 4745
4734 4746 * Made initialization a bit more robust against invalid color
4735 4747 options in user input (exit, not traceback-crash).
4736 4748
4737 4749 * Changed the bug crash reporter to write the report only in the
4738 4750 user's .ipython directory. That way IPython won't litter people's
4739 4751 hard disks with crash files all over the place. Also print on
4740 4752 screen the necessary mail command.
4741 4753
4742 4754 * With the new ultraTB, implemented LightBG color scheme for light
4743 4755 background terminals. A lot of people like white backgrounds, so I
4744 4756 guess we should at least give them something readable.
4745 4757
4746 4758 2001-12-06 Fernando Perez <fperez@colorado.edu>
4747 4759
4748 4760 * Modified the structure of ultraTB. Now there's a proper class
4749 4761 for tables of color schemes which allow adding schemes easily and
4750 4762 switching the active scheme without creating a new instance every
4751 4763 time (which was ridiculous). The syntax for creating new schemes
4752 4764 is also cleaner. I think ultraTB is finally done, with a clean
4753 4765 class structure. Names are also much cleaner (now there's proper
4754 4766 color tables, no need for every variable to also have 'color' in
4755 4767 its name).
4756 4768
4757 4769 * Broke down genutils into separate files. Now genutils only
4758 4770 contains utility functions, and classes have been moved to their
4759 4771 own files (they had enough independent functionality to warrant
4760 4772 it): ConfigLoader, OutputTrap, Struct.
4761 4773
4762 4774 2001-12-05 Fernando Perez <fperez@colorado.edu>
4763 4775
4764 4776 * IPython turns 21! Released version 0.1.21, as a candidate for
4765 4777 public consumption. If all goes well, release in a few days.
4766 4778
4767 4779 * Fixed path bug (files in Extensions/ directory wouldn't be found
4768 4780 unless IPython/ was explicitly in sys.path).
4769 4781
4770 4782 * Extended the FlexCompleter class as MagicCompleter to allow
4771 4783 completion of @-starting lines.
4772 4784
4773 4785 * Created __release__.py file as a central repository for release
4774 4786 info that other files can read from.
4775 4787
4776 4788 * Fixed small bug in logging: when logging was turned on in
4777 4789 mid-session, old lines with special meanings (!@?) were being
4778 4790 logged without the prepended comment, which is necessary since
4779 4791 they are not truly valid python syntax. This should make session
4780 4792 restores produce less errors.
4781 4793
4782 4794 * The namespace cleanup forced me to make a FlexCompleter class
4783 4795 which is nothing but a ripoff of rlcompleter, but with selectable
4784 4796 namespace (rlcompleter only works in __main__.__dict__). I'll try
4785 4797 to submit a note to the authors to see if this change can be
4786 4798 incorporated in future rlcompleter releases (Dec.6: done)
4787 4799
4788 4800 * More fixes to namespace handling. It was a mess! Now all
4789 4801 explicit references to __main__.__dict__ are gone (except when
4790 4802 really needed) and everything is handled through the namespace
4791 4803 dicts in the IPython instance. We seem to be getting somewhere
4792 4804 with this, finally...
4793 4805
4794 4806 * Small documentation updates.
4795 4807
4796 4808 * Created the Extensions directory under IPython (with an
4797 4809 __init__.py). Put the PhysicalQ stuff there. This directory should
4798 4810 be used for all special-purpose extensions.
4799 4811
4800 4812 * File renaming:
4801 4813 ipythonlib --> ipmaker
4802 4814 ipplib --> iplib
4803 4815 This makes a bit more sense in terms of what these files actually do.
4804 4816
4805 4817 * Moved all the classes and functions in ipythonlib to ipplib, so
4806 4818 now ipythonlib only has make_IPython(). This will ease up its
4807 4819 splitting in smaller functional chunks later.
4808 4820
4809 4821 * Cleaned up (done, I think) output of @whos. Better column
4810 4822 formatting, and now shows str(var) for as much as it can, which is
4811 4823 typically what one gets with a 'print var'.
4812 4824
4813 4825 2001-12-04 Fernando Perez <fperez@colorado.edu>
4814 4826
4815 4827 * Fixed namespace problems. Now builtin/IPyhton/user names get
4816 4828 properly reported in their namespace. Internal namespace handling
4817 4829 is finally getting decent (not perfect yet, but much better than
4818 4830 the ad-hoc mess we had).
4819 4831
4820 4832 * Removed -exit option. If people just want to run a python
4821 4833 script, that's what the normal interpreter is for. Less
4822 4834 unnecessary options, less chances for bugs.
4823 4835
4824 4836 * Added a crash handler which generates a complete post-mortem if
4825 4837 IPython crashes. This will help a lot in tracking bugs down the
4826 4838 road.
4827 4839
4828 4840 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4829 4841 which were boud to functions being reassigned would bypass the
4830 4842 logger, breaking the sync of _il with the prompt counter. This
4831 4843 would then crash IPython later when a new line was logged.
4832 4844
4833 4845 2001-12-02 Fernando Perez <fperez@colorado.edu>
4834 4846
4835 4847 * Made IPython a package. This means people don't have to clutter
4836 4848 their sys.path with yet another directory. Changed the INSTALL
4837 4849 file accordingly.
4838 4850
4839 4851 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4840 4852 sorts its output (so @who shows it sorted) and @whos formats the
4841 4853 table according to the width of the first column. Nicer, easier to
4842 4854 read. Todo: write a generic table_format() which takes a list of
4843 4855 lists and prints it nicely formatted, with optional row/column
4844 4856 separators and proper padding and justification.
4845 4857
4846 4858 * Released 0.1.20
4847 4859
4848 4860 * Fixed bug in @log which would reverse the inputcache list (a
4849 4861 copy operation was missing).
4850 4862
4851 4863 * Code cleanup. @config was changed to use page(). Better, since
4852 4864 its output is always quite long.
4853 4865
4854 4866 * Itpl is back as a dependency. I was having too many problems
4855 4867 getting the parametric aliases to work reliably, and it's just
4856 4868 easier to code weird string operations with it than playing %()s
4857 4869 games. It's only ~6k, so I don't think it's too big a deal.
4858 4870
4859 4871 * Found (and fixed) a very nasty bug with history. !lines weren't
4860 4872 getting cached, and the out of sync caches would crash
4861 4873 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4862 4874 division of labor a bit better. Bug fixed, cleaner structure.
4863 4875
4864 4876 2001-12-01 Fernando Perez <fperez@colorado.edu>
4865 4877
4866 4878 * Released 0.1.19
4867 4879
4868 4880 * Added option -n to @hist to prevent line number printing. Much
4869 4881 easier to copy/paste code this way.
4870 4882
4871 4883 * Created global _il to hold the input list. Allows easy
4872 4884 re-execution of blocks of code by slicing it (inspired by Janko's
4873 4885 comment on 'macros').
4874 4886
4875 4887 * Small fixes and doc updates.
4876 4888
4877 4889 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4878 4890 much too fragile with automagic. Handles properly multi-line
4879 4891 statements and takes parameters.
4880 4892
4881 4893 2001-11-30 Fernando Perez <fperez@colorado.edu>
4882 4894
4883 4895 * Version 0.1.18 released.
4884 4896
4885 4897 * Fixed nasty namespace bug in initial module imports.
4886 4898
4887 4899 * Added copyright/license notes to all code files (except
4888 4900 DPyGetOpt). For the time being, LGPL. That could change.
4889 4901
4890 4902 * Rewrote a much nicer README, updated INSTALL, cleaned up
4891 4903 ipythonrc-* samples.
4892 4904
4893 4905 * Overall code/documentation cleanup. Basically ready for
4894 4906 release. Only remaining thing: licence decision (LGPL?).
4895 4907
4896 4908 * Converted load_config to a class, ConfigLoader. Now recursion
4897 4909 control is better organized. Doesn't include the same file twice.
4898 4910
4899 4911 2001-11-29 Fernando Perez <fperez@colorado.edu>
4900 4912
4901 4913 * Got input history working. Changed output history variables from
4902 4914 _p to _o so that _i is for input and _o for output. Just cleaner
4903 4915 convention.
4904 4916
4905 4917 * Implemented parametric aliases. This pretty much allows the
4906 4918 alias system to offer full-blown shell convenience, I think.
4907 4919
4908 4920 * Version 0.1.17 released, 0.1.18 opened.
4909 4921
4910 4922 * dot_ipython/ipythonrc (alias): added documentation.
4911 4923 (xcolor): Fixed small bug (xcolors -> xcolor)
4912 4924
4913 4925 * Changed the alias system. Now alias is a magic command to define
4914 4926 aliases just like the shell. Rationale: the builtin magics should
4915 4927 be there for things deeply connected to IPython's
4916 4928 architecture. And this is a much lighter system for what I think
4917 4929 is the really important feature: allowing users to define quickly
4918 4930 magics that will do shell things for them, so they can customize
4919 4931 IPython easily to match their work habits. If someone is really
4920 4932 desperate to have another name for a builtin alias, they can
4921 4933 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4922 4934 works.
4923 4935
4924 4936 2001-11-28 Fernando Perez <fperez@colorado.edu>
4925 4937
4926 4938 * Changed @file so that it opens the source file at the proper
4927 4939 line. Since it uses less, if your EDITOR environment is
4928 4940 configured, typing v will immediately open your editor of choice
4929 4941 right at the line where the object is defined. Not as quick as
4930 4942 having a direct @edit command, but for all intents and purposes it
4931 4943 works. And I don't have to worry about writing @edit to deal with
4932 4944 all the editors, less does that.
4933 4945
4934 4946 * Version 0.1.16 released, 0.1.17 opened.
4935 4947
4936 4948 * Fixed some nasty bugs in the page/page_dumb combo that could
4937 4949 crash IPython.
4938 4950
4939 4951 2001-11-27 Fernando Perez <fperez@colorado.edu>
4940 4952
4941 4953 * Version 0.1.15 released, 0.1.16 opened.
4942 4954
4943 4955 * Finally got ? and ?? to work for undefined things: now it's
4944 4956 possible to type {}.get? and get information about the get method
4945 4957 of dicts, or os.path? even if only os is defined (so technically
4946 4958 os.path isn't). Works at any level. For example, after import os,
4947 4959 os?, os.path?, os.path.abspath? all work. This is great, took some
4948 4960 work in _ofind.
4949 4961
4950 4962 * Fixed more bugs with logging. The sanest way to do it was to add
4951 4963 to @log a 'mode' parameter. Killed two in one shot (this mode
4952 4964 option was a request of Janko's). I think it's finally clean
4953 4965 (famous last words).
4954 4966
4955 4967 * Added a page_dumb() pager which does a decent job of paging on
4956 4968 screen, if better things (like less) aren't available. One less
4957 4969 unix dependency (someday maybe somebody will port this to
4958 4970 windows).
4959 4971
4960 4972 * Fixed problem in magic_log: would lock of logging out if log
4961 4973 creation failed (because it would still think it had succeeded).
4962 4974
4963 4975 * Improved the page() function using curses to auto-detect screen
4964 4976 size. Now it can make a much better decision on whether to print
4965 4977 or page a string. Option screen_length was modified: a value 0
4966 4978 means auto-detect, and that's the default now.
4967 4979
4968 4980 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4969 4981 go out. I'll test it for a few days, then talk to Janko about
4970 4982 licences and announce it.
4971 4983
4972 4984 * Fixed the length of the auto-generated ---> prompt which appears
4973 4985 for auto-parens and auto-quotes. Getting this right isn't trivial,
4974 4986 with all the color escapes, different prompt types and optional
4975 4987 separators. But it seems to be working in all the combinations.
4976 4988
4977 4989 2001-11-26 Fernando Perez <fperez@colorado.edu>
4978 4990
4979 4991 * Wrote a regexp filter to get option types from the option names
4980 4992 string. This eliminates the need to manually keep two duplicate
4981 4993 lists.
4982 4994
4983 4995 * Removed the unneeded check_option_names. Now options are handled
4984 4996 in a much saner manner and it's easy to visually check that things
4985 4997 are ok.
4986 4998
4987 4999 * Updated version numbers on all files I modified to carry a
4988 5000 notice so Janko and Nathan have clear version markers.
4989 5001
4990 5002 * Updated docstring for ultraTB with my changes. I should send
4991 5003 this to Nathan.
4992 5004
4993 5005 * Lots of small fixes. Ran everything through pychecker again.
4994 5006
4995 5007 * Made loading of deep_reload an cmd line option. If it's not too
4996 5008 kosher, now people can just disable it. With -nodeep_reload it's
4997 5009 still available as dreload(), it just won't overwrite reload().
4998 5010
4999 5011 * Moved many options to the no| form (-opt and -noopt
5000 5012 accepted). Cleaner.
5001 5013
5002 5014 * Changed magic_log so that if called with no parameters, it uses
5003 5015 'rotate' mode. That way auto-generated logs aren't automatically
5004 5016 over-written. For normal logs, now a backup is made if it exists
5005 5017 (only 1 level of backups). A new 'backup' mode was added to the
5006 5018 Logger class to support this. This was a request by Janko.
5007 5019
5008 5020 * Added @logoff/@logon to stop/restart an active log.
5009 5021
5010 5022 * Fixed a lot of bugs in log saving/replay. It was pretty
5011 5023 broken. Now special lines (!@,/) appear properly in the command
5012 5024 history after a log replay.
5013 5025
5014 5026 * Tried and failed to implement full session saving via pickle. My
5015 5027 idea was to pickle __main__.__dict__, but modules can't be
5016 5028 pickled. This would be a better alternative to replaying logs, but
5017 5029 seems quite tricky to get to work. Changed -session to be called
5018 5030 -logplay, which more accurately reflects what it does. And if we
5019 5031 ever get real session saving working, -session is now available.
5020 5032
5021 5033 * Implemented color schemes for prompts also. As for tracebacks,
5022 5034 currently only NoColor and Linux are supported. But now the
5023 5035 infrastructure is in place, based on a generic ColorScheme
5024 5036 class. So writing and activating new schemes both for the prompts
5025 5037 and the tracebacks should be straightforward.
5026 5038
5027 5039 * Version 0.1.13 released, 0.1.14 opened.
5028 5040
5029 5041 * Changed handling of options for output cache. Now counter is
5030 5042 hardwired starting at 1 and one specifies the maximum number of
5031 5043 entries *in the outcache* (not the max prompt counter). This is
5032 5044 much better, since many statements won't increase the cache
5033 5045 count. It also eliminated some confusing options, now there's only
5034 5046 one: cache_size.
5035 5047
5036 5048 * Added 'alias' magic function and magic_alias option in the
5037 5049 ipythonrc file. Now the user can easily define whatever names he
5038 5050 wants for the magic functions without having to play weird
5039 5051 namespace games. This gives IPython a real shell-like feel.
5040 5052
5041 5053 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5042 5054 @ or not).
5043 5055
5044 5056 This was one of the last remaining 'visible' bugs (that I know
5045 5057 of). I think if I can clean up the session loading so it works
5046 5058 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5047 5059 about licensing).
5048 5060
5049 5061 2001-11-25 Fernando Perez <fperez@colorado.edu>
5050 5062
5051 5063 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5052 5064 there's a cleaner distinction between what ? and ?? show.
5053 5065
5054 5066 * Added screen_length option. Now the user can define his own
5055 5067 screen size for page() operations.
5056 5068
5057 5069 * Implemented magic shell-like functions with automatic code
5058 5070 generation. Now adding another function is just a matter of adding
5059 5071 an entry to a dict, and the function is dynamically generated at
5060 5072 run-time. Python has some really cool features!
5061 5073
5062 5074 * Renamed many options to cleanup conventions a little. Now all
5063 5075 are lowercase, and only underscores where needed. Also in the code
5064 5076 option name tables are clearer.
5065 5077
5066 5078 * Changed prompts a little. Now input is 'In [n]:' instead of
5067 5079 'In[n]:='. This allows it the numbers to be aligned with the
5068 5080 Out[n] numbers, and removes usage of ':=' which doesn't exist in
5069 5081 Python (it was a Mathematica thing). The '...' continuation prompt
5070 5082 was also changed a little to align better.
5071 5083
5072 5084 * Fixed bug when flushing output cache. Not all _p<n> variables
5073 5085 exist, so their deletion needs to be wrapped in a try:
5074 5086
5075 5087 * Figured out how to properly use inspect.formatargspec() (it
5076 5088 requires the args preceded by *). So I removed all the code from
5077 5089 _get_pdef in Magic, which was just replicating that.
5078 5090
5079 5091 * Added test to prefilter to allow redefining magic function names
5080 5092 as variables. This is ok, since the @ form is always available,
5081 5093 but whe should allow the user to define a variable called 'ls' if
5082 5094 he needs it.
5083 5095
5084 5096 * Moved the ToDo information from README into a separate ToDo.
5085 5097
5086 5098 * General code cleanup and small bugfixes. I think it's close to a
5087 5099 state where it can be released, obviously with a big 'beta'
5088 5100 warning on it.
5089 5101
5090 5102 * Got the magic function split to work. Now all magics are defined
5091 5103 in a separate class. It just organizes things a bit, and now
5092 5104 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
5093 5105 was too long).
5094 5106
5095 5107 * Changed @clear to @reset to avoid potential confusions with
5096 5108 the shell command clear. Also renamed @cl to @clear, which does
5097 5109 exactly what people expect it to from their shell experience.
5098 5110
5099 5111 Added a check to the @reset command (since it's so
5100 5112 destructive, it's probably a good idea to ask for confirmation).
5101 5113 But now reset only works for full namespace resetting. Since the
5102 5114 del keyword is already there for deleting a few specific
5103 5115 variables, I don't see the point of having a redundant magic
5104 5116 function for the same task.
5105 5117
5106 5118 2001-11-24 Fernando Perez <fperez@colorado.edu>
5107 5119
5108 5120 * Updated the builtin docs (esp. the ? ones).
5109 5121
5110 5122 * Ran all the code through pychecker. Not terribly impressed with
5111 5123 it: lots of spurious warnings and didn't really find anything of
5112 5124 substance (just a few modules being imported and not used).
5113 5125
5114 5126 * Implemented the new ultraTB functionality into IPython. New
5115 5127 option: xcolors. This chooses color scheme. xmode now only selects
5116 5128 between Plain and Verbose. Better orthogonality.
5117 5129
5118 5130 * Large rewrite of ultraTB. Much cleaner now, with a separation of
5119 5131 mode and color scheme for the exception handlers. Now it's
5120 5132 possible to have the verbose traceback with no coloring.
5121 5133
5122 5134 2001-11-23 Fernando Perez <fperez@colorado.edu>
5123 5135
5124 5136 * Version 0.1.12 released, 0.1.13 opened.
5125 5137
5126 5138 * Removed option to set auto-quote and auto-paren escapes by
5127 5139 user. The chances of breaking valid syntax are just too high. If
5128 5140 someone *really* wants, they can always dig into the code.
5129 5141
5130 5142 * Made prompt separators configurable.
5131 5143
5132 5144 2001-11-22 Fernando Perez <fperez@colorado.edu>
5133 5145
5134 5146 * Small bugfixes in many places.
5135 5147
5136 5148 * Removed the MyCompleter class from ipplib. It seemed redundant
5137 5149 with the C-p,C-n history search functionality. Less code to
5138 5150 maintain.
5139 5151
5140 5152 * Moved all the original ipython.py code into ipythonlib.py. Right
5141 5153 now it's just one big dump into a function called make_IPython, so
5142 5154 no real modularity has been gained. But at least it makes the
5143 5155 wrapper script tiny, and since ipythonlib is a module, it gets
5144 5156 compiled and startup is much faster.
5145 5157
5146 5158 This is a reasobably 'deep' change, so we should test it for a
5147 5159 while without messing too much more with the code.
5148 5160
5149 5161 2001-11-21 Fernando Perez <fperez@colorado.edu>
5150 5162
5151 5163 * Version 0.1.11 released, 0.1.12 opened for further work.
5152 5164
5153 5165 * Removed dependency on Itpl. It was only needed in one place. It
5154 5166 would be nice if this became part of python, though. It makes life
5155 5167 *a lot* easier in some cases.
5156 5168
5157 5169 * Simplified the prefilter code a bit. Now all handlers are
5158 5170 expected to explicitly return a value (at least a blank string).
5159 5171
5160 5172 * Heavy edits in ipplib. Removed the help system altogether. Now
5161 5173 obj?/?? is used for inspecting objects, a magic @doc prints
5162 5174 docstrings, and full-blown Python help is accessed via the 'help'
5163 5175 keyword. This cleans up a lot of code (less to maintain) and does
5164 5176 the job. Since 'help' is now a standard Python component, might as
5165 5177 well use it and remove duplicate functionality.
5166 5178
5167 5179 Also removed the option to use ipplib as a standalone program. By
5168 5180 now it's too dependent on other parts of IPython to function alone.
5169 5181
5170 5182 * Fixed bug in genutils.pager. It would crash if the pager was
5171 5183 exited immediately after opening (broken pipe).
5172 5184
5173 5185 * Trimmed down the VerboseTB reporting a little. The header is
5174 5186 much shorter now and the repeated exception arguments at the end
5175 5187 have been removed. For interactive use the old header seemed a bit
5176 5188 excessive.
5177 5189
5178 5190 * Fixed small bug in output of @whos for variables with multi-word
5179 5191 types (only first word was displayed).
5180 5192
5181 5193 2001-11-17 Fernando Perez <fperez@colorado.edu>
5182 5194
5183 5195 * Version 0.1.10 released, 0.1.11 opened for further work.
5184 5196
5185 5197 * Modified dirs and friends. dirs now *returns* the stack (not
5186 5198 prints), so one can manipulate it as a variable. Convenient to
5187 5199 travel along many directories.
5188 5200
5189 5201 * Fixed bug in magic_pdef: would only work with functions with
5190 5202 arguments with default values.
5191 5203
5192 5204 2001-11-14 Fernando Perez <fperez@colorado.edu>
5193 5205
5194 5206 * Added the PhysicsInput stuff to dot_ipython so it ships as an
5195 5207 example with IPython. Various other minor fixes and cleanups.
5196 5208
5197 5209 * Version 0.1.9 released, 0.1.10 opened for further work.
5198 5210
5199 5211 * Added sys.path to the list of directories searched in the
5200 5212 execfile= option. It used to be the current directory and the
5201 5213 user's IPYTHONDIR only.
5202 5214
5203 5215 2001-11-13 Fernando Perez <fperez@colorado.edu>
5204 5216
5205 5217 * Reinstated the raw_input/prefilter separation that Janko had
5206 5218 initially. This gives a more convenient setup for extending the
5207 5219 pre-processor from the outside: raw_input always gets a string,
5208 5220 and prefilter has to process it. We can then redefine prefilter
5209 5221 from the outside and implement extensions for special
5210 5222 purposes.
5211 5223
5212 5224 Today I got one for inputting PhysicalQuantity objects
5213 5225 (from Scientific) without needing any function calls at
5214 5226 all. Extremely convenient, and it's all done as a user-level
5215 5227 extension (no IPython code was touched). Now instead of:
5216 5228 a = PhysicalQuantity(4.2,'m/s**2')
5217 5229 one can simply say
5218 5230 a = 4.2 m/s**2
5219 5231 or even
5220 5232 a = 4.2 m/s^2
5221 5233
5222 5234 I use this, but it's also a proof of concept: IPython really is
5223 5235 fully user-extensible, even at the level of the parsing of the
5224 5236 command line. It's not trivial, but it's perfectly doable.
5225 5237
5226 5238 * Added 'add_flip' method to inclusion conflict resolver. Fixes
5227 5239 the problem of modules being loaded in the inverse order in which
5228 5240 they were defined in
5229 5241
5230 5242 * Version 0.1.8 released, 0.1.9 opened for further work.
5231 5243
5232 5244 * Added magics pdef, source and file. They respectively show the
5233 5245 definition line ('prototype' in C), source code and full python
5234 5246 file for any callable object. The object inspector oinfo uses
5235 5247 these to show the same information.
5236 5248
5237 5249 * Version 0.1.7 released, 0.1.8 opened for further work.
5238 5250
5239 5251 * Separated all the magic functions into a class called Magic. The
5240 5252 InteractiveShell class was becoming too big for Xemacs to handle
5241 5253 (de-indenting a line would lock it up for 10 seconds while it
5242 5254 backtracked on the whole class!)
5243 5255
5244 5256 FIXME: didn't work. It can be done, but right now namespaces are
5245 5257 all messed up. Do it later (reverted it for now, so at least
5246 5258 everything works as before).
5247 5259
5248 5260 * Got the object introspection system (magic_oinfo) working! I
5249 5261 think this is pretty much ready for release to Janko, so he can
5250 5262 test it for a while and then announce it. Pretty much 100% of what
5251 5263 I wanted for the 'phase 1' release is ready. Happy, tired.
5252 5264
5253 5265 2001-11-12 Fernando Perez <fperez@colorado.edu>
5254 5266
5255 5267 * Version 0.1.6 released, 0.1.7 opened for further work.
5256 5268
5257 5269 * Fixed bug in printing: it used to test for truth before
5258 5270 printing, so 0 wouldn't print. Now checks for None.
5259 5271
5260 5272 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
5261 5273 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
5262 5274 reaches by hand into the outputcache. Think of a better way to do
5263 5275 this later.
5264 5276
5265 5277 * Various small fixes thanks to Nathan's comments.
5266 5278
5267 5279 * Changed magic_pprint to magic_Pprint. This way it doesn't
5268 5280 collide with pprint() and the name is consistent with the command
5269 5281 line option.
5270 5282
5271 5283 * Changed prompt counter behavior to be fully like
5272 5284 Mathematica's. That is, even input that doesn't return a result
5273 5285 raises the prompt counter. The old behavior was kind of confusing
5274 5286 (getting the same prompt number several times if the operation
5275 5287 didn't return a result).
5276 5288
5277 5289 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
5278 5290
5279 5291 * Fixed -Classic mode (wasn't working anymore).
5280 5292
5281 5293 * Added colored prompts using Nathan's new code. Colors are
5282 5294 currently hardwired, they can be user-configurable. For
5283 5295 developers, they can be chosen in file ipythonlib.py, at the
5284 5296 beginning of the CachedOutput class def.
5285 5297
5286 5298 2001-11-11 Fernando Perez <fperez@colorado.edu>
5287 5299
5288 5300 * Version 0.1.5 released, 0.1.6 opened for further work.
5289 5301
5290 5302 * Changed magic_env to *return* the environment as a dict (not to
5291 5303 print it). This way it prints, but it can also be processed.
5292 5304
5293 5305 * Added Verbose exception reporting to interactive
5294 5306 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
5295 5307 traceback. Had to make some changes to the ultraTB file. This is
5296 5308 probably the last 'big' thing in my mental todo list. This ties
5297 5309 in with the next entry:
5298 5310
5299 5311 * Changed -Xi and -Xf to a single -xmode option. Now all the user
5300 5312 has to specify is Plain, Color or Verbose for all exception
5301 5313 handling.
5302 5314
5303 5315 * Removed ShellServices option. All this can really be done via
5304 5316 the magic system. It's easier to extend, cleaner and has automatic
5305 5317 namespace protection and documentation.
5306 5318
5307 5319 2001-11-09 Fernando Perez <fperez@colorado.edu>
5308 5320
5309 5321 * Fixed bug in output cache flushing (missing parameter to
5310 5322 __init__). Other small bugs fixed (found using pychecker).
5311 5323
5312 5324 * Version 0.1.4 opened for bugfixing.
5313 5325
5314 5326 2001-11-07 Fernando Perez <fperez@colorado.edu>
5315 5327
5316 5328 * Version 0.1.3 released, mainly because of the raw_input bug.
5317 5329
5318 5330 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
5319 5331 and when testing for whether things were callable, a call could
5320 5332 actually be made to certain functions. They would get called again
5321 5333 once 'really' executed, with a resulting double call. A disaster
5322 5334 in many cases (list.reverse() would never work!).
5323 5335
5324 5336 * Removed prefilter() function, moved its code to raw_input (which
5325 5337 after all was just a near-empty caller for prefilter). This saves
5326 5338 a function call on every prompt, and simplifies the class a tiny bit.
5327 5339
5328 5340 * Fix _ip to __ip name in magic example file.
5329 5341
5330 5342 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
5331 5343 work with non-gnu versions of tar.
5332 5344
5333 5345 2001-11-06 Fernando Perez <fperez@colorado.edu>
5334 5346
5335 5347 * Version 0.1.2. Just to keep track of the recent changes.
5336 5348
5337 5349 * Fixed nasty bug in output prompt routine. It used to check 'if
5338 5350 arg != None...'. Problem is, this fails if arg implements a
5339 5351 special comparison (__cmp__) which disallows comparing to
5340 5352 None. Found it when trying to use the PhysicalQuantity module from
5341 5353 ScientificPython.
5342 5354
5343 5355 2001-11-05 Fernando Perez <fperez@colorado.edu>
5344 5356
5345 5357 * Also added dirs. Now the pushd/popd/dirs family functions
5346 5358 basically like the shell, with the added convenience of going home
5347 5359 when called with no args.
5348 5360
5349 5361 * pushd/popd slightly modified to mimic shell behavior more
5350 5362 closely.
5351 5363
5352 5364 * Added env,pushd,popd from ShellServices as magic functions. I
5353 5365 think the cleanest will be to port all desired functions from
5354 5366 ShellServices as magics and remove ShellServices altogether. This
5355 5367 will provide a single, clean way of adding functionality
5356 5368 (shell-type or otherwise) to IP.
5357 5369
5358 5370 2001-11-04 Fernando Perez <fperez@colorado.edu>
5359 5371
5360 5372 * Added .ipython/ directory to sys.path. This way users can keep
5361 5373 customizations there and access them via import.
5362 5374
5363 5375 2001-11-03 Fernando Perez <fperez@colorado.edu>
5364 5376
5365 5377 * Opened version 0.1.1 for new changes.
5366 5378
5367 5379 * Changed version number to 0.1.0: first 'public' release, sent to
5368 5380 Nathan and Janko.
5369 5381
5370 5382 * Lots of small fixes and tweaks.
5371 5383
5372 5384 * Minor changes to whos format. Now strings are shown, snipped if
5373 5385 too long.
5374 5386
5375 5387 * Changed ShellServices to work on __main__ so they show up in @who
5376 5388
5377 5389 * Help also works with ? at the end of a line:
5378 5390 ?sin and sin?
5379 5391 both produce the same effect. This is nice, as often I use the
5380 5392 tab-complete to find the name of a method, but I used to then have
5381 5393 to go to the beginning of the line to put a ? if I wanted more
5382 5394 info. Now I can just add the ? and hit return. Convenient.
5383 5395
5384 5396 2001-11-02 Fernando Perez <fperez@colorado.edu>
5385 5397
5386 5398 * Python version check (>=2.1) added.
5387 5399
5388 5400 * Added LazyPython documentation. At this point the docs are quite
5389 5401 a mess. A cleanup is in order.
5390 5402
5391 5403 * Auto-installer created. For some bizarre reason, the zipfiles
5392 5404 module isn't working on my system. So I made a tar version
5393 5405 (hopefully the command line options in various systems won't kill
5394 5406 me).
5395 5407
5396 5408 * Fixes to Struct in genutils. Now all dictionary-like methods are
5397 5409 protected (reasonably).
5398 5410
5399 5411 * Added pager function to genutils and changed ? to print usage
5400 5412 note through it (it was too long).
5401 5413
5402 5414 * Added the LazyPython functionality. Works great! I changed the
5403 5415 auto-quote escape to ';', it's on home row and next to '. But
5404 5416 both auto-quote and auto-paren (still /) escapes are command-line
5405 5417 parameters.
5406 5418
5407 5419
5408 5420 2001-11-01 Fernando Perez <fperez@colorado.edu>
5409 5421
5410 5422 * Version changed to 0.0.7. Fairly large change: configuration now
5411 5423 is all stored in a directory, by default .ipython. There, all
5412 5424 config files have normal looking names (not .names)
5413 5425
5414 5426 * Version 0.0.6 Released first to Lucas and Archie as a test
5415 5427 run. Since it's the first 'semi-public' release, change version to
5416 5428 > 0.0.6 for any changes now.
5417 5429
5418 5430 * Stuff I had put in the ipplib.py changelog:
5419 5431
5420 5432 Changes to InteractiveShell:
5421 5433
5422 5434 - Made the usage message a parameter.
5423 5435
5424 5436 - Require the name of the shell variable to be given. It's a bit
5425 5437 of a hack, but allows the name 'shell' not to be hardwire in the
5426 5438 magic (@) handler, which is problematic b/c it requires
5427 5439 polluting the global namespace with 'shell'. This in turn is
5428 5440 fragile: if a user redefines a variable called shell, things
5429 5441 break.
5430 5442
5431 5443 - magic @: all functions available through @ need to be defined
5432 5444 as magic_<name>, even though they can be called simply as
5433 5445 @<name>. This allows the special command @magic to gather
5434 5446 information automatically about all existing magic functions,
5435 5447 even if they are run-time user extensions, by parsing the shell
5436 5448 instance __dict__ looking for special magic_ names.
5437 5449
5438 5450 - mainloop: added *two* local namespace parameters. This allows
5439 5451 the class to differentiate between parameters which were there
5440 5452 before and after command line initialization was processed. This
5441 5453 way, later @who can show things loaded at startup by the
5442 5454 user. This trick was necessary to make session saving/reloading
5443 5455 really work: ideally after saving/exiting/reloading a session,
5444 5456 *everythin* should look the same, including the output of @who. I
5445 5457 was only able to make this work with this double namespace
5446 5458 trick.
5447 5459
5448 5460 - added a header to the logfile which allows (almost) full
5449 5461 session restoring.
5450 5462
5451 5463 - prepend lines beginning with @ or !, with a and log
5452 5464 them. Why? !lines: may be useful to know what you did @lines:
5453 5465 they may affect session state. So when restoring a session, at
5454 5466 least inform the user of their presence. I couldn't quite get
5455 5467 them to properly re-execute, but at least the user is warned.
5456 5468
5457 5469 * Started ChangeLog.
@@ -1,406 +1,406 b''
1 1 .\" Hey, EMACS: -*- nroff -*-
2 2 .\" First parameter, NAME, should be all caps
3 3 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
4 4 .\" other parameters are allowed: see man(7), man(1)
5 5 .TH IPYTHON 1 "November 30, 2004"
6 6 .\" Please adjust this date whenever revising the manpage.
7 7 .\"
8 8 .\" Some roff macros, for reference:
9 9 .\" .nh disable hyphenation
10 10 .\" .hy enable hyphenation
11 11 .\" .ad l left justify
12 12 .\" .ad b justify to both left and right margins
13 13 .\" .nf disable filling
14 14 .\" .fi enable filling
15 15 .\" .br insert line break
16 16 .\" .sp <n> insert n+1 empty lines
17 17 .\" for manpage-specific macros, see man(7) and groff_man(7)
18 18 .\" .SH section heading
19 19 .\" .SS secondary section heading
20 20 .\"
21 21 .\"
22 22 .\" To preview this page as plain text: nroff -man ipython.1
23 23 .\"
24 24 .SH NAME
25 25 ipython \- An Enhanced Interactive Python
26 26 .SH SYNOPSIS
27 27 .B ipython
28 28 .RI [ options ] " files" ...
29 29 .SH DESCRIPTION
30 30 An interactive Python shell with automatic history (input and output),
31 31 dynamic object introspection, easier configuration, command
32 32 completion, access to the system shell, integration with numerical and
33 33 scientific computing tools, and more.
34 34 .SH SPECIAL THREADING OPTIONS
35 35 The following special options are ONLY valid at the beginning of the command
36 36 line, and not later. This is because they control the initialization of
37 37 ipython itself, before the normal option-handling mechanism is active.
38 38 .TP
39 39 .B \-gthread, \-qthread, \-wthread, \-pylab
40 40 Only ONE of these can be given, and it can only be given as the first option
41 41 passed to IPython (it will have no effect in any other position). They
42 42 provide threading support for the GTK, QT and WXWidgets toolkits, and for the
43 43 matplotlib library.
44 44 .br
45 45 .sp 1
46 46 With any of the first three options, IPython starts running a separate thread
47 47 for the graphical toolkit's operation, so that you can open and control
48 48 graphical elements from within an IPython command line, without blocking. All
49 49 three provide essentially the same functionality, respectively for GTK, QT and
50 50 WXWidgets (via their Python interfaces).
51 51 .br
52 52 .sp 1
53 53 Note that with \-wthread, you can additionally use the \-wxversion option to
54 54 request a specific version of wx to be used. This requires that you have the
55 55 'wxversion' Python module installed, which is part of recent wxPython
56 56 distributions.
57 57 .br
58 58 .sp 1
59 59 If \-pylab is given, IPython loads special support for the matplotlib library
60 60 (http://matplotlib.sourceforge.net), allowing interactive usage of any of its
61 61 backends as defined in the user's .matplotlibrc file. It automatically
62 62 activates GTK, QT or WX threading for IPyhton if the choice of matplotlib
63 63 backend requires it. It also modifies the %run command to correctly execute
64 64 (without blocking) any matplotlib-based script which calls show() at the end.
65 65 .TP
66 66 .B \-tk
67 67 The \-g/q/wthread options, and \-pylab (if matplotlib is configured to use
68 68 GTK, QT or WX), will normally block Tk graphical interfaces. This means that
69 69 when GTK, QT or WX threading is active, any attempt to open a Tk GUI will
70 70 result in a dead window, and possibly cause the Python interpreter to crash.
71 71 An extra option, \-tk, is available to address this issue. It can ONLY be
72 72 given as a SECOND option after any of the above (\-gthread, \-qthread,
73 73 \-wthread or \-pylab).
74 74 .br
75 75 .sp 1
76 76 If \-tk is given, IPython will try to coordinate Tk threading with GTK, QT or
77 77 WX. This is however potentially unreliable, and you will have to test on your
78 78 platform and Python configuration to determine whether it works for you.
79 79 Debian users have reported success, apparently due to the fact that Debian
80 80 builds all of Tcl, Tk, Tkinter and Python with pthreads support. Under other
81 81 Linux environments (such as Fedora Core 2), this option has caused random
82 82 crashes and lockups of the Python interpreter. Under other operating systems
83 83 (Mac OSX and Windows), you'll need to try it to find out, since currently no
84 84 user reports are available.
85 85 .br
86 86 .sp 1
87 87 There is unfortunately no way for IPython to determine at runtime whether \-tk
88 88 will work reliably or not, so you will need to do some experiments before
89 89 relying on it for regular work.
90 90 .
91 91 .SS A WARNING ABOUT SIGNALS AND THREADS
92 92 When any of the thread systems (GTK, QT or WX) are active, either directly or
93 93 via \-pylab with a threaded backend, it is impossible to interrupt
94 94 long-running Python code via Ctrl\-C. IPython can not pass the
95 95 KeyboardInterrupt exception (or the underlying SIGINT) across threads, so any
96 96 long-running process started from IPython will run to completion, or will have
97 97 to be killed via an external (OS-based) mechanism.
98 98 .br
99 99 .sp 1
100 100 To the best of my knowledge, this limitation is imposed by the Python
101 101 interpreter itself, and it comes from the difficulty of writing portable
102 102 signal/threaded code. If any user is an expert on this topic and can suggest
103 103 a better solution, I would love to hear about it. In the IPython sources,
104 104 look at the Shell.py module, and in particular at the runcode() method.
105 105 .
106 106 .SH REGULAR OPTIONS
107 107 After the above threading options have been given, regular options can follow
108 108 in any order. All options can be abbreviated to their shortest non-ambiguous
109 109 form and are case-sensitive. One or two dashes can be used. Some options
110 110 have an alternate short form, indicated after a |.
111 111 .br
112 112 .sp 1
113 113 Most options can also be set from your ipythonrc configuration file.
114 114 See the provided examples for assistance. Options given on the
115 115 commandline override the values set in the ipythonrc file.
116 116 .br
117 117 .sp 1
118 118 All options with a [no] prepended can be specified in negated form
119 119 (\-nooption instead of \-option) to turn the feature off.
120 120 .TP
121 121 .B \-h, \-\-help
122 122 Show summary of options.
123 123 .TP
124 124 .B \-autocall <val>
125 125 Make IPython automatically call any callable object even if you didn't type
126 126 explicit parentheses. For example, 'str 43' becomes
127 127 'str(43)' automatically. The value can be '0' to disable the
128 128 feature, '1' for 'smart' autocall, where it is not applied if
129 129 there are no more arguments on the line, and '2' for 'full'
130 130 autocall, where all callable objects are automatically called
131 131 (even if no arguments are present). The default is '1'.
132 132 .TP
133 133 .B \-[no]autoindent
134 134 Turn automatic indentation on/off.
135 135 .TP
136 136 .B \-[no]automagic
137 137 Make magic commands automatic (without needing their first character
138 138 to be %). Type %magic at the IPython prompt for more information.
139 139 .TP
140 140 .B \-[no]autoedit_syntax
141 141 When a syntax error occurs after editing a file, automatically open the file
142 142 to the trouble causing line for convenient fixing.
143 143 .TP
144 144 .B \-[no]banner
145 145 Print the intial information banner (default on).
146 146 .TP
147 147 .B \-c <command>
148 148 Execute the given command string, and set sys.argv to ['c']. This is similar
149 149 to the \-c option in the normal Python interpreter.
150 150 .TP
151 151 .B \-cache_size|cs <n>
152 152 Size of the output cache (maximum number of entries to hold in
153 153 memory). The default is 1000, you can change it permanently in your
154 154 config file. Setting it to 0 completely disables the caching system,
155 155 and the minimum value accepted is 20 (if you provide a value less than
156 156 20, it is reset to 0 and a warning is issued). This limit is defined
157 157 because otherwise you'll spend more time re-flushing a too small cache
158 158 than working.
159 159 .TP
160 160 .B \-classic|cl
161 161 Gives IPython a similar feel to the classic Python prompt.
162 162 .TP
163 163 .B \-colors <scheme>
164 164 Color scheme for prompts and exception reporting. Currently
165 165 implemented: NoColor, Linux, and LightBG.
166 166 .TP
167 167 .B \-[no]color_info
168 168 IPython can display information about objects via a set of functions,
169 169 and optionally can use colors for this, syntax highlighting source
170 170 code and various other elements. However, because this information is
171 171 passed through a pager (like 'less') and many pagers get confused with
172 172 color codes, this option is off by default. You can test it and turn
173 173 it on permanently in your ipythonrc file if it works for you. As a
174 174 reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
175 175 that in RedHat 7.2 doesn't.
176 176 .br
177 177 .sp 1
178 178 Test it and turn it on permanently if it works with your system. The
179 179 magic function @color_info allows you to toggle this interactively for
180 180 testing.
181 181 .TP
182 182 .B \-[no]confirm_exit
183 183 Set to confirm when you try to exit IPython with an EOF (Control-D in
184 184 Unix, Control-Z/Enter in Windows). Note that using the magic functions
185 185 @Exit or @Quit you can force a direct exit, bypassing any
186 186 confirmation.
187 187 .TP
188 188 .B \-[no]debug
189 189 Show information about the loading process. Very useful to pin down
190 190 problems with your configuration files or to get details about session
191 191 restores.
192 192 .TP
193 193 .B \-[no]deep_reload
194 194 IPython can use the deep_reload module which reloads changes in
195 195 modules recursively (it replaces the reload() function, so you don't
196 196 need to change anything to use it). deep_reload() forces a full reload
197 197 of modules whose code may have changed, which the default reload()
198 198 function does not.
199 199 .br
200 200 .sp 1
201 201 When deep_reload is off, IPython will use the normal reload(), but
202 202 deep_reload will still be available as dreload(). This feature is off
203 203 by default [which means that you have both normal reload() and
204 204 dreload()].
205 205 .TP
206 206 .B \-editor <name>
207 207 Which editor to use with the @edit command. By default, IPython will
208 208 honor your EDITOR environment variable (if not set, vi is the Unix
209 209 default and notepad the Windows one). Since this editor is invoked on
210 210 the fly by IPython and is meant for editing small code snippets, you
211 211 may want to use a small, lightweight editor here (in case your default
212 212 EDITOR is something like Emacs).
213 213 .TP
214 214 .B \-ipythondir <name>
215 215 The name of your IPython configuration directory IPYTHONDIR. This can
216 216 also be specified through the environment variable IPYTHONDIR.
217 217 .TP
218 218 .B \-log|l
219 219 Generate a log file of all input. The file is named ipython_log.py in your
220 220 current directory (which prevents logs from multiple IPython sessions from
221 221 trampling each other). You can use this to later restore a session by loading
222 222 your logfile as a file to be executed with option -logplay (see below).
223 223 .TP
224 224 .B \-logfile|lf
225 225 Specify the name of your logfile.
226 226 .TP
227 227 .B \-logplay|lp
228 228 Replay a previous log. For restoring a session as close as possible to
229 229 the state you left it in, use this option (don't just run the
230 230 logfile). With \-logplay, IPython will try to reconstruct the previous
231 231 working environment in full, not just execute the commands in the
232 232 logfile.
233 233 .br
234 234 .sh 1
235 235 When a session is restored, logging is automatically turned on again
236 236 with the name of the logfile it was invoked with (it is read from the
237 237 log header). So once you've turned logging on for a session, you can
238 238 quit IPython and reload it as many times as you want and it will
239 239 continue to log its history and restore from the beginning every time.
240 240 .br
241 241 .sp 1
242 242 Caveats: there are limitations in this option. The history variables
243 243 _i*,_* and _dh don't get restored properly. In the future we will try
244 244 to implement full session saving by writing and retrieving a
245 245 'snapshot' of the memory state of IPython. But our first attempts
246 246 failed because of inherent limitations of Python's Pickle module, so
247 247 this may have to wait.
248 248 .TP
249 249 .B \-[no]messages
250 250 Print messages which IPython collects about its startup process
251 251 (default on).
252 252 .TP
253 253 .B \-[no]pdb
254 254 Automatically call the pdb debugger after every uncaught exception. If
255 255 you are used to debugging using pdb, this puts you automatically
256 256 inside of it after any call (either in IPython or in code called by
257 257 it) which triggers an exception which goes uncaught.
258 258 .TP
259 259 .B \-[no]pprint
260 260 IPython can optionally use the pprint (pretty printer) module for
261 261 displaying results. pprint tends to give a nicer display of nested
262 262 data structures. If you like it, you can turn it on permanently in
263 263 your config file (default off).
264 264 .TP
265 265 .B \-profile|p <name>
266 266 Assume that your config file is ipythonrc-<name> (looks in current dir
267 267 first, then in IPYTHONDIR). This is a quick way to keep and load
268 268 multiple config files for different tasks, especially if you use the
269 269 include option of config files. You can keep a basic
270 270 IPYTHONDIR/ipythonrc file and then have other 'profiles' which include
271 271 this one and load extra things for particular tasks. For example:
272 272 .br
273 273 .sp 1
274 274 1) $HOME/.ipython/ipythonrc : load basic things you always want.
275 275 .br
276 276 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math-related
277 277 modules.
278 278 .br
279 279 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
280 280 plotting modules.
281 281 .br
282 282 .sp 1
283 283 Since it is possible to create an endless loop by having circular file
284 284 inclusions, IPython will stop if it reaches 15 recursive inclusions.
285 285 .TP
286 286 .B \-prompt_in1|pi1 <string>
287 287 Specify the string used for input prompts. Note that if you are using
288 288 numbered prompts, the number is represented with a '\\#' in the
289 289 string. Don't forget to quote strings with spaces embedded in
290 them. Default: 'In [\\#]:'.
290 them. Default: 'In [\\#]: '.
291 291 .br
292 292 .sp 1
293 293 Most bash-like escapes can be used to customize IPython's prompts, as well as
294 294 a few additional ones which are IPython-specific. All valid prompt escapes
295 295 are described in detail in the Customization section of the IPython HTML/PDF
296 296 manual.
297 297 .TP
298 298 .B \-prompt_in2|pi2 <string>
299 299 Similar to the previous option, but used for the continuation prompts. The
300 300 special sequence '\\D' is similar to '\\#', but with all digits replaced dots
301 301 (so you can have your continuation prompt aligned with your input
302 prompt). Default: ' .\\D.:' (note three spaces at the start for alignment
302 prompt). Default: ' .\\D.: ' (note three spaces at the start for alignment
303 303 with 'In [\\#]').
304 304 .TP
305 305 .B \-prompt_out|po <string>
306 306 String used for output prompts, also uses numbers like prompt_in1.
307 307 Default: 'Out[\\#]:'.
308 308 .TP
309 309 .B \-quick
310 310 Start in bare bones mode (no config file loaded).
311 311 .TP
312 312 .B \-rcfile <name>
313 313 Name of your IPython resource configuration file. normally IPython
314 314 loads ipythonrc (from current directory) or IPYTHONDIR/ipythonrc. If
315 315 the loading of your config file fails, IPython starts with a bare
316 316 bones configuration (no modules loaded at all).
317 317 .TP
318 318 .B \-[no]readline
319 319 Use the readline library, which is needed to support name completion
320 320 and command history, among other things. It is enabled by default, but
321 321 may cause problems for users of X/Emacs in Python comint or shell
322 322 buffers.
323 323 .br
324 324 .sp 1
325 325 Note that emacs 'eterm' buffers (opened with M-x term) support
326 326 IPython's readline and syntax coloring fine, only 'emacs' (M-x shell
327 327 and C-c !) buffers do not.
328 328 .TP
329 329 .B \-screen_length|sl <n>
330 330 Number of lines of your screen. This is used to control printing of
331 331 very long strings. Strings longer than this number of lines will be
332 332 sent through a pager instead of directly printed.
333 333 .br
334 334 .sp 1
335 335 The default value for this is 0, which means IPython will auto-detect
336 336 your screen size every time it needs to print certain potentially long
337 337 strings (this doesn't change the behavior of the 'print' keyword, it's
338 338 only triggered internally). If for some reason this isn't working well
339 339 (it needs curses support), specify it yourself. Otherwise don't change
340 340 the default.
341 341 .TP
342 342 .B \-separate_in|si <string>
343 343 Separator before input prompts. Default '\n'.
344 344 .TP
345 345 .B \-separate_out|so <string>
346 346 Separator before output prompts. Default: 0 (nothing).
347 347 .TP
348 348 .B \-separate_out2|so2 <string>
349 349 Separator after output prompts. Default: 0 (nothing).
350 350 .TP
351 351 .B \-nosep
352 352 Shorthand for '\-separate_in 0 \-separate_out 0 \-separate_out2 0'.
353 353 Simply removes all input/output separators.
354 354 .TP
355 355 .B \-upgrade
356 356 Allows you to upgrade your IPYTHONDIR configuration when you install a
357 357 new version of IPython. Since new versions may include new command
358 358 lines options or example files, this copies updated ipythonrc-type
359 359 files. However, it backs up (with a .old extension) all files which
360 360 it overwrites so that you can merge back any custimizations you might
361 361 have in your personal files.
362 362 .TP
363 363 .B \-Version
364 364 Print version information and exit.
365 365 .TP
366 366 .B -wxversion <string>
367 367 Select a specific version of wxPython (used in conjunction with
368 368 \-wthread). Requires the wxversion module, part of recent wxPython
369 369 distributions.
370 370 .TP
371 371 .B \-xmode <modename>
372 372 Mode for exception reporting. The valid modes are Plain, Context, and
373 373 Verbose.
374 374 .br
375 375 .sp 1
376 376 \- Plain: similar to python's normal traceback printing.
377 377 .br
378 378 .sp 1
379 379 \- Context: prints 5 lines of context source code around each line in the
380 380 traceback.
381 381 .br
382 382 .sp 1
383 383 \- Verbose: similar to Context, but additionally prints the variables
384 384 currently visible where the exception happened (shortening their strings if
385 385 too long). This can potentially be very slow, if you happen to have a huge
386 386 data structure whose string representation is complex to compute. Your
387 387 computer may appear to freeze for a while with cpu usage at 100%. If this
388 388 occurs, you can cancel the traceback with Ctrl-C (maybe hitting it more than
389 389 once).
390 390 .
391 391 .SH EMBEDDING
392 392 It is possible to start an IPython instance inside your own Python
393 393 programs. In the documentation example files there are some
394 394 illustrations on how to do this.
395 395 .br
396 396 .sp 1
397 397 This feature allows you to evalutate dynamically the state of your
398 398 code, operate with your variables, analyze them, etc. Note however
399 399 that any changes you make to values while in the shell do NOT
400 400 propagate back to the running code, so it is safe to modify your
401 401 values because you won't break your code in bizarre ways by doing so.
402 402 .SH AUTHOR
403 403 IPython was written by Fernando Perez <fperez@colorado.edu>, based on earlier
404 404 code by Janko Hauser <jh@comunit.de> and Nathaniel Gray
405 405 <n8gray@caltech.edu>. This manual page was written by Jack Moffitt
406 406 <jack@xiph.org>, for the Debian project (but may be used by others).
@@ -1,9515 +1,9524 b''
1 1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
2 2 \lyxformat 221
3 3 \textclass article
4 4 \begin_preamble
5 5 %\usepackage{ae,aecompl}
6 6 \usepackage{color}
7 7
8 8 % A few colors to replace the defaults for certain link types
9 9 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
10 10 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
11 11 \definecolor{darkred}{rgb}{.52,0.08,0.01}
12 12 \definecolor{darkgreen}{rgb}{.12,.54,.11}
13 13
14 14 % Use and configure listings package for nicely formatted code
15 15 \usepackage{listings}
16 16 \lstset{
17 17 language=Python,
18 18 basicstyle=\small\ttfamily,
19 19 commentstyle=\ttfamily\color{blue},
20 20 stringstyle=\ttfamily\color{darkorange},
21 21 showstringspaces=false,
22 22 breaklines=true,
23 23 postbreak = \space\dots
24 24 }
25 25
26 26 \usepackage[%pdftex, % needed for pdflatex
27 27 breaklinks=true, % so long urls are correctly broken across lines
28 28 colorlinks=true,
29 29 urlcolor=blue,
30 30 linkcolor=darkred,
31 31 citecolor=darkgreen,
32 32 ]{hyperref}
33 33
34 34 \usepackage{html}
35 35
36 36 % This helps prevent overly long lines that stretch beyond the margins
37 37 \sloppy
38 38
39 39 % Define a \codelist command which either uses listings for latex, or
40 40 % plain verbatim for html (since latex2html doesn't understand the
41 41 % listings package).
42 42 \usepackage{verbatim}
43 43 \newcommand{\codelist}[1] {
44 44 \latex{\lstinputlisting{#1}}
45 45 \html{\verbatiminput{#1}}
46 46 }
47 47 \end_preamble
48 48 \language english
49 49 \inputencoding latin1
50 50 \fontscheme palatino
51 51 \graphics default
52 52 \paperfontsize 11
53 53 \spacing single
54 54 \papersize Default
55 55 \paperpackage a4
56 56 \use_geometry 1
57 57 \use_amsmath 0
58 58 \use_natbib 0
59 59 \use_numerical_citations 0
60 60 \paperorientation portrait
61 61 \leftmargin 1in
62 62 \topmargin 1in
63 63 \rightmargin 1in
64 64 \bottommargin 1in
65 65 \secnumdepth 3
66 66 \tocdepth 3
67 67 \paragraph_separation skip
68 68 \defskip medskip
69 69 \quotes_language english
70 70 \quotes_times 2
71 71 \papercolumns 1
72 72 \papersides 2
73 73 \paperpagestyle fancy
74 74
75 75 \layout Title
76 76
77 77 IPython
78 78 \newline
79 79
80 80 \size larger
81 81 An enhanced Interactive Python
82 82 \size large
83 83
84 84 \newline
85 85 User Manual, v.
86 86 __version__
87 87 \layout Author
88 88
89 89 Fernando PοΏ½rez
90 90 \begin_inset Foot
91 91 collapsed true
92 92
93 93 \layout Standard
94 94
95 95
96 96 \size scriptsize
97 97 Department of Applied Mathematics, University of Colorado at Boulder.
98 98
99 99 \family typewriter
100 100 <Fernando.Perez@colorado.edu>
101 101 \end_inset
102 102
103 103
104 104 \layout Standard
105 105
106 106
107 107 \begin_inset ERT
108 108 status Collapsed
109 109
110 110 \layout Standard
111 111
112 112 \backslash
113 113 latex{
114 114 \end_inset
115 115
116 116
117 117 \begin_inset LatexCommand \tableofcontents{}
118 118
119 119 \end_inset
120 120
121 121
122 122 \begin_inset ERT
123 123 status Collapsed
124 124
125 125 \layout Standard
126 126 }
127 127 \end_inset
128 128
129 129
130 130 \layout Standard
131 131
132 132
133 133 \begin_inset ERT
134 134 status Open
135 135
136 136 \layout Standard
137 137
138 138 \backslash
139 139 html{
140 140 \backslash
141 141 bodytext{bgcolor=#ffffff}}
142 142 \end_inset
143 143
144 144
145 145 \layout Section
146 146 \pagebreak_top
147 147 Overview
148 148 \layout Standard
149 149
150 150 One of Python's most useful features is its interactive interpreter.
151 151 This system allows very fast testing of ideas without the overhead of creating
152 152 test files as is typical in most programming languages.
153 153 However, the interpreter supplied with the standard Python distribution
154 154 is somewhat limited for extended interactive use.
155 155 \layout Standard
156 156
157 157 IPython is a free software project (released under the BSD license) which
158 158 tries to:
159 159 \layout Enumerate
160 160
161 161 Provide an interactive shell superior to Python's default.
162 162 IPython has many features for object introspection, system shell access,
163 163 and its own special command system for adding functionality when working
164 164 interactively.
165 165 It tries to be a very efficient environment both for Python code development
166 166 and for exploration of problems using Python objects (in situations like
167 167 data analysis).
168 168 \layout Enumerate
169 169
170 170 Serve as an embeddable, ready to use interpreter for your own programs.
171 171 IPython can be started with a single call from inside another program,
172 172 providing access to the current namespace.
173 173 This can be very useful both for debugging purposes and for situations
174 174 where a blend of batch-processing and interactive exploration are needed.
175 175 \layout Enumerate
176 176
177 177 Offer a flexible framework which can be used as the base environment for
178 178 other systems with Python as the underlying language.
179 179 Specifically scientific environments like Mathematica, IDL and Matlab inspired
180 180 its design, but similar ideas can be useful in many fields.
181 181 \layout Enumerate
182 182
183 183 Allow interactive testing of threaded graphical toolkits.
184 184 IPython has support for interactive, non-blocking control of GTK, Qt and
185 185 WX applications via special threading flags.
186 186 The normal Python shell can only do this for Tkinter applications.
187 187 \layout Subsection
188 188
189 189 Main features
190 190 \layout Itemize
191 191
192 192 Dynamic object introspection.
193 193 One can access docstrings, function definition prototypes, source code,
194 194 source files and other details of any object accessible to the interpreter
195 195 with a single keystroke (`
196 196 \family typewriter
197 197 ?
198 198 \family default
199 199 ', and using `
200 200 \family typewriter
201 201 ??
202 202 \family default
203 203 ' provides additional detail).
204 204 \layout Itemize
205 205
206 206 Searching through modules and namespaces with `
207 207 \family typewriter
208 208 *
209 209 \family default
210 210 ' wildcards, both when using the `
211 211 \family typewriter
212 212 ?
213 213 \family default
214 214 ' system and via the
215 215 \family typewriter
216 216 %psearch
217 217 \family default
218 218 command.
219 219 \layout Itemize
220 220
221 221 Completion in the local namespace, by typing TAB at the prompt.
222 222 This works for keywords, methods, variables and files in the current directory.
223 223 This is supported via the readline library, and full access to configuring
224 224 readline's behavior is provided.
225 225 \layout Itemize
226 226
227 227 Numbered input/output prompts with command history (persistent across sessions
228 228 and tied to each profile), full searching in this history and caching of
229 229 all input and output.
230 230 \layout Itemize
231 231
232 232 User-extensible `magic' commands.
233 233 A set of commands prefixed with
234 234 \family typewriter
235 235 %
236 236 \family default
237 237 is available for controlling IPython itself and provides directory control,
238 238 namespace information and many aliases to common system shell commands.
239 239 \layout Itemize
240 240
241 241 Alias facility for defining your own system aliases.
242 242 \layout Itemize
243 243
244 244 Complete system shell access.
245 245 Lines starting with ! are passed directly to the system shell, and using
246 246 !! captures shell output into python variables for further use.
247 247 \layout Itemize
248 248
249 249 Background execution of Python commands in a separate thread.
250 250 IPython has an internal job manager called
251 251 \family typewriter
252 252 jobs
253 253 \family default
254 254 , and a conveninence backgrounding magic function called
255 255 \family typewriter
256 256 %bg
257 257 \family default
258 258 .
259 259 \layout Itemize
260 260
261 261 The ability to expand python variables when calling the system shell.
262 262 In a shell command, any python variable prefixed with
263 263 \family typewriter
264 264 $
265 265 \family default
266 266 is expanded.
267 267 A double
268 268 \family typewriter
269 269 $$
270 270 \family default
271 271 allows passing a literal
272 272 \family typewriter
273 273 $
274 274 \family default
275 275 to the shell (for access to shell and environment variables like
276 276 \family typewriter
277 277 $PATH
278 278 \family default
279 279 ).
280 280 \layout Itemize
281 281
282 282 Filesystem navigation, via a magic
283 283 \family typewriter
284 284 %cd
285 285 \family default
286 286 command, along with a persistent bookmark system (using
287 287 \family typewriter
288 288 %bookmark
289 289 \family default
290 290 ) for fast access to frequently visited directories.
291 291 \layout Itemize
292 292
293 293 A lightweight persistence framework via the
294 294 \family typewriter
295 295 %store
296 296 \family default
297 297 command, which allows you to save arbitrary Python variables.
298 298 These get restored automatically when your session restarts.
299 299 \layout Itemize
300 300
301 301 Automatic indentation (optional) of code as you type (through the readline
302 302 library).
303 303 \layout Itemize
304 304
305 305 Macro system for quickly re-executing multiple lines of previous input with
306 306 a single name.
307 307 Macros can be stored persistently via
308 308 \family typewriter
309 309 %store
310 310 \family default
311 311 and edited via
312 312 \family typewriter
313 313 %edit
314 314 \family default
315 315 .
316 316
317 317 \layout Itemize
318 318
319 319 Session logging (you can then later use these logs as code in your programs).
320 320 Logs can optionally timestamp all input, and also store session output
321 321 (marked as comments, so the log remains valid Python source code).
322 322 \layout Itemize
323 323
324 324 Session restoring: logs can be replayed to restore a previous session to
325 325 the state where you left it.
326 326 \layout Itemize
327 327
328 328 Verbose and colored exception traceback printouts.
329 329 Easier to parse visually, and in verbose mode they produce a lot of useful
330 330 debugging information (basically a terminal version of the cgitb module).
331 331 \layout Itemize
332 332
333 333 Auto-parentheses: callable objects can be executed without parentheses:
334 334
335 335 \family typewriter
336 336 `sin 3'
337 337 \family default
338 338 is automatically converted to
339 339 \family typewriter
340 340 `sin(3)
341 341 \family default
342 342 '.
343 343 \layout Itemize
344 344
345 345 Auto-quoting: using `
346 346 \family typewriter
347 347 ,
348 348 \family default
349 349 ' or `
350 350 \family typewriter
351 351 ;
352 352 \family default
353 353 ' as the first character forces auto-quoting of the rest of the line:
354 354 \family typewriter
355 355 `,my_function a\SpecialChar ~
356 356 b'
357 357 \family default
358 358 becomes automatically
359 359 \family typewriter
360 360 `my_function("a","b")'
361 361 \family default
362 362 , while
363 363 \family typewriter
364 364 `;my_function a\SpecialChar ~
365 365 b'
366 366 \family default
367 367 becomes
368 368 \family typewriter
369 369 `my_function("a b")'
370 370 \family default
371 371 .
372 372 \layout Itemize
373 373
374 374 Extensible input syntax.
375 375 You can define filters that pre-process user input to simplify input in
376 376 special situations.
377 377 This allows for example pasting multi-line code fragments which start with
378 378
379 379 \family typewriter
380 380 `>>>'
381 381 \family default
382 382 or
383 383 \family typewriter
384 384 `...'
385 385 \family default
386 386 such as those from other python sessions or the standard Python documentation.
387 387 \layout Itemize
388 388
389 389 Flexible configuration system.
390 390 It uses a configuration file which allows permanent setting of all command-line
391 391 options, module loading, code and file execution.
392 392 The system allows recursive file inclusion, so you can have a base file
393 393 with defaults and layers which load other customizations for particular
394 394 projects.
395 395 \layout Itemize
396 396
397 397 Embeddable.
398 398 You can call IPython as a python shell inside your own python programs.
399 399 This can be used both for debugging code or for providing interactive abilities
400 400 to your programs with knowledge about the local namespaces (very useful
401 401 in debugging and data analysis situations).
402 402 \layout Itemize
403 403
404 404 Easy debugger access.
405 405 You can set IPython to call up an enhanced version of the Python debugger
406 406 (
407 407 \family typewriter
408 408 pdb
409 409 \family default
410 410 ) every time there is an uncaught exception.
411 411 This drops you inside the code which triggered the exception with all the
412 412 data live and it is possible to navigate the stack to rapidly isolate the
413 413 source of a bug.
414 414 The
415 415 \family typewriter
416 416 %run
417 417 \family default
418 418 magic command --with the
419 419 \family typewriter
420 420 -d
421 421 \family default
422 422 option-- can run any script under
423 423 \family typewriter
424 424 pdb
425 425 \family default
426 426 's control, automatically setting initial breakpoints for you.
427 427 This version of
428 428 \family typewriter
429 429 pdb
430 430 \family default
431 431 has IPython-specific improvements, including tab-completion and traceback
432 432 coloring support.
433 433 \layout Itemize
434 434
435 435 Profiler support.
436 436 You can run single statements (similar to
437 437 \family typewriter
438 438 profile.run()
439 439 \family default
440 440 ) or complete programs under the profiler's control.
441 441 While this is possible with the standard
442 442 \family typewriter
443 443 profile
444 444 \family default
445 445 module, IPython wraps this functionality with magic commands (see
446 446 \family typewriter
447 447 `%prun'
448 448 \family default
449 449 and
450 450 \family typewriter
451 451 `%run -p
452 452 \family default
453 453 ') convenient for rapid interactive work.
454 454 \layout Subsection
455 455
456 456 Portability and Python requirements
457 457 \layout Standard
458 458
459 459
460 460 \series bold
461 461 Python requirements:
462 462 \series default
463 463 IPython requires with Python version 2.3 or newer.
464 464 If you are still using Python 2.2 and can not upgrade, the last version
465 465 of IPython which worked with Python 2.2 was 0.6.15, so you will have to use
466 466 that.
467 467 \layout Standard
468 468
469 469 IPython is developed under
470 470 \series bold
471 471 Linux
472 472 \series default
473 473 , but it should work in any reasonable Unix-type system (tested OK under
474 474 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
475 475 \layout Standard
476 476
477 477
478 478 \series bold
479 479 Mac OS X
480 480 \series default
481 481 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
482 482 Livermore for the information).
483 483 Thanks to Andrea Riciputi, Fink support is available.
484 484 \layout Standard
485 485
486 486
487 487 \series bold
488 488 CygWin
489 489 \series default
490 490 : it works mostly OK, though some users have reported problems with prompt
491 491 coloring.
492 492 No satisfactory solution to this has been found so far, you may want to
493 493 disable colors permanently in the
494 494 \family typewriter
495 495 ipythonrc
496 496 \family default
497 497 configuration file if you experience problems.
498 498 If you have proper color support under cygwin, please post to the IPython
499 499 mailing list so this issue can be resolved for all users.
500 500 \layout Standard
501 501
502 502
503 503 \series bold
504 504 Windows
505 505 \series default
506 506 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
507 507 Section\SpecialChar ~
508 508
509 509 \begin_inset LatexCommand \ref{sub:Under-Windows}
510 510
511 511 \end_inset
512 512
513 513 describes installation details for Windows, including some additional tools
514 514 needed on this platform.
515 515 \layout Standard
516 516
517 517 Windows 9x support is present, and has been reported to work fine (at least
518 518 on WinME).
519 519 \layout Standard
520 520
521 521 Note, that I have very little access to and experience with Windows development.
522 522 However, an excellent group of Win32 users (led by Ville Vainio), consistenly
523 523 contribute bugfixes and platform-specific enhancements, so they more than
524 524 make up for my deficiencies on that front.
525 525 In fact, Win32 users report using IPython as a system shell (see Sec.\SpecialChar ~
526 526
527 527 \begin_inset LatexCommand \ref{sec:IPython-as-shell}
528 528
529 529 \end_inset
530 530
531 531 for details), as it offers a level of control and features which the default
532 532
533 533 \family typewriter
534 534 cmd.exe
535 535 \family default
536 536 doesn't provide.
537 537 \layout Subsection
538 538
539 539 Location
540 540 \layout Standard
541 541
542 542 IPython is generously hosted at
543 543 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
544 544
545 545 \end_inset
546 546
547 547 by the Enthought, Inc and the SciPy project.
548 548 This site offers downloads, subversion access, mailing lists and a bug
549 549 tracking system.
550 550 I am very grateful to Enthought (
551 551 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
552 552
553 553 \end_inset
554 554
555 555 ) and all of the SciPy team for their contribution.
556 556 \layout Section
557 557
558 558
559 559 \begin_inset LatexCommand \label{sec:install}
560 560
561 561 \end_inset
562 562
563 563 Installation
564 564 \layout Subsection
565 565
566 566 Instant instructions
567 567 \layout Standard
568 568
569 569 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
570 570 download, then install with
571 571 \family typewriter
572 572 `python setup.py install'
573 573 \family default
574 574 .
575 575 Under Windows, double-click on the provided
576 576 \family typewriter
577 577 .exe
578 578 \family default
579 579 binary installer.
580 580 \layout Standard
581 581
582 582 Then, take a look at Sections
583 583 \begin_inset LatexCommand \ref{sec:good_config}
584 584
585 585 \end_inset
586 586
587 587 for configuring things optimally and
588 588 \begin_inset LatexCommand \ref{sec:quick_tips}
589 589
590 590 \end_inset
591 591
592 592 for quick tips on efficient use of IPython.
593 593 You can later refer to the rest of the manual for all the gory details.
594 594 \layout Standard
595 595
596 596 See the notes in sec.
597 597
598 598 \begin_inset LatexCommand \ref{sec:upgrade}
599 599
600 600 \end_inset
601 601
602 602 for upgrading IPython versions.
603 603 \layout Subsection
604 604
605 605 Detailed Unix instructions (Linux, Mac OS X, etc.)
606 606 \layout Standard
607 607
608 608 For RPM based systems, simply install the supplied package in the usual
609 609 manner.
610 610 If you download the tar archive, the process is:
611 611 \layout Enumerate
612 612
613 613 Unzip/untar the
614 614 \family typewriter
615 615 ipython-XXX.tar.gz
616 616 \family default
617 617 file wherever you want (
618 618 \family typewriter
619 619 XXX
620 620 \family default
621 621 is the version number).
622 622 It will make a directory called
623 623 \family typewriter
624 624 ipython-XXX.
625 625
626 626 \family default
627 627 Change into that directory where you will find the files
628 628 \family typewriter
629 629 README
630 630 \family default
631 631 and
632 632 \family typewriter
633 633 setup.py
634 634 \family default
635 635 .
636 636
637 637 \family typewriter
638 638 O
639 639 \family default
640 640 nce you've completed the installation, you can safely remove this directory.
641 641
642 642 \layout Enumerate
643 643
644 644 If you are installing over a previous installation of version 0.2.0 or earlier,
645 645 first remove your
646 646 \family typewriter
647 647 $HOME/.ipython
648 648 \family default
649 649 directory, since the configuration file format has changed somewhat (the
650 650 '=' were removed from all option specifications).
651 651 Or you can call ipython with the
652 652 \family typewriter
653 653 -upgrade
654 654 \family default
655 655 option and it will do this automatically for you.
656 656 \layout Enumerate
657 657
658 658 IPython uses distutils, so you can install it by simply typing at the system
659 659 prompt (don't type the
660 660 \family typewriter
661 661 $
662 662 \family default
663 663 )
664 664 \newline
665 665
666 666 \family typewriter
667 667 $ python setup.py install
668 668 \family default
669 669
670 670 \newline
671 671 Note that this assumes you have root access to your machine.
672 672 If you don't have root access or don't want IPython to go in the default
673 673 python directories, you'll need to use the
674 674 \begin_inset ERT
675 675 status Collapsed
676 676
677 677 \layout Standard
678 678
679 679 \backslash
680 680 verb|--home|
681 681 \end_inset
682 682
683 683 option (or
684 684 \begin_inset ERT
685 685 status Collapsed
686 686
687 687 \layout Standard
688 688
689 689 \backslash
690 690 verb|--prefix|
691 691 \end_inset
692 692
693 693 ).
694 694 For example:
695 695 \newline
696 696
697 697 \begin_inset ERT
698 698 status Collapsed
699 699
700 700 \layout Standard
701 701
702 702 \backslash
703 703 verb|$ python setup.py install --home $HOME/local|
704 704 \end_inset
705 705
706 706
707 707 \newline
708 708 will install IPython into
709 709 \family typewriter
710 710 $HOME/local
711 711 \family default
712 712 and its subdirectories (creating them if necessary).
713 713 \newline
714 714 You can type
715 715 \newline
716 716
717 717 \begin_inset ERT
718 718 status Collapsed
719 719
720 720 \layout Standard
721 721
722 722 \backslash
723 723 verb|$ python setup.py --help|
724 724 \end_inset
725 725
726 726
727 727 \newline
728 728 for more details.
729 729 \newline
730 730 Note that if you change the default location for
731 731 \begin_inset ERT
732 732 status Collapsed
733 733
734 734 \layout Standard
735 735
736 736 \backslash
737 737 verb|--home|
738 738 \end_inset
739 739
740 740 at installation, IPython may end up installed at a location which is not
741 741 part of your
742 742 \family typewriter
743 743 $PYTHONPATH
744 744 \family default
745 745 environment variable.
746 746 In this case, you'll need to configure this variable to include the actual
747 747 directory where the
748 748 \family typewriter
749 749 IPython/
750 750 \family default
751 751 directory ended (typically the value you give to
752 752 \begin_inset ERT
753 753 status Collapsed
754 754
755 755 \layout Standard
756 756
757 757 \backslash
758 758 verb|--home|
759 759 \end_inset
760 760
761 761 plus
762 762 \family typewriter
763 763 /lib/python
764 764 \family default
765 765 ).
766 766 \layout Subsubsection
767 767
768 768 Mac OSX information
769 769 \layout Standard
770 770
771 771 Under OSX, there is a choice you need to make.
772 772 Apple ships its own build of Python, which lives in the core OSX filesystem
773 773 hierarchy.
774 774 You can also manually install a separate Python, either purely by hand
775 775 (typically in
776 776 \family typewriter
777 777 /usr/local
778 778 \family default
779 779 ) or by using Fink, which puts everything under
780 780 \family typewriter
781 781 /sw
782 782 \family default
783 783 .
784 784 Which route to follow is a matter of personal preference, as I've seen
785 785 users who favor each of the approaches.
786 786 Here I will simply list the known installation issues under OSX, along
787 787 with their solutions.
788 788 \layout Standard
789 789
790 790 This page:
791 791 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
792 792
793 793 \end_inset
794 794
795 795 contains information on this topic, with additional details on how to make
796 796 IPython and matplotlib play nicely under OSX.
797 797 \layout Subsubsection*
798 798
799 799 GUI problems
800 800 \layout Standard
801 801
802 802 The following instructions apply to an install of IPython under OSX from
803 803 unpacking the
804 804 \family typewriter
805 805 .tar.gz
806 806 \family default
807 807 distribution and installing it for the default Python interpreter shipped
808 808 by Apple.
809 809 If you are using a fink install, fink will take care of these details for
810 810 you, by installing IPython against fink's Python.
811 811 \layout Standard
812 812
813 813 IPython offers various forms of support for interacting with graphical applicati
814 814 ons from the command line, from simple Tk apps (which are in principle always
815 815 supported by Python) to interactive control of WX, Qt and GTK apps.
816 816 Under OSX, however, this requires that ipython is installed by calling
817 817 the special
818 818 \family typewriter
819 819 pythonw
820 820 \family default
821 821 script at installation time, which takes care of coordinating things with
822 822 Apple's graphical environment.
823 823 \layout Standard
824 824
825 825 So when installing under OSX, it is best to use the following command:
826 826 \family typewriter
827 827
828 828 \newline
829 829
830 830 \family default
831 831
832 832 \begin_inset ERT
833 833 status Collapsed
834 834
835 835 \layout Standard
836 836
837 837 \backslash
838 838 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
839 839 \end_inset
840 840
841 841
842 842 \newline
843 843 or
844 844 \newline
845 845
846 846 \begin_inset ERT
847 847 status Collapsed
848 848
849 849 \layout Standard
850 850
851 851 \backslash
852 852 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
853 853 \end_inset
854 854
855 855
856 856 \newline
857 857 depending on where you like to keep hand-installed executables.
858 858 \layout Standard
859 859
860 860 The resulting script will have an appropriate shebang line (the first line
861 861 in the script whic begins with
862 862 \family typewriter
863 863 #!...
864 864 \family default
865 865 ) such that the ipython interpreter can interact with the OS X GUI.
866 866 If the installed version does not work and has a shebang line that points
867 867 to, for example, just
868 868 \family typewriter
869 869 /usr/bin/python
870 870 \family default
871 871 , then you might have a stale, cached version in your
872 872 \family typewriter
873 873 build/scripts-<python-version>
874 874 \family default
875 875 directory.
876 876 Delete that directory and rerun the
877 877 \family typewriter
878 878 setup.py
879 879 \family default
880 880 .
881 881
882 882 \layout Standard
883 883
884 884 It is also a good idea to use the special flag
885 885 \begin_inset ERT
886 886 status Collapsed
887 887
888 888 \layout Standard
889 889
890 890 \backslash
891 891 verb|--install-scripts|
892 892 \end_inset
893 893
894 894 as indicated above, to ensure that the ipython scripts end up in a location
895 895 which is part of your
896 896 \family typewriter
897 897 $PATH
898 898 \family default
899 899 .
900 900 Otherwise Apple's Python will put the scripts in an internal directory
901 901 not available by default at the command line (if you use
902 902 \family typewriter
903 903 /usr/local/bin
904 904 \family default
905 905 , you need to make sure this is in your
906 906 \family typewriter
907 907 $PATH
908 908 \family default
909 909 , which may not be true by default).
910 910 \layout Subsubsection*
911 911
912 912 Readline problems
913 913 \layout Standard
914 914
915 915 By default, the Python version shipped by Apple does
916 916 \emph on
917 917 not
918 918 \emph default
919 919 include the readline library, so central to IPython's behavior.
920 920 If you install IPython against Apple's Python, you will not have arrow
921 921 keys, tab completion, etc.
922 922 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
923 923 \newline
924 924
925 925 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
926 926
927 927 \end_inset
928 928
929 929
930 930 \layout Standard
931 931
932 932 If you are using OSX 10.4 (Tiger), after installing this package you need
933 933 to either:
934 934 \layout Enumerate
935 935
936 936 move
937 937 \family typewriter
938 938 readline.so
939 939 \family default
940 940 from
941 941 \family typewriter
942 942 /Library/Python/2.3
943 943 \family default
944 944 to
945 945 \family typewriter
946 946 /Library/Python/2.3/site-packages
947 947 \family default
948 948 , or
949 949 \layout Enumerate
950 950
951 951 install
952 952 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
953 953
954 954 \end_inset
955 955
956 956
957 957 \layout Standard
958 958
959 959 Users installing against Fink's Python or a properly hand-built one should
960 960 not have this problem.
961 961 \layout Subsubsection*
962 962
963 963 DarwinPorts
964 964 \layout Standard
965 965
966 966 I report here a message from an OSX user, who suggests an alternative means
967 967 of using IPython under this operating system with good results.
968 968 Please let me know of any updates that may be useful for this section.
969 969 His message is reproduced verbatim below:
970 970 \layout Quote
971 971
972 972 From: Markus Banfi
973 973 \family typewriter
974 974 <markus.banfi-AT-mospheira.net>
975 975 \layout Quote
976 976
977 977 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
978 978 of Fink.
979 979 I had no problems installing ipython with DarwinPorts.
980 980 It's just:
981 981 \layout Quote
982 982
983 983
984 984 \family typewriter
985 985 sudo port install py-ipython
986 986 \layout Quote
987 987
988 988 It automatically resolved all dependencies (python24, readline, py-readline).
989 989 So far I did not encounter any problems with the DarwinPorts port of ipython.
990 990
991 991 \layout Subsection
992 992
993 993
994 994 \begin_inset LatexCommand \label{sub:Under-Windows}
995 995
996 996 \end_inset
997 997
998 998 Windows instructions
999 999 \layout Standard
1000 1000
1001 1001 Some of IPython's very useful features are:
1002 1002 \layout Itemize
1003 1003
1004 1004 Integrated readline support (Tab-based file, object and attribute completion,
1005 1005 input history across sessions, editable command line, etc.)
1006 1006 \layout Itemize
1007 1007
1008 1008 Coloring of prompts, code and tracebacks.
1009 1009 \layout Standard
1010 1010
1011 1011 These, by default, are only available under Unix-like operating systems.
1012 1012 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
1013 1013 from them.
1014 1014 His readline library implements both GNU readline functionality and color
1015 1015 support, so that IPython under Windows XP/2k can be as friendly and powerful
1016 1016 as under Unix-like environments.
1017 1017 \layout Standard
1018 1018
1019 1019 The
1020 1020 \family typewriter
1021 1021 readline
1022 1022 \family default
1023 1023 extension needs two other libraries to work, so in all you need:
1024 1024 \layout Enumerate
1025 1025
1026 1026
1027 1027 \family typewriter
1028 1028 PyWin32
1029 1029 \family default
1030 1030 from
1031 1031 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
1032 1032
1033 1033 \end_inset
1034 1034
1035 1035 .
1036 1036 \layout Enumerate
1037 1037
1038 1038
1039 1039 \family typewriter
1040 1040 CTypes
1041 1041 \family default
1042 1042 from
1043 1043 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1044 1044
1045 1045 \end_inset
1046 1046
1047 1047 (you
1048 1048 \emph on
1049 1049 must
1050 1050 \emph default
1051 1051 use version 0.9.1 or newer).
1052 1052 \layout Enumerate
1053 1053
1054 1054
1055 1055 \family typewriter
1056 1056 Readline
1057 1057 \family default
1058 1058 for Windows from
1059 1059 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
1060 1060
1061 1061 \end_inset
1062 1062
1063 1063 .
1064 1064 \layout Standard
1065 1065
1066 1066
1067 1067 \series bold
1068 1068 Warning about a broken readline-like library:
1069 1069 \series default
1070 1070 several users have reported problems stemming from using the pseudo-readline
1071 1071 library at
1072 1072 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1073 1073
1074 1074 \end_inset
1075 1075
1076 1076 .
1077 1077 This is a broken library which, while called readline, only implements
1078 1078 an incomplete subset of the readline API.
1079 1079 Since it is still called readline, it fools IPython's detection mechanisms
1080 1080 and causes unpredictable crashes later.
1081 1081 If you wish to use IPython under Windows, you must NOT use this library,
1082 1082 which for all purposes is (at least as of version 1.6) terminally broken.
1083 1083 \layout Subsubsection
1084 1084
1085 1085 Installation procedure
1086 1086 \layout Standard
1087 1087
1088 1088 Once you have the above installed, from the IPython download directory grab
1089 1089 the
1090 1090 \family typewriter
1091 1091 ipython-XXX.win32.exe
1092 1092 \family default
1093 1093 file, where
1094 1094 \family typewriter
1095 1095 XXX
1096 1096 \family default
1097 1097 represents the version number.
1098 1098 This is a regular windows executable installer, which you can simply double-cli
1099 1099 ck to install.
1100 1100 It will add an entry for IPython to your Start Menu, as well as registering
1101 1101 IPython in the Windows list of applications, so you can later uninstall
1102 1102 it from the Control Panel.
1103 1103
1104 1104 \layout Standard
1105 1105
1106 1106 IPython tries to install the configuration information in a directory named
1107 1107
1108 1108 \family typewriter
1109 1109 .ipython
1110 1110 \family default
1111 1111 (
1112 1112 \family typewriter
1113 1113 _ipython
1114 1114 \family default
1115 1115 under Windows) located in your `home' directory.
1116 1116 IPython sets this directory by looking for a
1117 1117 \family typewriter
1118 1118 HOME
1119 1119 \family default
1120 1120 environment variable; if such a variable does not exist, it uses
1121 1121 \family typewriter
1122 1122 HOMEDRIVE
1123 1123 \backslash
1124 1124 HOMEPATH
1125 1125 \family default
1126 1126 (these are always defined by Windows).
1127 1127 This typically gives something like
1128 1128 \family typewriter
1129 1129 C:
1130 1130 \backslash
1131 1131 Documents and Settings
1132 1132 \backslash
1133 1133 YourUserName
1134 1134 \family default
1135 1135 , but your local details may vary.
1136 1136 In this directory you will find all the files that configure IPython's
1137 1137 defaults, and you can put there your profiles and extensions.
1138 1138 This directory is automatically added by IPython to
1139 1139 \family typewriter
1140 1140 sys.path
1141 1141 \family default
1142 1142 , so anything you place there can be found by
1143 1143 \family typewriter
1144 1144 import
1145 1145 \family default
1146 1146 statements.
1147 1147 \layout Paragraph
1148 1148
1149 1149 Upgrading
1150 1150 \layout Standard
1151 1151
1152 1152 For an IPython upgrade, you should first uninstall the previous version.
1153 1153 This will ensure that all files and directories (such as the documentation)
1154 1154 which carry embedded version strings in their names are properly removed.
1155 1155 \layout Paragraph
1156 1156
1157 1157 Manual installation under Win32
1158 1158 \layout Standard
1159 1159
1160 1160 In case the automatic installer does not work for some reason, you can download
1161 1161 the
1162 1162 \family typewriter
1163 1163 ipython-XXX.tar.gz
1164 1164 \family default
1165 1165 file, which contains the full IPython source distribution (the popular
1166 1166 WinZip can read
1167 1167 \family typewriter
1168 1168 .tar.gz
1169 1169 \family default
1170 1170 files).
1171 1171 After uncompressing the archive, you can install it at a command terminal
1172 1172 just like any other Python module, by using
1173 1173 \family typewriter
1174 1174 `python setup.py install'
1175 1175 \family default
1176 1176 .
1177 1177
1178 1178 \layout Standard
1179 1179
1180 1180 After the installation, run the supplied
1181 1181 \family typewriter
1182 1182 win32_manual_post_install.py
1183 1183 \family default
1184 1184 script, which creates the necessary Start Menu shortcuts for you.
1185 1185 \layout Subsection
1186 1186
1187 1187
1188 1188 \begin_inset LatexCommand \label{sec:upgrade}
1189 1189
1190 1190 \end_inset
1191 1191
1192 1192 Upgrading from a previous version
1193 1193 \layout Standard
1194 1194
1195 1195 If you are upgrading from a previous version of IPython, after doing the
1196 1196 routine installation described above, you should call IPython with the
1197 1197
1198 1198 \family typewriter
1199 1199 -upgrade
1200 1200 \family default
1201 1201 option the first time you run your new copy.
1202 1202 This will automatically update your configuration directory while preserving
1203 1203 copies of your old files.
1204 1204 You can then later merge back any personal customizations you may have
1205 1205 made into the new files.
1206 1206 It is a good idea to do this as there may be new options available in the
1207 1207 new configuration files which you will not have.
1208 1208 \layout Standard
1209 1209
1210 1210 Under Windows, if you don't know how to call python scripts with arguments
1211 1211 from a command line, simply delete the old config directory and IPython
1212 1212 will make a new one.
1213 1213 Win2k and WinXP users will find it in
1214 1214 \family typewriter
1215 1215 C:
1216 1216 \backslash
1217 1217 Documents and Settings
1218 1218 \backslash
1219 1219 YourUserName
1220 1220 \backslash
1221 1221 _ipython
1222 1222 \family default
1223 1223 , and Win 9x users under
1224 1224 \family typewriter
1225 1225 C:
1226 1226 \backslash
1227 1227 Program Files
1228 1228 \backslash
1229 1229 IPython
1230 1230 \backslash
1231 1231 _ipython.
1232 1232 \layout Section
1233 1233
1234 1234
1235 1235 \begin_inset LatexCommand \label{sec:good_config}
1236 1236
1237 1237 \end_inset
1238 1238
1239 1239
1240 1240 \begin_inset OptArg
1241 1241 collapsed true
1242 1242
1243 1243 \layout Standard
1244 1244
1245 1245 Initial configuration
1246 1246 \begin_inset ERT
1247 1247 status Collapsed
1248 1248
1249 1249 \layout Standard
1250 1250
1251 1251 \backslash
1252 1252 ldots
1253 1253 \end_inset
1254 1254
1255 1255
1256 1256 \end_inset
1257 1257
1258 1258 Initial configuration of your environment
1259 1259 \layout Standard
1260 1260
1261 1261 This section will help you set various things in your environment for your
1262 1262 IPython sessions to be as efficient as possible.
1263 1263 All of IPython's configuration information, along with several example
1264 1264 files, is stored in a directory named by default
1265 1265 \family typewriter
1266 1266 $HOME/.ipython
1267 1267 \family default
1268 1268 .
1269 1269 You can change this by defining the environment variable
1270 1270 \family typewriter
1271 1271 IPYTHONDIR
1272 1272 \family default
1273 1273 , or at runtime with the command line option
1274 1274 \family typewriter
1275 1275 -ipythondir
1276 1276 \family default
1277 1277 .
1278 1278 \layout Standard
1279 1279
1280 1280 If all goes well, the first time you run IPython it should automatically
1281 1281 create a user copy of the config directory for you, based on its builtin
1282 1282 defaults.
1283 1283 You can look at the files it creates to learn more about configuring the
1284 1284 system.
1285 1285 The main file you will modify to configure IPython's behavior is called
1286 1286
1287 1287 \family typewriter
1288 1288 ipythonrc
1289 1289 \family default
1290 1290 (with a
1291 1291 \family typewriter
1292 1292 .ini
1293 1293 \family default
1294 1294 extension under Windows), included for reference in Sec.
1295 1295
1296 1296 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1297 1297
1298 1298 \end_inset
1299 1299
1300 1300 .
1301 1301 This file is very commented and has many variables you can change to suit
1302 1302 your taste, you can find more details in Sec.
1303 1303
1304 1304 \begin_inset LatexCommand \ref{sec:customization}
1305 1305
1306 1306 \end_inset
1307 1307
1308 1308 .
1309 1309 Here we discuss the basic things you will want to make sure things are
1310 1310 working properly from the beginning.
1311 1311 \layout Subsection
1312 1312
1313 1313
1314 1314 \begin_inset LatexCommand \label{sec:help-access}
1315 1315
1316 1316 \end_inset
1317 1317
1318 1318 Access to the Python help system
1319 1319 \layout Standard
1320 1320
1321 1321 This is true for Python in general (not just for IPython): you should have
1322 1322 an environment variable called
1323 1323 \family typewriter
1324 1324 PYTHONDOCS
1325 1325 \family default
1326 1326 pointing to the directory where your HTML Python documentation lives.
1327 1327 In my system it's
1328 1328 \family typewriter
1329 1329 /usr/share/doc/python-docs-2.3.4/html
1330 1330 \family default
1331 1331 , check your local details or ask your systems administrator.
1332 1332
1333 1333 \layout Standard
1334 1334
1335 1335 This is the directory which holds the HTML version of the Python manuals.
1336 1336 Unfortunately it seems that different Linux distributions package these
1337 1337 files differently, so you may have to look around a bit.
1338 1338 Below I show the contents of this directory on my system for reference:
1339 1339 \layout Standard
1340 1340
1341 1341
1342 1342 \family typewriter
1343 1343 [html]> ls
1344 1344 \newline
1345 1345 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1346 1346 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1347 1347 \layout Standard
1348 1348
1349 1349 You should really make sure this variable is correctly set so that Python's
1350 1350 pydoc-based help system works.
1351 1351 It is a powerful and convenient system with full access to the Python manuals
1352 1352 and all modules accessible to you.
1353 1353 \layout Standard
1354 1354
1355 1355 Under Windows it seems that pydoc finds the documentation automatically,
1356 1356 so no extra setup appears necessary.
1357 1357 \layout Subsection
1358 1358
1359 1359 Editor
1360 1360 \layout Standard
1361 1361
1362 1362 The
1363 1363 \family typewriter
1364 1364 %edit
1365 1365 \family default
1366 1366 command (and its alias
1367 1367 \family typewriter
1368 1368 %ed
1369 1369 \family default
1370 1370 ) will invoke the editor set in your environment as
1371 1371 \family typewriter
1372 1372 EDITOR
1373 1373 \family default
1374 1374 .
1375 1375 If this variable is not set, it will default to
1376 1376 \family typewriter
1377 1377 vi
1378 1378 \family default
1379 1379 under Linux/Unix and to
1380 1380 \family typewriter
1381 1381 notepad
1382 1382 \family default
1383 1383 under Windows.
1384 1384 You may want to set this variable properly and to a lightweight editor
1385 1385 which doesn't take too long to start (that is, something other than a new
1386 1386 instance of
1387 1387 \family typewriter
1388 1388 Emacs
1389 1389 \family default
1390 1390 ).
1391 1391 This way you can edit multi-line code quickly and with the power of a real
1392 1392 editor right inside IPython.
1393 1393
1394 1394 \layout Standard
1395 1395
1396 1396 If you are a dedicated
1397 1397 \family typewriter
1398 1398 Emacs
1399 1399 \family default
1400 1400 user, you should set up the
1401 1401 \family typewriter
1402 1402 Emacs
1403 1403 \family default
1404 1404 server so that new requests are handled by the original process.
1405 1405 This means that almost no time is spent in handling the request (assuming
1406 1406 an
1407 1407 \family typewriter
1408 1408 Emacs
1409 1409 \family default
1410 1410 process is already running).
1411 1411 For this to work, you need to set your
1412 1412 \family typewriter
1413 1413 EDITOR
1414 1414 \family default
1415 1415 environment variable to
1416 1416 \family typewriter
1417 1417 'emacsclient'
1418 1418 \family default
1419 1419 .
1420 1420
1421 1421 \family typewriter
1422 1422
1423 1423 \family default
1424 1424 The code below, supplied by Francois Pinard, can then be used in your
1425 1425 \family typewriter
1426 1426 .emacs
1427 1427 \family default
1428 1428 file to enable the server:
1429 1429 \layout Standard
1430 1430
1431 1431
1432 1432 \family typewriter
1433 1433 (defvar server-buffer-clients)
1434 1434 \newline
1435 1435 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1436 1436 \newline
1437 1437
1438 1438 \begin_inset ERT
1439 1439 status Collapsed
1440 1440
1441 1441 \layout Standard
1442 1442
1443 1443 \backslash
1444 1444 hspace*{0mm}
1445 1445 \end_inset
1446 1446
1447 1447 \SpecialChar ~
1448 1448 \SpecialChar ~
1449 1449 (server-start)
1450 1450 \newline
1451 1451
1452 1452 \begin_inset ERT
1453 1453 status Collapsed
1454 1454
1455 1455 \layout Standard
1456 1456
1457 1457 \backslash
1458 1458 hspace*{0mm}
1459 1459 \end_inset
1460 1460
1461 1461 \SpecialChar ~
1462 1462 \SpecialChar ~
1463 1463 (defun fp-kill-server-with-buffer-routine ()
1464 1464 \newline
1465 1465
1466 1466 \begin_inset ERT
1467 1467 status Collapsed
1468 1468
1469 1469 \layout Standard
1470 1470
1471 1471 \backslash
1472 1472 hspace*{0mm}
1473 1473 \end_inset
1474 1474
1475 1475 \SpecialChar ~
1476 1476 \SpecialChar ~
1477 1477 \SpecialChar ~
1478 1478 \SpecialChar ~
1479 1479 (and server-buffer-clients (server-done)))
1480 1480 \newline
1481 1481
1482 1482 \begin_inset ERT
1483 1483 status Collapsed
1484 1484
1485 1485 \layout Standard
1486 1486
1487 1487 \backslash
1488 1488 hspace*{0mm}
1489 1489 \end_inset
1490 1490
1491 1491 \SpecialChar ~
1492 1492 \SpecialChar ~
1493 1493 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1494 1494 \layout Standard
1495 1495
1496 1496 You can also set the value of this editor via the commmand-line option '-
1497 1497 \family typewriter
1498 1498 editor'
1499 1499 \family default
1500 1500 or in your
1501 1501 \family typewriter
1502 1502 ipythonrc
1503 1503 \family default
1504 1504 file.
1505 1505 This is useful if you wish to use specifically for IPython an editor different
1506 1506 from your typical default (and for Windows users who tend to use fewer
1507 1507 environment variables).
1508 1508 \layout Subsection
1509 1509
1510 1510 Color
1511 1511 \layout Standard
1512 1512
1513 1513 The default IPython configuration has most bells and whistles turned on
1514 1514 (they're pretty safe).
1515 1515 But there's one that
1516 1516 \emph on
1517 1517 may
1518 1518 \emph default
1519 1519 cause problems on some systems: the use of color on screen for displaying
1520 1520 information.
1521 1521 This is very useful, since IPython can show prompts and exception tracebacks
1522 1522 with various colors, display syntax-highlighted source code, and in general
1523 1523 make it easier to visually parse information.
1524 1524 \layout Standard
1525 1525
1526 1526 The following terminals seem to handle the color sequences fine:
1527 1527 \layout Itemize
1528 1528
1529 1529 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1530 1530 \layout Itemize
1531 1531
1532 1532 CDE terminal (tested under Solaris).
1533 1533 This one boldfaces light colors.
1534 1534 \layout Itemize
1535 1535
1536 1536 (X)Emacs buffers.
1537 1537 See sec.
1538 1538 \begin_inset LatexCommand \ref{sec:emacs}
1539 1539
1540 1540 \end_inset
1541 1541
1542 1542 for more details on using IPython with (X)Emacs.
1543 1543 \layout Itemize
1544 1544
1545 1545 A Windows (XP/2k) command prompt
1546 1546 \emph on
1547 1547 with Gary Bishop's support extensions
1548 1548 \emph default
1549 1549 .
1550 1550 Gary's extensions are discussed in Sec.\SpecialChar ~
1551 1551
1552 1552 \begin_inset LatexCommand \ref{sub:Under-Windows}
1553 1553
1554 1554 \end_inset
1555 1555
1556 1556 .
1557 1557 \layout Itemize
1558 1558
1559 1559 A Windows (XP/2k) CygWin shell.
1560 1560 Although some users have reported problems; it is not clear whether there
1561 1561 is an issue for everyone or only under specific configurations.
1562 1562 If you have full color support under cygwin, please post to the IPython
1563 1563 mailing list so this issue can be resolved for all users.
1564 1564 \layout Standard
1565 1565
1566 1566 These have shown problems:
1567 1567 \layout Itemize
1568 1568
1569 1569 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1570 1570 or ssh.
1571 1571 \layout Itemize
1572 1572
1573 1573 Windows native command prompt in WinXP/2k,
1574 1574 \emph on
1575 1575 without
1576 1576 \emph default
1577 1577 Gary Bishop's extensions.
1578 1578 Once Gary's readline library is installed, the normal WinXP/2k command
1579 1579 prompt works perfectly.
1580 1580 \layout Standard
1581 1581
1582 1582 Currently the following color schemes are available:
1583 1583 \layout Itemize
1584 1584
1585 1585
1586 1586 \family typewriter
1587 1587 NoColor
1588 1588 \family default
1589 1589 : uses no color escapes at all (all escapes are empty
1590 1590 \begin_inset Quotes eld
1591 1591 \end_inset
1592 1592
1593 1593
1594 1594 \begin_inset Quotes eld
1595 1595 \end_inset
1596 1596
1597 1597 strings).
1598 1598 This 'scheme' is thus fully safe to use in any terminal.
1599 1599 \layout Itemize
1600 1600
1601 1601
1602 1602 \family typewriter
1603 1603 Linux
1604 1604 \family default
1605 1605 : works well in Linux console type environments: dark background with light
1606 1606 fonts.
1607 1607 It uses bright colors for information, so it is difficult to read if you
1608 1608 have a light colored background.
1609 1609 \layout Itemize
1610 1610
1611 1611
1612 1612 \family typewriter
1613 1613 LightBG
1614 1614 \family default
1615 1615 : the basic colors are similar to those in the
1616 1616 \family typewriter
1617 1617 Linux
1618 1618 \family default
1619 1619 scheme but darker.
1620 1620 It is easy to read in terminals with light backgrounds.
1621 1621 \layout Standard
1622 1622
1623 1623 IPython uses colors for two main groups of things: prompts and tracebacks
1624 1624 which are directly printed to the terminal, and the object introspection
1625 1625 system which passes large sets of data through a pager.
1626 1626 \layout Subsubsection
1627 1627
1628 1628 Input/Output prompts and exception tracebacks
1629 1629 \layout Standard
1630 1630
1631 1631 You can test whether the colored prompts and tracebacks work on your system
1632 1632 interactively by typing
1633 1633 \family typewriter
1634 1634 '%colors Linux'
1635 1635 \family default
1636 1636 at the prompt (use '
1637 1637 \family typewriter
1638 1638 %colors LightBG'
1639 1639 \family default
1640 1640 if your terminal has a light background).
1641 1641 If the input prompt shows garbage like:
1642 1642 \newline
1643 1643
1644 1644 \family typewriter
1645 1645 [0;32mIn [[1;32m1[0;32m]: [0;00m
1646 1646 \family default
1647 1647
1648 1648 \newline
1649 1649 instead of (in color) something like:
1650 1650 \newline
1651 1651
1652 1652 \family typewriter
1653 1653 In [1]:
1654 1654 \family default
1655 1655
1656 1656 \newline
1657 1657 this means that your terminal doesn't properly handle color escape sequences.
1658 1658 You can go to a 'no color' mode by typing '
1659 1659 \family typewriter
1660 1660 %colors NoColor
1661 1661 \family default
1662 1662 '.
1663 1663
1664 1664 \layout Standard
1665 1665
1666 1666 You can try using a different terminal emulator program (Emacs users, see
1667 1667 below).
1668 1668 To permanently set your color preferences, edit the file
1669 1669 \family typewriter
1670 1670 $HOME/.ipython/ipythonrc
1671 1671 \family default
1672 1672 and set the
1673 1673 \family typewriter
1674 1674 colors
1675 1675 \family default
1676 1676 option to the desired value.
1677 1677 \layout Subsubsection
1678 1678
1679 1679 Object details (types, docstrings, source code, etc.)
1680 1680 \layout Standard
1681 1681
1682 1682 IPython has a set of special functions for studying the objects you are
1683 1683 working with, discussed in detail in Sec.
1684 1684
1685 1685 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1686 1686
1687 1687 \end_inset
1688 1688
1689 1689 .
1690 1690 But this system relies on passing information which is longer than your
1691 1691 screen through a data pager, such as the common Unix
1692 1692 \family typewriter
1693 1693 less
1694 1694 \family default
1695 1695 and
1696 1696 \family typewriter
1697 1697 more
1698 1698 \family default
1699 1699 programs.
1700 1700 In order to be able to see this information in color, your pager needs
1701 1701 to be properly configured.
1702 1702 I strongly recommend using
1703 1703 \family typewriter
1704 1704 less
1705 1705 \family default
1706 1706 instead of
1707 1707 \family typewriter
1708 1708 more
1709 1709 \family default
1710 1710 , as it seems that
1711 1711 \family typewriter
1712 1712 more
1713 1713 \family default
1714 1714 simply can not understand colored text correctly.
1715 1715 \layout Standard
1716 1716
1717 1717 In order to configure
1718 1718 \family typewriter
1719 1719 less
1720 1720 \family default
1721 1721 as your default pager, do the following:
1722 1722 \layout Enumerate
1723 1723
1724 1724 Set the environment
1725 1725 \family typewriter
1726 1726 PAGER
1727 1727 \family default
1728 1728 variable to
1729 1729 \family typewriter
1730 1730 less
1731 1731 \family default
1732 1732 .
1733 1733 \layout Enumerate
1734 1734
1735 1735 Set the environment
1736 1736 \family typewriter
1737 1737 LESS
1738 1738 \family default
1739 1739 variable to
1740 1740 \family typewriter
1741 1741 -r
1742 1742 \family default
1743 1743 (plus any other options you always want to pass to
1744 1744 \family typewriter
1745 1745 less
1746 1746 \family default
1747 1747 by default).
1748 1748 This tells
1749 1749 \family typewriter
1750 1750 less
1751 1751 \family default
1752 1752 to properly interpret control sequences, which is how color information
1753 1753 is given to your terminal.
1754 1754 \layout Standard
1755 1755
1756 1756 For the
1757 1757 \family typewriter
1758 1758 csh
1759 1759 \family default
1760 1760 or
1761 1761 \family typewriter
1762 1762 tcsh
1763 1763 \family default
1764 1764 shells, add to your
1765 1765 \family typewriter
1766 1766 ~/.cshrc
1767 1767 \family default
1768 1768 file the lines:
1769 1769 \layout Standard
1770 1770
1771 1771
1772 1772 \family typewriter
1773 1773 setenv PAGER less
1774 1774 \newline
1775 1775 setenv LESS -r
1776 1776 \layout Standard
1777 1777
1778 1778 There is similar syntax for other Unix shells, look at your system documentation
1779 1779 for details.
1780 1780 \layout Standard
1781 1781
1782 1782 If you are on a system which lacks proper data pagers (such as Windows),
1783 1783 IPython will use a very limited builtin pager.
1784 1784 \layout Subsection
1785 1785
1786 1786
1787 1787 \begin_inset LatexCommand \label{sec:emacs}
1788 1788
1789 1789 \end_inset
1790 1790
1791 1791 (X)Emacs configuration
1792 1792 \layout Standard
1793 1793
1794 1794 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1795 1795 (X)Emacs and IPython get along very well.
1796 1796
1797 1797 \layout Standard
1798 1798
1799 1799
1800 1800 \series bold
1801 1801 Important note:
1802 1802 \series default
1803 1803 You will need to use a recent enough version of
1804 1804 \family typewriter
1805 1805 python-mode.el
1806 1806 \family default
1807 1807 , along with the file
1808 1808 \family typewriter
1809 1809 ipython.el
1810 1810 \family default
1811 1811 .
1812 1812 You can check that the version you have of
1813 1813 \family typewriter
1814 1814 python-mode.el
1815 1815 \family default
1816 1816 is new enough by either looking at the revision number in the file itself,
1817 1817 or asking for it in (X)Emacs via
1818 1818 \family typewriter
1819 1819 M-x py-version
1820 1820 \family default
1821 1821 .
1822 1822 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1823 1823 \layout Standard
1824 1824
1825 1825 The file
1826 1826 \family typewriter
1827 1827 ipython.el
1828 1828 \family default
1829 1829 is included with the IPython distribution, in the documentation directory
1830 1830 (where this manual resides in PDF and HTML formats).
1831 1831 \layout Standard
1832 1832
1833 1833 Once you put these files in your Emacs path, all you need in your
1834 1834 \family typewriter
1835 1835 .emacs
1836 1836 \family default
1837 1837 file is:
1838 1838 \layout LyX-Code
1839 1839
1840 1840 (require 'ipython)
1841 1841 \layout Standard
1842 1842
1843 1843 This should give you full support for executing code snippets via IPython,
1844 1844 opening IPython as your Python shell via
1845 1845 \family typewriter
1846 1846 C-c\SpecialChar ~
1847 1847 !
1848 1848 \family default
1849 1849 , etc.
1850 1850
1851 1851 \layout Standard
1852 1852
1853 1853 If you happen to get garbage instead of colored prompts as described in
1854 1854 the previous section, you may need to set also in your
1855 1855 \family typewriter
1856 1856 .emacs
1857 1857 \family default
1858 1858 file:
1859 1859 \layout LyX-Code
1860 1860
1861 1861 (setq ansi-color-for-comint-mode t)
1862 1862 \layout Subsubsection*
1863 1863
1864 1864 Notes
1865 1865 \layout Itemize
1866 1866
1867 1867 There is one caveat you should be aware of: you must start the IPython shell
1868 1868
1869 1869 \emph on
1870 1870 before
1871 1871 \emph default
1872 1872 attempting to execute any code regions via
1873 1873 \family typewriter
1874 1874 C-c\SpecialChar ~
1875 1875 |
1876 1876 \family default
1877 1877 .
1878 1878 Simply type
1879 1879 \family typewriter
1880 1880 C-c\SpecialChar ~
1881 1881 !
1882 1882 \family default
1883 1883 to start IPython before passing any code regions to the interpreter, and
1884 1884 you shouldn't experience any problems.
1885 1885 \newline
1886 1886 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1887 1887 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1888 1888 \layout Itemize
1889 1889
1890 1890 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1891 1891 ts should be directed to him through the IPython mailing lists.
1892 1892
1893 1893 \layout Itemize
1894 1894
1895 1895 This code is still somewhat experimental so it's a bit rough around the
1896 1896 edges (although in practice, it works quite well).
1897 1897 \layout Itemize
1898 1898
1899 1899 Be aware that if you customize
1900 1900 \family typewriter
1901 1901 py-python-command
1902 1902 \family default
1903 1903 previously, this value will override what
1904 1904 \family typewriter
1905 1905 ipython.el
1906 1906 \family default
1907 1907 does (because loading the customization variables comes later).
1908 1908 \layout Section
1909 1909
1910 1910
1911 1911 \begin_inset LatexCommand \label{sec:quick_tips}
1912 1912
1913 1913 \end_inset
1914 1914
1915 1915 Quick tips
1916 1916 \layout Standard
1917 1917
1918 1918 IPython can be used as an improved replacement for the Python prompt, and
1919 1919 for that you don't really need to read any more of this manual.
1920 1920 But in this section we'll try to summarize a few tips on how to make the
1921 1921 most effective use of it for everyday Python development, highlighting
1922 1922 things you might miss in the rest of the manual (which is getting long).
1923 1923 We'll give references to parts in the manual which provide more detail
1924 1924 when appropriate.
1925 1925 \layout Standard
1926 1926
1927 1927 The following article by Jeremy Jones provides an introductory tutorial
1928 1928 about IPython:
1929 1929 \newline
1930 1930
1931 1931 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1932 1932
1933 1933 \end_inset
1934 1934
1935 1935
1936 1936 \layout Itemize
1937 1937
1938 1938 The TAB key.
1939 1939 TAB-completion, especially for attributes, is a convenient way to explore
1940 1940 the structure of any object you're dealing with.
1941 1941 Simply type
1942 1942 \family typewriter
1943 1943 object_name.<TAB>
1944 1944 \family default
1945 1945 and a list of the object's attributes will be printed (see sec.
1946 1946
1947 1947 \begin_inset LatexCommand \ref{sec:readline}
1948 1948
1949 1949 \end_inset
1950 1950
1951 1951 for more).
1952 1952 Tab completion also works on file and directory names, which combined with
1953 1953 IPython's alias system allows you to do from within IPython many of the
1954 1954 things you normally would need the system shell for.
1955 1955
1956 1956 \layout Itemize
1957 1957
1958 1958 Explore your objects.
1959 1959 Typing
1960 1960 \family typewriter
1961 1961 object_name?
1962 1962 \family default
1963 1963 will print all sorts of details about any object, including docstrings,
1964 1964 function definition lines (for call arguments) and constructor details
1965 1965 for classes.
1966 1966 The magic commands
1967 1967 \family typewriter
1968 1968 %pdoc
1969 1969 \family default
1970 1970 ,
1971 1971 \family typewriter
1972 1972 %pdef
1973 1973 \family default
1974 1974 ,
1975 1975 \family typewriter
1976 1976 %psource
1977 1977 \family default
1978 1978 and
1979 1979 \family typewriter
1980 1980 %pfile
1981 1981 \family default
1982 1982 will respectively print the docstring, function definition line, full source
1983 1983 code and the complete file for any object (when they can be found).
1984 1984 If automagic is on (it is by default), you don't need to type the '
1985 1985 \family typewriter
1986 1986 %
1987 1987 \family default
1988 1988 ' explicitly.
1989 1989 See sec.
1990 1990
1991 1991 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1992 1992
1993 1993 \end_inset
1994 1994
1995 1995 for more.
1996 1996 \layout Itemize
1997 1997
1998 1998 The
1999 1999 \family typewriter
2000 2000 %run
2001 2001 \family default
2002 2002 magic command allows you to run any python script and load all of its data
2003 2003 directly into the interactive namespace.
2004 2004 Since the file is re-read from disk each time, changes you make to it are
2005 2005 reflected immediately (in contrast to the behavior of
2006 2006 \family typewriter
2007 2007 import
2008 2008 \family default
2009 2009 ).
2010 2010 I rarely use
2011 2011 \family typewriter
2012 2012 import
2013 2013 \family default
2014 2014 for code I am testing, relying on
2015 2015 \family typewriter
2016 2016 %run
2017 2017 \family default
2018 2018 instead.
2019 2019 See sec.
2020 2020
2021 2021 \begin_inset LatexCommand \ref{sec:magic}
2022 2022
2023 2023 \end_inset
2024 2024
2025 2025 for more on this and other magic commands, or type the name of any magic
2026 2026 command and ? to get details on it.
2027 2027 See also sec.
2028 2028
2029 2029 \begin_inset LatexCommand \ref{sec:dreload}
2030 2030
2031 2031 \end_inset
2032 2032
2033 2033 for a recursive reload command.
2034 2034 \newline
2035 2035
2036 2036 \family typewriter
2037 2037 %run
2038 2038 \family default
2039 2039 also has special flags for timing the execution of your scripts (
2040 2040 \family typewriter
2041 2041 -t
2042 2042 \family default
2043 2043 ) and for executing them under the control of either Python's
2044 2044 \family typewriter
2045 2045 pdb
2046 2046 \family default
2047 2047 debugger (
2048 2048 \family typewriter
2049 2049 -d
2050 2050 \family default
2051 2051 ) or profiler (
2052 2052 \family typewriter
2053 2053 -p
2054 2054 \family default
2055 2055 ).
2056 2056 With all of these,
2057 2057 \family typewriter
2058 2058 %run
2059 2059 \family default
2060 2060 can be used as the main tool for efficient interactive development of code
2061 2061 which you write in your editor of choice.
2062 2062 \layout Itemize
2063 2063
2064 2064 Use the Python debugger,
2065 2065 \family typewriter
2066 2066 pdb
2067 2067 \family default
2068 2068
2069 2069 \begin_inset Foot
2070 2070 collapsed true
2071 2071
2072 2072 \layout Standard
2073 2073
2074 2074 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2075 2075 to IPython's improved debugger and profiler support.
2076 2076 \end_inset
2077 2077
2078 2078 .
2079 2079 The
2080 2080 \family typewriter
2081 2081 %pdb
2082 2082 \family default
2083 2083 command allows you to toggle on and off the automatic invocation of an
2084 2084 IPython-enhanced
2085 2085 \family typewriter
2086 2086 pdb
2087 2087 \family default
2088 2088 debugger (with coloring, tab completion and more) at any uncaught exception.
2089 2089 The advantage of this is that
2090 2090 \family typewriter
2091 2091 pdb
2092 2092 \family default
2093 2093 starts
2094 2094 \emph on
2095 2095 inside
2096 2096 \emph default
2097 2097 the function where the exception occurred, with all data still available.
2098 2098 You can print variables, see code, execute statements and even walk up
2099 2099 and down the call stack to track down the true source of the problem (which
2100 2100 often is many layers in the stack above where the exception gets triggered).
2101 2101 \newline
2102 2102 Running programs with
2103 2103 \family typewriter
2104 2104 %run
2105 2105 \family default
2106 2106 and pdb active can be an efficient to develop and debug code, in many cases
2107 2107 eliminating the need for
2108 2108 \family typewriter
2109 2109 print
2110 2110 \family default
2111 2111 statements or external debugging tools.
2112 2112 I often simply put a
2113 2113 \family typewriter
2114 2114 1/0
2115 2115 \family default
2116 2116 in a place where I want to take a look so that pdb gets called, quickly
2117 2117 view whatever variables I need to or test various pieces of code and then
2118 2118 remove the
2119 2119 \family typewriter
2120 2120 1/0
2121 2121 \family default
2122 2122 .
2123 2123 \newline
2124 2124 Note also that `
2125 2125 \family typewriter
2126 2126 %run -d
2127 2127 \family default
2128 2128 ' activates
2129 2129 \family typewriter
2130 2130 pdb
2131 2131 \family default
2132 2132 and automatically sets initial breakpoints for you to step through your
2133 2133 code, watch variables, etc.
2134 2134 See Sec.\SpecialChar ~
2135 2135
2136 2136 \begin_inset LatexCommand \ref{sec:cache_output}
2137 2137
2138 2138 \end_inset
2139 2139
2140 2140 for details.
2141 2141 \layout Itemize
2142 2142
2143 2143 Use the output cache.
2144 2144 All output results are automatically stored in a global dictionary named
2145 2145
2146 2146 \family typewriter
2147 2147 Out
2148 2148 \family default
2149 2149 and variables named
2150 2150 \family typewriter
2151 2151 _1
2152 2152 \family default
2153 2153 ,
2154 2154 \family typewriter
2155 2155 _2
2156 2156 \family default
2157 2157 , etc.
2158 2158 alias them.
2159 2159 For example, the result of input line 4 is available either as
2160 2160 \family typewriter
2161 2161 Out[4]
2162 2162 \family default
2163 2163 or as
2164 2164 \family typewriter
2165 2165 _4
2166 2166 \family default
2167 2167 .
2168 2168 Additionally, three variables named
2169 2169 \family typewriter
2170 2170 _
2171 2171 \family default
2172 2172 ,
2173 2173 \family typewriter
2174 2174 __
2175 2175 \family default
2176 2176 and
2177 2177 \family typewriter
2178 2178 ___
2179 2179 \family default
2180 2180 are always kept updated with the for the last three results.
2181 2181 This allows you to recall any previous result and further use it for new
2182 2182 calculations.
2183 2183 See Sec.\SpecialChar ~
2184 2184
2185 2185 \begin_inset LatexCommand \ref{sec:cache_output}
2186 2186
2187 2187 \end_inset
2188 2188
2189 2189 for more.
2190 2190 \layout Itemize
2191 2191
2192 2192 Put a '
2193 2193 \family typewriter
2194 2194 ;
2195 2195 \family default
2196 2196 ' at the end of a line to supress the printing of output.
2197 2197 This is useful when doing calculations which generate long output you are
2198 2198 not interested in seeing.
2199 2199 The
2200 2200 \family typewriter
2201 2201 _*
2202 2202 \family default
2203 2203 variables and the
2204 2204 \family typewriter
2205 2205 Out[]
2206 2206 \family default
2207 2207 list do get updated with the contents of the output, even if it is not
2208 2208 printed.
2209 2209 You can thus still access the generated results this way for further processing.
2210 2210 \layout Itemize
2211 2211
2212 2212 A similar system exists for caching input.
2213 2213 All input is stored in a global list called
2214 2214 \family typewriter
2215 2215 In
2216 2216 \family default
2217 2217 , so you can re-execute lines 22 through 28 plus line 34 by typing
2218 2218 \family typewriter
2219 2219 'exec In[22:29]+In[34]'
2220 2220 \family default
2221 2221 (using Python slicing notation).
2222 2222 If you need to execute the same set of lines often, you can assign them
2223 2223 to a macro with the
2224 2224 \family typewriter
2225 2225 %macro
2226 2226 \family default
2227 2227
2228 2228 \family typewriter
2229 2229 function.
2230 2230
2231 2231 \family default
2232 2232 See sec.
2233 2233
2234 2234 \begin_inset LatexCommand \ref{sec:cache_input}
2235 2235
2236 2236 \end_inset
2237 2237
2238 2238 for more.
2239 2239 \layout Itemize
2240 2240
2241 2241 Use your input history.
2242 2242 The
2243 2243 \family typewriter
2244 2244 %hist
2245 2245 \family default
2246 2246 command can show you all previous input, without line numbers if desired
2247 2247 (option
2248 2248 \family typewriter
2249 2249 -n
2250 2250 \family default
2251 2251 ) so you can directly copy and paste code either back in IPython or in a
2252 2252 text editor.
2253 2253 You can also save all your history by turning on logging via
2254 2254 \family typewriter
2255 2255 %logstart
2256 2256 \family default
2257 2257 ; these logs can later be either reloaded as IPython sessions or used as
2258 2258 code for your programs.
2259 2259 \layout Itemize
2260 2260
2261 2261 Define your own system aliases.
2262 2262 Even though IPython gives you access to your system shell via the
2263 2263 \family typewriter
2264 2264 !
2265 2265 \family default
2266 2266 prefix, it is convenient to have aliases to the system commands you use
2267 2267 most often.
2268 2268 This allows you to work seamlessly from inside IPython with the same commands
2269 2269 you are used to in your system shell.
2270 2270 \newline
2271 2271 IPython comes with some pre-defined aliases and a complete system for changing
2272 2272 directories, both via a stack (see
2273 2273 \family typewriter
2274 2274 %pushd
2275 2275 \family default
2276 2276 ,
2277 2277 \family typewriter
2278 2278 %popd
2279 2279 \family default
2280 2280 and
2281 2281 \family typewriter
2282 2282 %ds
2283 2283 \family default
2284 2284 ) and via direct
2285 2285 \family typewriter
2286 2286 %cd
2287 2287 \family default
2288 2288 .
2289 2289 The latter keeps a history of visited directories and allows you to go
2290 2290 to any previously visited one.
2291 2291 \layout Itemize
2292 2292
2293 2293 Use Python to manipulate the results of system commands.
2294 2294 The `
2295 2295 \family typewriter
2296 2296 !!
2297 2297 \family default
2298 2298 ' special syntax, and the
2299 2299 \family typewriter
2300 2300 %sc
2301 2301 \family default
2302 2302 and
2303 2303 \family typewriter
2304 2304 %sx
2305 2305 \family default
2306 2306 magic commands allow you to capture system output into Python variables.
2307 2307 \layout Itemize
2308 2308
2309 2309 Expand python variables when calling the shell (either via
2310 2310 \family typewriter
2311 2311 `!'
2312 2312 \family default
2313 2313 and
2314 2314 \family typewriter
2315 2315 `!!'
2316 2316 \family default
2317 2317 or via aliases) by prepending a
2318 2318 \family typewriter
2319 2319 $
2320 2320 \family default
2321 2321 in front of them.
2322 2322 You can also expand complete python expressions.
2323 2323 See sec.\SpecialChar ~
2324 2324
2325 2325 \begin_inset LatexCommand \ref{sub:System-shell-access}
2326 2326
2327 2327 \end_inset
2328 2328
2329 2329 for more.
2330 2330 \layout Itemize
2331 2331
2332 2332 Use profiles to maintain different configurations (modules to load, function
2333 2333 definitions, option settings) for particular tasks.
2334 2334 You can then have customized versions of IPython for specific purposes.
2335 2335 See sec.\SpecialChar ~
2336 2336
2337 2337 \begin_inset LatexCommand \ref{sec:profiles}
2338 2338
2339 2339 \end_inset
2340 2340
2341 2341 for more.
2342 2342 \layout Itemize
2343 2343
2344 2344 Embed IPython in your programs.
2345 2345 A few lines of code are enough to load a complete IPython inside your own
2346 2346 programs, giving you the ability to work with your data interactively after
2347 2347 automatic processing has been completed.
2348 2348 See sec.\SpecialChar ~
2349 2349
2350 2350 \begin_inset LatexCommand \ref{sec:embed}
2351 2351
2352 2352 \end_inset
2353 2353
2354 2354 for more.
2355 2355 \layout Itemize
2356 2356
2357 2357 Use the Python profiler.
2358 2358 When dealing with performance issues, the
2359 2359 \family typewriter
2360 2360 %run
2361 2361 \family default
2362 2362 command with a
2363 2363 \family typewriter
2364 2364 -p
2365 2365 \family default
2366 2366 option allows you to run complete programs under the control of the Python
2367 2367 profiler.
2368 2368 The
2369 2369 \family typewriter
2370 2370 %prun
2371 2371 \family default
2372 2372 command does a similar job for single Python expressions (like function
2373 2373 calls).
2374 2374 \layout Itemize
2375 2375
2376 2376 Use the IPython.demo.Demo class to load any Python script as an interactive
2377 2377 demo.
2378 2378 With a minimal amount of simple markup, you can control the execution of
2379 2379 the script, stopping as needed.
2380 2380 See sec.\SpecialChar ~
2381 2381
2382 2382 \begin_inset LatexCommand \ref{sec:interactive-demos}
2383 2383
2384 2384 \end_inset
2385 2385
2386 2386 for more.
2387 2387 \layout Subsection
2388 2388
2389 2389 Source code handling tips
2390 2390 \layout Standard
2391 2391
2392 2392 IPython is a line-oriented program, without full control of the terminal.
2393 2393 Therefore, it doesn't support true multiline editing.
2394 2394 However, it has a number of useful tools to help you in dealing effectively
2395 2395 with more complex editing.
2396 2396 \layout Standard
2397 2397
2398 2398 The
2399 2399 \family typewriter
2400 2400 %edit
2401 2401 \family default
2402 2402 command gives a reasonable approximation of multiline editing, by invoking
2403 2403 your favorite editor on the spot.
2404 2404 IPython will execute the code you type in there as if it were typed interactive
2405 2405 ly.
2406 2406 Type
2407 2407 \family typewriter
2408 2408 %edit?
2409 2409 \family default
2410 2410 for the full details on the edit command.
2411 2411 \layout Standard
2412 2412
2413 2413 If you have typed various commands during a session, which you'd like to
2414 2414 reuse, IPython provides you with a number of tools.
2415 2415 Start by using
2416 2416 \family typewriter
2417 2417 %hist
2418 2418 \family default
2419 2419 to see your input history, so you can see the line numbers of all input.
2420 2420 Let us say that you'd like to reuse lines 10 through 20, plus lines 24
2421 2421 and 28.
2422 2422 All the commands below can operate on these with the syntax
2423 2423 \layout LyX-Code
2424 2424
2425 2425 %command 10-20 24 28
2426 2426 \layout Standard
2427 2427
2428 2428 where the command given can be:
2429 2429 \layout Itemize
2430 2430
2431 2431
2432 2432 \family typewriter
2433 2433 %macro <macroname>
2434 2434 \family default
2435 2435 : this stores the lines into a variable which, when called at the prompt,
2436 2436 re-executes the input.
2437 2437 Macros can be edited later using
2438 2438 \family typewriter
2439 2439 `%edit macroname
2440 2440 \family default
2441 2441 ', and they can be stored persistently across sessions with `
2442 2442 \family typewriter
2443 2443 %store macroname
2444 2444 \family default
2445 2445 ' (the storage system is per-profile).
2446 2446 The combination of quick macros, persistent storage and editing, allows
2447 2447 you to easily refine quick-and-dirty interactive input into permanent utilities
2448 2448 , always available both in IPython and as files for general reuse.
2449 2449 \layout Itemize
2450 2450
2451 2451
2452 2452 \family typewriter
2453 2453 %edit
2454 2454 \family default
2455 2455 : this will open a text editor with those lines pre-loaded for further modificat
2456 2456 ion.
2457 2457 It will then execute the resulting file's contents as if you had typed
2458 2458 it at the prompt.
2459 2459 \layout Itemize
2460 2460
2461 2461
2462 2462 \family typewriter
2463 2463 %save <filename>
2464 2464 \family default
2465 2465 : this saves the lines directly to a named file on disk.
2466 2466 \layout Standard
2467 2467
2468 2468 While
2469 2469 \family typewriter
2470 2470 %macro
2471 2471 \family default
2472 2472 saves input lines into memory for interactive re-execution, sometimes you'd
2473 2473 like to save your input directly to a file.
2474 2474 The
2475 2475 \family typewriter
2476 2476 %save
2477 2477 \family default
2478 2478 magic does this: its input sytnax is the same as
2479 2479 \family typewriter
2480 2480 %macro
2481 2481 \family default
2482 2482 , but it saves your input directly to a Python file.
2483 2483 Note that the
2484 2484 \family typewriter
2485 2485 %logstart
2486 2486 \family default
2487 2487 command also saves input, but it logs
2488 2488 \emph on
2489 2489 all
2490 2490 \emph default
2491 2491 input to disk (though you can temporarily suspend it and reactivate it
2492 2492 with
2493 2493 \family typewriter
2494 2494 %logoff/%logon
2495 2495 \family default
2496 2496 );
2497 2497 \family typewriter
2498 2498 %save
2499 2499 \family default
2500 2500 allows you to select which lines of input you need to save.
2501 2501 \layout Subsubsection*
2502 2502
2503 2503 Lightweight 'version control'
2504 2504 \layout Standard
2505 2505
2506 2506 When you call
2507 2507 \family typewriter
2508 2508 %edit
2509 2509 \family default
2510 2510 with no arguments, IPython opens an empty editor with a temporary file,
2511 2511 and it returns the contents of your editing session as a string variable.
2512 2512 Thanks to IPython's output caching mechanism, this is automatically stored:
2513 2513 \layout LyX-Code
2514 2514
2515 2515 In [1]: %edit
2516 2516 \layout LyX-Code
2517 2517
2518 2518 IPython will make a temporary file named: /tmp/ipython_edit_yR-HCN.py
2519 2519 \layout LyX-Code
2520 2520
2521 2521 Editing...
2522 2522 done.
2523 2523 Executing edited code...
2524 2524 \layout LyX-Code
2525 2525
2526 2526 hello - this is a temporary file
2527 2527 \layout LyX-Code
2528 2528
2529 2529 Out[1]: "print 'hello - this is a temporary file'
2530 2530 \backslash
2531 2531 n"
2532 2532 \layout Standard
2533 2533
2534 2534 Now, if you call
2535 2535 \family typewriter
2536 2536 `%edit -p'
2537 2537 \family default
2538 2538 , IPython tries to open an editor with the same data as the last time you
2539 2539 used
2540 2540 \family typewriter
2541 2541 %edit
2542 2542 \family default
2543 2543 .
2544 2544 So if you haven't used
2545 2545 \family typewriter
2546 2546 %edit
2547 2547 \family default
2548 2548 in the meantime, this same contents will reopen; however, it will be done
2549 2549 in a
2550 2550 \emph on
2551 2551 new file
2552 2552 \emph default
2553 2553 .
2554 2554 This means that if you make changes and you later want to find an old version,
2555 2555 you can always retrieve it by using its output number, via
2556 2556 \family typewriter
2557 2557 `%edit _NN'
2558 2558 \family default
2559 2559 , where
2560 2560 \family typewriter
2561 2561 NN
2562 2562 \family default
2563 2563 is the number of the output prompt.
2564 2564 \layout Standard
2565 2565
2566 2566 Continuing with the example above, this should illustrate this idea:
2567 2567 \layout LyX-Code
2568 2568
2569 2569 In [2]: edit -p
2570 2570 \layout LyX-Code
2571 2571
2572 2572 IPython will make a temporary file named: /tmp/ipython_edit_nA09Qk.py
2573 2573 \layout LyX-Code
2574 2574
2575 2575 Editing...
2576 2576 done.
2577 2577 Executing edited code...
2578 2578 \layout LyX-Code
2579 2579
2580 2580 hello - now I made some changes
2581 2581 \layout LyX-Code
2582 2582
2583 2583 Out[2]: "print 'hello - now I made some changes'
2584 2584 \backslash
2585 2585 n"
2586 2586 \layout LyX-Code
2587 2587
2588 2588 In [3]: edit _1
2589 2589 \layout LyX-Code
2590 2590
2591 2591 IPython will make a temporary file named: /tmp/ipython_edit_gy6-zD.py
2592 2592 \layout LyX-Code
2593 2593
2594 2594 Editing...
2595 2595 done.
2596 2596 Executing edited code...
2597 2597 \layout LyX-Code
2598 2598
2599 2599 hello - this is a temporary file
2600 2600 \layout LyX-Code
2601 2601
2602 2602 IPython version control at work :)
2603 2603 \layout LyX-Code
2604 2604
2605 2605 Out[3]: "print 'hello - this is a temporary file'
2606 2606 \backslash
2607 2607 nprint 'IPython version control at work :)'
2608 2608 \backslash
2609 2609 n"
2610 2610 \layout Standard
2611 2611
2612 2612 This section was written after a contribution by Alexander Belchenko on
2613 2613 the IPython user list.
2614 2614 \layout LyX-Code
2615 2615
2616 2616 \layout Subsection
2617 2617
2618 2618 Effective logging
2619 2619 \layout Standard
2620 2620
2621 2621 A very useful suggestion sent in by Robert Kern follows:
2622 2622 \layout Standard
2623 2623
2624 2624 I recently happened on a nifty way to keep tidy per-project log files.
2625 2625 I made a profile for my project (which is called "parkfield").
2626 2626 \layout LyX-Code
2627 2627
2628 2628 include ipythonrc
2629 2629 \layout LyX-Code
2630 2630
2631 2631 # cancel earlier logfile invocation:
2632 2632 \layout LyX-Code
2633 2633
2634 2634 logfile ''
2635 2635 \layout LyX-Code
2636 2636
2637 2637 execute import time
2638 2638 \layout LyX-Code
2639 2639
2640 2640 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2641 2641 \layout LyX-Code
2642 2642
2643 2643 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2644 2644 \layout Standard
2645 2645
2646 2646 I also added a shell alias for convenience:
2647 2647 \layout LyX-Code
2648 2648
2649 2649 alias parkfield="ipython -pylab -profile parkfield"
2650 2650 \layout Standard
2651 2651
2652 2652 Now I have a nice little directory with everything I ever type in, organized
2653 2653 by project and date.
2654 2654 \layout Standard
2655 2655
2656 2656
2657 2657 \series bold
2658 2658 Contribute your own:
2659 2659 \series default
2660 2660 If you have your own favorite tip on using IPython efficiently for a certain
2661 2661 task (especially things which can't be done in the normal Python interpreter),
2662 2662 don't hesitate to send it!
2663 2663 \layout Section
2664 2664
2665 2665 Command-line use
2666 2666 \layout Standard
2667 2667
2668 2668 You start IPython with the command:
2669 2669 \layout Standard
2670 2670
2671 2671
2672 2672 \family typewriter
2673 2673 $ ipython [options] files
2674 2674 \layout Standard
2675 2675
2676 2676 If invoked with no options, it executes all the files listed in sequence
2677 2677 and drops you into the interpreter while still acknowledging any options
2678 2678 you may have set in your ipythonrc file.
2679 2679 This behavior is different from standard Python, which when called as
2680 2680 \family typewriter
2681 2681 python -i
2682 2682 \family default
2683 2683 will only execute one file and ignore your configuration setup.
2684 2684 \layout Standard
2685 2685
2686 2686 Please note that some of the configuration options are not available at
2687 2687 the command line, simply because they are not practical here.
2688 2688 Look into your ipythonrc configuration file for details on those.
2689 2689 This file typically installed in the
2690 2690 \family typewriter
2691 2691 $HOME/.ipython
2692 2692 \family default
2693 2693 directory.
2694 2694 For Windows users,
2695 2695 \family typewriter
2696 2696 $HOME
2697 2697 \family default
2698 2698 resolves to
2699 2699 \family typewriter
2700 2700 C:
2701 2701 \backslash
2702 2702
2703 2703 \backslash
2704 2704 Documents and Settings
2705 2705 \backslash
2706 2706
2707 2707 \backslash
2708 2708 YourUserName
2709 2709 \family default
2710 2710 in most instances.
2711 2711 In the rest of this text, we will refer to this directory as
2712 2712 \family typewriter
2713 2713 IPYTHONDIR
2714 2714 \family default
2715 2715 .
2716 2716 \layout Subsection
2717 2717
2718 2718
2719 2719 \begin_inset LatexCommand \label{sec:threading-opts}
2720 2720
2721 2721 \end_inset
2722 2722
2723 2723 Special Threading Options
2724 2724 \layout Standard
2725 2725
2726 2726 The following special options are ONLY valid at the beginning of the command
2727 2727 line, and not later.
2728 2728 This is because they control the initial- ization of ipython itself, before
2729 2729 the normal option-handling mechanism is active.
2730 2730 \layout List
2731 2731 \labelwidthstring 00.00.0000
2732 2732
2733 2733
2734 2734 \family typewriter
2735 2735 \series bold
2736 2736 -gthread,\SpecialChar ~
2737 2737 -qthread,\SpecialChar ~
2738 2738 -wthread,\SpecialChar ~
2739 2739 -pylab:
2740 2740 \family default
2741 2741 \series default
2742 2742 Only
2743 2743 \emph on
2744 2744 one
2745 2745 \emph default
2746 2746 of these can be given, and it can only be given as the first option passed
2747 2747 to IPython (it will have no effect in any other position).
2748 2748 They provide threading support for the GTK Qt and WXPython toolkits, and
2749 2749 for the matplotlib library.
2750 2750 \layout List
2751 2751 \labelwidthstring 00.00.0000
2752 2752
2753 2753 \SpecialChar ~
2754 2754 With any of the first three options, IPython starts running a separate
2755 2755 thread for the graphical toolkit's operation, so that you can open and
2756 2756 control graphical elements from within an IPython command line, without
2757 2757 blocking.
2758 2758 All three provide essentially the same functionality, respectively for
2759 2759 GTK, QT and WXWidgets (via their Python interfaces).
2760 2760 \layout List
2761 2761 \labelwidthstring 00.00.0000
2762 2762
2763 2763 \SpecialChar ~
2764 2764 Note that with
2765 2765 \family typewriter
2766 2766 -wthread
2767 2767 \family default
2768 2768 , you can additionally use the -wxversion option to request a specific version
2769 2769 of wx to be used.
2770 2770 This requires that you have the
2771 2771 \family typewriter
2772 2772 wxversion
2773 2773 \family default
2774 2774 Python module installed, which is part of recent wxPython distributions.
2775 2775 \layout List
2776 2776 \labelwidthstring 00.00.0000
2777 2777
2778 2778 \SpecialChar ~
2779 2779 If
2780 2780 \family typewriter
2781 2781 -pylab
2782 2782 \family default
2783 2783 is given, IPython loads special support for the mat plotlib library (
2784 2784 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2785 2785
2786 2786 \end_inset
2787 2787
2788 2788 ), allowing interactive usage of any of its backends as defined in the user's
2789 2789
2790 2790 \family typewriter
2791 2791 ~/.matplotlib/matplotlibrc
2792 2792 \family default
2793 2793 file.
2794 2794 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2795 2795 of matplotlib backend requires it.
2796 2796 It also modifies the
2797 2797 \family typewriter
2798 2798 %run
2799 2799 \family default
2800 2800 command to correctly execute (without blocking) any matplotlib-based script
2801 2801 which calls
2802 2802 \family typewriter
2803 2803 show()
2804 2804 \family default
2805 2805 at the end.
2806 2806
2807 2807 \layout List
2808 2808 \labelwidthstring 00.00.0000
2809 2809
2810 2810
2811 2811 \family typewriter
2812 2812 \series bold
2813 2813 -tk
2814 2814 \family default
2815 2815 \series default
2816 2816 The
2817 2817 \family typewriter
2818 2818 -g/q/wthread
2819 2819 \family default
2820 2820 options, and
2821 2821 \family typewriter
2822 2822 -pylab
2823 2823 \family default
2824 2824 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2825 2825 Tk graphical interfaces.
2826 2826 This means that when either GTK, Qt or WX threading is active, any attempt
2827 2827 to open a Tk GUI will result in a dead window, and possibly cause the Python
2828 2828 interpreter to crash.
2829 2829 An extra option,
2830 2830 \family typewriter
2831 2831 -tk
2832 2832 \family default
2833 2833 , is available to address this issue.
2834 2834 It can
2835 2835 \emph on
2836 2836 only
2837 2837 \emph default
2838 2838 be given as a
2839 2839 \emph on
2840 2840 second
2841 2841 \emph default
2842 2842 option after any of the above (
2843 2843 \family typewriter
2844 2844 -gthread
2845 2845 \family default
2846 2846 ,
2847 2847 \family typewriter
2848 2848 -wthread
2849 2849 \family default
2850 2850 or
2851 2851 \family typewriter
2852 2852 -pylab
2853 2853 \family default
2854 2854 ).
2855 2855 \layout List
2856 2856 \labelwidthstring 00.00.0000
2857 2857
2858 2858 \SpecialChar ~
2859 2859 If
2860 2860 \family typewriter
2861 2861 -tk
2862 2862 \family default
2863 2863 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2864 2864 This is however potentially unreliable, and you will have to test on your
2865 2865 platform and Python configuration to determine whether it works for you.
2866 2866 Debian users have reported success, apparently due to the fact that Debian
2867 2867 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2868 2868 Under other Linux environments (such as Fedora Core 2/3), this option has
2869 2869 caused random crashes and lockups of the Python interpreter.
2870 2870 Under other operating systems (Mac OSX and Windows), you'll need to try
2871 2871 it to find out, since currently no user reports are available.
2872 2872 \layout List
2873 2873 \labelwidthstring 00.00.0000
2874 2874
2875 2875 \SpecialChar ~
2876 2876 There is unfortunately no way for IPython to determine at run time whether
2877 2877
2878 2878 \family typewriter
2879 2879 -tk
2880 2880 \family default
2881 2881 will work reliably or not, so you will need to do some experiments before
2882 2882 relying on it for regular work.
2883 2883
2884 2884 \layout Subsection
2885 2885
2886 2886
2887 2887 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2888 2888
2889 2889 \end_inset
2890 2890
2891 2891 Regular Options
2892 2892 \layout Standard
2893 2893
2894 2894 After the above threading options have been given, regular options can follow
2895 2895 in any order.
2896 2896 All options can be abbreviated to their shortest non-ambiguous form and
2897 2897 are case-sensitive.
2898 2898 One or two dashes can be used.
2899 2899 Some options have an alternate short form, indicated after a
2900 2900 \family typewriter
2901 2901 |
2902 2902 \family default
2903 2903 .
2904 2904 \layout Standard
2905 2905
2906 2906 Most options can also be set from your ipythonrc configuration file.
2907 2907 See the provided example for more details on what the options do.
2908 2908 Options given at the command line override the values set in the ipythonrc
2909 2909 file.
2910 2910 \layout Standard
2911 2911
2912 2912 All options with a
2913 2913 \family typewriter
2914 2914 [no]
2915 2915 \family default
2916 2916 prepended can be specified in negated form (
2917 2917 \family typewriter
2918 2918 -nooption
2919 2919 \family default
2920 2920 instead of
2921 2921 \family typewriter
2922 2922 -option
2923 2923 \family default
2924 2924 ) to turn the feature off.
2925 2925 \layout List
2926 2926 \labelwidthstring 00.00.0000
2927 2927
2928 2928
2929 2929 \family typewriter
2930 2930 \series bold
2931 2931 -help
2932 2932 \family default
2933 2933 \series default
2934 2934 : print a help message and exit.
2935 2935 \layout List
2936 2936 \labelwidthstring 00.00.0000
2937 2937
2938 2938
2939 2939 \family typewriter
2940 2940 \series bold
2941 2941 -pylab:
2942 2942 \family default
2943 2943 \series default
2944 2944 this can
2945 2945 \emph on
2946 2946 only
2947 2947 \emph default
2948 2948 be given as the
2949 2949 \emph on
2950 2950 first
2951 2951 \emph default
2952 2952 option passed to IPython (it will have no effect in any other position).
2953 2953 It adds special support for the matplotlib library (
2954 2954 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2955 2955
2956 2956 \end_inset
2957 2957
2958 2958 ), allowing interactive usage of any of its backends as defined in the user's
2959 2959
2960 2960 \family typewriter
2961 2961 .matplotlibrc
2962 2962 \family default
2963 2963 file.
2964 2964 It automatically activates GTK or WX threading for IPyhton if the choice
2965 2965 of matplotlib backend requires it.
2966 2966 It also modifies the
2967 2967 \family typewriter
2968 2968 %run
2969 2969 \family default
2970 2970 command to correctly execute (without blocking) any matplotlib-based script
2971 2971 which calls
2972 2972 \family typewriter
2973 2973 show()
2974 2974 \family default
2975 2975 at the end.
2976 2976 See Sec.\SpecialChar ~
2977 2977
2978 2978 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2979 2979
2980 2980 \end_inset
2981 2981
2982 2982 for more details.
2983 2983 \layout List
2984 2984 \labelwidthstring 00.00.0000
2985 2985
2986 2986
2987 2987 \family typewriter
2988 2988 \series bold
2989 2989 -autocall <val>:
2990 2990 \family default
2991 2991 \series default
2992 2992 Make IPython automatically call any callable object even if you didn't
2993 2993 type explicit parentheses.
2994 2994 For example, `str 43' becomes `str(43)' automatically.
2995 2995 The value can be `0' to disable the feature, `1' for
2996 2996 \emph on
2997 2997 smart
2998 2998 \emph default
2999 2999 autocall, where it is not applied if there are no more arguments on the
3000 3000 line, and `2' for
3001 3001 \emph on
3002 3002 full
3003 3003 \emph default
3004 3004 autocall, where all callable objects are automatically called (even if
3005 3005 no arguments are present).
3006 3006 The default is `1'.
3007 3007 \layout List
3008 3008 \labelwidthstring 00.00.0000
3009 3009
3010 3010
3011 3011 \family typewriter
3012 3012 \series bold
3013 3013 -[no]autoindent:
3014 3014 \family default
3015 3015 \series default
3016 3016 Turn automatic indentation on/off.
3017 3017 \layout List
3018 3018 \labelwidthstring 00.00.0000
3019 3019
3020 3020
3021 3021 \family typewriter
3022 3022 \series bold
3023 3023 -[no]automagic
3024 3024 \series default
3025 3025 :
3026 3026 \family default
3027 3027 make magic commands automatic (without needing their first character to
3028 3028 be
3029 3029 \family typewriter
3030 3030 %
3031 3031 \family default
3032 3032 ).
3033 3033 Type
3034 3034 \family typewriter
3035 3035 %magic
3036 3036 \family default
3037 3037 at the IPython prompt for more information.
3038 3038 \layout List
3039 3039 \labelwidthstring 00.00.0000
3040 3040
3041 3041
3042 3042 \family typewriter
3043 3043 \series bold
3044 3044 -[no]autoedit_syntax:
3045 3045 \family default
3046 3046 \series default
3047 3047 When a syntax error occurs after editing a file, automatically open the
3048 3048 file to the trouble causing line for convenient fixing.
3049 3049
3050 3050 \layout List
3051 3051 \labelwidthstring 00.00.0000
3052 3052
3053 3053
3054 3054 \family typewriter
3055 3055 \series bold
3056 3056 -[no]banner
3057 3057 \series default
3058 3058 :
3059 3059 \family default
3060 3060 Print the initial information banner (default on).
3061 3061 \layout List
3062 3062 \labelwidthstring 00.00.0000
3063 3063
3064 3064
3065 3065 \family typewriter
3066 3066 \series bold
3067 3067 -c\SpecialChar ~
3068 3068 <command>:
3069 3069 \family default
3070 3070 \series default
3071 3071 execute the given command string, and set sys.argv to
3072 3072 \family typewriter
3073 3073 ['c']
3074 3074 \family default
3075 3075 .
3076 3076 This is similar to the
3077 3077 \family typewriter
3078 3078 -c
3079 3079 \family default
3080 3080 option in the normal Python interpreter.
3081 3081
3082 3082 \layout List
3083 3083 \labelwidthstring 00.00.0000
3084 3084
3085 3085
3086 3086 \family typewriter
3087 3087 \series bold
3088 3088 -cache_size|cs\SpecialChar ~
3089 3089 <n>
3090 3090 \series default
3091 3091 :
3092 3092 \family default
3093 3093 size of the output cache (maximum number of entries to hold in memory).
3094 3094 The default is 1000, you can change it permanently in your config file.
3095 3095 Setting it to 0 completely disables the caching system, and the minimum
3096 3096 value accepted is 20 (if you provide a value less than 20, it is reset
3097 3097 to 0 and a warning is issued) This limit is defined because otherwise you'll
3098 3098 spend more time re-flushing a too small cache than working.
3099 3099 \layout List
3100 3100 \labelwidthstring 00.00.0000
3101 3101
3102 3102
3103 3103 \family typewriter
3104 3104 \series bold
3105 3105 -classic|cl
3106 3106 \series default
3107 3107 :
3108 3108 \family default
3109 3109 Gives IPython a similar feel to the classic Python prompt.
3110 3110 \layout List
3111 3111 \labelwidthstring 00.00.0000
3112 3112
3113 3113
3114 3114 \family typewriter
3115 3115 \series bold
3116 3116 -colors\SpecialChar ~
3117 3117 <scheme>:
3118 3118 \family default
3119 3119 \series default
3120 3120 Color scheme for prompts and exception reporting.
3121 3121 Currently implemented: NoColor, Linux and LightBG.
3122 3122 \layout List
3123 3123 \labelwidthstring 00.00.0000
3124 3124
3125 3125
3126 3126 \family typewriter
3127 3127 \series bold
3128 3128 -[no]color_info:
3129 3129 \family default
3130 3130 \series default
3131 3131 IPython can display information about objects via a set of functions, and
3132 3132 optionally can use colors for this, syntax highlighting source code and
3133 3133 various other elements.
3134 3134 However, because this information is passed through a pager (like 'less')
3135 3135 and many pagers get confused with color codes, this option is off by default.
3136 3136 You can test it and turn it on permanently in your ipythonrc file if it
3137 3137 works for you.
3138 3138 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
3139 3139 that in RedHat 7.2 doesn't.
3140 3140 \layout List
3141 3141 \labelwidthstring 00.00.0000
3142 3142
3143 3143 \SpecialChar ~
3144 3144 Test it and turn it on permanently if it works with your system.
3145 3145 The magic function
3146 3146 \family typewriter
3147 3147 %color_info
3148 3148 \family default
3149 3149 allows you to toggle this interactively for testing.
3150 3150 \layout List
3151 3151 \labelwidthstring 00.00.0000
3152 3152
3153 3153
3154 3154 \family typewriter
3155 3155 \series bold
3156 3156 -[no]debug
3157 3157 \family default
3158 3158 \series default
3159 3159 : Show information about the loading process.
3160 3160 Very useful to pin down problems with your configuration files or to get
3161 3161 details about session restores.
3162 3162 \layout List
3163 3163 \labelwidthstring 00.00.0000
3164 3164
3165 3165
3166 3166 \family typewriter
3167 3167 \series bold
3168 3168 -[no]deep_reload
3169 3169 \series default
3170 3170 :
3171 3171 \family default
3172 3172 IPython can use the
3173 3173 \family typewriter
3174 3174 deep_reload
3175 3175 \family default
3176 3176 module which reloads changes in modules recursively (it replaces the
3177 3177 \family typewriter
3178 3178 reload()
3179 3179 \family default
3180 3180 function, so you don't need to change anything to use it).
3181 3181
3182 3182 \family typewriter
3183 3183 deep_reload()
3184 3184 \family default
3185 3185 forces a full reload of modules whose code may have changed, which the
3186 3186 default
3187 3187 \family typewriter
3188 3188 reload()
3189 3189 \family default
3190 3190 function does not.
3191 3191 \layout List
3192 3192 \labelwidthstring 00.00.0000
3193 3193
3194 3194 \SpecialChar ~
3195 3195 When deep_reload is off, IPython will use the normal
3196 3196 \family typewriter
3197 3197 reload()
3198 3198 \family default
3199 3199 , but deep_reload will still be available as
3200 3200 \family typewriter
3201 3201 dreload()
3202 3202 \family default
3203 3203 .
3204 3204 This feature is off by default [which means that you have both normal
3205 3205 \family typewriter
3206 3206 reload()
3207 3207 \family default
3208 3208 and
3209 3209 \family typewriter
3210 3210 dreload()
3211 3211 \family default
3212 3212 ].
3213 3213 \layout List
3214 3214 \labelwidthstring 00.00.0000
3215 3215
3216 3216
3217 3217 \family typewriter
3218 3218 \series bold
3219 3219 -editor\SpecialChar ~
3220 3220 <name>
3221 3221 \family default
3222 3222 \series default
3223 3223 : Which editor to use with the
3224 3224 \family typewriter
3225 3225 %edit
3226 3226 \family default
3227 3227 command.
3228 3228 By default, IPython will honor your
3229 3229 \family typewriter
3230 3230 EDITOR
3231 3231 \family default
3232 3232 environment variable (if not set, vi is the Unix default and notepad the
3233 3233 Windows one).
3234 3234 Since this editor is invoked on the fly by IPython and is meant for editing
3235 3235 small code snippets, you may want to use a small, lightweight editor here
3236 3236 (in case your default
3237 3237 \family typewriter
3238 3238 EDITOR
3239 3239 \family default
3240 3240 is something like Emacs).
3241 3241 \layout List
3242 3242 \labelwidthstring 00.00.0000
3243 3243
3244 3244
3245 3245 \family typewriter
3246 3246 \series bold
3247 3247 -ipythondir\SpecialChar ~
3248 3248 <name>
3249 3249 \series default
3250 3250 :
3251 3251 \family default
3252 3252 name of your IPython configuration directory
3253 3253 \family typewriter
3254 3254 IPYTHONDIR
3255 3255 \family default
3256 3256 .
3257 3257 This can also be specified through the environment variable
3258 3258 \family typewriter
3259 3259 IPYTHONDIR
3260 3260 \family default
3261 3261 .
3262 3262 \layout List
3263 3263 \labelwidthstring 00.00.0000
3264 3264
3265 3265
3266 3266 \family typewriter
3267 3267 \series bold
3268 3268 -log|l
3269 3269 \family default
3270 3270 \series default
3271 3271 : generate a log file of all input.
3272 3272 The file is named
3273 3273 \family typewriter
3274 3274 ipython_log.py
3275 3275 \family default
3276 3276 in your current directory (which prevents logs from multiple IPython sessions
3277 3277 from trampling each other).
3278 3278 You can use this to later restore a session by loading your logfile as
3279 3279 a file to be executed with option
3280 3280 \family typewriter
3281 3281 -logplay
3282 3282 \family default
3283 3283 (see below).
3284 3284 \layout List
3285 3285 \labelwidthstring 00.00.0000
3286 3286
3287 3287
3288 3288 \family typewriter
3289 3289 \series bold
3290 3290 -logfile|lf\SpecialChar ~
3291 3291 <name>
3292 3292 \series default
3293 3293 :
3294 3294 \family default
3295 3295 specify the name of your logfile.
3296 3296 \layout List
3297 3297 \labelwidthstring 00.00.0000
3298 3298
3299 3299
3300 3300 \family typewriter
3301 3301 \series bold
3302 3302 -logplay|lp\SpecialChar ~
3303 3303 <name>
3304 3304 \series default
3305 3305 :
3306 3306 \family default
3307 3307 you can replay a previous log.
3308 3308 For restoring a session as close as possible to the state you left it in,
3309 3309 use this option (don't just run the logfile).
3310 3310 With
3311 3311 \family typewriter
3312 3312 -logplay
3313 3313 \family default
3314 3314 , IPython will try to reconstruct the previous working environment in full,
3315 3315 not just execute the commands in the logfile.
3316 3316 \layout List
3317 3317 \labelwidthstring 00.00.0000
3318 3318
3319 3319 \SpecialChar ~
3320 3320 When a session is restored, logging is automatically turned on again with
3321 3321 the name of the logfile it was invoked with (it is read from the log header).
3322 3322 So once you've turned logging on for a session, you can quit IPython and
3323 3323 reload it as many times as you want and it will continue to log its history
3324 3324 and restore from the beginning every time.
3325 3325 \layout List
3326 3326 \labelwidthstring 00.00.0000
3327 3327
3328 3328 \SpecialChar ~
3329 3329 Caveats: there are limitations in this option.
3330 3330 The history variables
3331 3331 \family typewriter
3332 3332 _i*
3333 3333 \family default
3334 3334 ,
3335 3335 \family typewriter
3336 3336 _*
3337 3337 \family default
3338 3338 and
3339 3339 \family typewriter
3340 3340 _dh
3341 3341 \family default
3342 3342 don't get restored properly.
3343 3343 In the future we will try to implement full session saving by writing and
3344 3344 retrieving a 'snapshot' of the memory state of IPython.
3345 3345 But our first attempts failed because of inherent limitations of Python's
3346 3346 Pickle module, so this may have to wait.
3347 3347 \layout List
3348 3348 \labelwidthstring 00.00.0000
3349 3349
3350 3350
3351 3351 \family typewriter
3352 3352 \series bold
3353 3353 -[no]messages
3354 3354 \series default
3355 3355 :
3356 3356 \family default
3357 3357 Print messages which IPython collects about its startup process (default
3358 3358 on).
3359 3359 \layout List
3360 3360 \labelwidthstring 00.00.0000
3361 3361
3362 3362
3363 3363 \family typewriter
3364 3364 \series bold
3365 3365 -[no]pdb
3366 3366 \family default
3367 3367 \series default
3368 3368 : Automatically call the pdb debugger after every uncaught exception.
3369 3369 If you are used to debugging using pdb, this puts you automatically inside
3370 3370 of it after any call (either in IPython or in code called by it) which
3371 3371 triggers an exception which goes uncaught.
3372 3372 \layout List
3373 3373 \labelwidthstring 00.00.0000
3374 3374
3375 3375
3376 3376 \family typewriter
3377 3377 \series bold
3378 3378 -[no]pprint
3379 3379 \series default
3380 3380 :
3381 3381 \family default
3382 3382 ipython can optionally use the pprint (pretty printer) module for displaying
3383 3383 results.
3384 3384 pprint tends to give a nicer display of nested data structures.
3385 3385 If you like it, you can turn it on permanently in your config file (default
3386 3386 off).
3387 3387 \layout List
3388 3388 \labelwidthstring 00.00.0000
3389 3389
3390 3390
3391 3391 \family typewriter
3392 3392 \series bold
3393 3393 -profile|p <name>
3394 3394 \series default
3395 3395 :
3396 3396 \family default
3397 3397 assume that your config file is
3398 3398 \family typewriter
3399 3399 ipythonrc-<name>
3400 3400 \family default
3401 3401 (looks in current dir first, then in
3402 3402 \family typewriter
3403 3403 IPYTHONDIR
3404 3404 \family default
3405 3405 ).
3406 3406 This is a quick way to keep and load multiple config files for different
3407 3407 tasks, especially if you use the include option of config files.
3408 3408 You can keep a basic
3409 3409 \family typewriter
3410 3410 IPYTHONDIR/ipythonrc
3411 3411 \family default
3412 3412 file and then have other 'profiles' which include this one and load extra
3413 3413 things for particular tasks.
3414 3414 For example:
3415 3415 \layout List
3416 3416 \labelwidthstring 00.00.0000
3417 3417
3418 3418
3419 3419 \family typewriter
3420 3420 \SpecialChar ~
3421 3421
3422 3422 \family default
3423 3423 1.
3424 3424
3425 3425 \family typewriter
3426 3426 $HOME/.ipython/ipythonrc
3427 3427 \family default
3428 3428 : load basic things you always want.
3429 3429 \layout List
3430 3430 \labelwidthstring 00.00.0000
3431 3431
3432 3432
3433 3433 \family typewriter
3434 3434 \SpecialChar ~
3435 3435
3436 3436 \family default
3437 3437 2.
3438 3438
3439 3439 \family typewriter
3440 3440 $HOME/.ipython/ipythonrc-math
3441 3441 \family default
3442 3442 : load (1) and basic math-related modules.
3443 3443
3444 3444 \layout List
3445 3445 \labelwidthstring 00.00.0000
3446 3446
3447 3447
3448 3448 \family typewriter
3449 3449 \SpecialChar ~
3450 3450
3451 3451 \family default
3452 3452 3.
3453 3453
3454 3454 \family typewriter
3455 3455 $HOME/.ipython/ipythonrc-numeric
3456 3456 \family default
3457 3457 : load (1) and Numeric and plotting modules.
3458 3458 \layout List
3459 3459 \labelwidthstring 00.00.0000
3460 3460
3461 3461 \SpecialChar ~
3462 3462 Since it is possible to create an endless loop by having circular file
3463 3463 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3464 3464 \layout List
3465 3465 \labelwidthstring 00.00.0000
3466 3466
3467 3467
3468 3468 \family typewriter
3469 3469 \series bold
3470 3470 -prompt_in1|pi1\SpecialChar ~
3471 3471 <string>:
3472 3472 \family default
3473 3473 \series default
3474 3474 Specify the string used for input prompts.
3475 3475 Note that if you are using numbered prompts, the number is represented
3476 3476 with a '
3477 3477 \backslash
3478 3478 #' in the string.
3479 3479 Don't forget to quote strings with spaces embedded in them.
3480 3480 Default: '
3481 3481 \family typewriter
3482 3482 In\SpecialChar ~
3483 3483 [
3484 3484 \backslash
3485 3485 #]:
3486 3486 \family default
3487 3487 '.
3488 3488 Sec.\SpecialChar ~
3489 3489
3490 3490 \begin_inset LatexCommand \ref{sec:prompts}
3491 3491
3492 3492 \end_inset
3493 3493
3494 3494 discusses in detail all the available escapes to customize your prompts.
3495 3495 \layout List
3496 3496 \labelwidthstring 00.00.0000
3497 3497
3498 3498
3499 3499 \family typewriter
3500 3500 \series bold
3501 3501 -prompt_in2|pi2\SpecialChar ~
3502 3502 <string>:
3503 3503 \family default
3504 3504 \series default
3505 3505 Similar to the previous option, but used for the continuation prompts.
3506 3506 The special sequence '
3507 3507 \family typewriter
3508 3508
3509 3509 \backslash
3510 3510 D
3511 3511 \family default
3512 3512 ' is similar to '
3513 3513 \family typewriter
3514 3514
3515 3515 \backslash
3516 3516 #
3517 3517 \family default
3518 3518 ', but with all digits replaced dots (so you can have your continuation
3519 3519 prompt aligned with your input prompt).
3520 3520 Default: '
3521 3521 \family typewriter
3522 3522 \SpecialChar ~
3523 3523 \SpecialChar ~
3524 3524 \SpecialChar ~
3525 3525 .
3526 3526 \backslash
3527 3527 D.:
3528 3528 \family default
3529 3529 ' (note three spaces at the start for alignment with '
3530 3530 \family typewriter
3531 3531 In\SpecialChar ~
3532 3532 [
3533 3533 \backslash
3534 3534 #]
3535 3535 \family default
3536 3536 ').
3537 3537 \layout List
3538 3538 \labelwidthstring 00.00.0000
3539 3539
3540 3540
3541 3541 \family typewriter
3542 3542 \series bold
3543 3543 -prompt_out|po\SpecialChar ~
3544 3544 <string>:
3545 3545 \family default
3546 3546 \series default
3547 3547 String used for output prompts, also uses numbers like
3548 3548 \family typewriter
3549 3549 prompt_in1
3550 3550 \family default
3551 3551 .
3552 3552 Default: '
3553 3553 \family typewriter
3554 3554 Out[
3555 3555 \backslash
3556 3556 #]:
3557 3557 \family default
3558 3558 '
3559 3559 \layout List
3560 3560 \labelwidthstring 00.00.0000
3561 3561
3562 3562
3563 3563 \family typewriter
3564 3564 \series bold
3565 3565 -quick
3566 3566 \family default
3567 3567 \series default
3568 3568 : start in bare bones mode (no config file loaded).
3569 3569 \layout List
3570 3570 \labelwidthstring 00.00.0000
3571 3571
3572 3572
3573 3573 \family typewriter
3574 3574 \series bold
3575 3575 -rcfile\SpecialChar ~
3576 3576 <name>
3577 3577 \series default
3578 3578 :
3579 3579 \family default
3580 3580 name of your IPython resource configuration file.
3581 3581 Normally IPython loads ipythonrc (from current directory) or
3582 3582 \family typewriter
3583 3583 IPYTHONDIR/ipythonrc
3584 3584 \family default
3585 3585 .
3586 3586 \layout List
3587 3587 \labelwidthstring 00.00.0000
3588 3588
3589 3589 \SpecialChar ~
3590 3590 If the loading of your config file fails, IPython starts with a bare bones
3591 3591 configuration (no modules loaded at all).
3592 3592 \layout List
3593 3593 \labelwidthstring 00.00.0000
3594 3594
3595 3595
3596 3596 \family typewriter
3597 3597 \series bold
3598 3598 -[no]readline
3599 3599 \family default
3600 3600 \series default
3601 3601 : use the readline library, which is needed to support name completion and
3602 3602 command history, among other things.
3603 3603 It is enabled by default, but may cause problems for users of X/Emacs in
3604 3604 Python comint or shell buffers.
3605 3605 \layout List
3606 3606 \labelwidthstring 00.00.0000
3607 3607
3608 3608 \SpecialChar ~
3609 3609 Note that X/Emacs 'eterm' buffers (opened with
3610 3610 \family typewriter
3611 3611 M-x\SpecialChar ~
3612 3612 term
3613 3613 \family default
3614 3614 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3615 3615 \family typewriter
3616 3616 M-x\SpecialChar ~
3617 3617 shell
3618 3618 \family default
3619 3619 and
3620 3620 \family typewriter
3621 3621 C-c\SpecialChar ~
3622 3622 !
3623 3623 \family default
3624 3624 ) buffers do not.
3625 3625 \layout List
3626 3626 \labelwidthstring 00.00.0000
3627 3627
3628 3628
3629 3629 \family typewriter
3630 3630 \series bold
3631 3631 -screen_length|sl\SpecialChar ~
3632 3632 <n>
3633 3633 \series default
3634 3634 :
3635 3635 \family default
3636 3636 number of lines of your screen.
3637 3637 This is used to control printing of very long strings.
3638 3638 Strings longer than this number of lines will be sent through a pager instead
3639 3639 of directly printed.
3640 3640 \layout List
3641 3641 \labelwidthstring 00.00.0000
3642 3642
3643 3643 \SpecialChar ~
3644 3644 The default value for this is 0, which means IPython will auto-detect your
3645 3645 screen size every time it needs to print certain potentially long strings
3646 3646 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3647 3647 internally).
3648 3648 If for some reason this isn't working well (it needs curses support), specify
3649 3649 it yourself.
3650 3650 Otherwise don't change the default.
3651 3651 \layout List
3652 3652 \labelwidthstring 00.00.0000
3653 3653
3654 3654
3655 3655 \family typewriter
3656 3656 \series bold
3657 3657 -separate_in|si\SpecialChar ~
3658 3658 <string>
3659 3659 \series default
3660 3660 :
3661 3661 \family default
3662 3662 separator before input prompts.
3663 3663 Default: '
3664 3664 \family typewriter
3665 3665
3666 3666 \backslash
3667 3667 n
3668 3668 \family default
3669 3669 '
3670 3670 \layout List
3671 3671 \labelwidthstring 00.00.0000
3672 3672
3673 3673
3674 3674 \family typewriter
3675 3675 \series bold
3676 3676 -separate_out|so\SpecialChar ~
3677 3677 <string>
3678 3678 \family default
3679 3679 \series default
3680 3680 : separator before output prompts.
3681 3681 Default: nothing.
3682 3682 \layout List
3683 3683 \labelwidthstring 00.00.0000
3684 3684
3685 3685
3686 3686 \family typewriter
3687 3687 \series bold
3688 3688 -separate_out2|so2\SpecialChar ~
3689 3689 <string>
3690 3690 \series default
3691 3691 :
3692 3692 \family default
3693 3693 separator after output prompts.
3694 3694 Default: nothing.
3695 3695 \layout List
3696 3696 \labelwidthstring 00.00.0000
3697 3697
3698 3698 \SpecialChar ~
3699 3699 For these three options, use the value 0 to specify no separator.
3700 3700 \layout List
3701 3701 \labelwidthstring 00.00.0000
3702 3702
3703 3703
3704 3704 \family typewriter
3705 3705 \series bold
3706 3706 -nosep
3707 3707 \series default
3708 3708 :
3709 3709 \family default
3710 3710 shorthand for
3711 3711 \family typewriter
3712 3712 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3713 3713 \family default
3714 3714 .
3715 3715 Simply removes all input/output separators.
3716 3716 \layout List
3717 3717 \labelwidthstring 00.00.0000
3718 3718
3719 3719
3720 3720 \family typewriter
3721 3721 \series bold
3722 3722 -upgrade
3723 3723 \family default
3724 3724 \series default
3725 3725 : allows you to upgrade your
3726 3726 \family typewriter
3727 3727 IPYTHONDIR
3728 3728 \family default
3729 3729 configuration when you install a new version of IPython.
3730 3730 Since new versions may include new command line options or example files,
3731 3731 this copies updated ipythonrc-type files.
3732 3732 However, it backs up (with a
3733 3733 \family typewriter
3734 3734 .old
3735 3735 \family default
3736 3736 extension) all files which it overwrites so that you can merge back any
3737 3737 customizations you might have in your personal files.
3738 3738 \layout List
3739 3739 \labelwidthstring 00.00.0000
3740 3740
3741 3741
3742 3742 \family typewriter
3743 3743 \series bold
3744 3744 -Version
3745 3745 \series default
3746 3746 :
3747 3747 \family default
3748 3748 print version information and exit.
3749 3749 \layout List
3750 3750 \labelwidthstring 00.00.0000
3751 3751
3752 3752
3753 3753 \family typewriter
3754 3754 \series bold
3755 3755 -wxversion\SpecialChar ~
3756 3756 <string>:
3757 3757 \family default
3758 3758 \series default
3759 3759 Select a specific version of wxPython (used in conjunction with
3760 3760 \family typewriter
3761 3761 -wthread
3762 3762 \family default
3763 3763 ).
3764 3764 Requires the wxversion module, part of recent wxPython distributions
3765 3765 \layout List
3766 3766 \labelwidthstring 00.00.0000
3767 3767
3768 3768
3769 3769 \family typewriter
3770 3770 \series bold
3771 3771 -xmode\SpecialChar ~
3772 3772 <modename>
3773 3773 \series default
3774 3774 :
3775 3775 \family default
3776 3776 Mode for exception reporting.
3777 3777 \layout List
3778 3778 \labelwidthstring 00.00.0000
3779 3779
3780 3780 \SpecialChar ~
3781 3781 Valid modes: Plain, Context and Verbose.
3782 3782 \layout List
3783 3783 \labelwidthstring 00.00.0000
3784 3784
3785 3785 \SpecialChar ~
3786 3786 Plain: similar to python's normal traceback printing.
3787 3787 \layout List
3788 3788 \labelwidthstring 00.00.0000
3789 3789
3790 3790 \SpecialChar ~
3791 3791 Context: prints 5 lines of context source code around each line in the
3792 3792 traceback.
3793 3793 \layout List
3794 3794 \labelwidthstring 00.00.0000
3795 3795
3796 3796 \SpecialChar ~
3797 3797 Verbose: similar to Context, but additionally prints the variables currently
3798 3798 visible where the exception happened (shortening their strings if too long).
3799 3799 This can potentially be very slow, if you happen to have a huge data structure
3800 3800 whose string representation is complex to compute.
3801 3801 Your computer may appear to freeze for a while with cpu usage at 100%.
3802 3802 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3803 3803 it more than once).
3804 3804 \layout Section
3805 3805
3806 3806 Interactive use
3807 3807 \layout Standard
3808 3808
3809 3809
3810 3810 \series bold
3811 3811 Warning
3812 3812 \series default
3813 3813 : IPython relies on the existence of a global variable called
3814 3814 \family typewriter
3815 3815 __IP
3816 3816 \family default
3817 3817 which controls the shell itself.
3818 3818 If you redefine
3819 3819 \family typewriter
3820 3820 __IP
3821 3821 \family default
3822 3822 to anything, bizarre behavior will quickly occur.
3823 3823 \layout Standard
3824 3824
3825 3825 Other than the above warning, IPython is meant to work as a drop-in replacement
3826 3826 for the standard interactive interpreter.
3827 3827 As such, any code which is valid python should execute normally under IPython
3828 3828 (cases where this is not true should be reported as bugs).
3829 3829 It does, however, offer many features which are not available at a standard
3830 3830 python prompt.
3831 3831 What follows is a list of these.
3832 3832 \layout Subsection
3833 3833
3834 3834 Caution for Windows users
3835 3835 \layout Standard
3836 3836
3837 3837 Windows, unfortunately, uses the `
3838 3838 \family typewriter
3839 3839
3840 3840 \backslash
3841 3841
3842 3842 \family default
3843 3843 ' character as a path separator.
3844 3844 This is a terrible choice, because `
3845 3845 \family typewriter
3846 3846
3847 3847 \backslash
3848 3848
3849 3849 \family default
3850 3850 ' also represents the escape character in most modern programming languages,
3851 3851 including Python.
3852 3852 For this reason, issuing many of the commands discussed below (especially
3853 3853 magics which affect the filesystem) with `
3854 3854 \family typewriter
3855 3855
3856 3856 \backslash
3857 3857
3858 3858 \family default
3859 3859 ' in them will cause strange errors.
3860 3860 \layout Standard
3861 3861
3862 3862 A partial solution is to use instead the `
3863 3863 \family typewriter
3864 3864 /
3865 3865 \family default
3866 3866 ' character as a path separator, which Windows recognizes in
3867 3867 \emph on
3868 3868 most
3869 3869 \emph default
3870 3870 situations.
3871 3871 However, in Windows commands `
3872 3872 \family typewriter
3873 3873 /
3874 3874 \family default
3875 3875 ' flags options, so you can not use it for the root directory.
3876 3876 This means that paths beginning at the root must be typed in a contrived
3877 3877 manner like:
3878 3878 \newline
3879 3879
3880 3880 \family typewriter
3881 3881 %copy
3882 3882 \backslash
3883 3883 opt/foo/bar.txt
3884 3884 \backslash
3885 3885 tmp
3886 3886 \layout Standard
3887 3887
3888 3888 There is no sensible thing IPython can do to truly work around this flaw
3889 3889 in Windows
3890 3890 \begin_inset Foot
3891 3891 collapsed true
3892 3892
3893 3893 \layout Standard
3894 3894
3895 3895 If anyone comes up with a
3896 3896 \emph on
3897 3897 clean
3898 3898 \emph default
3899 3899 solution which works consistently and does not negatively impact other
3900 3900 platforms at all, I'll gladly accept a patch.
3901 3901 \end_inset
3902 3902
3903 3903 .
3904 3904 \layout Subsection
3905 3905
3906 3906
3907 3907 \begin_inset LatexCommand \label{sec:magic}
3908 3908
3909 3909 \end_inset
3910 3910
3911 3911 Magic command system
3912 3912 \layout Standard
3913 3913
3914 3914 IPython will treat any line whose first character is a
3915 3915 \family typewriter
3916 3916 %
3917 3917 \family default
3918 3918 as a special call to a 'magic' function.
3919 3919 These allow you to control the behavior of IPython itself, plus a lot of
3920 3920 system-type features.
3921 3921 They are all prefixed with a
3922 3922 \family typewriter
3923 3923 %
3924 3924 \family default
3925 3925 character, but parameters are given without parentheses or quotes.
3926 3926 \layout Standard
3927 3927
3928 3928 Example: typing
3929 3929 \family typewriter
3930 3930 '%cd mydir'
3931 3931 \family default
3932 3932 (without the quotes) changes you working directory to
3933 3933 \family typewriter
3934 3934 'mydir'
3935 3935 \family default
3936 3936 , if it exists.
3937 3937 \layout Standard
3938 3938
3939 3939 If you have 'automagic' enabled (in your
3940 3940 \family typewriter
3941 3941 ipythonrc
3942 3942 \family default
3943 3943 file, via the command line option
3944 3944 \family typewriter
3945 3945 -automagic
3946 3946 \family default
3947 3947 or with the
3948 3948 \family typewriter
3949 3949 %automagic
3950 3950 \family default
3951 3951 function), you don't need to type in the
3952 3952 \family typewriter
3953 3953 %
3954 3954 \family default
3955 3955 explicitly.
3956 3956 IPython will scan its internal list of magic functions and call one if
3957 3957 it exists.
3958 3958 With automagic on you can then just type '
3959 3959 \family typewriter
3960 3960 cd mydir
3961 3961 \family default
3962 3962 ' to go to directory '
3963 3963 \family typewriter
3964 3964 mydir
3965 3965 \family default
3966 3966 '.
3967 3967 The automagic system has the lowest possible precedence in name searches,
3968 3968 so defining an identifier with the same name as an existing magic function
3969 3969 will shadow it for automagic use.
3970 3970 You can still access the shadowed magic function by explicitly using the
3971 3971
3972 3972 \family typewriter
3973 3973 %
3974 3974 \family default
3975 3975 character at the beginning of the line.
3976 3976 \layout Standard
3977 3977
3978 3978 An example (with automagic on) should clarify all this:
3979 3979 \layout LyX-Code
3980 3980
3981 3981 In [1]: cd ipython # %cd is called by automagic
3982 3982 \layout LyX-Code
3983 3983
3984 3984 /home/fperez/ipython
3985 3985 \layout LyX-Code
3986 3986
3987 3987 In [2]: cd=1 # now cd is just a variable
3988 3988 \layout LyX-Code
3989 3989
3990 3990 In [3]: cd ..
3991 3991 # and doesn't work as a function anymore
3992 3992 \layout LyX-Code
3993 3993
3994 3994 ------------------------------------------------------------
3995 3995 \layout LyX-Code
3996 3996
3997 3997 File "<console>", line 1
3998 3998 \layout LyX-Code
3999 3999
4000 4000 cd ..
4001 4001 \layout LyX-Code
4002 4002
4003 4003 ^
4004 4004 \layout LyX-Code
4005 4005
4006 4006 SyntaxError: invalid syntax
4007 4007 \layout LyX-Code
4008 4008
4009 4009 \layout LyX-Code
4010 4010
4011 4011 In [4]: %cd ..
4012 4012 # but %cd always works
4013 4013 \layout LyX-Code
4014 4014
4015 4015 /home/fperez
4016 4016 \layout LyX-Code
4017 4017
4018 4018 In [5]: del cd # if you remove the cd variable
4019 4019 \layout LyX-Code
4020 4020
4021 4021 In [6]: cd ipython # automagic can work again
4022 4022 \layout LyX-Code
4023 4023
4024 4024 /home/fperez/ipython
4025 4025 \layout Standard
4026 4026
4027 4027 You can define your own magic functions to extend the system.
4028 4028 The following is a snippet of code which shows how to do it.
4029 4029 It is provided as file
4030 4030 \family typewriter
4031 4031 example-magic.py
4032 4032 \family default
4033 4033 in the examples directory:
4034 4034 \layout Standard
4035 4035
4036 4036
4037 4037 \begin_inset ERT
4038 4038 status Open
4039 4039
4040 4040 \layout Standard
4041 4041
4042 4042 \backslash
4043 4043 codelist{examples/example-magic.py}
4044 4044 \end_inset
4045 4045
4046 4046
4047 4047 \layout Standard
4048 4048
4049 4049 You can also define your own aliased names for magic functions.
4050 4050 In your
4051 4051 \family typewriter
4052 4052 ipythonrc
4053 4053 \family default
4054 4054 file, placing a line like:
4055 4055 \layout Standard
4056 4056
4057 4057
4058 4058 \family typewriter
4059 4059 execute __IP.magic_cl = __IP.magic_clear
4060 4060 \layout Standard
4061 4061
4062 4062 will define
4063 4063 \family typewriter
4064 4064 %cl
4065 4065 \family default
4066 4066 as a new name for
4067 4067 \family typewriter
4068 4068 %clear
4069 4069 \family default
4070 4070 .
4071 4071 \layout Standard
4072 4072
4073 4073 Type
4074 4074 \family typewriter
4075 4075 %magic
4076 4076 \family default
4077 4077 for more information, including a list of all available magic functions
4078 4078 at any time and their docstrings.
4079 4079 You can also type
4080 4080 \family typewriter
4081 4081 %magic_function_name?
4082 4082 \family default
4083 4083 (see sec.
4084 4084
4085 4085 \begin_inset LatexCommand \ref{sec:dyn-object-info}
4086 4086
4087 4087 \end_inset
4088 4088
4089 4089 for information on the
4090 4090 \family typewriter
4091 4091 '?'
4092 4092 \family default
4093 4093 system) to get information about any particular magic function you are
4094 4094 interested in.
4095 4095 \layout Subsubsection
4096 4096
4097 4097 Magic commands
4098 4098 \layout Standard
4099 4099
4100 4100 The rest of this section is automatically generated for each release from
4101 4101 the docstrings in the IPython code.
4102 4102 Therefore the formatting is somewhat minimal, but this method has the advantage
4103 4103 of having information always in sync with the code.
4104 4104 \layout Standard
4105 4105
4106 4106 A list of all the magic commands available in IPython's
4107 4107 \emph on
4108 4108 default
4109 4109 \emph default
4110 4110 installation follows.
4111 4111 This is similar to what you'll see by simply typing
4112 4112 \family typewriter
4113 4113 %magic
4114 4114 \family default
4115 4115 at the prompt, but that will also give you information about magic commands
4116 4116 you may have added as part of your personal customizations.
4117 4117 \layout Standard
4118 4118
4119 4119
4120 4120 \begin_inset Include \input{magic.tex}
4121 4121 preview false
4122 4122
4123 4123 \end_inset
4124 4124
4125 4125
4126 4126 \layout Subsection
4127 4127
4128 4128 Access to the standard Python help
4129 4129 \layout Standard
4130 4130
4131 4131 As of Python 2.1, a help system is available with access to object docstrings
4132 4132 and the Python manuals.
4133 4133 Simply type
4134 4134 \family typewriter
4135 4135 'help'
4136 4136 \family default
4137 4137 (no quotes) to access it.
4138 4138 You can also type
4139 4139 \family typewriter
4140 4140 help(object)
4141 4141 \family default
4142 4142 to obtain information about a given object, and
4143 4143 \family typewriter
4144 4144 help('keyword')
4145 4145 \family default
4146 4146 for information on a keyword.
4147 4147 As noted in sec.
4148 4148
4149 4149 \begin_inset LatexCommand \ref{sec:help-access}
4150 4150
4151 4151 \end_inset
4152 4152
4153 4153 , you need to properly configure your environment variable
4154 4154 \family typewriter
4155 4155 PYTHONDOCS
4156 4156 \family default
4157 4157 for this feature to work correctly.
4158 4158 \layout Subsection
4159 4159
4160 4160
4161 4161 \begin_inset LatexCommand \label{sec:dyn-object-info}
4162 4162
4163 4163 \end_inset
4164 4164
4165 4165 Dynamic object information
4166 4166 \layout Standard
4167 4167
4168 4168 Typing
4169 4169 \family typewriter
4170 4170 ?word
4171 4171 \family default
4172 4172 or
4173 4173 \family typewriter
4174 4174 word?
4175 4175 \family default
4176 4176 prints detailed information about an object.
4177 4177 If certain strings in the object are too long (docstrings, code, etc.) they
4178 4178 get snipped in the center for brevity.
4179 4179 This system gives access variable types and values, full source code for
4180 4180 any object (if available), function prototypes and other useful information.
4181 4181 \layout Standard
4182 4182
4183 4183 Typing
4184 4184 \family typewriter
4185 4185 ??word
4186 4186 \family default
4187 4187 or
4188 4188 \family typewriter
4189 4189 word??
4190 4190 \family default
4191 4191 gives access to the full information without snipping long strings.
4192 4192 Long strings are sent to the screen through the
4193 4193 \family typewriter
4194 4194 less
4195 4195 \family default
4196 4196 pager if longer than the screen and printed otherwise.
4197 4197 On systems lacking the
4198 4198 \family typewriter
4199 4199 less
4200 4200 \family default
4201 4201 command, IPython uses a very basic internal pager.
4202 4202 \layout Standard
4203 4203
4204 4204 The following magic functions are particularly useful for gathering information
4205 4205 about your working environment.
4206 4206 You can get more details by typing
4207 4207 \family typewriter
4208 4208 %magic
4209 4209 \family default
4210 4210 or querying them individually (use
4211 4211 \family typewriter
4212 4212 %function_name?
4213 4213 \family default
4214 4214 with or without the
4215 4215 \family typewriter
4216 4216 %
4217 4217 \family default
4218 4218 ), this is just a summary:
4219 4219 \layout List
4220 4220 \labelwidthstring 00.00.0000
4221 4221
4222 4222
4223 4223 \family typewriter
4224 4224 \series bold
4225 4225 %pdoc\SpecialChar ~
4226 4226 <object>
4227 4227 \family default
4228 4228 \series default
4229 4229 : Print (or run through a pager if too long) the docstring for an object.
4230 4230 If the given object is a class, it will print both the class and the constructo
4231 4231 r docstrings.
4232 4232 \layout List
4233 4233 \labelwidthstring 00.00.0000
4234 4234
4235 4235
4236 4236 \family typewriter
4237 4237 \series bold
4238 4238 %pdef\SpecialChar ~
4239 4239 <object>
4240 4240 \family default
4241 4241 \series default
4242 4242 : Print the definition header for any callable object.
4243 4243 If the object is a class, print the constructor information.
4244 4244 \layout List
4245 4245 \labelwidthstring 00.00.0000
4246 4246
4247 4247
4248 4248 \family typewriter
4249 4249 \series bold
4250 4250 %psource\SpecialChar ~
4251 4251 <object>
4252 4252 \family default
4253 4253 \series default
4254 4254 : Print (or run through a pager if too long) the source code for an object.
4255 4255 \layout List
4256 4256 \labelwidthstring 00.00.0000
4257 4257
4258 4258
4259 4259 \family typewriter
4260 4260 \series bold
4261 4261 %pfile\SpecialChar ~
4262 4262 <object>
4263 4263 \family default
4264 4264 \series default
4265 4265 : Show the entire source file where an object was defined via a pager, opening
4266 4266 it at the line where the object definition begins.
4267 4267 \layout List
4268 4268 \labelwidthstring 00.00.0000
4269 4269
4270 4270
4271 4271 \family typewriter
4272 4272 \series bold
4273 4273 %who/%whos
4274 4274 \family default
4275 4275 \series default
4276 4276 : These functions give information about identifiers you have defined interactiv
4277 4277 ely (not things you loaded or defined in your configuration files).
4278 4278
4279 4279 \family typewriter
4280 4280 %who
4281 4281 \family default
4282 4282 just prints a list of identifiers and
4283 4283 \family typewriter
4284 4284 %whos
4285 4285 \family default
4286 4286 prints a table with some basic details about each identifier.
4287 4287 \layout Standard
4288 4288
4289 4289 Note that the dynamic object information functions (
4290 4290 \family typewriter
4291 4291 ?/??, %pdoc, %pfile, %pdef, %psource
4292 4292 \family default
4293 4293 ) give you access to documentation even on things which are not really defined
4294 4294 as separate identifiers.
4295 4295 Try for example typing
4296 4296 \family typewriter
4297 4297 {}.get?
4298 4298 \family default
4299 4299 or after doing
4300 4300 \family typewriter
4301 4301 import os
4302 4302 \family default
4303 4303 , type
4304 4304 \family typewriter
4305 4305 os.path.abspath??
4306 4306 \family default
4307 4307 .
4308 4308 \layout Subsection
4309 4309
4310 4310
4311 4311 \begin_inset LatexCommand \label{sec:readline}
4312 4312
4313 4313 \end_inset
4314 4314
4315 4315 Readline-based features
4316 4316 \layout Standard
4317 4317
4318 4318 These features require the GNU readline library, so they won't work if your
4319 4319 Python installation lacks readline support.
4320 4320 We will first describe the default behavior IPython uses, and then how
4321 4321 to change it to suit your preferences.
4322 4322 \layout Subsubsection
4323 4323
4324 4324 Command line completion
4325 4325 \layout Standard
4326 4326
4327 4327 At any time, hitting TAB will complete any available python commands or
4328 4328 variable names, and show you a list of the possible completions if there's
4329 4329 no unambiguous one.
4330 4330 It will also complete filenames in the current directory if no python names
4331 4331 match what you've typed so far.
4332 4332 \layout Subsubsection
4333 4333
4334 4334 Search command history
4335 4335 \layout Standard
4336 4336
4337 4337 IPython provides two ways for searching through previous input and thus
4338 4338 reduce the need for repetitive typing:
4339 4339 \layout Enumerate
4340 4340
4341 4341 Start typing, and then use
4342 4342 \family typewriter
4343 4343 Ctrl-p
4344 4344 \family default
4345 4345 (previous,up) and
4346 4346 \family typewriter
4347 4347 Ctrl-n
4348 4348 \family default
4349 4349 (next,down) to search through only the history items that match what you've
4350 4350 typed so far.
4351 4351 If you use
4352 4352 \family typewriter
4353 4353 Ctrl-p/Ctrl-n
4354 4354 \family default
4355 4355 at a blank prompt, they just behave like normal arrow keys.
4356 4356 \layout Enumerate
4357 4357
4358 4358 Hit
4359 4359 \family typewriter
4360 4360 Ctrl-r
4361 4361 \family default
4362 4362 : opens a search prompt.
4363 4363 Begin typing and the system searches your history for lines that contain
4364 4364 what you've typed so far, completing as much as it can.
4365 4365 \layout Subsubsection
4366 4366
4367 4367 Persistent command history across sessions
4368 4368 \layout Standard
4369 4369
4370 4370 IPython will save your input history when it leaves and reload it next time
4371 4371 you restart it.
4372 4372 By default, the history file is named
4373 4373 \family typewriter
4374 4374 $IPYTHONDIR/history
4375 4375 \family default
4376 4376 , but if you've loaded a named profile, '
4377 4377 \family typewriter
4378 4378 -PROFILE_NAME
4379 4379 \family default
4380 4380 ' is appended to the name.
4381 4381 This allows you to keep separate histories related to various tasks: commands
4382 4382 related to numerical work will not be clobbered by a system shell history,
4383 4383 for example.
4384 4384 \layout Subsubsection
4385 4385
4386 4386 Autoindent
4387 4387 \layout Standard
4388 4388
4389 4389 IPython can recognize lines ending in ':' and indent the next line, while
4390 4390 also un-indenting automatically after 'raise' or 'return'.
4391 4391
4392 4392 \layout Standard
4393 4393
4394 4394 This feature uses the readline library, so it will honor your
4395 4395 \family typewriter
4396 4396 ~/.inputrc
4397 4397 \family default
4398 4398 configuration (or whatever file your
4399 4399 \family typewriter
4400 4400 INPUTRC
4401 4401 \family default
4402 4402 variable points to).
4403 4403 Adding the following lines to your
4404 4404 \family typewriter
4405 4405 .inputrc
4406 4406 \family default
4407 4407 file can make indenting/unindenting more convenient (
4408 4408 \family typewriter
4409 4409 M-i
4410 4410 \family default
4411 4411 indents,
4412 4412 \family typewriter
4413 4413 M-u
4414 4414 \family default
4415 4415 unindents):
4416 4416 \layout Standard
4417 4417
4418 4418
4419 4419 \family typewriter
4420 4420 $if Python
4421 4421 \newline
4422 4422 "
4423 4423 \backslash
4424 4424 M-i": "\SpecialChar ~
4425 4425 \SpecialChar ~
4426 4426 \SpecialChar ~
4427 4427 \SpecialChar ~
4428 4428 "
4429 4429 \newline
4430 4430 "
4431 4431 \backslash
4432 4432 M-u": "
4433 4433 \backslash
4434 4434 d
4435 4435 \backslash
4436 4436 d
4437 4437 \backslash
4438 4438 d
4439 4439 \backslash
4440 4440 d"
4441 4441 \newline
4442 4442 $endif
4443 4443 \layout Standard
4444 4444
4445 4445 Note that there are 4 spaces between the quote marks after
4446 4446 \family typewriter
4447 4447 "M-i"
4448 4448 \family default
4449 4449 above.
4450 4450 \layout Standard
4451 4451
4452 4452
4453 4453 \series bold
4454 4454 Warning:
4455 4455 \series default
4456 4456 this feature is ON by default, but it can cause problems with the pasting
4457 4457 of multi-line indented code (the pasted code gets re-indented on each line).
4458 4458 A magic function
4459 4459 \family typewriter
4460 4460 %autoindent
4461 4461 \family default
4462 4462 allows you to toggle it on/off at runtime.
4463 4463 You can also disable it permanently on in your
4464 4464 \family typewriter
4465 4465 ipythonrc
4466 4466 \family default
4467 4467 file (set
4468 4468 \family typewriter
4469 4469 autoindent 0
4470 4470 \family default
4471 4471 ).
4472 4472 \layout Subsubsection
4473 4473
4474 4474 Customizing readline behavior
4475 4475 \layout Standard
4476 4476
4477 4477 All these features are based on the GNU readline library, which has an extremely
4478 4478 customizable interface.
4479 4479 Normally, readline is configured via a file which defines the behavior
4480 4480 of the library; the details of the syntax for this can be found in the
4481 4481 readline documentation available with your system or on the Internet.
4482 4482 IPython doesn't read this file (if it exists) directly, but it does support
4483 4483 passing to readline valid options via a simple interface.
4484 4484 In brief, you can customize readline by setting the following options in
4485 4485 your
4486 4486 \family typewriter
4487 4487 ipythonrc
4488 4488 \family default
4489 4489 configuration file (note that these options can
4490 4490 \emph on
4491 4491 not
4492 4492 \emph default
4493 4493 be specified at the command line):
4494 4494 \layout List
4495 4495 \labelwidthstring 00.00.0000
4496 4496
4497 4497
4498 4498 \family typewriter
4499 4499 \series bold
4500 4500 readline_parse_and_bind:
4501 4501 \family default
4502 4502 \series default
4503 4503 this option can appear as many times as you want, each time defining a
4504 4504 string to be executed via a
4505 4505 \family typewriter
4506 4506 readline.parse_and_bind()
4507 4507 \family default
4508 4508 command.
4509 4509 The syntax for valid commands of this kind can be found by reading the
4510 4510 documentation for the GNU readline library, as these commands are of the
4511 4511 kind which readline accepts in its configuration file.
4512 4512 \layout List
4513 4513 \labelwidthstring 00.00.0000
4514 4514
4515 4515
4516 4516 \family typewriter
4517 4517 \series bold
4518 4518 readline_remove_delims:
4519 4519 \family default
4520 4520 \series default
4521 4521 a string of characters to be removed from the default word-delimiters list
4522 4522 used by readline, so that completions may be performed on strings which
4523 4523 contain them.
4524 4524 Do not change the default value unless you know what you're doing.
4525 4525 \layout List
4526 4526 \labelwidthstring 00.00.0000
4527 4527
4528 4528
4529 4529 \family typewriter
4530 4530 \series bold
4531 4531 readline_omit__names
4532 4532 \family default
4533 4533 \series default
4534 4534 : when tab-completion is enabled, hitting
4535 4535 \family typewriter
4536 4536 <tab>
4537 4537 \family default
4538 4538 after a '
4539 4539 \family typewriter
4540 4540 .
4541 4541 \family default
4542 4542 ' in a name will complete all attributes of an object, including all the
4543 4543 special methods whose names include double underscores (like
4544 4544 \family typewriter
4545 4545 __getitem__
4546 4546 \family default
4547 4547 or
4548 4548 \family typewriter
4549 4549 __class__
4550 4550 \family default
4551 4551 ).
4552 4552 If you'd rather not see these names by default, you can set this option
4553 4553 to 1.
4554 4554 Note that even when this option is set, you can still see those names by
4555 4555 explicitly typing a
4556 4556 \family typewriter
4557 4557 _
4558 4558 \family default
4559 4559 after the period and hitting
4560 4560 \family typewriter
4561 4561 <tab>
4562 4562 \family default
4563 4563 : '
4564 4564 \family typewriter
4565 4565 name._<tab>
4566 4566 \family default
4567 4567 ' will always complete attribute names starting with '
4568 4568 \family typewriter
4569 4569 _
4570 4570 \family default
4571 4571 '.
4572 4572 \layout List
4573 4573 \labelwidthstring 00.00.0000
4574 4574
4575 4575 \SpecialChar ~
4576 4576 This option is off by default so that new users see all attributes of any
4577 4577 objects they are dealing with.
4578 4578 \layout Standard
4579 4579
4580 4580 You will find the default values along with a corresponding detailed explanation
4581 4581 in your
4582 4582 \family typewriter
4583 4583 ipythonrc
4584 4584 \family default
4585 4585 file.
4586 4586 \layout Subsection
4587 4587
4588 4588 Session logging and restoring
4589 4589 \layout Standard
4590 4590
4591 4591 You can log all input from a session either by starting IPython with the
4592 4592 command line switches
4593 4593 \family typewriter
4594 4594 -log
4595 4595 \family default
4596 4596 or
4597 4597 \family typewriter
4598 4598 -logfile
4599 4599 \family default
4600 4600 (see sec.
4601 4601
4602 4602 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4603 4603
4604 4604 \end_inset
4605 4605
4606 4606 )or by activating the logging at any moment with the magic function
4607 4607 \family typewriter
4608 4608 %logstart
4609 4609 \family default
4610 4610 .
4611 4611
4612 4612 \layout Standard
4613 4613
4614 4614 Log files can later be reloaded with the
4615 4615 \family typewriter
4616 4616 -logplay
4617 4617 \family default
4618 4618 option and IPython will attempt to 'replay' the log by executing all the
4619 4619 lines in it, thus restoring the state of a previous session.
4620 4620 This feature is not quite perfect, but can still be useful in many cases.
4621 4621 \layout Standard
4622 4622
4623 4623 The log files can also be used as a way to have a permanent record of any
4624 4624 code you wrote while experimenting.
4625 4625 Log files are regular text files which you can later open in your favorite
4626 4626 text editor to extract code or to 'clean them up' before using them to
4627 4627 replay a session.
4628 4628 \layout Standard
4629 4629
4630 4630 The
4631 4631 \family typewriter
4632 4632 %logstart
4633 4633 \family default
4634 4634 function for activating logging in mid-session is used as follows:
4635 4635 \layout Standard
4636 4636
4637 4637
4638 4638 \family typewriter
4639 4639 %logstart [log_name [log_mode]]
4640 4640 \layout Standard
4641 4641
4642 4642 If no name is given, it defaults to a file named
4643 4643 \family typewriter
4644 4644 'log'
4645 4645 \family default
4646 4646 in your IPYTHONDIR directory, in
4647 4647 \family typewriter
4648 4648 'rotate'
4649 4649 \family default
4650 4650 mode (see below).
4651 4651 \layout Standard
4652 4652
4653 4653 '
4654 4654 \family typewriter
4655 4655 %logstart name
4656 4656 \family default
4657 4657 ' saves to file
4658 4658 \family typewriter
4659 4659 'name'
4660 4660 \family default
4661 4661 in
4662 4662 \family typewriter
4663 4663 'backup'
4664 4664 \family default
4665 4665 mode.
4666 4666 It saves your history up to that point and then continues logging.
4667 4667 \layout Standard
4668 4668
4669 4669
4670 4670 \family typewriter
4671 4671 %logstart
4672 4672 \family default
4673 4673 takes a second optional parameter: logging mode.
4674 4674 This can be one of (note that the modes are given unquoted):
4675 4675 \layout List
4676 4676 \labelwidthstring 00.00.0000
4677 4677
4678 4678
4679 4679 \family typewriter
4680 4680 over
4681 4681 \family default
4682 4682 : overwrite existing
4683 4683 \family typewriter
4684 4684 log_name
4685 4685 \family default
4686 4686 .
4687 4687 \layout List
4688 4688 \labelwidthstring 00.00.0000
4689 4689
4690 4690
4691 4691 \family typewriter
4692 4692 backup
4693 4693 \family default
4694 4694 : rename (if exists) to
4695 4695 \family typewriter
4696 4696 log_name~
4697 4697 \family default
4698 4698 and start
4699 4699 \family typewriter
4700 4700 log_name
4701 4701 \family default
4702 4702 .
4703 4703 \layout List
4704 4704 \labelwidthstring 00.00.0000
4705 4705
4706 4706
4707 4707 \family typewriter
4708 4708 append
4709 4709 \family default
4710 4710 : well, that says it.
4711 4711 \layout List
4712 4712 \labelwidthstring 00.00.0000
4713 4713
4714 4714
4715 4715 \family typewriter
4716 4716 rotate
4717 4717 \family default
4718 4718 : create rotating logs
4719 4719 \family typewriter
4720 4720 log_name
4721 4721 \family default
4722 4722 .
4723 4723 \family typewriter
4724 4724 1~
4725 4725 \family default
4726 4726 ,
4727 4727 \family typewriter
4728 4728 log_name.2~
4729 4729 \family default
4730 4730 , etc.
4731 4731 \layout Standard
4732 4732
4733 4733 The
4734 4734 \family typewriter
4735 4735 %logoff
4736 4736 \family default
4737 4737 and
4738 4738 \family typewriter
4739 4739 %logon
4740 4740 \family default
4741 4741 functions allow you to temporarily stop and resume logging to a file which
4742 4742 had previously been started with
4743 4743 \family typewriter
4744 4744 %logstart
4745 4745 \family default
4746 4746 .
4747 4747 They will fail (with an explanation) if you try to use them before logging
4748 4748 has been started.
4749 4749 \layout Subsection
4750 4750
4751 4751
4752 4752 \begin_inset LatexCommand \label{sub:System-shell-access}
4753 4753
4754 4754 \end_inset
4755 4755
4756 4756 System shell access
4757 4757 \layout Standard
4758 4758
4759 4759 Any input line beginning with a
4760 4760 \family typewriter
4761 4761 !
4762 4762 \family default
4763 4763 character is passed verbatim (minus the
4764 4764 \family typewriter
4765 4765 !
4766 4766 \family default
4767 4767 , of course) to the underlying operating system.
4768 4768 For example, typing
4769 4769 \family typewriter
4770 4770 !ls
4771 4771 \family default
4772 4772 will run
4773 4773 \family typewriter
4774 4774 'ls'
4775 4775 \family default
4776 4776 in the current directory.
4777 4777 \layout Subsubsection
4778 4778
4779 4779 Manual capture of command output
4780 4780 \layout Standard
4781 4781
4782 4782 If the input line begins with
4783 4783 \emph on
4784 4784 two
4785 4785 \emph default
4786 4786 exclamation marks,
4787 4787 \family typewriter
4788 4788 !!
4789 4789 \family default
4790 4790 , the command is executed but its output is captured and returned as a python
4791 4791 list, split on newlines.
4792 4792 Any output sent by the subprocess to standard error is printed separately,
4793 4793 so that the resulting list only captures standard output.
4794 4794 The
4795 4795 \family typewriter
4796 4796 !!
4797 4797 \family default
4798 4798 syntax is a shorthand for the
4799 4799 \family typewriter
4800 4800 %sx
4801 4801 \family default
4802 4802 magic command.
4803 4803 \layout Standard
4804 4804
4805 4805 Finally, the
4806 4806 \family typewriter
4807 4807 %sc
4808 4808 \family default
4809 4809 magic (short for `shell capture') is similar to
4810 4810 \family typewriter
4811 4811 %sx
4812 4812 \family default
4813 4813 , but allowing more fine-grained control of the capture details, and storing
4814 4814 the result directly into a named variable.
4815 4815 \layout Standard
4816 4816
4817 4817 See Sec.\SpecialChar ~
4818 4818
4819 4819 \begin_inset LatexCommand \ref{sec:magic}
4820 4820
4821 4821 \end_inset
4822 4822
4823 4823 for details on the magics
4824 4824 \family typewriter
4825 4825 %sc
4826 4826 \family default
4827 4827 and
4828 4828 \family typewriter
4829 4829 %sx
4830 4830 \family default
4831 4831 , or use IPython's own help (
4832 4832 \family typewriter
4833 4833 sc?
4834 4834 \family default
4835 4835 and
4836 4836 \family typewriter
4837 4837 sx?
4838 4838 \family default
4839 4839 ) for further details.
4840 4840 \layout Standard
4841 4841
4842 4842 IPython also allows you to expand the value of python variables when making
4843 4843 system calls.
4844 4844 Any python variable or expression which you prepend with
4845 4845 \family typewriter
4846 4846 $
4847 4847 \family default
4848 4848 will get expanded before the system call is made.
4849 4849
4850 4850 \layout Standard
4851 4851
4852 4852
4853 4853 \family typewriter
4854 4854 In [1]: pyvar='Hello world'
4855 4855 \newline
4856 4856 In [2]: !echo "A python variable: $pyvar"
4857 4857 \newline
4858 4858 A python variable: Hello world
4859 4859 \layout Standard
4860 4860
4861 4861 If you want the shell to actually see a literal
4862 4862 \family typewriter
4863 4863 $
4864 4864 \family default
4865 4865 , you need to type it twice:
4866 4866 \layout Standard
4867 4867
4868 4868
4869 4869 \family typewriter
4870 4870 In [3]: !echo "A system variable: $$HOME"
4871 4871 \newline
4872 4872 A system variable: /home/fperez
4873 4873 \layout Standard
4874 4874
4875 4875 You can pass arbitrary expressions, though you'll need to delimit them with
4876 4876
4877 4877 \family typewriter
4878 4878 {}
4879 4879 \family default
4880 4880 if there is ambiguity as to the extent of the expression:
4881 4881 \layout Standard
4882 4882
4883 4883
4884 4884 \family typewriter
4885 4885 In [5]: x=10
4886 4886 \newline
4887 4887 In [6]: y=20
4888 4888 \newline
4889 4889 In [13]: !echo $x+y
4890 4890 \newline
4891 4891 10+y
4892 4892 \newline
4893 4893 In [7]: !echo ${x+y}
4894 4894 \newline
4895 4895 30
4896 4896 \layout Standard
4897 4897
4898 4898 Even object attributes can be expanded:
4899 4899 \layout Standard
4900 4900
4901 4901
4902 4902 \family typewriter
4903 4903 In [12]: !echo $sys.argv
4904 4904 \newline
4905 4905 [/home/fperez/usr/bin/ipython]
4906 4906 \layout Subsection
4907 4907
4908 4908 System command aliases
4909 4909 \layout Standard
4910 4910
4911 4911 The
4912 4912 \family typewriter
4913 4913 %alias
4914 4914 \family default
4915 4915 magic function and the
4916 4916 \family typewriter
4917 4917 alias
4918 4918 \family default
4919 4919 option in the
4920 4920 \family typewriter
4921 4921 ipythonrc
4922 4922 \family default
4923 4923 configuration file allow you to define magic functions which are in fact
4924 4924 system shell commands.
4925 4925 These aliases can have parameters.
4926 4926
4927 4927 \layout Standard
4928 4928
4929 4929 '
4930 4930 \family typewriter
4931 4931 %alias alias_name cmd
4932 4932 \family default
4933 4933 ' defines '
4934 4934 \family typewriter
4935 4935 alias_name
4936 4936 \family default
4937 4937 ' as an alias for '
4938 4938 \family typewriter
4939 4939 cmd
4940 4940 \family default
4941 4941 '
4942 4942 \layout Standard
4943 4943
4944 4944 Then, typing '
4945 4945 \family typewriter
4946 4946 %alias_name params
4947 4947 \family default
4948 4948 ' will execute the system command '
4949 4949 \family typewriter
4950 4950 cmd params
4951 4951 \family default
4952 4952 ' (from your underlying operating system).
4953 4953
4954 4954 \layout Standard
4955 4955
4956 4956 You can also define aliases with parameters using
4957 4957 \family typewriter
4958 4958 %s
4959 4959 \family default
4960 4960 specifiers (one per parameter).
4961 4961 The following example defines the
4962 4962 \family typewriter
4963 4963 %parts
4964 4964 \family default
4965 4965 function as an alias to the command '
4966 4966 \family typewriter
4967 4967 echo first %s second %s
4968 4968 \family default
4969 4969 ' where each
4970 4970 \family typewriter
4971 4971 %s
4972 4972 \family default
4973 4973 will be replaced by a positional parameter to the call to
4974 4974 \family typewriter
4975 4975 %parts:
4976 4976 \layout Standard
4977 4977
4978 4978
4979 4979 \family typewriter
4980 4980 In [1]: alias parts echo first %s second %s
4981 4981 \newline
4982 4982 In [2]: %parts A B
4983 4983 \newline
4984 4984 first A second B
4985 4985 \newline
4986 4986 In [3]: %parts A
4987 4987 \newline
4988 4988 Incorrect number of arguments: 2 expected.
4989 4989
4990 4990 \newline
4991 4991 parts is an alias to: 'echo first %s second %s'
4992 4992 \layout Standard
4993 4993
4994 4994 If called with no parameters,
4995 4995 \family typewriter
4996 4996 %alias
4997 4997 \family default
4998 4998 prints the table of currently defined aliases.
4999 4999 \layout Standard
5000 5000
5001 5001 The
5002 5002 \family typewriter
5003 5003 %rehash/rehashx
5004 5004 \family default
5005 5005 magics allow you to load your entire
5006 5006 \family typewriter
5007 5007 $PATH
5008 5008 \family default
5009 5009 as ipython aliases.
5010 5010 See their respective docstrings (or sec.\SpecialChar ~
5011 5011
5012 5012 \begin_inset LatexCommand \ref{sec:magic}
5013 5013
5014 5014 \end_inset
5015 5015
5016 5016 for further details).
5017 5017 \layout Subsection
5018 5018
5019 5019
5020 5020 \begin_inset LatexCommand \label{sec:dreload}
5021 5021
5022 5022 \end_inset
5023 5023
5024 5024 Recursive reload
5025 5025 \layout Standard
5026 5026
5027 5027 The
5028 5028 \family typewriter
5029 5029 %dreload
5030 5030 \family default
5031 5031 command does a recursive reload of a module: changes made to the module
5032 5032 since you imported will actually be available without having to exit.
5033 5033 \layout Subsection
5034 5034
5035 5035 Verbose and colored exception traceback printouts
5036 5036 \layout Standard
5037 5037
5038 5038 IPython provides the option to see very detailed exception tracebacks, which
5039 5039 can be especially useful when debugging large programs.
5040 5040 You can run any Python file with the
5041 5041 \family typewriter
5042 5042 %run
5043 5043 \family default
5044 5044 function to benefit from these detailed tracebacks.
5045 5045 Furthermore, both normal and verbose tracebacks can be colored (if your
5046 5046 terminal supports it) which makes them much easier to parse visually.
5047 5047 \layout Standard
5048 5048
5049 5049 See the magic
5050 5050 \family typewriter
5051 5051 xmode
5052 5052 \family default
5053 5053 and
5054 5054 \family typewriter
5055 5055 colors
5056 5056 \family default
5057 5057 functions for details (just type
5058 5058 \family typewriter
5059 5059 %magic
5060 5060 \family default
5061 5061 ).
5062 5062 \layout Standard
5063 5063
5064 5064 These features are basically a terminal version of Ka-Ping Yee's
5065 5065 \family typewriter
5066 5066 cgitb
5067 5067 \family default
5068 5068 module, now part of the standard Python library.
5069 5069 \layout Subsection
5070 5070
5071 5071
5072 5072 \begin_inset LatexCommand \label{sec:cache_input}
5073 5073
5074 5074 \end_inset
5075 5075
5076 5076 Input caching system
5077 5077 \layout Standard
5078 5078
5079 5079 IPython offers numbered prompts (In/Out) with input and output caching.
5080 5080 All input is saved and can be retrieved as variables (besides the usual
5081 5081 arrow key recall).
5082 5082 \layout Standard
5083 5083
5084 5084 The following GLOBAL variables always exist (so don't overwrite them!):
5085 5085
5086 5086 \family typewriter
5087 5087 _i
5088 5088 \family default
5089 5089 : stores previous input.
5090 5090
5091 5091 \family typewriter
5092 5092 _ii
5093 5093 \family default
5094 5094 : next previous.
5095 5095
5096 5096 \family typewriter
5097 5097 _iii
5098 5098 \family default
5099 5099 : next-next previous.
5100 5100
5101 5101 \family typewriter
5102 5102 _ih
5103 5103 \family default
5104 5104 : a list of all input
5105 5105 \family typewriter
5106 5106 _ih[n]
5107 5107 \family default
5108 5108 is the input from line
5109 5109 \family typewriter
5110 5110 n
5111 5111 \family default
5112 5112 and this list is aliased to the global variable
5113 5113 \family typewriter
5114 5114 In
5115 5115 \family default
5116 5116 .
5117 5117 If you overwrite
5118 5118 \family typewriter
5119 5119 In
5120 5120 \family default
5121 5121 with a variable of your own, you can remake the assignment to the internal
5122 5122 list with a simple
5123 5123 \family typewriter
5124 5124 'In=_ih'
5125 5125 \family default
5126 5126 .
5127 5127 \layout Standard
5128 5128
5129 5129 Additionally, global variables named
5130 5130 \family typewriter
5131 5131 _i<n>
5132 5132 \family default
5133 5133 are dynamically created (
5134 5134 \family typewriter
5135 5135 <n>
5136 5136 \family default
5137 5137 being the prompt counter), such that
5138 5138 \newline
5139 5139
5140 5140 \family typewriter
5141 5141 _i<n> == _ih[<n>] == In[<n>].
5142 5142 \layout Standard
5143 5143
5144 5144 For example, what you typed at prompt 14 is available as
5145 5145 \family typewriter
5146 5146 _i14,
5147 5147 \family default
5148 5148
5149 5149 \family typewriter
5150 5150 _ih[14]
5151 5151 \family default
5152 5152 and
5153 5153 \family typewriter
5154 5154 In[14]
5155 5155 \family default
5156 5156 .
5157 5157 \layout Standard
5158 5158
5159 5159 This allows you to easily cut and paste multi line interactive prompts by
5160 5160 printing them out: they print like a clean string, without prompt characters.
5161 5161 You can also manipulate them like regular variables (they are strings),
5162 5162 modify or exec them (typing
5163 5163 \family typewriter
5164 5164 'exec _i9'
5165 5165 \family default
5166 5166 will re-execute the contents of input prompt 9, '
5167 5167 \family typewriter
5168 5168 exec In[9:14]+In[18]
5169 5169 \family default
5170 5170 ' will re-execute lines 9 through 13 and line 18).
5171 5171 \layout Standard
5172 5172
5173 5173 You can also re-execute multiple lines of input easily by using the magic
5174 5174
5175 5175 \family typewriter
5176 5176 %macro
5177 5177 \family default
5178 5178 function (which automates the process and allows re-execution without having
5179 5179 to type '
5180 5180 \family typewriter
5181 5181 exec
5182 5182 \family default
5183 5183 ' every time).
5184 5184 The macro system also allows you to re-execute previous lines which include
5185 5185 magic function calls (which require special processing).
5186 5186 Type
5187 5187 \family typewriter
5188 5188 %macro?
5189 5189 \family default
5190 5190 or see sec.
5191 5191
5192 5192 \begin_inset LatexCommand \ref{sec:magic}
5193 5193
5194 5194 \end_inset
5195 5195
5196 5196 for more details on the macro system.
5197 5197 \layout Standard
5198 5198
5199 5199 A history function
5200 5200 \family typewriter
5201 5201 %hist
5202 5202 \family default
5203 5203 allows you to see any part of your input history by printing a range of
5204 5204 the
5205 5205 \family typewriter
5206 5206 _i
5207 5207 \family default
5208 5208 variables.
5209 5209 \layout Subsection
5210 5210
5211 5211
5212 5212 \begin_inset LatexCommand \label{sec:cache_output}
5213 5213
5214 5214 \end_inset
5215 5215
5216 5216 Output caching system
5217 5217 \layout Standard
5218 5218
5219 5219 For output that is returned from actions, a system similar to the input
5220 5220 cache exists but using
5221 5221 \family typewriter
5222 5222 _
5223 5223 \family default
5224 5224 instead of
5225 5225 \family typewriter
5226 5226 _i
5227 5227 \family default
5228 5228 .
5229 5229 Only actions that produce a result (NOT assignments, for example) are cached.
5230 5230 If you are familiar with Mathematica, IPython's
5231 5231 \family typewriter
5232 5232 _
5233 5233 \family default
5234 5234 variables behave exactly like Mathematica's
5235 5235 \family typewriter
5236 5236 %
5237 5237 \family default
5238 5238 variables.
5239 5239 \layout Standard
5240 5240
5241 5241 The following GLOBAL variables always exist (so don't overwrite them!):
5242 5242
5243 5243 \layout List
5244 5244 \labelwidthstring 00.00.0000
5245 5245
5246 5246
5247 5247 \family typewriter
5248 5248 \series bold
5249 5249 _
5250 5250 \family default
5251 5251 \series default
5252 5252 (a
5253 5253 \emph on
5254 5254 single
5255 5255 \emph default
5256 5256 underscore) : stores previous output, like Python's default interpreter.
5257 5257 \layout List
5258 5258 \labelwidthstring 00.00.0000
5259 5259
5260 5260
5261 5261 \family typewriter
5262 5262 \series bold
5263 5263 __
5264 5264 \family default
5265 5265 \series default
5266 5266 (two underscores): next previous.
5267 5267 \layout List
5268 5268 \labelwidthstring 00.00.0000
5269 5269
5270 5270
5271 5271 \family typewriter
5272 5272 \series bold
5273 5273 ___
5274 5274 \family default
5275 5275 \series default
5276 5276 (three underscores): next-next previous.
5277 5277 \layout Standard
5278 5278
5279 5279 Additionally, global variables named
5280 5280 \family typewriter
5281 5281 _<n>
5282 5282 \family default
5283 5283 are dynamically created (
5284 5284 \family typewriter
5285 5285 <n>
5286 5286 \family default
5287 5287 being the prompt counter), such that the result of output
5288 5288 \family typewriter
5289 5289 <n>
5290 5290 \family default
5291 5291 is always available as
5292 5292 \family typewriter
5293 5293 _<n>
5294 5294 \family default
5295 5295 (don't use the angle brackets, just the number, e.g.
5296 5296
5297 5297 \family typewriter
5298 5298 _21
5299 5299 \family default
5300 5300 ).
5301 5301 \layout Standard
5302 5302
5303 5303 These global variables are all stored in a global dictionary (not a list,
5304 5304 since it only has entries for lines which returned a result) available
5305 5305 under the names
5306 5306 \family typewriter
5307 5307 _oh
5308 5308 \family default
5309 5309 and
5310 5310 \family typewriter
5311 5311 Out
5312 5312 \family default
5313 5313 (similar to
5314 5314 \family typewriter
5315 5315 _ih
5316 5316 \family default
5317 5317 and
5318 5318 \family typewriter
5319 5319 In
5320 5320 \family default
5321 5321 ).
5322 5322 So the output from line 12 can be obtained as
5323 5323 \family typewriter
5324 5324 _12
5325 5325 \family default
5326 5326 ,
5327 5327 \family typewriter
5328 5328 Out[12]
5329 5329 \family default
5330 5330 or
5331 5331 \family typewriter
5332 5332 _oh[12]
5333 5333 \family default
5334 5334 .
5335 5335 If you accidentally overwrite the
5336 5336 \family typewriter
5337 5337 Out
5338 5338 \family default
5339 5339 variable you can recover it by typing
5340 5340 \family typewriter
5341 5341 'Out=_oh
5342 5342 \family default
5343 5343 ' at the prompt.
5344 5344 \layout Standard
5345 5345
5346 5346 This system obviously can potentially put heavy memory demands on your system,
5347 5347 since it prevents Python's garbage collector from removing any previously
5348 5348 computed results.
5349 5349 You can control how many results are kept in memory with the option (at
5350 5350 the command line or in your
5351 5351 \family typewriter
5352 5352 ipythonrc
5353 5353 \family default
5354 5354 file)
5355 5355 \family typewriter
5356 5356 cache_size
5357 5357 \family default
5358 5358 .
5359 5359 If you set it to 0, the whole system is completely disabled and the prompts
5360 5360 revert to the classic
5361 5361 \family typewriter
5362 5362 '>>>'
5363 5363 \family default
5364 5364 of normal Python.
5365 5365 \layout Subsection
5366 5366
5367 5367 Directory history
5368 5368 \layout Standard
5369 5369
5370 5370 Your history of visited directories is kept in the global list
5371 5371 \family typewriter
5372 5372 _dh
5373 5373 \family default
5374 5374 , and the magic
5375 5375 \family typewriter
5376 5376 %cd
5377 5377 \family default
5378 5378 command can be used to go to any entry in that list.
5379 5379 The
5380 5380 \family typewriter
5381 5381 %dhist
5382 5382 \family default
5383 5383 command allows you to view this history.
5384 5384 \layout Subsection
5385 5385
5386 5386 Automatic parentheses and quotes
5387 5387 \layout Standard
5388 5388
5389 5389 These features were adapted from Nathan Gray's LazyPython.
5390 5390 They are meant to allow less typing for common situations.
5391 5391 \layout Subsubsection
5392 5392
5393 5393 Automatic parentheses
5394 5394 \layout Standard
5395 5395
5396 5396 Callable objects (i.e.
5397 5397 functions, methods, etc) can be invoked like this (notice the commas between
5398 5398 the arguments):
5399 5399 \layout Standard
5400 5400
5401 5401
5402 5402 \family typewriter
5403 5403 >>> callable_ob arg1, arg2, arg3
5404 5404 \layout Standard
5405 5405
5406 5406 and the input will be translated to this:
5407 5407 \layout Standard
5408 5408
5409 5409
5410 5410 \family typewriter
5411 5411 --> callable_ob(arg1, arg2, arg3)
5412 5412 \layout Standard
5413 5413
5414 5414 You can force automatic parentheses by using '/' as the first character
5415 5415 of a line.
5416 5416 For example:
5417 5417 \layout Standard
5418 5418
5419 5419
5420 5420 \family typewriter
5421 5421 >>> /globals # becomes 'globals()'
5422 5422 \layout Standard
5423 5423
5424 5424 Note that the '/' MUST be the first character on the line! This won't work:
5425 5425
5426 5426 \layout Standard
5427 5427
5428 5428
5429 5429 \family typewriter
5430 5430 >>> print /globals # syntax error
5431 5431 \layout Standard
5432 5432
5433 5433 In most cases the automatic algorithm should work, so you should rarely
5434 5434 need to explicitly invoke /.
5435 5435 One notable exception is if you are trying to call a function with a list
5436 5436 of tuples as arguments (the parenthesis will confuse IPython):
5437 5437 \layout Standard
5438 5438
5439 5439
5440 5440 \family typewriter
5441 5441 In [1]: zip (1,2,3),(4,5,6) # won't work
5442 5442 \layout Standard
5443 5443
5444 5444 but this will work:
5445 5445 \layout Standard
5446 5446
5447 5447
5448 5448 \family typewriter
5449 5449 In [2]: /zip (1,2,3),(4,5,6)
5450 5450 \newline
5451 5451 ------> zip ((1,2,3),(4,5,6))
5452 5452 \newline
5453 5453 Out[2]= [(1, 4), (2, 5), (3, 6)]
5454 5454 \layout Standard
5455 5455
5456 5456 IPython tells you that it has altered your command line by displaying the
5457 5457 new command line preceded by
5458 5458 \family typewriter
5459 5459 -->
5460 5460 \family default
5461 5461 .
5462 5462 e.g.:
5463 5463 \layout Standard
5464 5464
5465 5465
5466 5466 \family typewriter
5467 5467 In [18]: callable list
5468 5468 \newline
5469 5469 -------> callable (list)
5470 5470 \layout Subsubsection
5471 5471
5472 5472 Automatic quoting
5473 5473 \layout Standard
5474 5474
5475 5475 You can force automatic quoting of a function's arguments by using
5476 5476 \family typewriter
5477 5477 `,'
5478 5478 \family default
5479 5479 or
5480 5480 \family typewriter
5481 5481 `;'
5482 5482 \family default
5483 5483 as the first character of a line.
5484 5484 For example:
5485 5485 \layout Standard
5486 5486
5487 5487
5488 5488 \family typewriter
5489 5489 >>> ,my_function /home/me # becomes my_function("/home/me")
5490 5490 \layout Standard
5491 5491
5492 5492 If you use
5493 5493 \family typewriter
5494 5494 `;'
5495 5495 \family default
5496 5496 instead, the whole argument is quoted as a single string (while
5497 5497 \family typewriter
5498 5498 `,'
5499 5499 \family default
5500 5500 splits on whitespace):
5501 5501 \layout Standard
5502 5502
5503 5503
5504 5504 \family typewriter
5505 5505 >>> ,my_function a b c # becomes my_function("a","b","c")
5506 5506 \layout Standard
5507 5507
5508 5508
5509 5509 \family typewriter
5510 5510 >>> ;my_function a b c # becomes my_function("a b c")
5511 5511 \layout Standard
5512 5512
5513 5513 Note that the `
5514 5514 \family typewriter
5515 5515 ,
5516 5516 \family default
5517 5517 ' or `
5518 5518 \family typewriter
5519 5519 ;
5520 5520 \family default
5521 5521 ' MUST be the first character on the line! This won't work:
5522 5522 \layout Standard
5523 5523
5524 5524
5525 5525 \family typewriter
5526 5526 >>> x = ,my_function /home/me # syntax error
5527 5527 \layout Section
5528 5528
5529 5529
5530 5530 \begin_inset LatexCommand \label{sec:customization}
5531 5531
5532 5532 \end_inset
5533 5533
5534 5534 Customization
5535 5535 \layout Standard
5536 5536
5537 5537 As we've already mentioned, IPython reads a configuration file which can
5538 5538 be specified at the command line (
5539 5539 \family typewriter
5540 5540 -rcfile
5541 5541 \family default
5542 5542 ) or which by default is assumed to be called
5543 5543 \family typewriter
5544 5544 ipythonrc
5545 5545 \family default
5546 5546 .
5547 5547 Such a file is looked for in the current directory where IPython is started
5548 5548 and then in your
5549 5549 \family typewriter
5550 5550 IPYTHONDIR
5551 5551 \family default
5552 5552 , which allows you to have local configuration files for specific projects.
5553 5553 In this section we will call these types of configuration files simply
5554 5554 rcfiles (short for resource configuration file).
5555 5555 \layout Standard
5556 5556
5557 5557 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5558 5558 one per line.
5559 5559 Lines beginning with a
5560 5560 \family typewriter
5561 5561 #
5562 5562 \family default
5563 5563 are ignored as comments, but comments can
5564 5564 \series bold
5565 5565 not
5566 5566 \series default
5567 5567 be put on lines with data (the parser is fairly primitive).
5568 5568 Note that these are not python files, and this is deliberate, because it
5569 5569 allows us to do some things which would be quite tricky to implement if
5570 5570 they were normal python files.
5571 5571 \layout Standard
5572 5572
5573 5573 First, an rcfile can contain permanent default values for almost all command
5574 5574 line options (except things like
5575 5575 \family typewriter
5576 5576 -help
5577 5577 \family default
5578 5578 or
5579 5579 \family typewriter
5580 5580 -Version
5581 5581 \family default
5582 5582 ).
5583 5583 Sec\SpecialChar ~
5584 5584
5585 5585 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5586 5586
5587 5587 \end_inset
5588 5588
5589 5589 contains a description of all command-line options.
5590 5590 However, values you explicitly specify at the command line override the
5591 5591 values defined in the rcfile.
5592 5592 \layout Standard
5593 5593
5594 5594 Besides command line option values, the rcfile can specify values for certain
5595 5595 extra special options which are not available at the command line.
5596 5596 These options are briefly described below.
5597 5597
5598 5598 \layout Standard
5599 5599
5600 5600 Each of these options may appear as many times as you need it in the file.
5601 5601 \layout List
5602 5602 \labelwidthstring 00.00.0000
5603 5603
5604 5604
5605 5605 \family typewriter
5606 5606 \series bold
5607 5607 include\SpecialChar ~
5608 5608 <file1>\SpecialChar ~
5609 5609 <file2>\SpecialChar ~
5610 5610 ...
5611 5611 \family default
5612 5612 \series default
5613 5613 : you can name
5614 5614 \emph on
5615 5615 other
5616 5616 \emph default
5617 5617 rcfiles you want to recursively load up to 15 levels (don't use the
5618 5618 \family typewriter
5619 5619 <>
5620 5620 \family default
5621 5621 brackets in your names!).
5622 5622 This feature allows you to define a 'base' rcfile with general options
5623 5623 and special-purpose files which can be loaded only when needed with particular
5624 5624 configuration options.
5625 5625 To make this more convenient, IPython accepts the
5626 5626 \family typewriter
5627 5627 -profile <name>
5628 5628 \family default
5629 5629 option (abbreviates to
5630 5630 \family typewriter
5631 5631 -p <name
5632 5632 \family default
5633 5633 >)
5634 5634 \family typewriter
5635 5635 which
5636 5636 \family default
5637 5637 tells it to look for an rcfile named
5638 5638 \family typewriter
5639 5639 ipythonrc-<name>
5640 5640 \family default
5641 5641 .
5642 5642
5643 5643 \layout List
5644 5644 \labelwidthstring 00.00.0000
5645 5645
5646 5646
5647 5647 \family typewriter
5648 5648 \series bold
5649 5649 import_mod\SpecialChar ~
5650 5650 <mod1>\SpecialChar ~
5651 5651 <mod2>\SpecialChar ~
5652 5652 ...
5653 5653 \family default
5654 5654 \series default
5655 5655 : import modules with '
5656 5656 \family typewriter
5657 5657 import
5658 5658 \family default
5659 5659
5660 5660 \family typewriter
5661 5661 <mod1>,<mod2>,...
5662 5662 \family default
5663 5663 '
5664 5664 \layout List
5665 5665 \labelwidthstring 00.00.0000
5666 5666
5667 5667
5668 5668 \family typewriter
5669 5669 \series bold
5670 5670 import_some\SpecialChar ~
5671 5671 <mod>\SpecialChar ~
5672 5672 <f1>\SpecialChar ~
5673 5673 <f2>\SpecialChar ~
5674 5674 ...
5675 5675 \family default
5676 5676 \series default
5677 5677 : import functions with '
5678 5678 \family typewriter
5679 5679 from <mod> import
5680 5680 \family default
5681 5681
5682 5682 \family typewriter
5683 5683 <f1>,<f2>,...
5684 5684 \family default
5685 5685 '
5686 5686 \layout List
5687 5687 \labelwidthstring 00.00.0000
5688 5688
5689 5689
5690 5690 \family typewriter
5691 5691 \series bold
5692 5692 import_all\SpecialChar ~
5693 5693 <mod1>\SpecialChar ~
5694 5694 <mod2>\SpecialChar ~
5695 5695 ...
5696 5696 \family default
5697 5697 \series default
5698 5698 : for each module listed import functions with '
5699 5699 \family typewriter
5700 5700 from <mod> import *
5701 5701 \family default
5702 5702 '
5703 5703 \layout List
5704 5704 \labelwidthstring 00.00.0000
5705 5705
5706 5706
5707 5707 \family typewriter
5708 5708 \series bold
5709 5709 execute\SpecialChar ~
5710 5710 <python\SpecialChar ~
5711 5711 code>
5712 5712 \family default
5713 5713 \series default
5714 5714 : give any single-line python code to be executed.
5715 5715 \layout List
5716 5716 \labelwidthstring 00.00.0000
5717 5717
5718 5718
5719 5719 \family typewriter
5720 5720 \series bold
5721 5721 execfile\SpecialChar ~
5722 5722 <filename>
5723 5723 \family default
5724 5724 \series default
5725 5725 : execute the python file given with an '
5726 5726 \family typewriter
5727 5727 execfile(filename)
5728 5728 \family default
5729 5729 ' command.
5730 5730 Username expansion is performed on the given names.
5731 5731 So if you need any amount of extra fancy customization that won't fit in
5732 5732 any of the above 'canned' options, you can just put it in a separate python
5733 5733 file and execute it.
5734 5734 \layout List
5735 5735 \labelwidthstring 00.00.0000
5736 5736
5737 5737
5738 5738 \family typewriter
5739 5739 \series bold
5740 5740 alias\SpecialChar ~
5741 5741 <alias_def>
5742 5742 \family default
5743 5743 \series default
5744 5744 : this is equivalent to calling '
5745 5745 \family typewriter
5746 5746 %alias\SpecialChar ~
5747 5747 <alias_def>
5748 5748 \family default
5749 5749 ' at the IPython command line.
5750 5750 This way, from within IPython you can do common system tasks without having
5751 5751 to exit it or use the
5752 5752 \family typewriter
5753 5753 !
5754 5754 \family default
5755 5755 escape.
5756 5756 IPython isn't meant to be a shell replacement, but it is often very useful
5757 5757 to be able to do things with files while testing code.
5758 5758 This gives you the flexibility to have within IPython any aliases you may
5759 5759 be used to under your normal system shell.
5760 5760 \layout Subsection
5761 5761
5762 5762
5763 5763 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5764 5764
5765 5765 \end_inset
5766 5766
5767 5767 Sample
5768 5768 \family typewriter
5769 5769 ipythonrc
5770 5770 \family default
5771 5771 file
5772 5772 \layout Standard
5773 5773
5774 5774 The default rcfile, called
5775 5775 \family typewriter
5776 5776 ipythonrc
5777 5777 \family default
5778 5778 and supplied in your
5779 5779 \family typewriter
5780 5780 IPYTHONDIR
5781 5781 \family default
5782 5782 directory contains lots of comments on all of these options.
5783 5783 We reproduce it here for reference:
5784 5784 \layout Standard
5785 5785
5786 5786
5787 5787 \begin_inset ERT
5788 5788 status Open
5789 5789
5790 5790 \layout Standard
5791 5791
5792 5792 \backslash
5793 5793 codelist{../IPython/UserConfig/ipythonrc}
5794 5794 \end_inset
5795 5795
5796 5796
5797 5797 \layout Subsection
5798 5798
5799 5799
5800 5800 \begin_inset LatexCommand \label{sec:prompts}
5801 5801
5802 5802 \end_inset
5803 5803
5804 5804 Fine-tuning your prompt
5805 5805 \layout Standard
5806 5806
5807 5807 IPython's prompts can be customized using a syntax similar to that of the
5808 5808
5809 5809 \family typewriter
5810 5810 bash
5811 5811 \family default
5812 5812 shell.
5813 5813 Many of
5814 5814 \family typewriter
5815 5815 bash
5816 5816 \family default
5817 5817 's escapes are supported, as well as a few additional ones.
5818 5818 We list them below:
5819 5819 \layout Description
5820 5820
5821 5821
5822 5822 \backslash
5823 5823 # the prompt/history count number
5824 5824 \layout Description
5825 5825
5826 5826
5827 5827 \backslash
5828 5828 D the prompt/history count, with the actual digits replaced by dots.
5829 5829 Used mainly in continuation prompts (prompt_in2)
5830 5830 \layout Description
5831 5831
5832 5832
5833 5833 \backslash
5834 5834 w the current working directory
5835 5835 \layout Description
5836 5836
5837 5837
5838 5838 \backslash
5839 5839 W the basename of current working directory
5840 5840 \layout Description
5841 5841
5842 5842
5843 5843 \backslash
5844 5844 X
5845 5845 \emph on
5846 5846 n
5847 5847 \emph default
5848 5848 where
5849 5849 \begin_inset Formula $n=0\ldots5.$
5850 5850 \end_inset
5851 5851
5852 5852 The current working directory, with
5853 5853 \family typewriter
5854 5854 $HOME
5855 5855 \family default
5856 5856 replaced by
5857 5857 \family typewriter
5858 5858 ~
5859 5859 \family default
5860 5860 , and filtered out to contain only
5861 5861 \begin_inset Formula $n$
5862 5862 \end_inset
5863 5863
5864 5864 path elements
5865 5865 \layout Description
5866 5866
5867 5867
5868 5868 \backslash
5869 5869 Y
5870 5870 \emph on
5871 5871 n
5872 5872 \emph default
5873 5873 Similar to
5874 5874 \backslash
5875 5875 X
5876 5876 \emph on
5877 5877 n
5878 5878 \emph default
5879 5879 , but with the
5880 5880 \begin_inset Formula $n+1$
5881 5881 \end_inset
5882 5882
5883 5883 element included if it is
5884 5884 \family typewriter
5885 5885 ~
5886 5886 \family default
5887 5887 (this is similar to the behavior of the %c
5888 5888 \emph on
5889 5889 n
5890 5890 \emph default
5891 5891 escapes in
5892 5892 \family typewriter
5893 5893 tcsh
5894 5894 \family default
5895 5895 )
5896 5896 \layout Description
5897 5897
5898 5898
5899 5899 \backslash
5900 5900 u the username of the current user
5901 5901 \layout Description
5902 5902
5903 5903
5904 5904 \backslash
5905 5905 $ if the effective UID is 0, a #, otherwise a $
5906 5906 \layout Description
5907 5907
5908 5908
5909 5909 \backslash
5910 5910 h the hostname up to the first `.'
5911 5911 \layout Description
5912 5912
5913 5913
5914 5914 \backslash
5915 5915 H the hostname
5916 5916 \layout Description
5917 5917
5918 5918
5919 5919 \backslash
5920 5920 n a newline
5921 5921 \layout Description
5922 5922
5923 5923
5924 5924 \backslash
5925 5925 r a carriage return
5926 5926 \layout Description
5927 5927
5928 5928
5929 5929 \backslash
5930 5930 v IPython version string
5931 5931 \layout Standard
5932 5932
5933 5933 In addition to these, ANSI color escapes can be insterted into the prompts,
5934 5934 as
5935 5935 \family typewriter
5936 5936
5937 5937 \backslash
5938 5938 C_
5939 5939 \emph on
5940 5940 ColorName
5941 5941 \family default
5942 5942 \emph default
5943 5943 .
5944 5944 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5945 5945 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5946 5946 Normal, Purple, Red, White, Yellow.
5947 5947 \layout Standard
5948 5948
5949 5949 Finally, IPython supports the evaluation of arbitrary expressions in your
5950 5950 prompt string.
5951 5951 The prompt strings are evaluated through the syntax of PEP 215, but basically
5952 5952 you can use
5953 5953 \family typewriter
5954 5954 $x.y
5955 5955 \family default
5956 5956 to expand the value of
5957 5957 \family typewriter
5958 5958 x.y
5959 5959 \family default
5960 5960 , and for more complicated expressions you can use braces:
5961 5961 \family typewriter
5962 5962 ${foo()+x}
5963 5963 \family default
5964 5964 will call function
5965 5965 \family typewriter
5966 5966 foo
5967 5967 \family default
5968 5968 and add to it the value of
5969 5969 \family typewriter
5970 5970 x
5971 5971 \family default
5972 5972 , before putting the result into your prompt.
5973 5973 For example, using
5974 5974 \newline
5975 5975
5976 5976 \family typewriter
5977 5977 prompt_in1 '${commands.getoutput("uptime")}
5978 5978 \backslash
5979 5979 nIn [
5980 5980 \backslash
5981 5981 #]: '
5982 5982 \newline
5983 5983
5984 5984 \family default
5985 5985 will print the result of the uptime command on each prompt (assuming the
5986 5986
5987 5987 \family typewriter
5988 5988 commands
5989 5989 \family default
5990 5990 module has been imported in your
5991 5991 \family typewriter
5992 5992 ipythonrc
5993 5993 \family default
5994 5994 file).
5995 5995 \layout Subsubsection
5996 5996
5997 5997 Prompt examples
5998 5998 \layout Standard
5999 5999
6000 6000 The following options in an ipythonrc file will give you IPython's default
6001 6001 prompts:
6002 6002 \layout Standard
6003 6003
6004 6004
6005 6005 \family typewriter
6006 6006 prompt_in1 'In [
6007 6007 \backslash
6008 6008 #]:'
6009 6009 \newline
6010 6010 prompt_in2 '\SpecialChar ~
6011 6011 \SpecialChar ~
6012 6012 \SpecialChar ~
6013 6013 .
6014 6014 \backslash
6015 6015 D.:'
6016 6016 \newline
6017 6017 prompt_out 'Out[
6018 6018 \backslash
6019 6019 #]:'
6020 6020 \layout Standard
6021 6021
6022 6022 which look like this:
6023 6023 \layout Standard
6024 6024
6025 6025
6026 6026 \family typewriter
6027 6027 In [1]: 1+2
6028 6028 \newline
6029 6029 Out[1]: 3
6030 6030 \layout Standard
6031 6031
6032 6032
6033 6033 \family typewriter
6034 6034 In [2]: for i in (1,2,3):
6035 6035 \newline
6036 6036
6037 6037 \begin_inset ERT
6038 6038 status Collapsed
6039 6039
6040 6040 \layout Standard
6041 6041
6042 6042 \backslash
6043 6043 hspace*{0mm}
6044 6044 \end_inset
6045 6045
6046 6046 \SpecialChar ~
6047 6047 \SpecialChar ~
6048 6048 \SpecialChar ~
6049 6049 ...: \SpecialChar ~
6050 6050 \SpecialChar ~
6051 6051 \SpecialChar ~
6052 6052 \SpecialChar ~
6053 6053 print i,
6054 6054 \newline
6055 6055
6056 6056 \begin_inset ERT
6057 6057 status Collapsed
6058 6058
6059 6059 \layout Standard
6060 6060
6061 6061 \backslash
6062 6062 hspace*{0mm}
6063 6063 \end_inset
6064 6064
6065 6065 \SpecialChar ~
6066 6066 \SpecialChar ~
6067 6067 \SpecialChar ~
6068 6068 ...:
6069 6069 \newline
6070 6070 1 2 3
6071 6071 \layout Standard
6072 6072
6073 6073 These will give you a very colorful prompt with path information:
6074 6074 \layout Standard
6075 6075
6076 6076
6077 6077 \family typewriter
6078 6078 #prompt_in1 '
6079 6079 \backslash
6080 6080 C_Red
6081 6081 \backslash
6082 6082 u
6083 6083 \backslash
6084 6084 C_Blue[
6085 6085 \backslash
6086 6086 C_Cyan
6087 6087 \backslash
6088 6088 Y1
6089 6089 \backslash
6090 6090 C_Blue]
6091 6091 \backslash
6092 6092 C_LightGreen
6093 6093 \backslash
6094 6094 #>'
6095 6095 \newline
6096 6096 prompt_in2 ' ..
6097 6097 \backslash
6098 6098 D>'
6099 6099 \newline
6100 6100 prompt_out '<
6101 6101 \backslash
6102 6102 #>'
6103 6103 \layout Standard
6104 6104
6105 6105 which look like this:
6106 6106 \layout Standard
6107 6107
6108 6108
6109 6109 \family typewriter
6110 6110 \color red
6111 6111 fperez
6112 6112 \color blue
6113 6113 [
6114 6114 \color cyan
6115 6115 ~/ipython
6116 6116 \color blue
6117 6117 ]
6118 6118 \color green
6119 6119 1>
6120 6120 \color default
6121 6121 1+2
6122 6122 \newline
6123 6123
6124 6124 \begin_inset ERT
6125 6125 status Collapsed
6126 6126
6127 6127 \layout Standard
6128 6128
6129 6129 \backslash
6130 6130 hspace*{0mm}
6131 6131 \end_inset
6132 6132
6133 6133 \SpecialChar ~
6134 6134 \SpecialChar ~
6135 6135 \SpecialChar ~
6136 6136 \SpecialChar ~
6137 6137 \SpecialChar ~
6138 6138 \SpecialChar ~
6139 6139 \SpecialChar ~
6140 6140 \SpecialChar ~
6141 6141 \SpecialChar ~
6142 6142 \SpecialChar ~
6143 6143 \SpecialChar ~
6144 6144 \SpecialChar ~
6145 6145 \SpecialChar ~
6146 6146 \SpecialChar ~
6147 6147 \SpecialChar ~
6148 6148 \SpecialChar ~
6149 6149
6150 6150 \color red
6151 6151 <1>
6152 6152 \color default
6153 6153 3
6154 6154 \newline
6155 6155
6156 6156 \color red
6157 6157 fperez
6158 6158 \color blue
6159 6159 [
6160 6160 \color cyan
6161 6161 ~/ipython
6162 6162 \color blue
6163 6163 ]
6164 6164 \color green
6165 6165 2>
6166 6166 \color default
6167 6167 for i in (1,2,3):
6168 6168 \newline
6169 6169
6170 6170 \begin_inset ERT
6171 6171 status Collapsed
6172 6172
6173 6173 \layout Standard
6174 6174
6175 6175 \backslash
6176 6176 hspace*{0mm}
6177 6177 \end_inset
6178 6178
6179 6179 \SpecialChar ~
6180 6180 \SpecialChar ~
6181 6181 \SpecialChar ~
6182 6182 \SpecialChar ~
6183 6183 \SpecialChar ~
6184 6184 \SpecialChar ~
6185 6185 \SpecialChar ~
6186 6186 \SpecialChar ~
6187 6187 \SpecialChar ~
6188 6188 \SpecialChar ~
6189 6189 \SpecialChar ~
6190 6190 \SpecialChar ~
6191 6191 \SpecialChar ~
6192 6192 \SpecialChar ~
6193 6193 \SpecialChar ~
6194 6194
6195 6195 \color green
6196 6196 ...>
6197 6197 \color default
6198 6198 \SpecialChar ~
6199 6199 \SpecialChar ~
6200 6200 \SpecialChar ~
6201 6201 \SpecialChar ~
6202 6202 print i,
6203 6203 \newline
6204 6204
6205 6205 \begin_inset ERT
6206 6206 status Collapsed
6207 6207
6208 6208 \layout Standard
6209 6209
6210 6210 \backslash
6211 6211 hspace*{0mm}
6212 6212 \end_inset
6213 6213
6214 6214 \SpecialChar ~
6215 6215 \SpecialChar ~
6216 6216 \SpecialChar ~
6217 6217 \SpecialChar ~
6218 6218 \SpecialChar ~
6219 6219 \SpecialChar ~
6220 6220 \SpecialChar ~
6221 6221 \SpecialChar ~
6222 6222 \SpecialChar ~
6223 6223 \SpecialChar ~
6224 6224 \SpecialChar ~
6225 6225 \SpecialChar ~
6226 6226 \SpecialChar ~
6227 6227 \SpecialChar ~
6228 6228 \SpecialChar ~
6229 6229
6230 6230 \color green
6231 6231 ...>
6232 6232 \color default
6233 6233
6234 6234 \newline
6235 6235 1 2 3
6236 6236 \layout Standard
6237 6237
6238 6238 The following shows the usage of dynamic expression evaluation:
6239 6239 \layout Subsection
6240 6240
6241 6241
6242 6242 \begin_inset LatexCommand \label{sec:profiles}
6243 6243
6244 6244 \end_inset
6245 6245
6246 6246 IPython profiles
6247 6247 \layout Standard
6248 6248
6249 6249 As we already mentioned, IPython supports the
6250 6250 \family typewriter
6251 6251 -profile
6252 6252 \family default
6253 6253 command-line option (see sec.
6254 6254
6255 6255 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
6256 6256
6257 6257 \end_inset
6258 6258
6259 6259 ).
6260 6260 A profile is nothing more than a particular configuration file like your
6261 6261 basic
6262 6262 \family typewriter
6263 6263 ipythonrc
6264 6264 \family default
6265 6265 one, but with particular customizations for a specific purpose.
6266 6266 When you start IPython with '
6267 6267 \family typewriter
6268 6268 ipython -profile <name>
6269 6269 \family default
6270 6270 ', it assumes that in your
6271 6271 \family typewriter
6272 6272 IPYTHONDIR
6273 6273 \family default
6274 6274 there is a file called
6275 6275 \family typewriter
6276 6276 ipythonrc-<name>
6277 6277 \family default
6278 6278 , and loads it instead of the normal
6279 6279 \family typewriter
6280 6280 ipythonrc
6281 6281 \family default
6282 6282 .
6283 6283 \layout Standard
6284 6284
6285 6285 This system allows you to maintain multiple configurations which load modules,
6286 6286 set options, define functions, etc.
6287 6287 suitable for different tasks and activate them in a very simple manner.
6288 6288 In order to avoid having to repeat all of your basic options (common things
6289 6289 that don't change such as your color preferences, for example), any profile
6290 6290 can include another configuration file.
6291 6291 The most common way to use profiles is then to have each one include your
6292 6292 basic
6293 6293 \family typewriter
6294 6294 ipythonrc
6295 6295 \family default
6296 6296 file as a starting point, and then add further customizations.
6297 6297 \layout Standard
6298 6298
6299 6299 In sections
6300 6300 \begin_inset LatexCommand \ref{sec:syntax-extensions}
6301 6301
6302 6302 \end_inset
6303 6303
6304 6304 and
6305 6305 \begin_inset LatexCommand \ref{sec:Gnuplot}
6306 6306
6307 6307 \end_inset
6308 6308
6309 6309 we discuss some particular profiles which come as part of the standard
6310 6310 IPython distribution.
6311 6311 You may also look in your
6312 6312 \family typewriter
6313 6313 IPYTHONDIR
6314 6314 \family default
6315 6315 directory, any file whose name begins with
6316 6316 \family typewriter
6317 6317 ipythonrc-
6318 6318 \family default
6319 6319 is a profile.
6320 6320 You can use those as examples for further customizations to suit your own
6321 6321 needs.
6322 6322 \layout Section
6323 6323
6324 6324
6325 6325 \begin_inset OptArg
6326 6326 collapsed false
6327 6327
6328 6328 \layout Standard
6329 6329
6330 6330 IPython as default...
6331 6331 \end_inset
6332 6332
6333 6333 IPython as your default Python environment
6334 6334 \layout Standard
6335 6335
6336 6336 Python honors the environment variable
6337 6337 \family typewriter
6338 6338 PYTHONSTARTUP
6339 6339 \family default
6340 6340 and will execute at startup the file referenced by this variable.
6341 6341 If you put at the end of this file the following two lines of code:
6342 6342 \layout Standard
6343 6343
6344 6344
6345 6345 \family typewriter
6346 6346 import IPython
6347 6347 \newline
6348 6348 IPython.Shell.IPShell().mainloop(sys_exit=1)
6349 6349 \layout Standard
6350 6350
6351 6351 then IPython will be your working environment anytime you start Python.
6352 6352 The
6353 6353 \family typewriter
6354 6354 sys_exit=1
6355 6355 \family default
6356 6356 is needed to have IPython issue a call to
6357 6357 \family typewriter
6358 6358 sys.exit()
6359 6359 \family default
6360 6360 when it finishes, otherwise you'll be back at the normal Python '
6361 6361 \family typewriter
6362 6362 >>>
6363 6363 \family default
6364 6364 ' prompt
6365 6365 \begin_inset Foot
6366 6366 collapsed true
6367 6367
6368 6368 \layout Standard
6369 6369
6370 6370 Based on an idea by Holger Krekel.
6371 6371 \end_inset
6372 6372
6373 6373 .
6374 6374 \layout Standard
6375 6375
6376 6376 This is probably useful to developers who manage multiple Python versions
6377 6377 and don't want to have correspondingly multiple IPython versions.
6378 6378 Note that in this mode, there is no way to pass IPython any command-line
6379 6379 options, as those are trapped first by Python itself.
6380 6380 \layout Section
6381 6381
6382 6382
6383 6383 \begin_inset LatexCommand \label{sec:embed}
6384 6384
6385 6385 \end_inset
6386 6386
6387 6387 Embedding IPython
6388 6388 \layout Standard
6389 6389
6390 6390 It is possible to start an IPython instance
6391 6391 \emph on
6392 6392 inside
6393 6393 \emph default
6394 6394 your own Python programs.
6395 6395 This allows you to evaluate dynamically the state of your code, operate
6396 6396 with your variables, analyze them, etc.
6397 6397 Note however that any changes you make to values while in the shell do
6398 6398
6399 6399 \emph on
6400 6400 not
6401 6401 \emph default
6402 6402 propagate back to the running code, so it is safe to modify your values
6403 6403 because you won't break your code in bizarre ways by doing so.
6404 6404 \layout Standard
6405 6405
6406 6406 This feature allows you to easily have a fully functional python environment
6407 6407 for doing object introspection anywhere in your code with a simple function
6408 6408 call.
6409 6409 In some cases a simple print statement is enough, but if you need to do
6410 6410 more detailed analysis of a code fragment this feature can be very valuable.
6411 6411 \layout Standard
6412 6412
6413 6413 It can also be useful in scientific computing situations where it is common
6414 6414 to need to do some automatic, computationally intensive part and then stop
6415 6415 to look at data, plots, etc
6416 6416 \begin_inset Foot
6417 6417 collapsed true
6418 6418
6419 6419 \layout Standard
6420 6420
6421 6421 This functionality was inspired by IDL's combination of the
6422 6422 \family typewriter
6423 6423 stop
6424 6424 \family default
6425 6425 keyword and the
6426 6426 \family typewriter
6427 6427 .continue
6428 6428 \family default
6429 6429 executive command, which I have found very useful in the past, and by a
6430 6430 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6431 6431 06/01 concerning similar uses of pyrepl.
6432 6432 \end_inset
6433 6433
6434 6434 .
6435 6435 Opening an IPython instance will give you full access to your data and
6436 6436 functions, and you can resume program execution once you are done with
6437 6437 the interactive part (perhaps to stop again later, as many times as needed).
6438 6438 \layout Standard
6439 6439
6440 6440 The following code snippet is the bare minimum you need to include in your
6441 6441 Python programs for this to work (detailed examples follow later):
6442 6442 \layout LyX-Code
6443 6443
6444 6444 from IPython.Shell import IPShellEmbed
6445 6445 \layout LyX-Code
6446 6446
6447 6447 ipshell = IPShellEmbed()
6448 6448 \layout LyX-Code
6449 6449
6450 6450 ipshell() # this call anywhere in your program will start IPython
6451 6451 \layout Standard
6452 6452
6453 6453 You can run embedded instances even in code which is itself being run at
6454 6454 the IPython interactive prompt with '
6455 6455 \family typewriter
6456 6456 %run\SpecialChar ~
6457 6457 <filename>
6458 6458 \family default
6459 6459 '.
6460 6460 Since it's easy to get lost as to where you are (in your top-level IPython
6461 6461 or in your embedded one), it's a good idea in such cases to set the in/out
6462 6462 prompts to something different for the embedded instances.
6463 6463 The code examples below illustrate this.
6464 6464 \layout Standard
6465 6465
6466 6466 You can also have multiple IPython instances in your program and open them
6467 6467 separately, for example with different options for data presentation.
6468 6468 If you close and open the same instance multiple times, its prompt counters
6469 6469 simply continue from each execution to the next.
6470 6470 \layout Standard
6471 6471
6472 6472 Please look at the docstrings in the
6473 6473 \family typewriter
6474 6474 Shell.py
6475 6475 \family default
6476 6476 module for more details on the use of this system.
6477 6477 \layout Standard
6478 6478
6479 6479 The following sample file illustrating how to use the embedding functionality
6480 6480 is provided in the examples directory as
6481 6481 \family typewriter
6482 6482 example-embed.py
6483 6483 \family default
6484 6484 .
6485 6485 It should be fairly self-explanatory:
6486 6486 \layout Standard
6487 6487
6488 6488
6489 6489 \begin_inset ERT
6490 6490 status Open
6491 6491
6492 6492 \layout Standard
6493 6493
6494 6494 \backslash
6495 6495 codelist{examples/example-embed.py}
6496 6496 \end_inset
6497 6497
6498 6498
6499 6499 \layout Standard
6500 6500
6501 6501 Once you understand how the system functions, you can use the following
6502 6502 code fragments in your programs which are ready for cut and paste:
6503 6503 \layout Standard
6504 6504
6505 6505
6506 6506 \begin_inset ERT
6507 6507 status Open
6508 6508
6509 6509 \layout Standard
6510 6510
6511 6511 \backslash
6512 6512 codelist{examples/example-embed-short.py}
6513 6513 \end_inset
6514 6514
6515 6515
6516 6516 \layout Section
6517 6517
6518 6518
6519 6519 \begin_inset LatexCommand \label{sec:using-pdb}
6520 6520
6521 6521 \end_inset
6522 6522
6523 6523 Using the Python debugger (
6524 6524 \family typewriter
6525 6525 pdb
6526 6526 \family default
6527 6527 )
6528 6528 \layout Subsection
6529 6529
6530 6530 Running entire programs via
6531 6531 \family typewriter
6532 6532 pdb
6533 6533 \layout Standard
6534 6534
6535 6535
6536 6536 \family typewriter
6537 6537 pdb
6538 6538 \family default
6539 6539 , the Python debugger, is a powerful interactive debugger which allows you
6540 6540 to step through code, set breakpoints, watch variables, etc.
6541 6541 IPython makes it very easy to start any script under the control of
6542 6542 \family typewriter
6543 6543 pdb
6544 6544 \family default
6545 6545 , regardless of whether you have wrapped it into a
6546 6546 \family typewriter
6547 6547 `main()'
6548 6548 \family default
6549 6549 function or not.
6550 6550 For this, simply type
6551 6551 \family typewriter
6552 6552 `%run -d myscript'
6553 6553 \family default
6554 6554 at an IPython prompt.
6555 6555 See the
6556 6556 \family typewriter
6557 6557 %run
6558 6558 \family default
6559 6559 command's documentation (via
6560 6560 \family typewriter
6561 6561 `%run?'
6562 6562 \family default
6563 6563 or in Sec.\SpecialChar ~
6564 6564
6565 6565 \begin_inset LatexCommand \ref{sec:magic}
6566 6566
6567 6567 \end_inset
6568 6568
6569 6569 ) for more details, including how to control where
6570 6570 \family typewriter
6571 6571 pdb
6572 6572 \family default
6573 6573 will stop execution first.
6574 6574 \layout Standard
6575 6575
6576 6576 For more information on the use of the
6577 6577 \family typewriter
6578 6578 pdb
6579 6579 \family default
6580 6580 debugger, read the included
6581 6581 \family typewriter
6582 6582 pdb.doc
6583 6583 \family default
6584 6584 file (part of the standard Python distribution).
6585 6585 On a stock Linux system it is located at
6586 6586 \family typewriter
6587 6587 /usr/lib/python2.3/pdb.doc
6588 6588 \family default
6589 6589 , but the easiest way to read it is by using the
6590 6590 \family typewriter
6591 6591 help()
6592 6592 \family default
6593 6593 function of the
6594 6594 \family typewriter
6595 6595 pdb
6596 6596 \family default
6597 6597 module as follows (in an IPython prompt):
6598 6598 \layout Standard
6599 6599
6600 6600
6601 6601 \family typewriter
6602 6602 In [1]: import pdb
6603 6603 \newline
6604 6604 In [2]: pdb.help()
6605 6605 \layout Standard
6606 6606
6607 6607 This will load the
6608 6608 \family typewriter
6609 6609 pdb.doc
6610 6610 \family default
6611 6611 document in a file viewer for you automatically.
6612 6612 \layout Subsection
6613 6613
6614 6614 Automatic invocation of
6615 6615 \family typewriter
6616 6616 pdb
6617 6617 \family default
6618 6618 on exceptions
6619 6619 \layout Standard
6620 6620
6621 6621 IPython, if started with the
6622 6622 \family typewriter
6623 6623 -pdb
6624 6624 \family default
6625 6625 option (or if the option is set in your rc file) can call the Python
6626 6626 \family typewriter
6627 6627 pdb
6628 6628 \family default
6629 6629 debugger every time your code triggers an uncaught exception
6630 6630 \begin_inset Foot
6631 6631 collapsed true
6632 6632
6633 6633 \layout Standard
6634 6634
6635 6635 Many thanks to Christopher Hart for the request which prompted adding this
6636 6636 feature to IPython.
6637 6637 \end_inset
6638 6638
6639 6639 .
6640 6640 This feature can also be toggled at any time with the
6641 6641 \family typewriter
6642 6642 %pdb
6643 6643 \family default
6644 6644 magic command.
6645 6645 This can be extremely useful in order to find the origin of subtle bugs,
6646 6646 because
6647 6647 \family typewriter
6648 6648 pdb
6649 6649 \family default
6650 6650 opens up at the point in your code which triggered the exception, and while
6651 6651 your program is at this point `dead', all the data is still available and
6652 6652 you can walk up and down the stack frame and understand the origin of the
6653 6653 problem.
6654 6654 \layout Standard
6655 6655
6656 6656 Furthermore, you can use these debugging facilities both with the embedded
6657 6657 IPython mode and without IPython at all.
6658 6658 For an embedded shell (see sec.
6659 6659
6660 6660 \begin_inset LatexCommand \ref{sec:embed}
6661 6661
6662 6662 \end_inset
6663 6663
6664 6664 ), simply call the constructor with
6665 6665 \family typewriter
6666 6666 `-pdb'
6667 6667 \family default
6668 6668 in the argument string and automatically
6669 6669 \family typewriter
6670 6670 pdb
6671 6671 \family default
6672 6672 will be called if an uncaught exception is triggered by your code.
6673 6673
6674 6674 \layout Standard
6675 6675
6676 6676 For stand-alone use of the feature in your programs which do not use IPython
6677 6677 at all, put the following lines toward the top of your `main' routine:
6678 6678 \layout Standard
6679 6679 \align left
6680 6680
6681 6681 \family typewriter
6682 6682 import sys,IPython.ultraTB
6683 6683 \newline
6684 6684 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6685 6685 call_pdb=1)
6686 6686 \layout Standard
6687 6687
6688 6688 The
6689 6689 \family typewriter
6690 6690 mode
6691 6691 \family default
6692 6692 keyword can be either
6693 6693 \family typewriter
6694 6694 `Verbose'
6695 6695 \family default
6696 6696 or
6697 6697 \family typewriter
6698 6698 `Plain'
6699 6699 \family default
6700 6700 , giving either very detailed or normal tracebacks respectively.
6701 6701 The
6702 6702 \family typewriter
6703 6703 color_scheme
6704 6704 \family default
6705 6705 keyword can be one of
6706 6706 \family typewriter
6707 6707 `NoColor'
6708 6708 \family default
6709 6709 ,
6710 6710 \family typewriter
6711 6711 `Linux'
6712 6712 \family default
6713 6713 (default) or
6714 6714 \family typewriter
6715 6715 `LightBG'
6716 6716 \family default
6717 6717 .
6718 6718 These are the same options which can be set in IPython with
6719 6719 \family typewriter
6720 6720 -colors
6721 6721 \family default
6722 6722 and
6723 6723 \family typewriter
6724 6724 -xmode
6725 6725 \family default
6726 6726 .
6727 6727 \layout Standard
6728 6728
6729 6729 This will give any of your programs detailed, colored tracebacks with automatic
6730 6730 invocation of
6731 6731 \family typewriter
6732 6732 pdb
6733 6733 \family default
6734 6734 .
6735 6735 \layout Section
6736 6736
6737 6737
6738 6738 \begin_inset LatexCommand \label{sec:syntax-extensions}
6739 6739
6740 6740 \end_inset
6741 6741
6742 6742 Extensions for syntax processing
6743 6743 \layout Standard
6744 6744
6745 6745 This isn't for the faint of heart, because the potential for breaking things
6746 6746 is quite high.
6747 6747 But it can be a very powerful and useful feature.
6748 6748 In a nutshell, you can redefine the way IPython processes the user input
6749 6749 line to accept new, special extensions to the syntax without needing to
6750 6750 change any of IPython's own code.
6751 6751 \layout Standard
6752 6752
6753 6753 In the
6754 6754 \family typewriter
6755 6755 IPython/Extensions
6756 6756 \family default
6757 6757 directory you will find some examples supplied, which we will briefly describe
6758 6758 now.
6759 6759 These can be used `as is' (and both provide very useful functionality),
6760 6760 or you can use them as a starting point for writing your own extensions.
6761 6761 \layout Subsection
6762 6762
6763 6763 Pasting of code starting with
6764 6764 \family typewriter
6765 6765 `>>>
6766 6766 \family default
6767 6767 ' or
6768 6768 \family typewriter
6769 6769 `...
6770 6770
6771 6771 \family default
6772 6772 '
6773 6773 \layout Standard
6774 6774
6775 6775 In the python tutorial it is common to find code examples which have been
6776 6776 taken from real python sessions.
6777 6777 The problem with those is that all the lines begin with either
6778 6778 \family typewriter
6779 6779 `>>>
6780 6780 \family default
6781 6781 ' or
6782 6782 \family typewriter
6783 6783 `...
6784 6784
6785 6785 \family default
6786 6786 ', which makes it impossible to paste them all at once.
6787 6787 One must instead do a line by line manual copying, carefully removing the
6788 6788 leading extraneous characters.
6789 6789 \layout Standard
6790 6790
6791 6791 This extension identifies those starting characters and removes them from
6792 6792 the input automatically, so that one can paste multi-line examples directly
6793 6793 into IPython, saving a lot of time.
6794 6794 Please look at the file
6795 6795 \family typewriter
6796 6796 InterpreterPasteInput.py
6797 6797 \family default
6798 6798 in the
6799 6799 \family typewriter
6800 6800 IPython/Extensions
6801 6801 \family default
6802 6802 directory for details on how this is done.
6803 6803 \layout Standard
6804 6804
6805 6805 IPython comes with a special profile enabling this feature, called
6806 6806 \family typewriter
6807 6807 tutorial
6808 6808 \family default
6809 6809 \emph on
6810 6810 .
6811 6811
6812 6812 \emph default
6813 6813 Simply start IPython via
6814 6814 \family typewriter
6815 6815 `ipython\SpecialChar ~
6816 6816 -p\SpecialChar ~
6817 6817 tutorial'
6818 6818 \family default
6819 6819 and the feature will be available.
6820 6820 In a normal IPython session you can activate the feature by importing the
6821 6821 corresponding module with:
6822 6822 \newline
6823 6823
6824 6824 \family typewriter
6825 6825 In [1]: import IPython.Extensions.InterpreterPasteInput
6826 6826 \layout Standard
6827 6827
6828 6828 The following is a 'screenshot' of how things work when this extension is
6829 6829 on, copying an example from the standard tutorial:
6830 6830 \layout Standard
6831 6831
6832 6832
6833 6833 \family typewriter
6834 6834 IPython profile: tutorial
6835 6835 \newline
6836 6836 \SpecialChar ~
6837 6837
6838 6838 \newline
6839 6839 *** Pasting of code with ">>>" or "..." has been enabled.
6840 6840 \newline
6841 6841 \SpecialChar ~
6842 6842
6843 6843 \newline
6844 6844 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6845 6845 \newline
6846 6846
6847 6847 \begin_inset ERT
6848 6848 status Collapsed
6849 6849
6850 6850 \layout Standard
6851 6851
6852 6852 \backslash
6853 6853 hspace*{0mm}
6854 6854 \end_inset
6855 6855
6856 6856 \SpecialChar ~
6857 6857 \SpecialChar ~
6858 6858 ...: ...\SpecialChar ~
6859 6859 \SpecialChar ~
6860 6860 \SpecialChar ~
6861 6861 \SpecialChar ~
6862 6862 """Return a list containing the Fibonacci series up to n."""
6863 6863 \newline
6864 6864
6865 6865 \begin_inset ERT
6866 6866 status Collapsed
6867 6867
6868 6868 \layout Standard
6869 6869
6870 6870 \backslash
6871 6871 hspace*{0mm}
6872 6872 \end_inset
6873 6873
6874 6874 \SpecialChar ~
6875 6875 \SpecialChar ~
6876 6876 ...: ...\SpecialChar ~
6877 6877 \SpecialChar ~
6878 6878 \SpecialChar ~
6879 6879 \SpecialChar ~
6880 6880 result = []
6881 6881 \newline
6882 6882
6883 6883 \begin_inset ERT
6884 6884 status Collapsed
6885 6885
6886 6886 \layout Standard
6887 6887
6888 6888 \backslash
6889 6889 hspace*{0mm}
6890 6890 \end_inset
6891 6891
6892 6892 \SpecialChar ~
6893 6893 \SpecialChar ~
6894 6894 ...: ...\SpecialChar ~
6895 6895 \SpecialChar ~
6896 6896 \SpecialChar ~
6897 6897 \SpecialChar ~
6898 6898 a, b = 0, 1
6899 6899 \newline
6900 6900
6901 6901 \begin_inset ERT
6902 6902 status Collapsed
6903 6903
6904 6904 \layout Standard
6905 6905
6906 6906 \backslash
6907 6907 hspace*{0mm}
6908 6908 \end_inset
6909 6909
6910 6910 \SpecialChar ~
6911 6911 \SpecialChar ~
6912 6912 ...: ...\SpecialChar ~
6913 6913 \SpecialChar ~
6914 6914 \SpecialChar ~
6915 6915 \SpecialChar ~
6916 6916 while b < n:
6917 6917 \newline
6918 6918
6919 6919 \begin_inset ERT
6920 6920 status Collapsed
6921 6921
6922 6922 \layout Standard
6923 6923
6924 6924 \backslash
6925 6925 hspace*{0mm}
6926 6926 \end_inset
6927 6927
6928 6928 \SpecialChar ~
6929 6929 \SpecialChar ~
6930 6930 ...: ...\SpecialChar ~
6931 6931 \SpecialChar ~
6932 6932 \SpecialChar ~
6933 6933 \SpecialChar ~
6934 6934 \SpecialChar ~
6935 6935 \SpecialChar ~
6936 6936 \SpecialChar ~
6937 6937 \SpecialChar ~
6938 6938 result.append(b)\SpecialChar ~
6939 6939 \SpecialChar ~
6940 6940 \SpecialChar ~
6941 6941 # see below
6942 6942 \newline
6943 6943
6944 6944 \begin_inset ERT
6945 6945 status Collapsed
6946 6946
6947 6947 \layout Standard
6948 6948
6949 6949 \backslash
6950 6950 hspace*{0mm}
6951 6951 \end_inset
6952 6952
6953 6953 \SpecialChar ~
6954 6954 \SpecialChar ~
6955 6955 ...: ...\SpecialChar ~
6956 6956 \SpecialChar ~
6957 6957 \SpecialChar ~
6958 6958 \SpecialChar ~
6959 6959 \SpecialChar ~
6960 6960 \SpecialChar ~
6961 6961 \SpecialChar ~
6962 6962 \SpecialChar ~
6963 6963 a, b = b, a+b
6964 6964 \newline
6965 6965
6966 6966 \begin_inset ERT
6967 6967 status Collapsed
6968 6968
6969 6969 \layout Standard
6970 6970
6971 6971 \backslash
6972 6972 hspace*{0mm}
6973 6973 \end_inset
6974 6974
6975 6975 \SpecialChar ~
6976 6976 \SpecialChar ~
6977 6977 ...: ...\SpecialChar ~
6978 6978 \SpecialChar ~
6979 6979 \SpecialChar ~
6980 6980 \SpecialChar ~
6981 6981 return result
6982 6982 \newline
6983 6983
6984 6984 \begin_inset ERT
6985 6985 status Collapsed
6986 6986
6987 6987 \layout Standard
6988 6988
6989 6989 \backslash
6990 6990 hspace*{0mm}
6991 6991 \end_inset
6992 6992
6993 6993 \SpecialChar ~
6994 6994 \SpecialChar ~
6995 6995 ...:
6996 6996 \newline
6997 6997 \SpecialChar ~
6998 6998
6999 6999 \newline
7000 7000 In [2]: fib2(10)
7001 7001 \newline
7002 7002 Out[2]: [1, 1, 2, 3, 5, 8]
7003 7003 \layout Standard
7004 7004
7005 7005 Note that as currently written, this extension does
7006 7006 \emph on
7007 7007 not
7008 7008 \emph default
7009 7009 recognize IPython's prompts for pasting.
7010 7010 Those are more complicated, since the user can change them very easily,
7011 7011 they involve numbers and can vary in length.
7012 7012 One could however extract all the relevant information from the IPython
7013 7013 instance and build an appropriate regular expression.
7014 7014 This is left as an exercise for the reader.
7015 7015 \layout Subsection
7016 7016
7017 7017 Input of physical quantities with units
7018 7018 \layout Standard
7019 7019
7020 7020 The module
7021 7021 \family typewriter
7022 7022 PhysicalQInput
7023 7023 \family default
7024 7024 allows a simplified form of input for physical quantities with units.
7025 7025 This file is meant to be used in conjunction with the
7026 7026 \family typewriter
7027 7027 PhysicalQInteractive
7028 7028 \family default
7029 7029 module (in the same directory) and
7030 7030 \family typewriter
7031 7031 Physics.PhysicalQuantities
7032 7032 \family default
7033 7033 from Konrad Hinsen's ScientificPython (
7034 7034 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
7035 7035
7036 7036 \end_inset
7037 7037
7038 7038 ).
7039 7039 \layout Standard
7040 7040
7041 7041 The
7042 7042 \family typewriter
7043 7043 Physics.PhysicalQuantities
7044 7044 \family default
7045 7045 module defines
7046 7046 \family typewriter
7047 7047 PhysicalQuantity
7048 7048 \family default
7049 7049 objects, but these must be declared as instances of a class.
7050 7050 For example, to define
7051 7051 \family typewriter
7052 7052 v
7053 7053 \family default
7054 7054 as a velocity of 3\SpecialChar ~
7055 7055 m/s, normally you would write:
7056 7056 \family typewriter
7057 7057
7058 7058 \newline
7059 7059 In [1]: v = PhysicalQuantity(3,'m/s')
7060 7060 \layout Standard
7061 7061
7062 7062 Using the
7063 7063 \family typewriter
7064 7064 PhysicalQ_Input
7065 7065 \family default
7066 7066 extension this can be input instead as:
7067 7067 \family typewriter
7068 7068
7069 7069 \newline
7070 7070 In [1]: v = 3 m/s
7071 7071 \family default
7072 7072
7073 7073 \newline
7074 7074 which is much more convenient for interactive use (even though it is blatantly
7075 7075 invalid Python syntax).
7076 7076 \layout Standard
7077 7077
7078 7078 The
7079 7079 \family typewriter
7080 7080 physics
7081 7081 \family default
7082 7082 profile supplied with IPython (enabled via
7083 7083 \family typewriter
7084 7084 'ipython -p physics'
7085 7085 \family default
7086 7086 ) uses these extensions, which you can also activate with:
7087 7087 \layout Standard
7088 7088
7089 7089
7090 7090 \family typewriter
7091 7091 from math import * # math MUST be imported BEFORE PhysicalQInteractive
7092 7092 \newline
7093 7093 from IPython.Extensions.PhysicalQInteractive import *
7094 7094 \newline
7095 7095 import IPython.Extensions.PhysicalQInput
7096 7096 \layout Section
7097 7097
7098 7098
7099 7099 \begin_inset LatexCommand \label{sec:IPython-as-shell}
7100 7100
7101 7101 \end_inset
7102 7102
7103 7103 IPython as a system shell
7104 7104 \layout Standard
7105 7105
7106 7106 IPython ships with a special profile called
7107 7107 \family typewriter
7108 7108 pysh
7109 7109 \family default
7110 7110 , which you can activate at the command line as
7111 7111 \family typewriter
7112 7112 `ipython -p pysh'
7113 7113 \family default
7114 7114 .
7115 7115 This loads
7116 7116 \family typewriter
7117 7117 InterpreterExec
7118 7118 \family default
7119 7119 , along with some additional facilities and a prompt customized for filesystem
7120 7120 navigation.
7121 7121 \layout Standard
7122 7122
7123 7123 Note that this does
7124 7124 \emph on
7125 7125 not
7126 7126 \emph default
7127 7127 make IPython a full-fledged system shell.
7128 7128 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
7129 7129 you'll suspend pysh itself, not the process you just started.
7130 7130
7131 7131 \layout Standard
7132 7132
7133 7133 What the shell profile allows you to do is to use the convenient and powerful
7134 7134 syntax of Python to do quick scripting at the command line.
7135 7135 Below we describe some of its features.
7136 7136 \layout Subsection
7137 7137
7138 7138 Aliases
7139 7139 \layout Standard
7140 7140
7141 7141 All of your
7142 7142 \family typewriter
7143 7143 $PATH
7144 7144 \family default
7145 7145 has been loaded as IPython aliases, so you should be able to type any normal
7146 7146 system command and have it executed.
7147 7147 See
7148 7148 \family typewriter
7149 7149 %alias?
7150 7150 \family default
7151 7151 and
7152 7152 \family typewriter
7153 7153 %unalias?
7154 7154 \family default
7155 7155 for details on the alias facilities.
7156 7156 See also
7157 7157 \family typewriter
7158 7158 %rehash?
7159 7159 \family default
7160 7160 and
7161 7161 \family typewriter
7162 7162 %rehashx?
7163 7163 \family default
7164 7164 for details on the mechanism used to load
7165 7165 \family typewriter
7166 7166 $PATH
7167 7167 \family default
7168 7168 .
7169 7169 \layout Subsection
7170 7170
7171 7171 Special syntax
7172 7172 \layout Standard
7173 7173
7174 7174 Any lines which begin with
7175 7175 \family typewriter
7176 7176 `~'
7177 7177 \family default
7178 7178 ,
7179 7179 \family typewriter
7180 7180 `/'
7181 7181 \family default
7182 7182 and
7183 7183 \family typewriter
7184 7184 `.'
7185 7185 \family default
7186 7186 will be executed as shell commands instead of as Python code.
7187 7187 The special escapes below are also recognized.
7188 7188
7189 7189 \family typewriter
7190 7190 !cmd
7191 7191 \family default
7192 7192 is valid in single or multi-line input, all others are only valid in single-lin
7193 7193 e input:
7194 7194 \layout Description
7195 7195
7196 7196
7197 7197 \family typewriter
7198 7198 !cmd
7199 7199 \family default
7200 7200 pass `cmd' directly to the shell
7201 7201 \layout Description
7202 7202
7203 7203
7204 7204 \family typewriter
7205 7205 !!cmd
7206 7206 \family default
7207 7207 execute `cmd' and return output as a list (split on `
7208 7208 \backslash
7209 7209 n')
7210 7210 \layout Description
7211 7211
7212 7212
7213 7213 \family typewriter
7214 7214 $var=cmd
7215 7215 \family default
7216 7216 capture output of cmd into var, as a string
7217 7217 \layout Description
7218 7218
7219 7219
7220 7220 \family typewriter
7221 7221 $$var=cmd
7222 7222 \family default
7223 7223 capture output of cmd into var, as a list (split on `
7224 7224 \backslash
7225 7225 n')
7226 7226 \layout Standard
7227 7227
7228 7228 The
7229 7229 \family typewriter
7230 7230 $
7231 7231 \family default
7232 7232 /
7233 7233 \family typewriter
7234 7234 $$
7235 7235 \family default
7236 7236 syntaxes make Python variables from system output, which you can later
7237 7237 use for further scripting.
7238 7238 The converse is also possible: when executing an alias or calling to the
7239 7239 system via
7240 7240 \family typewriter
7241 7241 !
7242 7242 \family default
7243 7243 /
7244 7244 \family typewriter
7245 7245 !!
7246 7246 \family default
7247 7247 , you can expand any python variable or expression by prepending it with
7248 7248
7249 7249 \family typewriter
7250 7250 $
7251 7251 \family default
7252 7252 .
7253 7253 Full details of the allowed syntax can be found in Python's PEP 215.
7254 7254 \layout Standard
7255 7255
7256 7256 A few brief examples will illustrate these (note that the indentation below
7257 7257 may be incorrectly displayed):
7258 7258 \layout Standard
7259 7259
7260 7260
7261 7261 \family typewriter
7262 7262 fperez[~/test]|3> !ls *s.py
7263 7263 \newline
7264 7264 scopes.py strings.py
7265 7265 \layout Standard
7266 7266
7267 7267 ls is an internal alias, so there's no need to use
7268 7268 \family typewriter
7269 7269 !
7270 7270 \family default
7271 7271 :
7272 7272 \layout Standard
7273 7273
7274 7274
7275 7275 \family typewriter
7276 7276 fperez[~/test]|4> ls *s.py
7277 7277 \newline
7278 7278 scopes.py* strings.py
7279 7279 \layout Standard
7280 7280
7281 7281 !!ls will return the output into a Python variable:
7282 7282 \layout Standard
7283 7283
7284 7284
7285 7285 \family typewriter
7286 7286 fperez[~/test]|5> !!ls *s.py
7287 7287 \newline
7288 7288
7289 7289 \begin_inset ERT
7290 7290 status Collapsed
7291 7291
7292 7292 \layout Standard
7293 7293
7294 7294 \backslash
7295 7295 hspace*{0mm}
7296 7296 \end_inset
7297 7297
7298 7298 \SpecialChar ~
7299 7299 \SpecialChar ~
7300 7300 \SpecialChar ~
7301 7301 \SpecialChar ~
7302 7302 \SpecialChar ~
7303 7303 \SpecialChar ~
7304 7304 \SpecialChar ~
7305 7305 \SpecialChar ~
7306 7306 \SpecialChar ~
7307 7307 \SpecialChar ~
7308 7308 \SpecialChar ~
7309 7309 \SpecialChar ~
7310 7310 \SpecialChar ~
7311 7311 \SpecialChar ~
7312 7312 <5> ['scopes.py', 'strings.py']
7313 7313 \newline
7314 7314 fperez[~/test]|6> print _5
7315 7315 \newline
7316 7316 ['scopes.py', 'strings.py']
7317 7317 \layout Standard
7318 7318
7319 7319
7320 7320 \family typewriter
7321 7321 $
7322 7322 \family default
7323 7323 and
7324 7324 \family typewriter
7325 7325 $$
7326 7326 \family default
7327 7327 allow direct capture to named variables:
7328 7328 \layout Standard
7329 7329
7330 7330
7331 7331 \family typewriter
7332 7332 fperez[~/test]|7> $astr = ls *s.py
7333 7333 \newline
7334 7334 fperez[~/test]|8> astr
7335 7335 \newline
7336 7336
7337 7337 \begin_inset ERT
7338 7338 status Collapsed
7339 7339
7340 7340 \layout Standard
7341 7341
7342 7342 \backslash
7343 7343 hspace*{0mm}
7344 7344 \end_inset
7345 7345
7346 7346 \SpecialChar ~
7347 7347 \SpecialChar ~
7348 7348 \SpecialChar ~
7349 7349 \SpecialChar ~
7350 7350 \SpecialChar ~
7351 7351 \SpecialChar ~
7352 7352 \SpecialChar ~
7353 7353 \SpecialChar ~
7354 7354 \SpecialChar ~
7355 7355 \SpecialChar ~
7356 7356 \SpecialChar ~
7357 7357 \SpecialChar ~
7358 7358 \SpecialChar ~
7359 7359 \SpecialChar ~
7360 7360 <8> 'scopes.py
7361 7361 \backslash
7362 7362 nstrings.py'
7363 7363 \layout Standard
7364 7364
7365 7365
7366 7366 \family typewriter
7367 7367 fperez[~/test]|9> $$alist = ls *s.py
7368 7368 \newline
7369 7369 fperez[~/test]|10> alist
7370 7370 \newline
7371 7371
7372 7372 \begin_inset ERT
7373 7373 status Collapsed
7374 7374
7375 7375 \layout Standard
7376 7376
7377 7377 \backslash
7378 7378 hspace*{0mm}
7379 7379 \end_inset
7380 7380
7381 7381 \SpecialChar ~
7382 7382 \SpecialChar ~
7383 7383 \SpecialChar ~
7384 7384 \SpecialChar ~
7385 7385 \SpecialChar ~
7386 7386 \SpecialChar ~
7387 7387 \SpecialChar ~
7388 7388 \SpecialChar ~
7389 7389 \SpecialChar ~
7390 7390 \SpecialChar ~
7391 7391 \SpecialChar ~
7392 7392 \SpecialChar ~
7393 7393 \SpecialChar ~
7394 7394 \SpecialChar ~
7395 7395 <10> ['scopes.py', 'strings.py']
7396 7396 \layout Standard
7397 7397
7398 7398 alist is now a normal python list you can loop over.
7399 7399 Using
7400 7400 \family typewriter
7401 7401 $
7402 7402 \family default
7403 7403 will expand back the python values when alias calls are made:
7404 7404 \layout Standard
7405 7405
7406 7406
7407 7407 \family typewriter
7408 7408 fperez[~/test]|11> for f in alist:
7409 7409 \newline
7410 7410
7411 7411 \begin_inset ERT
7412 7412 status Collapsed
7413 7413
7414 7414 \layout Standard
7415 7415
7416 7416 \backslash
7417 7417 hspace*{0mm}
7418 7418 \end_inset
7419 7419
7420 7420 \SpecialChar ~
7421 7421 \SpecialChar ~
7422 7422 \SpecialChar ~
7423 7423 \SpecialChar ~
7424 7424 \SpecialChar ~
7425 7425 \SpecialChar ~
7426 7426 \SpecialChar ~
7427 7427 \SpecialChar ~
7428 7428 \SpecialChar ~
7429 7429 \SpecialChar ~
7430 7430 \SpecialChar ~
7431 7431 \SpecialChar ~
7432 7432 \SpecialChar ~
7433 7433 \SpecialChar ~
7434 7434 |..> \SpecialChar ~
7435 7435 \SpecialChar ~
7436 7436 \SpecialChar ~
7437 7437 \SpecialChar ~
7438 7438 print 'file',f,
7439 7439 \newline
7440 7440
7441 7441 \begin_inset ERT
7442 7442 status Collapsed
7443 7443
7444 7444 \layout Standard
7445 7445
7446 7446 \backslash
7447 7447 hspace*{0mm}
7448 7448 \end_inset
7449 7449
7450 7450 \SpecialChar ~
7451 7451 \SpecialChar ~
7452 7452 \SpecialChar ~
7453 7453 \SpecialChar ~
7454 7454 \SpecialChar ~
7455 7455 \SpecialChar ~
7456 7456 \SpecialChar ~
7457 7457 \SpecialChar ~
7458 7458 \SpecialChar ~
7459 7459 \SpecialChar ~
7460 7460 \SpecialChar ~
7461 7461 \SpecialChar ~
7462 7462 \SpecialChar ~
7463 7463 \SpecialChar ~
7464 7464 |..> \SpecialChar ~
7465 7465 \SpecialChar ~
7466 7466 \SpecialChar ~
7467 7467 \SpecialChar ~
7468 7468 wc -l $f
7469 7469 \newline
7470 7470
7471 7471 \begin_inset ERT
7472 7472 status Collapsed
7473 7473
7474 7474 \layout Standard
7475 7475
7476 7476 \backslash
7477 7477 hspace*{0mm}
7478 7478 \end_inset
7479 7479
7480 7480 \SpecialChar ~
7481 7481 \SpecialChar ~
7482 7482 \SpecialChar ~
7483 7483 \SpecialChar ~
7484 7484 \SpecialChar ~
7485 7485 \SpecialChar ~
7486 7486 \SpecialChar ~
7487 7487 \SpecialChar ~
7488 7488 \SpecialChar ~
7489 7489 \SpecialChar ~
7490 7490 \SpecialChar ~
7491 7491 \SpecialChar ~
7492 7492 \SpecialChar ~
7493 7493 \SpecialChar ~
7494 7494 |..>
7495 7495 \newline
7496 7496 file scopes.py 13 scopes.py
7497 7497 \newline
7498 7498 file strings.py 4 strings.py
7499 7499 \layout Standard
7500 7500
7501 7501 Note that you may need to protect your variables with braces if you want
7502 7502 to append strings to their names.
7503 7503 To copy all files in alist to
7504 7504 \family typewriter
7505 7505 .bak
7506 7506 \family default
7507 7507 extensions, you must use:
7508 7508 \layout Standard
7509 7509
7510 7510
7511 7511 \family typewriter
7512 7512 fperez[~/test]|12> for f in alist:
7513 7513 \newline
7514 7514
7515 7515 \begin_inset ERT
7516 7516 status Collapsed
7517 7517
7518 7518 \layout Standard
7519 7519
7520 7520 \backslash
7521 7521 hspace*{0mm}
7522 7522 \end_inset
7523 7523
7524 7524 \SpecialChar ~
7525 7525 \SpecialChar ~
7526 7526 \SpecialChar ~
7527 7527 \SpecialChar ~
7528 7528 \SpecialChar ~
7529 7529 \SpecialChar ~
7530 7530 \SpecialChar ~
7531 7531 \SpecialChar ~
7532 7532 \SpecialChar ~
7533 7533 \SpecialChar ~
7534 7534 \SpecialChar ~
7535 7535 \SpecialChar ~
7536 7536 \SpecialChar ~
7537 7537 \SpecialChar ~
7538 7538 |..> \SpecialChar ~
7539 7539 \SpecialChar ~
7540 7540 \SpecialChar ~
7541 7541 \SpecialChar ~
7542 7542 cp $f ${f}.bak
7543 7543 \layout Standard
7544 7544
7545 7545 If you try using
7546 7546 \family typewriter
7547 7547 $f.bak
7548 7548 \family default
7549 7549 , you'll get an AttributeError exception saying that your string object
7550 7550 doesn't have a
7551 7551 \family typewriter
7552 7552 .bak
7553 7553 \family default
7554 7554 attribute.
7555 7555 This is because the
7556 7556 \family typewriter
7557 7557 $
7558 7558 \family default
7559 7559 expansion mechanism allows you to expand full Python expressions:
7560 7560 \layout Standard
7561 7561
7562 7562
7563 7563 \family typewriter
7564 7564 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7565 7565 \newline
7566 7566 sys.platform is: linux2
7567 7567 \layout Standard
7568 7568
7569 7569 IPython's input history handling is still active, which allows you to rerun
7570 7570 a single block of multi-line input by simply using exec:
7571 7571 \newline
7572 7572
7573 7573 \family typewriter
7574 7574 fperez[~/test]|14> $$alist = ls *.eps
7575 7575 \newline
7576 7576 fperez[~/test]|15> exec _i11
7577 7577 \newline
7578 7578 file image2.eps 921 image2.eps
7579 7579 \newline
7580 7580 file image.eps 921 image.eps
7581 7581 \layout Standard
7582 7582
7583 7583 While these are new special-case syntaxes, they are designed to allow very
7584 7584 efficient use of the shell with minimal typing.
7585 7585 At an interactive shell prompt, conciseness of expression wins over readability.
7586 7586 \layout Subsection
7587 7587
7588 7588 Useful functions and modules
7589 7589 \layout Standard
7590 7590
7591 7591 The os, sys and shutil modules from the Python standard library are automaticall
7592 7592 y loaded.
7593 7593 Some additional functions, useful for shell usage, are listed below.
7594 7594 You can request more help about them with `
7595 7595 \family typewriter
7596 7596 ?
7597 7597 \family default
7598 7598 '.
7599 7599 \layout Description
7600 7600
7601 7601
7602 7602 \family typewriter
7603 7603 shell
7604 7604 \family default
7605 7605 - execute a command in the underlying system shell
7606 7606 \layout Description
7607 7607
7608 7608
7609 7609 \family typewriter
7610 7610 system
7611 7611 \family default
7612 7612 - like
7613 7613 \family typewriter
7614 7614 shell()
7615 7615 \family default
7616 7616 , but return the exit status of the command
7617 7617 \layout Description
7618 7618
7619 7619
7620 7620 \family typewriter
7621 7621 sout
7622 7622 \family default
7623 7623 - capture the output of a command as a string
7624 7624 \layout Description
7625 7625
7626 7626
7627 7627 \family typewriter
7628 7628 lout
7629 7629 \family default
7630 7630 - capture the output of a command as a list (split on `
7631 7631 \backslash
7632 7632 n')
7633 7633 \layout Description
7634 7634
7635 7635
7636 7636 \family typewriter
7637 7637 getoutputerror
7638 7638 \family default
7639 7639 - capture (output,error) of a shell commandss
7640 7640 \layout Standard
7641 7641
7642 7642
7643 7643 \family typewriter
7644 7644 sout
7645 7645 \family default
7646 7646 /
7647 7647 \family typewriter
7648 7648 lout
7649 7649 \family default
7650 7650 are the functional equivalents of
7651 7651 \family typewriter
7652 7652 $
7653 7653 \family default
7654 7654 /
7655 7655 \family typewriter
7656 7656 $$
7657 7657 \family default
7658 7658 .
7659 7659 They are provided to allow you to capture system output in the middle of
7660 7660 true python code, function definitions, etc (where
7661 7661 \family typewriter
7662 7662 $
7663 7663 \family default
7664 7664 and
7665 7665 \family typewriter
7666 7666 $$
7667 7667 \family default
7668 7668 are invalid).
7669 7669 \layout Subsection
7670 7670
7671 7671 Directory management
7672 7672 \layout Standard
7673 7673
7674 7674 Since each command passed by pysh to the underlying system is executed in
7675 7675 a subshell which exits immediately, you can NOT use !cd to navigate the
7676 7676 filesystem.
7677 7677 \layout Standard
7678 7678
7679 7679 Pysh provides its own builtin
7680 7680 \family typewriter
7681 7681 `%cd
7682 7682 \family default
7683 7683 ' magic command to move in the filesystem (the
7684 7684 \family typewriter
7685 7685 %
7686 7686 \family default
7687 7687 is not required with automagic on).
7688 7688 It also maintains a list of visited directories (use
7689 7689 \family typewriter
7690 7690 %dhist
7691 7691 \family default
7692 7692 to see it) and allows direct switching to any of them.
7693 7693 Type
7694 7694 \family typewriter
7695 7695 `cd?
7696 7696 \family default
7697 7697 ' for more details.
7698 7698 \layout Standard
7699 7699
7700 7700
7701 7701 \family typewriter
7702 7702 %pushd
7703 7703 \family default
7704 7704 ,
7705 7705 \family typewriter
7706 7706 %popd
7707 7707 \family default
7708 7708 and
7709 7709 \family typewriter
7710 7710 %dirs
7711 7711 \family default
7712 7712 are provided for directory stack handling.
7713 7713 \layout Subsection
7714 7714
7715 7715 Prompt customization
7716 7716 \layout Standard
7717 7717
7718 7718 The supplied
7719 7719 \family typewriter
7720 7720 ipythonrc-pysh
7721 7721 \family default
7722 7722 profile comes with an example of a very colored and detailed prompt, mainly
7723 7723 to serve as an illustration.
7724 7724 The valid escape sequences, besides color names, are:
7725 7725 \layout Description
7726 7726
7727 7727
7728 7728 \backslash
7729 7729 # - Prompt number.
7730 7730 \layout Description
7731 7731
7732 7732
7733 7733 \backslash
7734 7734 D - Dots, as many as there are digits in
7735 7735 \backslash
7736 7736 # (so they align).
7737 7737 \layout Description
7738 7738
7739 7739
7740 7740 \backslash
7741 7741 w - Current working directory (cwd).
7742 7742 \layout Description
7743 7743
7744 7744
7745 7745 \backslash
7746 7746 W - Basename of current working directory.
7747 7747 \layout Description
7748 7748
7749 7749
7750 7750 \backslash
7751 7751 X
7752 7752 \emph on
7753 7753 N
7754 7754 \emph default
7755 7755 - Where
7756 7756 \emph on
7757 7757 N
7758 7758 \emph default
7759 7759 =0..5.
7760 7760 N terms of the cwd, with $HOME written as ~.
7761 7761 \layout Description
7762 7762
7763 7763
7764 7764 \backslash
7765 7765 Y
7766 7766 \emph on
7767 7767 N
7768 7768 \emph default
7769 7769 - Where
7770 7770 \emph on
7771 7771 N
7772 7772 \emph default
7773 7773 =0..5.
7774 7774 Like X
7775 7775 \emph on
7776 7776 N
7777 7777 \emph default
7778 7778 , but if ~ is term
7779 7779 \emph on
7780 7780 N
7781 7781 \emph default
7782 7782 +1 it's also shown.
7783 7783 \layout Description
7784 7784
7785 7785
7786 7786 \backslash
7787 7787 u - Username.
7788 7788 \layout Description
7789 7789
7790 7790
7791 7791 \backslash
7792 7792 H - Full hostname.
7793 7793 \layout Description
7794 7794
7795 7795
7796 7796 \backslash
7797 7797 h - Hostname up to first '.'
7798 7798 \layout Description
7799 7799
7800 7800
7801 7801 \backslash
7802 7802 $ - Root symbol ($ or #).
7803 7803
7804 7804 \layout Description
7805 7805
7806 7806
7807 7807 \backslash
7808 7808 t - Current time, in H:M:S format.
7809 7809 \layout Description
7810 7810
7811 7811
7812 7812 \backslash
7813 7813 v - IPython release version.
7814 7814
7815 7815 \layout Description
7816 7816
7817 7817
7818 7818 \backslash
7819 7819 n - Newline.
7820 7820
7821 7821 \layout Description
7822 7822
7823 7823
7824 7824 \backslash
7825 7825 r - Carriage return.
7826 7826
7827 7827 \layout Description
7828 7828
7829 7829
7830 7830 \backslash
7831 7831
7832 7832 \backslash
7833 7833 - An explicitly escaped '
7834 7834 \backslash
7835 7835 '.
7836 7836 \layout Standard
7837 7837
7838 7838 You can configure your prompt colors using any ANSI color escape.
7839 7839 Each color escape sets the color for any subsequent text, until another
7840 7840 escape comes in and changes things.
7841 7841 The valid color escapes are:
7842 7842 \layout Description
7843 7843
7844 7844
7845 7845 \backslash
7846 7846 C_Black
7847 7847 \layout Description
7848 7848
7849 7849
7850 7850 \backslash
7851 7851 C_Blue
7852 7852 \layout Description
7853 7853
7854 7854
7855 7855 \backslash
7856 7856 C_Brown
7857 7857 \layout Description
7858 7858
7859 7859
7860 7860 \backslash
7861 7861 C_Cyan
7862 7862 \layout Description
7863 7863
7864 7864
7865 7865 \backslash
7866 7866 C_DarkGray
7867 7867 \layout Description
7868 7868
7869 7869
7870 7870 \backslash
7871 7871 C_Green
7872 7872 \layout Description
7873 7873
7874 7874
7875 7875 \backslash
7876 7876 C_LightBlue
7877 7877 \layout Description
7878 7878
7879 7879
7880 7880 \backslash
7881 7881 C_LightCyan
7882 7882 \layout Description
7883 7883
7884 7884
7885 7885 \backslash
7886 7886 C_LightGray
7887 7887 \layout Description
7888 7888
7889 7889
7890 7890 \backslash
7891 7891 C_LightGreen
7892 7892 \layout Description
7893 7893
7894 7894
7895 7895 \backslash
7896 7896 C_LightPurple
7897 7897 \layout Description
7898 7898
7899 7899
7900 7900 \backslash
7901 7901 C_LightRed
7902 7902 \layout Description
7903 7903
7904 7904
7905 7905 \backslash
7906 7906 C_Purple
7907 7907 \layout Description
7908 7908
7909 7909
7910 7910 \backslash
7911 7911 C_Red
7912 7912 \layout Description
7913 7913
7914 7914
7915 7915 \backslash
7916 7916 C_White
7917 7917 \layout Description
7918 7918
7919 7919
7920 7920 \backslash
7921 7921 C_Yellow
7922 7922 \layout Description
7923 7923
7924 7924
7925 7925 \backslash
7926 7926 C_Normal Stop coloring, defaults to your terminal settings.
7927 7927 \layout Section
7928 7928
7929 7929
7930 7930 \begin_inset LatexCommand \label{sec:Threading-support}
7931 7931
7932 7932 \end_inset
7933 7933
7934 7934 Threading support
7935 7935 \layout Standard
7936 7936
7937 7937
7938 7938 \series bold
7939 7939 WARNING:
7940 7940 \series default
7941 7941 The threading support is still somewhat experimental, and it has only seen
7942 7942 reasonable testing under Linux.
7943 7943 Threaded code is particularly tricky to debug, and it tends to show extremely
7944 7944 platform-dependent behavior.
7945 7945 Since I only have access to Linux machines, I will have to rely on user's
7946 7946 experiences and assistance for this area of IPython to improve under other
7947 7947 platforms.
7948 7948 \layout Standard
7949 7949
7950 7950 IPython, via the
7951 7951 \family typewriter
7952 7952 -gthread
7953 7953 \family default
7954 7954 ,
7955 7955 \family typewriter
7956 7956 -qthread
7957 7957 \family default
7958 7958 and
7959 7959 \family typewriter
7960 7960 -wthread
7961 7961 \family default
7962 7962 options (described in Sec.\SpecialChar ~
7963 7963
7964 7964 \begin_inset LatexCommand \ref{sec:threading-opts}
7965 7965
7966 7966 \end_inset
7967 7967
7968 7968 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7969 7969 respectively.
7970 7970 These GUI toolkits need to control the python main loop of execution, so
7971 7971 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7972 7972 will immediately freeze the shell.
7973 7973
7974 7974 \layout Standard
7975 7975
7976 7976 IPython, with one of these options (you can only use one at a time), separates
7977 7977 the graphical loop and IPython's code execution run into different threads.
7978 7978 This allows you to test interactively (with
7979 7979 \family typewriter
7980 7980 %run
7981 7981 \family default
7982 7982 , for example) your GUI code without blocking.
7983 7983 \layout Standard
7984 7984
7985 7985 A nice mini-tutorial on using IPython along with the Qt Designer application
7986 7986 is available at the SciPy wiki:
7987 7987 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7988 7988
7989 7989 \end_inset
7990 7990
7991 7991 .
7992 7992 \layout Subsection
7993 7993
7994 7994 Tk issues
7995 7995 \layout Standard
7996 7996
7997 7997 As indicated in Sec.\SpecialChar ~
7998 7998
7999 7999 \begin_inset LatexCommand \ref{sec:threading-opts}
8000 8000
8001 8001 \end_inset
8002 8002
8003 8003 , a special
8004 8004 \family typewriter
8005 8005 -tk
8006 8006 \family default
8007 8007 option is provided to try and allow Tk graphical applications to coexist
8008 8008 interactively with WX, Qt or GTK ones.
8009 8009 Whether this works at all, however, is very platform and configuration
8010 8010 dependent.
8011 8011 Please experiment with simple test cases before committing to using this
8012 8012 combination of Tk and GTK/Qt/WX threading in a production environment.
8013 8013 \layout Subsection
8014 8014
8015 8015 Signals and Threads
8016 8016 \layout Standard
8017 8017
8018 8018 When any of the thread systems (GTK, Qt or WX) are active, either directly
8019 8019 or via
8020 8020 \family typewriter
8021 8021 -pylab
8022 8022 \family default
8023 8023 with a threaded backend, it is impossible to interrupt long-running Python
8024 8024 code via
8025 8025 \family typewriter
8026 8026 Ctrl-C
8027 8027 \family default
8028 8028 .
8029 8029 IPython can not pass the KeyboardInterrupt exception (or the underlying
8030 8030
8031 8031 \family typewriter
8032 8032 SIGINT
8033 8033 \family default
8034 8034 ) across threads, so any long-running process started from IPython will
8035 8035 run to completion, or will have to be killed via an external (OS-based)
8036 8036 mechanism.
8037 8037 \layout Standard
8038 8038
8039 8039 To the best of my knowledge, this limitation is imposed by the Python interprete
8040 8040 r itself, and it comes from the difficulty of writing portable signal/threaded
8041 8041 code.
8042 8042 If any user is an expert on this topic and can suggest a better solution,
8043 8043 I would love to hear about it.
8044 8044 In the IPython sources, look at the
8045 8045 \family typewriter
8046 8046 Shell.py
8047 8047 \family default
8048 8048 module, and in particular at the
8049 8049 \family typewriter
8050 8050 runcode()
8051 8051 \family default
8052 8052 method.
8053 8053
8054 8054 \layout Subsection
8055 8055
8056 8056 I/O pitfalls
8057 8057 \layout Standard
8058 8058
8059 8059 Be mindful that the Python interpreter switches between threads every
8060 8060 \begin_inset Formula $N$
8061 8061 \end_inset
8062 8062
8063 8063 bytecodes, where the default value as of Python\SpecialChar ~
8064 8064 2.3 is
8065 8065 \begin_inset Formula $N=100.$
8066 8066 \end_inset
8067 8067
8068 8068 This value can be read by using the
8069 8069 \family typewriter
8070 8070 sys.getcheckinterval()
8071 8071 \family default
8072 8072 function, and it can be reset via
8073 8073 \family typewriter
8074 8074 sys.setcheckinterval(
8075 8075 \emph on
8076 8076 N
8077 8077 \emph default
8078 8078 )
8079 8079 \family default
8080 8080 .
8081 8081 This switching of threads can cause subtly confusing effects if one of
8082 8082 your threads is doing file I/O.
8083 8083 In text mode, most systems only flush file buffers when they encounter
8084 8084 a
8085 8085 \family typewriter
8086 8086 `
8087 8087 \backslash
8088 8088 n'
8089 8089 \family default
8090 8090 .
8091 8091 An instruction as simple as
8092 8092 \family typewriter
8093 8093
8094 8094 \newline
8095 8095 \SpecialChar ~
8096 8096 \SpecialChar ~
8097 8097 print >> filehandle,
8098 8098 \begin_inset Quotes eld
8099 8099 \end_inset
8100 8100
8101 8101 hello world
8102 8102 \begin_inset Quotes erd
8103 8103 \end_inset
8104 8104
8105 8105
8106 8106 \family default
8107 8107
8108 8108 \newline
8109 8109 actually consists of several bytecodes, so it is possible that the newline
8110 8110 does not reach your file before the next thread switch.
8111 8111 Similarly, if you are writing to a file in binary mode, the file won't
8112 8112 be flushed until the buffer fills, and your other thread may see apparently
8113 8113 truncated files.
8114 8114
8115 8115 \layout Standard
8116 8116
8117 8117 For this reason, if you are using IPython's thread support and have (for
8118 8118 example) a GUI application which will read data generated by files written
8119 8119 to from the IPython thread, the safest approach is to open all of your
8120 8120 files in unbuffered mode (the third argument to the
8121 8121 \family typewriter
8122 8122 file/open
8123 8123 \family default
8124 8124 function is the buffering value):
8125 8125 \newline
8126 8126
8127 8127 \family typewriter
8128 8128 \SpecialChar ~
8129 8129 \SpecialChar ~
8130 8130 filehandle = open(filename,mode,0)
8131 8131 \layout Standard
8132 8132
8133 8133 This is obviously a brute force way of avoiding race conditions with the
8134 8134 file buffering.
8135 8135 If you want to do it cleanly, and you have a resource which is being shared
8136 8136 by the interactive IPython loop and your GUI thread, you should really
8137 8137 handle it with thread locking and syncrhonization properties.
8138 8138 The Python documentation discusses these.
8139 8139 \layout Section
8140 8140
8141 8141
8142 8142 \begin_inset LatexCommand \label{sec:interactive-demos}
8143 8143
8144 8144 \end_inset
8145 8145
8146 8146 Interactive demos with IPython
8147 8147 \layout Standard
8148 8148
8149 8149 IPython ships with a basic system for running scripts interactively in sections,
8150 8150 useful when presenting code to audiences.
8151 8151 A few tags embedded in comments (so that the script remains valid Python
8152 8152 code) divide a file into separate blocks, and the demo can be run one block
8153 8153 at a time, with IPython printing (with syntax highlighting) the block before
8154 8154 executing it, and returning to the interactive prompt after each block.
8155 8155 The interactive namespace is updated after each block is run with the contents
8156 8156 of the demo's namespace.
8157 8157 \layout Standard
8158 8158
8159 8159 This allows you to show a piece of code, run it and then execute interactively
8160 8160 commands based on the variables just created.
8161 8161 Once you want to continue, you simply execute the next block of the demo.
8162 8162 The following listing shows the markup necessary for dividing a script
8163 8163 into sections for execution as a demo.
8164 8164 \layout Standard
8165 8165
8166 8166
8167 8167 \begin_inset ERT
8168 8168 status Open
8169 8169
8170 8170 \layout Standard
8171 8171
8172 8172 \backslash
8173 8173 codelist{examples/example-demo.py}
8174 8174 \end_inset
8175 8175
8176 8176
8177 8177 \layout Standard
8178 8178
8179 8179 In order to run a file as a demo, you must first make a
8180 8180 \family typewriter
8181 8181 Demo
8182 8182 \family default
8183 8183 object out of it.
8184 8184 If the file is named
8185 8185 \family typewriter
8186 8186 myscript.py
8187 8187 \family default
8188 8188 , the following code will make a demo:
8189 8189 \layout LyX-Code
8190 8190
8191 8191 from IPython.demo import Demo
8192 8192 \layout LyX-Code
8193 8193
8194 8194 mydemo = Demo('myscript.py')
8195 8195 \layout Standard
8196 8196
8197 8197 This creates the
8198 8198 \family typewriter
8199 8199 mydemo
8200 8200 \family default
8201 8201 object, whose blocks you run one at a time by simply calling the object
8202 8202 with no arguments.
8203 8203 If you have autocall active in IPython (the default), all you need to do
8204 8204 is type
8205 8205 \layout LyX-Code
8206 8206
8207 8207 mydemo
8208 8208 \layout Standard
8209 8209
8210 8210 and IPython will call it, executing each block.
8211 8211 Demo objects can be restarted, you can move forward or back skipping blocks,
8212 8212 re-execute the last block, etc.
8213 8213 Simply use the Tab key on a demo object to see its methods, and call
8214 8214 \family typewriter
8215 8215 `?'
8216 8216 \family default
8217 8217 on them to see their docstrings for more usage details.
8218 8218 In addition, the
8219 8219 \family typewriter
8220 8220 demo
8221 8221 \family default
8222 8222 module itself contains a comprehensive docstring, which you can access
8223 8223 via
8224 8224 \layout LyX-Code
8225 8225
8226 8226 from IPython import demo
8227 8227 \layout LyX-Code
8228 8228
8229 8229 demo?
8230 8230 \layout Standard
8231 8231
8232 8232
8233 8233 \series bold
8234 8234 Limitations:
8235 8235 \series default
8236 8236 It is important to note that these demos are limited to fairly simple uses.
8237 8237 In particular, you can
8238 8238 \emph on
8239 8239 not
8240 8240 \emph default
8241 8241 put division marks in indented code (loops, if statements, function definitions
8242 8242 , etc.) Supporting something like this would basically require tracking the
8243 8243 internal execution state of the Python interpreter, so only top-level divisions
8244 8244 are allowed.
8245 8245 If you want to be able to open an IPython instance at an arbitrary point
8246 8246 in a program, you can use IPython's embedding facilities, described in
8247 8247 detail in Sec\SpecialChar \@.
8248 8248 \SpecialChar ~
8249 8249
8250 8250 \begin_inset LatexCommand \ref{sec:embed}
8251 8251
8252 8252 \end_inset
8253 8253
8254 8254 .
8255 8255 \layout Section
8256 8256
8257 8257
8258 8258 \begin_inset LatexCommand \label{sec:matplotlib-support}
8259 8259
8260 8260 \end_inset
8261 8261
8262 8262 Plotting with
8263 8263 \family typewriter
8264 8264 matplotlib
8265 8265 \family default
8266 8266
8267 8267 \layout Standard
8268 8268
8269 8269 The matplotlib library (
8270 8270 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
8271 8271
8272 8272 \end_inset
8273 8273
8274 8274 ) provides high quality 2D plotting for Python.
8275 8275 Matplotlib can produce plots on screen using a variety of GUI toolkits,
8276 8276 including Tk, GTK and WXPython.
8277 8277 It also provides a number of commands useful for scientific computing,
8278 8278 all with a syntax compatible with that of the popular Matlab program.
8279 8279 \layout Standard
8280 8280
8281 8281 IPython accepts the special option
8282 8282 \family typewriter
8283 8283 -pylab
8284 8284 \family default
8285 8285 (Sec.\SpecialChar ~
8286 8286
8287 8287 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
8288 8288
8289 8289 \end_inset
8290 8290
8291 8291 ).
8292 8292 This configures it to support matplotlib, honoring the settings in the
8293 8293
8294 8294 \family typewriter
8295 8295 .matplotlibrc
8296 8296 \family default
8297 8297 file.
8298 8298 IPython will detect the user's choice of matplotlib GUI backend, and automatica
8299 8299 lly select the proper threading model to prevent blocking.
8300 8300 It also sets matplotlib in interactive mode and modifies
8301 8301 \family typewriter
8302 8302 %run
8303 8303 \family default
8304 8304 slightly, so that any matplotlib-based script can be executed using
8305 8305 \family typewriter
8306 8306 %run
8307 8307 \family default
8308 8308 and the final
8309 8309 \family typewriter
8310 8310 show()
8311 8311 \family default
8312 8312 command does not block the interactive shell.
8313 8313 \layout Standard
8314 8314
8315 8315 The
8316 8316 \family typewriter
8317 8317 -pylab
8318 8318 \family default
8319 8319 option must be given first in order for IPython to configure its threading
8320 8320 mode.
8321 8321 However, you can still issue other options afterwards.
8322 8322 This allows you to have a matplotlib-based environment customized with
8323 8323 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
8324 8324
8325 8325 \begin_inset LatexCommand \ref{sec:profiles}
8326 8326
8327 8327 \end_inset
8328 8328
8329 8329 ): ``
8330 8330 \family typewriter
8331 8331 ipython -pylab -p myprofile
8332 8332 \family default
8333 8333 '' will load the profile defined in
8334 8334 \family typewriter
8335 8335 ipythonrc-myprofile
8336 8336 \family default
8337 8337 after configuring matplotlib.
8338 8338 \layout Section
8339 8339
8340 8340
8341 8341 \begin_inset LatexCommand \label{sec:Gnuplot}
8342 8342
8343 8343 \end_inset
8344 8344
8345 8345 Plotting with
8346 8346 \family typewriter
8347 8347 Gnuplot
8348 8348 \layout Standard
8349 8349
8350 8350 Through the magic extension system described in sec.
8351 8351
8352 8352 \begin_inset LatexCommand \ref{sec:magic}
8353 8353
8354 8354 \end_inset
8355 8355
8356 8356 , IPython incorporates a mechanism for conveniently interfacing with the
8357 8357 Gnuplot system (
8358 8358 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
8359 8359
8360 8360 \end_inset
8361 8361
8362 8362 ).
8363 8363 Gnuplot is a very complete 2D and 3D plotting package available for many
8364 8364 operating systems and commonly included in modern Linux distributions.
8365 8365
8366 8366 \layout Standard
8367 8367
8368 8368 Besides having Gnuplot installed, this functionality requires the
8369 8369 \family typewriter
8370 8370 Gnuplot.py
8371 8371 \family default
8372 8372 module for interfacing python with Gnuplot.
8373 8373 It can be downloaded from:
8374 8374 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8375 8375
8376 8376 \end_inset
8377 8377
8378 8378 .
8379 8379 \layout Subsection
8380 8380
8381 8381 Proper Gnuplot configuration
8382 8382 \layout Standard
8383 8383
8384 8384 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8385 8385 However, as of
8386 8386 \family typewriter
8387 8387 Gnuplot.py
8388 8388 \family default
8389 8389 version 1.7, a new option was added to communicate between Python and Gnuplot
8390 8390 via FIFOs (pipes).
8391 8391 This mechanism, while fast, also breaks the mouse system.
8392 8392 You must therefore set the variable
8393 8393 \family typewriter
8394 8394 prefer_fifo_data
8395 8395 \family default
8396 8396 to
8397 8397 \family typewriter
8398 8398 0
8399 8399 \family default
8400 8400 in file
8401 8401 \family typewriter
8402 8402 gp_unix.py
8403 8403 \family default
8404 8404 if you wish to keep the interactive mouse and keyboard features working
8405 8405 properly (
8406 8406 \family typewriter
8407 8407 prefer_inline_data
8408 8408 \family default
8409 8409 also must be
8410 8410 \family typewriter
8411 8411 0
8412 8412 \family default
8413 8413 , but this is the default so unless you've changed it manually you should
8414 8414 be fine).
8415 8415 \layout Standard
8416 8416
8417 8417 'Out of the box', Gnuplot is configured with a rather poor set of size,
8418 8418 color and linewidth choices which make the graphs fairly hard to read on
8419 8419 modern high-resolution displays (although they work fine on old 640x480
8420 8420 ones).
8421 8421 Below is a section of my
8422 8422 \family typewriter
8423 8423 .Xdefaults
8424 8424 \family default
8425 8425 file which I use for having a more convenient Gnuplot setup.
8426 8426 Remember to load it by running
8427 8427 \family typewriter
8428 8428 `xrdb .Xdefaults`
8429 8429 \family default
8430 8430 :
8431 8431 \layout Standard
8432 8432
8433 8433
8434 8434 \family typewriter
8435 8435 !******************************************************************
8436 8436 \newline
8437 8437 ! gnuplot options
8438 8438 \newline
8439 8439 ! modify this for a convenient window size
8440 8440 \newline
8441 8441 gnuplot*geometry: 780x580
8442 8442 \layout Standard
8443 8443
8444 8444
8445 8445 \family typewriter
8446 8446 ! on-screen font (not for PostScript)
8447 8447 \newline
8448 8448 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8449 8449 \layout Standard
8450 8450
8451 8451
8452 8452 \family typewriter
8453 8453 ! color options
8454 8454 \newline
8455 8455 gnuplot*background: black
8456 8456 \newline
8457 8457 gnuplot*textColor: white
8458 8458 \newline
8459 8459 gnuplot*borderColor: white
8460 8460 \newline
8461 8461 gnuplot*axisColor: white
8462 8462 \newline
8463 8463 gnuplot*line1Color: red
8464 8464 \newline
8465 8465 gnuplot*line2Color: green
8466 8466 \newline
8467 8467 gnuplot*line3Color: blue
8468 8468 \newline
8469 8469 gnuplot*line4Color: magenta
8470 8470 \newline
8471 8471 gnuplot*line5Color: cyan
8472 8472 \newline
8473 8473 gnuplot*line6Color: sienna
8474 8474 \newline
8475 8475 gnuplot*line7Color: orange
8476 8476 \newline
8477 8477 gnuplot*line8Color: coral
8478 8478 \layout Standard
8479 8479
8480 8480
8481 8481 \family typewriter
8482 8482 ! multiplicative factor for point styles
8483 8483 \newline
8484 8484 gnuplot*pointsize: 2
8485 8485 \layout Standard
8486 8486
8487 8487
8488 8488 \family typewriter
8489 8489 ! line width options (in pixels)
8490 8490 \newline
8491 8491 gnuplot*borderWidth: 2
8492 8492 \newline
8493 8493 gnuplot*axisWidth: 2
8494 8494 \newline
8495 8495 gnuplot*line1Width: 2
8496 8496 \newline
8497 8497 gnuplot*line2Width: 2
8498 8498 \newline
8499 8499 gnuplot*line3Width: 2
8500 8500 \newline
8501 8501 gnuplot*line4Width: 2
8502 8502 \newline
8503 8503 gnuplot*line5Width: 2
8504 8504 \newline
8505 8505 gnuplot*line6Width: 2
8506 8506 \newline
8507 8507 gnuplot*line7Width: 2
8508 8508 \newline
8509 8509 gnuplot*line8Width: 2
8510 8510 \layout Subsection
8511 8511
8512 8512 The
8513 8513 \family typewriter
8514 8514 IPython.GnuplotRuntime
8515 8515 \family default
8516 8516 module
8517 8517 \layout Standard
8518 8518
8519 8519 IPython includes a module called
8520 8520 \family typewriter
8521 8521 Gnuplot2.py
8522 8522 \family default
8523 8523 which extends and improves the default
8524 8524 \family typewriter
8525 8525 Gnuplot
8526 8526 \family default
8527 8527 .
8528 8528 \family typewriter
8529 8529 py
8530 8530 \family default
8531 8531 (which it still relies upon).
8532 8532 For example, the new
8533 8533 \family typewriter
8534 8534 plot
8535 8535 \family default
8536 8536 function adds several improvements to the original making it more convenient
8537 8537 for interactive use, and
8538 8538 \family typewriter
8539 8539 hardcopy
8540 8540 \family default
8541 8541 fixes a bug in the original which under some circumstances blocks the creation
8542 8542 of PostScript output.
8543 8543 \layout Standard
8544 8544
8545 8545 For scripting use,
8546 8546 \family typewriter
8547 8547 GnuplotRuntime.py
8548 8548 \family default
8549 8549 is provided, which wraps
8550 8550 \family typewriter
8551 8551 Gnuplot2.py
8552 8552 \family default
8553 8553 and creates a series of global aliases.
8554 8554 These make it easy to control Gnuplot plotting jobs through the Python
8555 8555 language.
8556 8556 \layout Standard
8557 8557
8558 8558 Below is some example code which illustrates how to configure Gnuplot inside
8559 8559 your own programs but have it available for further interactive use through
8560 8560 an embedded IPython instance.
8561 8561 Simply run this file at a system prompt.
8562 8562 This file is provided as
8563 8563 \family typewriter
8564 8564 example-gnuplot.py
8565 8565 \family default
8566 8566 in the examples directory:
8567 8567 \layout Standard
8568 8568
8569 8569
8570 8570 \begin_inset ERT
8571 8571 status Open
8572 8572
8573 8573 \layout Standard
8574 8574
8575 8575 \backslash
8576 8576 codelist{examples/example-gnuplot.py}
8577 8577 \end_inset
8578 8578
8579 8579
8580 8580 \layout Subsection
8581 8581
8582 8582 The
8583 8583 \family typewriter
8584 8584 numeric
8585 8585 \family default
8586 8586 profile: a scientific computing environment
8587 8587 \layout Standard
8588 8588
8589 8589 The
8590 8590 \family typewriter
8591 8591 numeric
8592 8592 \family default
8593 8593 IPython profile, which you can activate with
8594 8594 \family typewriter
8595 8595 `ipython -p numeric
8596 8596 \family default
8597 8597 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8598 8598 other useful things for numerical computing), contained in the
8599 8599 \family typewriter
8600 8600 IPython.GnuplotInteractive
8601 8601 \family default
8602 8602 module.
8603 8603 This will create the globals
8604 8604 \family typewriter
8605 8605 Gnuplot
8606 8606 \family default
8607 8607 (an alias to the improved Gnuplot2 module),
8608 8608 \family typewriter
8609 8609 gp
8610 8610 \family default
8611 8611 (a Gnuplot active instance), the new magic commands
8612 8612 \family typewriter
8613 8613 %gpc
8614 8614 \family default
8615 8615 and
8616 8616 \family typewriter
8617 8617 %gp_set_instance
8618 8618 \family default
8619 8619 and several other convenient globals.
8620 8620 Type
8621 8621 \family typewriter
8622 8622 gphelp()
8623 8623 \family default
8624 8624 for further details.
8625 8625 \layout Standard
8626 8626
8627 8627 This should turn IPython into a convenient environment for numerical computing,
8628 8628 with all the functions in the NumPy library and the Gnuplot facilities
8629 8629 for plotting.
8630 8630 Further improvements can be obtained by loading the SciPy libraries for
8631 8631 scientific computing, available at
8632 8632 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8633 8633
8634 8634 \end_inset
8635 8635
8636 8636 .
8637 8637 \layout Standard
8638 8638
8639 8639 If you are in the middle of a working session with numerical objects and
8640 8640 need to plot them but you didn't start the
8641 8641 \family typewriter
8642 8642 numeric
8643 8643 \family default
8644 8644 profile, you can load these extensions at any time by typing
8645 8645 \newline
8646 8646
8647 8647 \family typewriter
8648 8648 from IPython.GnuplotInteractive import *
8649 8649 \newline
8650 8650
8651 8651 \family default
8652 8652 at the IPython prompt.
8653 8653 This will allow you to keep your objects intact and start using Gnuplot
8654 8654 to view them.
8655 8655 \layout Section
8656 8656
8657 8657 Reporting bugs
8658 8658 \layout Subsection*
8659 8659
8660 8660 Automatic crash reports
8661 8661 \layout Standard
8662 8662
8663 8663 Ideally, IPython itself shouldn't crash.
8664 8664 It will catch exceptions produced by you, but bugs in its internals will
8665 8665 still crash it.
8666 8666 \layout Standard
8667 8667
8668 8668 In such a situation, IPython will leave a file named
8669 8669 \family typewriter
8670 8670 IPython_crash_report.txt
8671 8671 \family default
8672 8672 in your IPYTHONDIR directory (that way if crashes happen several times
8673 8673 it won't litter many directories, the post-mortem file is always located
8674 8674 in the same place and new occurrences just overwrite the previous one).
8675 8675 If you can mail this file to the developers (see sec.
8676 8676
8677 8677 \begin_inset LatexCommand \ref{sec:credits}
8678 8678
8679 8679 \end_inset
8680 8680
8681 8681 for names and addresses), it will help us
8682 8682 \emph on
8683 8683 a lot
8684 8684 \emph default
8685 8685 in understanding the cause of the problem and fixing it sooner.
8686 8686 \layout Subsection*
8687 8687
8688 8688 The bug tracker
8689 8689 \layout Standard
8690 8690
8691 8691 IPython also has an online bug-tracker, located at
8692 8692 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8693 8693
8694 8694 \end_inset
8695 8695
8696 8696 .
8697 8697 In addition to mailing the developers, it would be a good idea to file
8698 8698 a bug report here.
8699 8699 This will ensure that the issue is properly followed to conclusion.
8700 8700 \layout Standard
8701 8701
8702 8702 You can also use this bug tracker to file feature requests.
8703 8703 \layout Section
8704 8704
8705 8705 Brief history
8706 8706 \layout Subsection
8707 8707
8708 8708 Origins
8709 8709 \layout Standard
8710 8710
8711 8711 The current IPython system grew out of the following three projects:
8712 8712 \layout List
8713 8713 \labelwidthstring 00.00.0000
8714 8714
8715 8715 ipython by Fernando P
8716 8716 \begin_inset ERT
8717 8717 status Collapsed
8718 8718
8719 8719 \layout Standard
8720 8720
8721 8721 \backslash
8722 8722 '{e}
8723 8723 \end_inset
8724 8724
8725 8725 rez.
8726 8726 I was working on adding Mathematica-type prompts and a flexible configuration
8727 8727 system (something better than
8728 8728 \family typewriter
8729 8729 $PYTHONSTARTUP
8730 8730 \family default
8731 8731 ) to the standard Python interactive interpreter.
8732 8732 \layout List
8733 8733 \labelwidthstring 00.00.0000
8734 8734
8735 8735 IPP by Janko Hauser.
8736 8736 Very well organized, great usability.
8737 8737 Had an old help system.
8738 8738 IPP was used as the `container' code into which I added the functionality
8739 8739 from ipython and LazyPython.
8740 8740 \layout List
8741 8741 \labelwidthstring 00.00.0000
8742 8742
8743 8743 LazyPython by Nathan Gray.
8744 8744 Simple but
8745 8745 \emph on
8746 8746 very
8747 8747 \emph default
8748 8748 powerful.
8749 8749 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8750 8750 were all taken from here.
8751 8751 \layout Standard
8752 8752
8753 8753 When I found out (see sec.
8754 8754
8755 8755 \begin_inset LatexCommand \ref{figgins}
8756 8756
8757 8757 \end_inset
8758 8758
8759 8759 ) about IPP and LazyPython I tried to join all three into a unified system.
8760 8760 I thought this could provide a very nice working environment, both for
8761 8761 regular programming and scientific computing: shell-like features, IDL/Matlab
8762 8762 numerics, Mathematica-type prompt history and great object introspection
8763 8763 and help facilities.
8764 8764 I think it worked reasonably well, though it was a lot more work than I
8765 8765 had initially planned.
8766 8766 \layout Subsection
8767 8767
8768 8768 Current status
8769 8769 \layout Standard
8770 8770
8771 8771 The above listed features work, and quite well for the most part.
8772 8772 But until a major internal restructuring is done (see below), only bug
8773 8773 fixing will be done, no other features will be added (unless very minor
8774 8774 and well localized in the cleaner parts of the code).
8775 8775 \layout Standard
8776 8776
8777 8777 IPython consists of some 18000 lines of pure python code, of which roughly
8778 8778 two thirds is reasonably clean.
8779 8779 The rest is, messy code which needs a massive restructuring before any
8780 8780 further major work is done.
8781 8781 Even the messy code is fairly well documented though, and most of the problems
8782 8782 in the (non-existent) class design are well pointed to by a PyChecker run.
8783 8783 So the rewriting work isn't that bad, it will just be time-consuming.
8784 8784 \layout Subsection
8785 8785
8786 8786 Future
8787 8787 \layout Standard
8788 8788
8789 8789 See the separate
8790 8790 \family typewriter
8791 8791 new_design
8792 8792 \family default
8793 8793 document for details.
8794 8794 Ultimately, I would like to see IPython become part of the standard Python
8795 8795 distribution as a `big brother with batteries' to the standard Python interacti
8796 8796 ve interpreter.
8797 8797 But that will never happen with the current state of the code, so all contribut
8798 8798 ions are welcome.
8799 8799 \layout Section
8800 8800
8801 8801 License
8802 8802 \layout Standard
8803 8803
8804 8804 IPython is released under the terms of the BSD license, whose general form
8805 8805 can be found at:
8806 8806 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8807 8807
8808 8808 \end_inset
8809 8809
8810 8810 .
8811 8811 The full text of the IPython license is reproduced below:
8812 8812 \layout Quote
8813 8813
8814 8814
8815 8815 \family typewriter
8816 8816 \size small
8817 8817 IPython is released under a BSD-type license.
8818 8818 \layout Quote
8819 8819
8820 8820
8821 8821 \family typewriter
8822 8822 \size small
8823 8823 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8824 8824 \layout Quote
8825 8825
8826 8826
8827 8827 \family typewriter
8828 8828 \size small
8829 8829 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8830 8830 \newline
8831 8831 Nathaniel Gray <n8gray@caltech.edu>.
8832 8832 \layout Quote
8833 8833
8834 8834
8835 8835 \family typewriter
8836 8836 \size small
8837 8837 All rights reserved.
8838 8838 \layout Quote
8839 8839
8840 8840
8841 8841 \family typewriter
8842 8842 \size small
8843 8843 Redistribution and use in source and binary forms, with or without modification,
8844 8844 are permitted provided that the following conditions are met:
8845 8845 \layout Quote
8846 8846
8847 8847
8848 8848 \family typewriter
8849 8849 \size small
8850 8850 a.
8851 8851 Redistributions of source code must retain the above copyright notice,
8852 8852 this list of conditions and the following disclaimer.
8853 8853 \layout Quote
8854 8854
8855 8855
8856 8856 \family typewriter
8857 8857 \size small
8858 8858 b.
8859 8859 Redistributions in binary form must reproduce the above copyright notice,
8860 8860 this list of conditions and the following disclaimer in the documentation
8861 8861 and/or other materials provided with the distribution.
8862 8862 \layout Quote
8863 8863
8864 8864
8865 8865 \family typewriter
8866 8866 \size small
8867 8867 c.
8868 8868 Neither the name of the copyright holders nor the names of any contributors
8869 8869 to this software may be used to endorse or promote products derived from
8870 8870 this software without specific prior written permission.
8871 8871 \layout Quote
8872 8872
8873 8873
8874 8874 \family typewriter
8875 8875 \size small
8876 8876 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8877 8877 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8878 8878 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8879 8879 PURPOSE ARE DISCLAIMED.
8880 8880 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8881 8881 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8882 8882 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8883 8883 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8884 8884 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8885 8885 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8886 8886 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8887 8887
8888 8888 \layout Standard
8889 8889
8890 8890 Individual authors are the holders of the copyright for their code and are
8891 8891 listed in each file.
8892 8892 \layout Standard
8893 8893
8894 8894 Some files (
8895 8895 \family typewriter
8896 8896 DPyGetOpt.py
8897 8897 \family default
8898 8898 , for example) may be licensed under different conditions.
8899 8899 Ultimately each file indicates clearly the conditions under which its author/au
8900 8900 thors have decided to publish the code.
8901 8901 \layout Standard
8902 8902
8903 8903 Versions of IPython up to and including 0.6.3 were released under the GNU
8904 8904 Lesser General Public License (LGPL), available at
8905 8905 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8906 8906
8907 8907 \end_inset
8908 8908
8909 8909 .
8910 8910 \layout Section
8911 8911
8912 8912
8913 8913 \begin_inset LatexCommand \label{sec:credits}
8914 8914
8915 8915 \end_inset
8916 8916
8917 8917 Credits
8918 8918 \layout Standard
8919 8919
8920 8920 IPython is mainly developed by Fernando P
8921 8921 \begin_inset ERT
8922 8922 status Collapsed
8923 8923
8924 8924 \layout Standard
8925 8925
8926 8926 \backslash
8927 8927 '{e}
8928 8928 \end_inset
8929 8929
8930 8930 rez
8931 8931 \family typewriter
8932 8932 <Fernando.Perez@colorado.edu>
8933 8933 \family default
8934 8934 , but the project was born from mixing in Fernando's code with the IPP project
8935 8935 by Janko Hauser
8936 8936 \family typewriter
8937 8937 <jhauser-AT-zscout.de>
8938 8938 \family default
8939 8939 and LazyPython by Nathan Gray
8940 8940 \family typewriter
8941 8941 <n8gray-AT-caltech.edu>
8942 8942 \family default
8943 8943 .
8944 8944 For all IPython-related requests, please contact Fernando.
8945 8945
8946 8946 \layout Standard
8947 8947
8948 8948 As of early 2006, the following developers have joined the core team:
8949 8949 \layout List
8950 8950 \labelwidthstring 00.00.0000
8951 8951
8952 8952 Robert\SpecialChar ~
8953 8953 Kern
8954 8954 \family typewriter
8955 8955 <rkern-AT-enthought.com>
8956 8956 \family default
8957 8957 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8958 8958 ve notebooks (XML documents) and graphical interface.
8959 8959 This project was awarded to the students Tzanko Matev
8960 8960 \family typewriter
8961 8961 <tsanko-AT-gmail.com>
8962 8962 \family default
8963 8963 and Toni Alatalo
8964 8964 \family typewriter
8965 8965 <antont-AT-an.org>
8966 8966 \layout List
8967 8967 \labelwidthstring 00.00.0000
8968 8968
8969 8969 Brian\SpecialChar ~
8970 8970 Granger
8971 8971 \family typewriter
8972 8972 <bgranger-AT-scu.edu>
8973 8973 \family default
8974 8974 : extending IPython to allow support for interactive parallel computing.
8975 8975 \layout List
8976 8976 \labelwidthstring 00.00.0000
8977 8977
8978 8978 Ville\SpecialChar ~
8979 8979 Vainio
8980 8980 \family typewriter
8981 8981 <vivainio-AT-gmail.com>
8982 8982 \family default
8983 8983 : Ville is the new maintainer for the main trunk of IPython after version
8984 8984 0.7.1.
8985 8985 \layout Standard
8986 8986
8987 8987 User or development help should be requested via the IPython mailing lists:
8988 8988 \layout Description
8989 8989
8990 8990 User\SpecialChar ~
8991 8991 list:
8992 8992 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8993 8993
8994 8994 \end_inset
8995 8995
8996 8996
8997 8997 \layout Description
8998 8998
8999 8999 Developer's\SpecialChar ~
9000 9000 list:
9001 9001 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
9002 9002
9003 9003 \end_inset
9004 9004
9005 9005
9006 9006 \layout Standard
9007 9007
9008 9008 The IPython project is also very grateful to
9009 9009 \begin_inset Foot
9010 9010 collapsed true
9011 9011
9012 9012 \layout Standard
9013 9013
9014 9014 I've mangled email addresses to reduce spam, since the IPython manuals can
9015 9015 be accessed online.
9016 9016 \end_inset
9017 9017
9018 9018 :
9019 9019 \layout Standard
9020 9020
9021 9021 Bill Bumgarner
9022 9022 \family typewriter
9023 9023 <bbum-AT-friday.com>
9024 9024 \family default
9025 9025 : for providing the DPyGetOpt module which gives very powerful and convenient
9026 9026 handling of command-line options (light years ahead of what Python 2.1.1's
9027 9027 getopt module does).
9028 9028 \layout Standard
9029 9029
9030 9030 Ka-Ping Yee
9031 9031 \family typewriter
9032 9032 <ping-AT-lfw.org>
9033 9033 \family default
9034 9034 : for providing the Itpl module for convenient and powerful string interpolation
9035 9035 with a much nicer syntax than formatting through the '%' operator.
9036 9036 \layout Standard
9037 9037
9038 9038 Arnd Baecker
9039 9039 \family typewriter
9040 9040 <baecker-AT-physik.tu-dresden.de>
9041 9041 \family default
9042 9042 : for his many very useful suggestions and comments, and lots of help with
9043 9043 testing and documentation checking.
9044 9044 Many of IPython's newer features are a result of discussions with him (bugs
9045 9045 are still my fault, not his).
9046 9046 \layout Standard
9047 9047
9048 9048 Obviously Guido van\SpecialChar ~
9049 9049 Rossum and the whole Python development team, that goes
9050 9050 without saying.
9051 9051 \layout Standard
9052 9052
9053 9053 IPython's website is generously hosted at
9054 9054 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
9055 9055
9056 9056 \end_inset
9057 9057
9058 9058 by Enthought (
9059 9059 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
9060 9060
9061 9061 \end_inset
9062 9062
9063 9063 ).
9064 9064 I am very grateful to them and all of the SciPy team for their contribution.
9065 9065 \layout Standard
9066 9066
9067 9067
9068 9068 \begin_inset LatexCommand \label{figgins}
9069 9069
9070 9070 \end_inset
9071 9071
9072 9072 Fernando would also like to thank Stephen Figgins
9073 9073 \family typewriter
9074 9074 <fig-AT-monitor.net>
9075 9075 \family default
9076 9076 , an O'Reilly Python editor.
9077 9077 His Oct/11/2001 article about IPP and LazyPython, was what got this project
9078 9078 started.
9079 9079 You can read it at:
9080 9080 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
9081 9081
9082 9082 \end_inset
9083 9083
9084 9084 .
9085 9085 \layout Standard
9086 9086
9087 9087 And last but not least, all the kind IPython users who have emailed new
9088 9088 code, bug reports, fixes, comments and ideas.
9089 9089 A brief list follows, please let me know if I have ommitted your name by
9090 9090 accident:
9091 9091 \layout List
9092 9092 \labelwidthstring 00.00.0000
9093 9093
9094 9094 Jack\SpecialChar ~
9095 9095 Moffit
9096 9096 \family typewriter
9097 9097 <jack-AT-xiph.org>
9098 9098 \family default
9099 9099 Bug fixes, including the infamous color problem.
9100 9100 This bug alone caused many lost hours and frustration, many thanks to him
9101 9101 for the fix.
9102 9102 I've always been a fan of Ogg & friends, now I have one more reason to
9103 9103 like these folks.
9104 9104 \newline
9105 9105 Jack is also contributing with Debian packaging and many other things.
9106 9106 \layout List
9107 9107 \labelwidthstring 00.00.0000
9108 9108
9109 9109 Alexander\SpecialChar ~
9110 9110 Schmolck
9111 9111 \family typewriter
9112 9112 <a.schmolck-AT-gmx.net>
9113 9113 \family default
9114 9114 Emacs work, bug reports, bug fixes, ideas, lots more.
9115 9115 The ipython.el mode for (X)Emacs is Alex's code, providing full support
9116 9116 for IPython under (X)Emacs.
9117 9117 \layout List
9118 9118 \labelwidthstring 00.00.0000
9119 9119
9120 9120 Andrea\SpecialChar ~
9121 9121 Riciputi
9122 9122 \family typewriter
9123 9123 <andrea.riciputi-AT-libero.it>
9124 9124 \family default
9125 9125 Mac OSX information, Fink package management.
9126 9126 \layout List
9127 9127 \labelwidthstring 00.00.0000
9128 9128
9129 9129 Gary\SpecialChar ~
9130 9130 Bishop
9131 9131 \family typewriter
9132 9132 <gb-AT-cs.unc.edu>
9133 9133 \family default
9134 9134 Bug reports, and patches to work around the exception handling idiosyncracies
9135 9135 of WxPython.
9136 9136 Readline and color support for Windows.
9137 9137 \layout List
9138 9138 \labelwidthstring 00.00.0000
9139 9139
9140 9140 Jeffrey\SpecialChar ~
9141 9141 Collins
9142 9142 \family typewriter
9143 9143 <Jeff.Collins-AT-vexcel.com>
9144 9144 \family default
9145 9145 Bug reports.
9146 9146 Much improved readline support, including fixes for Python 2.3.
9147 9147 \layout List
9148 9148 \labelwidthstring 00.00.0000
9149 9149
9150 9150 Dryice\SpecialChar ~
9151 9151 Liu
9152 9152 \family typewriter
9153 9153 <dryice-AT-liu.com.cn>
9154 9154 \family default
9155 9155 FreeBSD port.
9156 9156 \layout List
9157 9157 \labelwidthstring 00.00.0000
9158 9158
9159 9159 Mike\SpecialChar ~
9160 9160 Heeter
9161 9161 \family typewriter
9162 9162 <korora-AT-SDF.LONESTAR.ORG>
9163 9163 \layout List
9164 9164 \labelwidthstring 00.00.0000
9165 9165
9166 9166 Christopher\SpecialChar ~
9167 9167 Hart
9168 9168 \family typewriter
9169 9169 <hart-AT-caltech.edu>
9170 9170 \family default
9171 9171 PDB integration.
9172 9172 \layout List
9173 9173 \labelwidthstring 00.00.0000
9174 9174
9175 9175 Milan\SpecialChar ~
9176 9176 Zamazal
9177 9177 \family typewriter
9178 9178 <pdm-AT-zamazal.org>
9179 9179 \family default
9180 9180 Emacs info.
9181 9181 \layout List
9182 9182 \labelwidthstring 00.00.0000
9183 9183
9184 9184 Philip\SpecialChar ~
9185 9185 Hisley
9186 9186 \family typewriter
9187 9187 <compsys-AT-starpower.net>
9188 9188 \layout List
9189 9189 \labelwidthstring 00.00.0000
9190 9190
9191 9191 Holger\SpecialChar ~
9192 9192 Krekel
9193 9193 \family typewriter
9194 9194 <pyth-AT-devel.trillke.net>
9195 9195 \family default
9196 9196 Tab completion, lots more.
9197 9197 \layout List
9198 9198 \labelwidthstring 00.00.0000
9199 9199
9200 9200 Robin\SpecialChar ~
9201 9201 Siebler
9202 9202 \family typewriter
9203 9203 <robinsiebler-AT-starband.net>
9204 9204 \layout List
9205 9205 \labelwidthstring 00.00.0000
9206 9206
9207 9207 Ralf\SpecialChar ~
9208 9208 Ahlbrink
9209 9209 \family typewriter
9210 9210 <ralf_ahlbrink-AT-web.de>
9211 9211 \layout List
9212 9212 \labelwidthstring 00.00.0000
9213 9213
9214 9214 Thorsten\SpecialChar ~
9215 9215 Kampe
9216 9216 \family typewriter
9217 9217 <thorsten-AT-thorstenkampe.de>
9218 9218 \layout List
9219 9219 \labelwidthstring 00.00.0000
9220 9220
9221 9221 Fredrik\SpecialChar ~
9222 9222 Kant
9223 9223 \family typewriter
9224 9224 <fredrik.kant-AT-front.com>
9225 9225 \family default
9226 9226 Windows setup.
9227 9227 \layout List
9228 9228 \labelwidthstring 00.00.0000
9229 9229
9230 9230 Syver\SpecialChar ~
9231 9231 Enstad
9232 9232 \family typewriter
9233 9233 <syver-en-AT-online.no>
9234 9234 \family default
9235 9235 Windows setup.
9236 9236 \layout List
9237 9237 \labelwidthstring 00.00.0000
9238 9238
9239 9239 Richard
9240 9240 \family typewriter
9241 9241 <rxe-AT-renre-europe.com>
9242 9242 \family default
9243 9243 Global embedding.
9244 9244 \layout List
9245 9245 \labelwidthstring 00.00.0000
9246 9246
9247 9247 Hayden\SpecialChar ~
9248 9248 Callow
9249 9249 \family typewriter
9250 9250 <h.callow-AT-elec.canterbury.ac.nz>
9251 9251 \family default
9252 9252 Gnuplot.py 1.6 compatibility.
9253 9253 \layout List
9254 9254 \labelwidthstring 00.00.0000
9255 9255
9256 9256 Leonardo\SpecialChar ~
9257 9257 Santagada
9258 9258 \family typewriter
9259 9259 <retype-AT-terra.com.br>
9260 9260 \family default
9261 9261 Fixes for Windows installation.
9262 9262 \layout List
9263 9263 \labelwidthstring 00.00.0000
9264 9264
9265 9265 Christopher\SpecialChar ~
9266 9266 Armstrong
9267 9267 \family typewriter
9268 9268 <radix-AT-twistedmatrix.com>
9269 9269 \family default
9270 9270 Bugfixes.
9271 9271 \layout List
9272 9272 \labelwidthstring 00.00.0000
9273 9273
9274 9274 Francois\SpecialChar ~
9275 9275 Pinard
9276 9276 \family typewriter
9277 9277 <pinard-AT-iro.umontreal.ca>
9278 9278 \family default
9279 9279 Code and documentation fixes.
9280 9280 \layout List
9281 9281 \labelwidthstring 00.00.0000
9282 9282
9283 9283 Cory\SpecialChar ~
9284 9284 Dodt
9285 9285 \family typewriter
9286 9286 <cdodt-AT-fcoe.k12.ca.us>
9287 9287 \family default
9288 9288 Bug reports and Windows ideas.
9289 9289 Patches for Windows installer.
9290 9290 \layout List
9291 9291 \labelwidthstring 00.00.0000
9292 9292
9293 9293 Olivier\SpecialChar ~
9294 9294 Aubert
9295 9295 \family typewriter
9296 9296 <oaubert-AT-bat710.univ-lyon1.fr>
9297 9297 \family default
9298 9298 New magics.
9299 9299 \layout List
9300 9300 \labelwidthstring 00.00.0000
9301 9301
9302 9302 King\SpecialChar ~
9303 9303 C.\SpecialChar ~
9304 9304 Shu
9305 9305 \family typewriter
9306 9306 <kingshu-AT-myrealbox.com>
9307 9307 \family default
9308 9308 Autoindent patch.
9309 9309 \layout List
9310 9310 \labelwidthstring 00.00.0000
9311 9311
9312 9312 Chris\SpecialChar ~
9313 9313 Drexler
9314 9314 \family typewriter
9315 9315 <chris-AT-ac-drexler.de>
9316 9316 \family default
9317 9317 Readline packages for Win32/CygWin.
9318 9318 \layout List
9319 9319 \labelwidthstring 00.00.0000
9320 9320
9321 9321 Gustavo\SpecialChar ~
9322 9322 Cordova\SpecialChar ~
9323 9323 Avila
9324 9324 \family typewriter
9325 9325 <gcordova-AT-sismex.com>
9326 9326 \family default
9327 9327 EvalDict code for nice, lightweight string interpolation.
9328 9328 \layout List
9329 9329 \labelwidthstring 00.00.0000
9330 9330
9331 9331 Kasper\SpecialChar ~
9332 9332 Souren
9333 9333 \family typewriter
9334 9334 <Kasper.Souren-AT-ircam.fr>
9335 9335 \family default
9336 9336 Bug reports, ideas.
9337 9337 \layout List
9338 9338 \labelwidthstring 00.00.0000
9339 9339
9340 9340 Gever\SpecialChar ~
9341 9341 Tulley
9342 9342 \family typewriter
9343 9343 <gever-AT-helium.com>
9344 9344 \family default
9345 9345 Code contributions.
9346 9346 \layout List
9347 9347 \labelwidthstring 00.00.0000
9348 9348
9349 9349 Ralf\SpecialChar ~
9350 9350 Schmitt
9351 9351 \family typewriter
9352 9352 <ralf-AT-brainbot.com>
9353 9353 \family default
9354 9354 Bug reports & fixes.
9355 9355 \layout List
9356 9356 \labelwidthstring 00.00.0000
9357 9357
9358 9358 Oliver\SpecialChar ~
9359 9359 Sander
9360 9360 \family typewriter
9361 9361 <osander-AT-gmx.de>
9362 9362 \family default
9363 9363 Bug reports.
9364 9364 \layout List
9365 9365 \labelwidthstring 00.00.0000
9366 9366
9367 9367 Rod\SpecialChar ~
9368 9368 Holland
9369 9369 \family typewriter
9370 9370 <rhh-AT-structurelabs.com>
9371 9371 \family default
9372 9372 Bug reports and fixes to logging module.
9373 9373 \layout List
9374 9374 \labelwidthstring 00.00.0000
9375 9375
9376 9376 Daniel\SpecialChar ~
9377 9377 'Dang'\SpecialChar ~
9378 9378 Griffith
9379 9379 \family typewriter
9380 9380 <pythondev-dang-AT-lazytwinacres.net>
9381 9381 \family default
9382 9382 Fixes, enhancement suggestions for system shell use.
9383 9383 \layout List
9384 9384 \labelwidthstring 00.00.0000
9385 9385
9386 9386 Viktor\SpecialChar ~
9387 9387 Ransmayr
9388 9388 \family typewriter
9389 9389 <viktor.ransmayr-AT-t-online.de>
9390 9390 \family default
9391 9391 Tests and reports on Windows installation issues.
9392 9392 Contributed a true Windows binary installer.
9393 9393 \layout List
9394 9394 \labelwidthstring 00.00.0000
9395 9395
9396 9396 Mike\SpecialChar ~
9397 9397 Salib
9398 9398 \family typewriter
9399 9399 <msalib-AT-mit.edu>
9400 9400 \family default
9401 9401 Help fixing a subtle bug related to traceback printing.
9402 9402 \layout List
9403 9403 \labelwidthstring 00.00.0000
9404 9404
9405 9405 W.J.\SpecialChar ~
9406 9406 van\SpecialChar ~
9407 9407 der\SpecialChar ~
9408 9408 Laan
9409 9409 \family typewriter
9410 9410 <gnufnork-AT-hetdigitalegat.nl>
9411 9411 \family default
9412 9412 Bash-like prompt specials.
9413 9413 \layout List
9414 9414 \labelwidthstring 00.00.0000
9415 9415
9416 9416 Antoon\SpecialChar ~
9417 9417 Pardon
9418 9418 \family typewriter
9419 9419 <Antoon.Pardon-AT-rece.vub.ac.be>
9420 9420 \family default
9421 9421 Critical fix for the multithreaded IPython.
9422 9422 \layout List
9423 9423 \labelwidthstring 00.00.0000
9424 9424
9425 9425 John\SpecialChar ~
9426 9426 Hunter
9427 9427 \family typewriter
9428 9428 <jdhunter-AT-nitace.bsd.uchicago.edu>
9429 9429 \family default
9430 9430 Matplotlib author, helped with all the development of support for matplotlib
9431 9431 in IPyhton, including making necessary changes to matplotlib itself.
9432 9432 \layout List
9433 9433 \labelwidthstring 00.00.0000
9434 9434
9435 9435 Matthew\SpecialChar ~
9436 9436 Arnison
9437 9437 \family typewriter
9438 9438 <maffew-AT-cat.org.au>
9439 9439 \family default
9440 9440 Bug reports, `
9441 9441 \family typewriter
9442 9442 %run -d
9443 9443 \family default
9444 9444 ' idea.
9445 9445 \layout List
9446 9446 \labelwidthstring 00.00.0000
9447 9447
9448 9448 Prabhu\SpecialChar ~
9449 9449 Ramachandran
9450 9450 \family typewriter
9451 9451 <prabhu_r-AT-users.sourceforge.net>
9452 9452 \family default
9453 9453 Help with (X)Emacs support, threading patches, ideas...
9454 9454 \layout List
9455 9455 \labelwidthstring 00.00.0000
9456 9456
9457 9457 Norbert\SpecialChar ~
9458 9458 Tretkowski
9459 9459 \family typewriter
9460 9460 <tretkowski-AT-inittab.de>
9461 9461 \family default
9462 9462 help with Debian packaging and distribution.
9463 9463 \layout List
9464 9464 \labelwidthstring 00.00.0000
9465 9465
9466 9466 George\SpecialChar ~
9467 9467 Sakkis <
9468 9468 \family typewriter
9469 9469 gsakkis-AT-eden.rutgers.edu>
9470 9470 \family default
9471 9471 New matcher for tab-completing named arguments of user-defined functions.
9472 9472 \layout List
9473 9473 \labelwidthstring 00.00.0000
9474 9474
9475 9475 JοΏ½rgen\SpecialChar ~
9476 9476 Stenarson
9477 9477 \family typewriter
9478 9478 <jorgen.stenarson-AT-bostream.nu>
9479 9479 \family default
9480 9480 Wildcard support implementation for searching namespaces.
9481 9481 \layout List
9482 9482 \labelwidthstring 00.00.0000
9483 9483
9484 9484 Vivian\SpecialChar ~
9485 9485 De\SpecialChar ~
9486 9486 Smedt
9487 9487 \family typewriter
9488 9488 <vivian-AT-vdesmedt.com>
9489 9489 \family default
9490 9490 Debugger enhancements, so that when pdb is activated from within IPython,
9491 9491 coloring, tab completion and other features continue to work seamlessly.
9492 9492 \layout List
9493 9493 \labelwidthstring 00.00.0000
9494 9494
9495 9495 Scott\SpecialChar ~
9496 9496 Tsai
9497 9497 \family typewriter
9498 9498 <scottt958-AT-yahoo.com.tw>
9499 9499 \family default
9500 9500 Support for automatic editor invocation on syntax errors (see
9501 9501 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9502 9502
9503 9503 \end_inset
9504 9504
9505 9505 ).
9506 9506 \layout List
9507 9507 \labelwidthstring 00.00.0000
9508 9508
9509 9509 Alexander\SpecialChar ~
9510 9510 Belchenko
9511 9511 \family typewriter
9512 9512 <bialix-AT-ukr.net>
9513 9513 \family default
9514 9514 Improvements for win32 paging system.
9515 \layout List
9516 \labelwidthstring 00.00.0000
9517
9518 Will\SpecialChar ~
9519 Maier
9520 \family typewriter
9521 <willmaier-AT-ml1.net>
9522 \family default
9523 Official OpenBSD port.
9515 9524 \the_end
@@ -1,102 +1,102 b''
1 1 #!/bin/sh
2 2 # IPython release script
3 3
4 4 PYVER=`python -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1$2}' `
5 5 version=`ipython -Version`
6 6 ipdir=~/ipython/ipython
7 7
8 8 echo
9 9 echo "Releasing IPython version $version"
10 10 echo "=================================="
11 11
12 12 echo "Marking ChangeLog with release information and making NEWS file..."
13 13
14 14 # Stamp changelog and save a copy of the status at each version, in case later
15 15 # we want the NEWS file to start from a point before the very last release (if
16 16 # very small interim releases have no significant changes).
17 17
18 18 cd $ipdir/doc
19 19 cp ChangeLog ChangeLog.old
20 20 cp ChangeLog ChangeLog.$version
21 21 daystamp=`date +%Y-%m-%d`
22 22 echo $daystamp " ***" Released version $version > ChangeLog
23 23 echo >> ChangeLog
24 24 cat ChangeLog.old >> ChangeLog
25 25 rm ChangeLog.old
26 26
27 27 # Build NEWS file
28 28 echo "Changes between the last two releases (major or minor)" > NEWS
29 29 echo "Note that this is an auto-generated diff of the ChangeLogs" >> NEWS
30 30 echo >> NEWS
31 31 diff ChangeLog.previous ChangeLog | grep -v '^0a' | sed 's/^> //g' >> NEWS
32 32 cp ChangeLog ChangeLog.previous
33 33
34 34 # Clean up build/dist directories
35 35 rm -rf $ipdir/build/*
36 36 rm -rf $ipdir/dist/*
37 37
38 38 # Perform local backup
39 39 cd $ipdir/tools
40 40 ./bkp.py
41 41
42 42 # Build source and binary distros
43 43 cd $ipdir
44 44 ./setup.py sdist --formats=gztar
45 45 #./setup.py bdist_rpm --release=py$PYVER
46 46 python2.3 ./setup.py bdist_rpm --release=py23 --python=/usr/bin/python2.3
47 47
48 48 # A 2.4-specific RPM, where we must use the --python option to ensure that
49 49 # the resulting RPM is really built with 2.4 (so things go to
50 50 # lib/python2.4/...)
51 51 python2.4 ./setup.py bdist_rpm --release=py24 --python=/usr/bin/python2.4
52 52
53 53 # Build eggs
54 54 python2.3 ./eggsetup.py bdist_egg
55 55 python2.4 ./eggsetup.py bdist_egg
56 56
57 57 # Call the windows build separately, so that the extra Windows scripts don't
58 58 # get pulled into Unix builds (setup.py has code which checks for
59 59 # bdist_wininst)
60 60 #./setup.py bdist_wininst --install-script=ipython_win_post_install.py
61 61
62 62 # For now, make the win32 installer with a hand-built 2.3.5 python, which is
63 63 # the only one that fixes a crash in the post-install phase.
64 64 $HOME/tmp/local/bin/python2.3 setup.py bdist_wininst \
65 65 --install-script=ipython_win_post_install.py
66 66
67 67 # Register with the Python Package Index (PyPI)
68 68 echo "Registering with PyPI..."
69 69 cd $ipdir
70 70 ./setup.py register
71 71
72 72 # Upload all files
73 73 cd $ipdir/dist
74 74 echo "Uploading distribution files..."
75 75 scp * ipython@ipython.scipy.org:www/dist/
76 76
77 77 echo "Uploading backup files..."
78 78 cd ~/ipython/backup
79 79 scp `ls -1tr | tail -1` ipython@ipython.scipy.org:www/backup/
80 80
81 81 echo "Updating webpage..."
82 82 cd $ipdir/doc
83 83 www=~/ipython/homepage
84 84 cp ChangeLog NEWS $www
85 85 rm -rf $www/doc/*
86 86 cp -r manual.pdf manual/ $www/doc
87 87 cd $www
88 88 ./update
89 89
90 90 # Alert package maintainers
91 91 echo "Alerting package maintainers..."
92 maintainers='fperez@colorado.edu ariciputi@users.sourceforge.net jack@xiph.org tretkowski@inittab.de dryice@hotpop.com'
92 maintainers='fperez@colorado.edu ariciputi@users.sourceforge.net jack@xiph.org tretkowski@inittab.de dryice@hotpop.com willmaier@ml1.net'
93 93 #maintainers='fperez@colorado.edu'
94 94
95 95 for email in $maintainers
96 96 do
97 97 echo "Emailing $email..."
98 98 mail -s "[Package maintainer notice] A new IPython is out. Version: $version" \
99 99 $email < NEWS
100 100 done
101 101
102 102 echo "Done!"
General Comments 0
You need to be logged in to leave comments. Login now