##// END OF EJS Templates
easy_install ipython==dev works correctly now...
vivainio -
Show More
@@ -1,273 +1,270 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Modified input prompt for executing files.
2 """Modified input prompt for executing files.
3
3
4 We define a special input line filter to allow typing lines which begin with
4 We define a special input line filter to allow typing lines which begin with
5 '~', '/' or '.'. If one of those strings is encountered, it is automatically
5 '~', '/' or '.'. If one of those strings is encountered, it is automatically
6 executed.
6 executed.
7
7
8 $Id: InterpreterExec.py 1041 2006-01-21 09:29:14Z vivainio $"""
8 $Id: InterpreterExec.py 1121 2006-02-01 21:12:20Z vivainio $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2004 W.J. van der Laan <gnufnork@hetdigitalegat.nl>
11 # Copyright (C) 2004 W.J. van der Laan <gnufnork@hetdigitalegat.nl>
12 # Copyright (C) 2004-2006 Fernando Perez <fperez@colorado.edu>
12 # Copyright (C) 2004-2006 Fernando Perez <fperez@colorado.edu>
13 #
13 #
14 # Distributed under the terms of the BSD License. The full license is in
14 # Distributed under the terms of the BSD License. The full license is in
15 # the file COPYING, distributed as part of this software.
15 # the file COPYING, distributed as part of this software.
16 #*****************************************************************************
16 #*****************************************************************************
17
17
18 from IPython import Release
18 from IPython import Release
19 __author__ = 'W.J. van der Laan <gnufnork@hetdigitalegat.nl>, '\
19 __author__ = 'W.J. van der Laan <gnufnork@hetdigitalegat.nl>, '\
20 '%s <%s>' % Release.authors['Fernando']
20 '%s <%s>' % Release.authors['Fernando']
21 __license__ = Release.license
21 __license__ = Release.license
22
22
23 # TODO: deprecated
23 def prefilter_shell(self,line,continuation):
24 def prefilter_shell(self,line,continuation):
24 """Alternate prefilter, modified for shell-like functionality.
25 """Alternate prefilter, modified for shell-like functionality.
25
26
26 - Execute all lines beginning with '~', '/' or '.'
27 - Execute all lines beginning with '~', '/' or '.'
27 - $var=cmd <=> %sc var=cmd
28 - $var=cmd <=> %sc var=cmd
28 - $$var=cmd <=> %sc -l var=cmd
29 - $$var=cmd <=> %sc -l var=cmd
29 """
30 """
30
31
31 if line:
32 if line:
32 l0 = line[0]
33 l0 = line[0]
33 if l0 in '~/.':
34 if l0 in '~/.':
34 return self._prefilter("!%s"%line,continuation)
35 return self._prefilter("!%s"%line,continuation)
35 elif l0=='$':
36 elif l0=='$':
36 lrest = line[1:]
37 lrest = line[1:]
37 if lrest.startswith('$'):
38 if lrest.startswith('$'):
38 # $$var=cmd <=> %sc -l var=cmd
39 # $$var=cmd <=> %sc -l var=cmd
39 return self._prefilter("%ssc -l %s" % (self.ESC_MAGIC,lrest[1:]),
40 return self._prefilter("%ssc -l %s" % (self.ESC_MAGIC,lrest[1:]),
40 continuation)
41 continuation)
41 else:
42 else:
42 # $var=cmd <=> %sc var=cmd
43 # $var=cmd <=> %sc var=cmd
43 return self._prefilter("%ssc %s" % (self.ESC_MAGIC,lrest),
44 return self._prefilter("%ssc %s" % (self.ESC_MAGIC,lrest),
44 continuation)
45 continuation)
45 else:
46 else:
46 return self._prefilter(line,continuation)
47 return self._prefilter(line,continuation)
47 else:
48 else:
48 return self._prefilter(line,continuation)
49 return self._prefilter(line,continuation)
49
50
50 # Rebind this to be the new IPython prefilter:
51 # Rebind this to be the new IPython prefilter:
51 from IPython.iplib import InteractiveShell
52 from IPython.iplib import InteractiveShell
52 InteractiveShell.prefilter = prefilter_shell
53 InteractiveShell.prefilter = prefilter_shell
53 # Clean up the namespace.
54 # Clean up the namespace.
54 del InteractiveShell,prefilter_shell
55 del InteractiveShell,prefilter_shell
55
56
56 # Provide pysh and further shell-oriented services
57 # Provide pysh and further shell-oriented services
57 import os,sys,shutil
58 import os,sys,shutil
58 from IPython.genutils import system,shell,getoutput,getoutputerror
59 from IPython.genutils import system,shell,getoutput,getoutputerror
59
60
60 # Short aliases for getting shell output as a string and a list
61 # Short aliases for getting shell output as a string and a list
61 sout = getoutput
62 sout = getoutput
62 lout = lambda cmd: getoutput(cmd,split=1)
63 lout = lambda cmd: getoutput(cmd,split=1)
63
64
64 # Empty function, meant as a docstring holder so help(pysh) works.
65 # Empty function, meant as a docstring holder so help(pysh) works.
65 def pysh():
66 def pysh():
66 """Pysh is a set of modules and extensions to IPython which make shell-like
67 """Pysh is a set of modules and extensions to IPython which make shell-like
67 usage with Python syntax more convenient. Keep in mind that pysh is NOT a
68 usage with Python syntax more convenient. Keep in mind that pysh is NOT a
68 full-blown shell, so don't try to make it your /etc/passwd entry!
69 full-blown shell, so don't try to make it your /etc/passwd entry!
69
70
70 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
71 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
71 you'll suspend pysh itself, not the process you just started.
72 you'll suspend pysh itself, not the process you just started.
72
73
73 Since pysh is really nothing but a customized IPython, you should
74 Since pysh is really nothing but a customized IPython, you should
74 familiarize yourself with IPython's features. This brief help mainly
75 familiarize yourself with IPython's features. This brief help mainly
75 documents areas in which pysh differs from the normal IPython.
76 documents areas in which pysh differs from the normal IPython.
76
77
77 ALIASES
78 ALIASES
78 -------
79 -------
79 All of your $PATH has been loaded as IPython aliases, so you should be
80 All of your $PATH has been loaded as IPython aliases, so you should be
80 able to type any normal system command and have it executed. See %alias?
81 able to type any normal system command and have it executed. See %alias?
81 and %unalias? for details on the alias facilities.
82 and %unalias? for details on the alias facilities.
82
83
83 SPECIAL SYNTAX
84 SPECIAL SYNTAX
84 --------------
85 --------------
85 Any lines which begin with '~', '/' and '.' will be executed as shell
86 Any lines which begin with '~', '/' and '.' will be executed as shell
86 commands instead of as Python code. The special escapes below are also
87 commands instead of as Python code. The special escapes below are also
87 recognized. !cmd is valid in single or multi-line input, all others are
88 recognized. !cmd is valid in single or multi-line input, all others are
88 only valid in single-line input:
89 only valid in single-line input:
89
90
90 !cmd - pass 'cmd' directly to the shell
91 !cmd - pass 'cmd' directly to the shell
91 !!cmd - execute 'cmd' and return output as a list (split on '\\n')
92 !!cmd - execute 'cmd' and return output as a list (split on '\\n')
92 $var=cmd - capture output of cmd into var, as a string
93 $var=cmd - capture output of cmd into var, as a string
93 $$var=cmd - capture output of cmd into var, as a list (split on '\\n')
94 $$var=cmd - capture output of cmd into var, as a list (split on '\\n')
94
95
95 The $/$$ syntaxes make Python variables from system output, which you can
96 The $/$$ syntaxes make Python variables from system output, which you can
96 later use for further scripting. The converse is also possible: when
97 later use for further scripting. The converse is also possible: when
97 executing an alias or calling to the system via !/!!, you can expand any
98 executing an alias or calling to the system via !/!!, you can expand any
98 python variable or expression by prepending it with $. Full details of
99 python variable or expression by prepending it with $. Full details of
99 the allowed syntax can be found in Python's PEP 215.
100 the allowed syntax can be found in Python's PEP 215.
100
101
101 A few brief examples will illustrate these:
102 A few brief examples will illustrate these:
102
103
103 fperez[~/test]|3> !ls *s.py
104 fperez[~/test]|3> !ls *s.py
104 scopes.py strings.py
105 scopes.py strings.py
105
106
106 ls is an internal alias, so there's no need to use !:
107 ls is an internal alias, so there's no need to use !:
107 fperez[~/test]|4> ls *s.py
108 fperez[~/test]|4> ls *s.py
108 scopes.py* strings.py
109 scopes.py* strings.py
109
110
110 !!ls will return the output into a Python variable:
111 !!ls will return the output into a Python variable:
111 fperez[~/test]|5> !!ls *s.py
112 fperez[~/test]|5> !!ls *s.py
112 <5> ['scopes.py', 'strings.py']
113 <5> ['scopes.py', 'strings.py']
113 fperez[~/test]|6> print _5
114 fperez[~/test]|6> print _5
114 ['scopes.py', 'strings.py']
115 ['scopes.py', 'strings.py']
115
116
116 $ and $$ allow direct capture to named variables:
117 $ and $$ allow direct capture to named variables:
117 fperez[~/test]|7> $astr = ls *s.py
118 fperez[~/test]|7> $astr = ls *s.py
118 fperez[~/test]|8> astr
119 fperez[~/test]|8> astr
119 <8> 'scopes.py\\nstrings.py'
120 <8> 'scopes.py\\nstrings.py'
120
121
121 fperez[~/test]|9> $$alist = ls *s.py
122 fperez[~/test]|9> $$alist = ls *s.py
122 fperez[~/test]|10> alist
123 fperez[~/test]|10> alist
123 <10> ['scopes.py', 'strings.py']
124 <10> ['scopes.py', 'strings.py']
124
125
125 alist is now a normal python list you can loop over. Using $ will expand
126 alist is now a normal python list you can loop over. Using $ will expand
126 back the python values when alias calls are made:
127 back the python values when alias calls are made:
127 fperez[~/test]|11> for f in alist:
128 fperez[~/test]|11> for f in alist:
128 |..> print 'file',f,
129 |..> print 'file',f,
129 |..> wc -l $f
130 |..> wc -l $f
130 |..>
131 |..>
131 file scopes.py 13 scopes.py
132 file scopes.py 13 scopes.py
132 file strings.py 4 strings.py
133 file strings.py 4 strings.py
133
134
134 Note that you may need to protect your variables with braces if you want
135 Note that you may need to protect your variables with braces if you want
135 to append strings to their names. To copy all files in alist to .bak
136 to append strings to their names. To copy all files in alist to .bak
136 extensions, you must use:
137 extensions, you must use:
137 fperez[~/test]|12> for f in alist:
138 fperez[~/test]|12> for f in alist:
138 |..> cp $f ${f}.bak
139 |..> cp $f ${f}.bak
139
140
140 If you try using $f.bak, you'll get an AttributeError exception saying
141 If you try using $f.bak, you'll get an AttributeError exception saying
141 that your string object doesn't have a .bak attribute. This is because
142 that your string object doesn't have a .bak attribute. This is because
142 the $ expansion mechanism allows you to expand full Python expressions:
143 the $ expansion mechanism allows you to expand full Python expressions:
143 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
144 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
144 sys.platform is: linux2
145 sys.platform is: linux2
145
146
146 IPython's input history handling is still active, which allows you to
147 IPython's input history handling is still active, which allows you to
147 rerun a single block of multi-line input by simply using exec:
148 rerun a single block of multi-line input by simply using exec:
148 fperez[~/test]|14> $$alist = ls *.eps
149 fperez[~/test]|14> $$alist = ls *.eps
149 fperez[~/test]|15> exec _i11
150 fperez[~/test]|15> exec _i11
150 file image2.eps 921 image2.eps
151 file image2.eps 921 image2.eps
151 file image.eps 921 image.eps
152 file image.eps 921 image.eps
152
153
153 While these are new special-case syntaxes, they are designed to allow very
154 While these are new special-case syntaxes, they are designed to allow very
154 efficient use of the shell with minimal typing. At an interactive shell
155 efficient use of the shell with minimal typing. At an interactive shell
155 prompt, conciseness of expression wins over readability.
156 prompt, conciseness of expression wins over readability.
156
157
157 USEFUL FUNCTIONS AND MODULES
158 USEFUL FUNCTIONS AND MODULES
158 ----------------------------
159 ----------------------------
159 The os, sys and shutil modules from the Python standard library are
160 The os, sys and shutil modules from the Python standard library are
160 automatically loaded. Some additional functions, useful for shell usage,
161 automatically loaded. Some additional functions, useful for shell usage,
161 are listed below. You can request more help about them with '?'.
162 are listed below. You can request more help about them with '?'.
162
163
163 shell - execute a command in the underlying system shell
164 shell - execute a command in the underlying system shell
164 system - like shell(), but return the exit status of the command
165 system - like shell(), but return the exit status of the command
165 sout - capture the output of a command as a string
166 sout - capture the output of a command as a string
166 lout - capture the output of a command as a list (split on '\\n')
167 lout - capture the output of a command as a list (split on '\\n')
167 getoutputerror - capture (output,error) of a shell command
168 getoutputerror - capture (output,error) of a shell command
168
169
169 sout/lout are the functional equivalents of $/$$. They are provided to
170 sout/lout are the functional equivalents of $/$$. They are provided to
170 allow you to capture system output in the middle of true python code,
171 allow you to capture system output in the middle of true python code,
171 function definitions, etc (where $ and $$ are invalid).
172 function definitions, etc (where $ and $$ are invalid).
172
173
173 DIRECTORY MANAGEMENT
174 DIRECTORY MANAGEMENT
174 --------------------
175 --------------------
175 Since each command passed by pysh to the underlying system is executed in
176 Since each command passed by pysh to the underlying system is executed in
176 a subshell which exits immediately, you can NOT use !cd to navigate the
177 a subshell which exits immediately, you can NOT use !cd to navigate the
177 filesystem.
178 filesystem.
178
179
179 Pysh provides its own builtin '%cd' magic command to move in the
180 Pysh provides its own builtin '%cd' magic command to move in the
180 filesystem (the % is not required with automagic on). It also maintains a
181 filesystem (the % is not required with automagic on). It also maintains a
181 list of visited directories (use %dhist to see it) and allows direct
182 list of visited directories (use %dhist to see it) and allows direct
182 switching to any of them. Type 'cd?' for more details.
183 switching to any of them. Type 'cd?' for more details.
183
184
184 %pushd, %popd and %dirs are provided for directory stack handling.
185 %pushd, %popd and %dirs are provided for directory stack handling.
185
186
186 PROMPT CUSTOMIZATION
187 PROMPT CUSTOMIZATION
187 --------------------
188 --------------------
188
189
189 The supplied ipythonrc-pysh profile comes with an example of a very
190 The supplied ipythonrc-pysh profile comes with an example of a very
190 colored and detailed prompt, mainly to serve as an illustration. The
191 colored and detailed prompt, mainly to serve as an illustration. The
191 valid escape sequences, besides color names, are:
192 valid escape sequences, besides color names, are:
192
193
193 \\# - Prompt number.
194 \\# - Prompt number.
194 \\D - Dots, as many as there are digits in \\# (so they align).
195 \\D - Dots, as many as there are digits in \\# (so they align).
195 \\w - Current working directory (cwd).
196 \\w - Current working directory (cwd).
196 \\W - Basename of current working directory.
197 \\W - Basename of current working directory.
197 \\XN - Where N=0..5. N terms of the cwd, with $HOME written as ~.
198 \\XN - Where N=0..5. N terms of the cwd, with $HOME written as ~.
198 \\YN - Where N=0..5. Like XN, but if ~ is term N+1 it's also shown.
199 \\YN - Where N=0..5. Like XN, but if ~ is term N+1 it's also shown.
199 \\u - Username.
200 \\u - Username.
200 \\H - Full hostname.
201 \\H - Full hostname.
201 \\h - Hostname up to first '.'
202 \\h - Hostname up to first '.'
202 \\$ - Root symbol ($ or #).
203 \\$ - Root symbol ($ or #).
203 \\t - Current time, in H:M:S format.
204 \\t - Current time, in H:M:S format.
204 \\v - IPython release version.
205 \\v - IPython release version.
205 \\n - Newline.
206 \\n - Newline.
206 \\r - Carriage return.
207 \\r - Carriage return.
207 \\\\ - An explicitly escaped '\\'.
208 \\\\ - An explicitly escaped '\\'.
208
209
209 You can configure your prompt colors using any ANSI color escape. Each
210 You can configure your prompt colors using any ANSI color escape. Each
210 color escape sets the color for any subsequent text, until another escape
211 color escape sets the color for any subsequent text, until another escape
211 comes in and changes things. The valid color escapes are:
212 comes in and changes things. The valid color escapes are:
212
213
213 \\C_Black
214 \\C_Black
214 \\C_Blue
215 \\C_Blue
215 \\C_Brown
216 \\C_Brown
216 \\C_Cyan
217 \\C_Cyan
217 \\C_DarkGray
218 \\C_DarkGray
218 \\C_Green
219 \\C_Green
219 \\C_LightBlue
220 \\C_LightBlue
220 \\C_LightCyan
221 \\C_LightCyan
221 \\C_LightGray
222 \\C_LightGray
222 \\C_LightGreen
223 \\C_LightGreen
223 \\C_LightPurple
224 \\C_LightPurple
224 \\C_LightRed
225 \\C_LightRed
225 \\C_Purple
226 \\C_Purple
226 \\C_Red
227 \\C_Red
227 \\C_White
228 \\C_White
228 \\C_Yellow
229 \\C_Yellow
229 \\C_Normal - Stop coloring, defaults to your terminal settings.
230 \\C_Normal - Stop coloring, defaults to your terminal settings.
230 """
231 """
231 pass
232 pass
232
233
233 # Configure a few things. Much of this is fairly hackish, since IPython
234 # Configure a few things. Much of this is fairly hackish, since IPython
234 # doesn't really expose a clean API for it. Be careful if you start making
235 # doesn't really expose a clean API for it. Be careful if you start making
235 # many modifications here.
236 # many modifications here.
236
237
237 print """\
238 Welcome to pysh, a set of extensions to IPython for shell usage.
239 help(pysh) -> help on the installed shell extensions and syntax.
240 """
241
238
242 # Set the 'cd' command to quiet mode, a more shell-like behavior
239 # Set the 'cd' command to quiet mode, a more shell-like behavior
243 __IPYTHON__.default_option('cd','-q')
240 __IPYTHON__.default_option('cd','-q')
244
241
245 # This is redundant, ipy_user_conf.py will determine this
242 # This is redundant, ipy_user_conf.py will determine this
246 # Load all of $PATH as aliases
243 # Load all of $PATH as aliases
247 if os.name == 'posix':
244 if os.name == 'posix':
248 # # %rehash is very fast, but it doesn't check for executability, it simply
245 # # %rehash is very fast, but it doesn't check for executability, it simply
249 # # dumps everything in $PATH as an alias. Use rehashx if you want more
246 # # dumps everything in $PATH as an alias. Use rehashx if you want more
250 # # checks.
247 # # checks.
251 __IPYTHON__.magic_rehash()
248 __IPYTHON__.magic_rehash()
252 else:
249 else:
253 # # Windows users: the list of extensions considered executable is read from
250 # # Windows users: the list of extensions considered executable is read from
254 # # the environment variable 'pathext'. If this is undefined, IPython
251 # # the environment variable 'pathext'. If this is undefined, IPython
255 # # defaults to EXE, COM and BAT.
252 # # defaults to EXE, COM and BAT.
256 # # %rehashx is the one which does extension analysis, at the cost of
253 # # %rehashx is the one which does extension analysis, at the cost of
257 # # being much slower than %rehash.
254 # # being much slower than %rehash.
258 __IPYTHON__.magic_rehashx()
255 __IPYTHON__.magic_rehashx()
259
256
260 # Remove %sc,%sx if present as aliases
257 # Remove %sc,%sx if present as aliases
261 __IPYTHON__.magic_unalias('sc')
258 __IPYTHON__.magic_unalias('sc')
262 __IPYTHON__.magic_unalias('sx')
259 __IPYTHON__.magic_unalias('sx')
263
260
264 # We need different criteria for line-splitting, so that aliases such as
261 # We need different criteria for line-splitting, so that aliases such as
265 # 'gnome-terminal' are interpreted as a single alias instead of variable
262 # 'gnome-terminal' are interpreted as a single alias instead of variable
266 # 'gnome' minus variable 'terminal'.
263 # 'gnome' minus variable 'terminal'.
267 import re
264 import re
268 __IPYTHON__.line_split = re.compile(r'^([\s*,;/])'
265 __IPYTHON__.line_split = re.compile(r'^([\s*,;/])'
269 r'([\?\w\.\-\+]+\w*\s*)'
266 r'([\?\w\.\-\+]+\w*\s*)'
270 r'(\(?.*$)')
267 r'(\(?.*$)')
271
268
272 # Namespace cleanup
269 # Namespace cleanup
273 del re
270 del re
@@ -1,2754 +1,2765 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 1107 2006-01-30 19:02:20Z vivainio $"""
4 $Id: Magic.py 1121 2006-02-01 21:12:20Z vivainio $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #*****************************************************************************
12 #*****************************************************************************
13
13
14 #****************************************************************************
14 #****************************************************************************
15 # Modules and globals
15 # Modules and globals
16
16
17 from IPython import Release
17 from IPython import Release
18 __author__ = '%s <%s>\n%s <%s>' % \
18 __author__ = '%s <%s>\n%s <%s>' % \
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 __license__ = Release.license
20 __license__ = Release.license
21
21
22 # Python standard modules
22 # Python standard modules
23 import __builtin__
23 import __builtin__
24 import bdb
24 import bdb
25 import inspect
25 import inspect
26 import os
26 import os
27 import pdb
27 import pdb
28 import pydoc
28 import pydoc
29 import sys
29 import sys
30 import re
30 import re
31 import tempfile
31 import tempfile
32 import time
32 import time
33 import cPickle as pickle
33 import cPickle as pickle
34 import textwrap
34 import textwrap
35 from cStringIO import StringIO
35 from cStringIO import StringIO
36 from getopt import getopt,GetoptError
36 from getopt import getopt,GetoptError
37 from pprint import pprint, pformat
37 from pprint import pprint, pformat
38
38
39 # profile isn't bundled by default in Debian for license reasons
39 # profile isn't bundled by default in Debian for license reasons
40 try:
40 try:
41 import profile,pstats
41 import profile,pstats
42 except ImportError:
42 except ImportError:
43 profile = pstats = None
43 profile = pstats = None
44
44
45 # Homebrewed
45 # Homebrewed
46 from IPython import Debugger, OInspect, wildcard
46 from IPython import Debugger, OInspect, wildcard
47 from IPython.FakeModule import FakeModule
47 from IPython.FakeModule import FakeModule
48 from IPython.Itpl import Itpl, itpl, printpl,itplns
48 from IPython.Itpl import Itpl, itpl, printpl,itplns
49 from IPython.PyColorize import Parser
49 from IPython.PyColorize import Parser
50 from IPython.ipstruct import Struct
50 from IPython.ipstruct import Struct
51 from IPython.macro import Macro
51 from IPython.macro import Macro
52 from IPython.genutils import *
52 from IPython.genutils import *
53 from IPython import platutils
53 from IPython import platutils
54
54
55 #***************************************************************************
55 #***************************************************************************
56 # Utility functions
56 # Utility functions
57 def on_off(tag):
57 def on_off(tag):
58 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
58 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
59 return ['OFF','ON'][tag]
59 return ['OFF','ON'][tag]
60
60
61 class Bunch: pass
61 class Bunch: pass
62
62
63 #***************************************************************************
63 #***************************************************************************
64 # Main class implementing Magic functionality
64 # Main class implementing Magic functionality
65 class Magic:
65 class Magic:
66 """Magic functions for InteractiveShell.
66 """Magic functions for InteractiveShell.
67
67
68 Shell functions which can be reached as %function_name. All magic
68 Shell functions which can be reached as %function_name. All magic
69 functions should accept a string, which they can parse for their own
69 functions should accept a string, which they can parse for their own
70 needs. This can make some functions easier to type, eg `%cd ../`
70 needs. This can make some functions easier to type, eg `%cd ../`
71 vs. `%cd("../")`
71 vs. `%cd("../")`
72
72
73 ALL definitions MUST begin with the prefix magic_. The user won't need it
73 ALL definitions MUST begin with the prefix magic_. The user won't need it
74 at the command line, but it is is needed in the definition. """
74 at the command line, but it is is needed in the definition. """
75
75
76 # class globals
76 # class globals
77 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
77 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
78 'Automagic is ON, % prefix NOT needed for magic functions.']
78 'Automagic is ON, % prefix NOT needed for magic functions.']
79
79
80 #......................................................................
80 #......................................................................
81 # some utility functions
81 # some utility functions
82
82
83 def __init__(self,shell):
83 def __init__(self,shell):
84
84
85 self.options_table = {}
85 self.options_table = {}
86 if profile is None:
86 if profile is None:
87 self.magic_prun = self.profile_missing_notice
87 self.magic_prun = self.profile_missing_notice
88 self.shell = shell
88 self.shell = shell
89
89
90 # namespace for holding state we may need
90 # namespace for holding state we may need
91 self._magic_state = Bunch()
91 self._magic_state = Bunch()
92
92
93 def profile_missing_notice(self, *args, **kwargs):
93 def profile_missing_notice(self, *args, **kwargs):
94 error("""\
94 error("""\
95 The profile module could not be found. If you are a Debian user,
95 The profile module could not be found. If you are a Debian user,
96 it has been removed from the standard Debian package because of its non-free
96 it has been removed from the standard Debian package because of its non-free
97 license. To use profiling, please install"python2.3-profiler" from non-free.""")
97 license. To use profiling, please install"python2.3-profiler" from non-free.""")
98
98
99 def default_option(self,fn,optstr):
99 def default_option(self,fn,optstr):
100 """Make an entry in the options_table for fn, with value optstr"""
100 """Make an entry in the options_table for fn, with value optstr"""
101
101
102 if fn not in self.lsmagic():
102 if fn not in self.lsmagic():
103 error("%s is not a magic function" % fn)
103 error("%s is not a magic function" % fn)
104 self.options_table[fn] = optstr
104 self.options_table[fn] = optstr
105
105
106 def lsmagic(self):
106 def lsmagic(self):
107 """Return a list of currently available magic functions.
107 """Return a list of currently available magic functions.
108
108
109 Gives a list of the bare names after mangling (['ls','cd', ...], not
109 Gives a list of the bare names after mangling (['ls','cd', ...], not
110 ['magic_ls','magic_cd',...]"""
110 ['magic_ls','magic_cd',...]"""
111
111
112 # FIXME. This needs a cleanup, in the way the magics list is built.
112 # FIXME. This needs a cleanup, in the way the magics list is built.
113
113
114 # magics in class definition
114 # magics in class definition
115 class_magic = lambda fn: fn.startswith('magic_') and \
115 class_magic = lambda fn: fn.startswith('magic_') and \
116 callable(Magic.__dict__[fn])
116 callable(Magic.__dict__[fn])
117 # in instance namespace (run-time user additions)
117 # in instance namespace (run-time user additions)
118 inst_magic = lambda fn: fn.startswith('magic_') and \
118 inst_magic = lambda fn: fn.startswith('magic_') and \
119 callable(self.__dict__[fn])
119 callable(self.__dict__[fn])
120 # and bound magics by user (so they can access self):
120 # and bound magics by user (so they can access self):
121 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
121 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
122 callable(self.__class__.__dict__[fn])
122 callable(self.__class__.__dict__[fn])
123 magics = filter(class_magic,Magic.__dict__.keys()) + \
123 magics = filter(class_magic,Magic.__dict__.keys()) + \
124 filter(inst_magic,self.__dict__.keys()) + \
124 filter(inst_magic,self.__dict__.keys()) + \
125 filter(inst_bound_magic,self.__class__.__dict__.keys())
125 filter(inst_bound_magic,self.__class__.__dict__.keys())
126 out = []
126 out = []
127 for fn in magics:
127 for fn in magics:
128 out.append(fn.replace('magic_','',1))
128 out.append(fn.replace('magic_','',1))
129 out.sort()
129 out.sort()
130 return out
130 return out
131
131
132 def extract_input_slices(self,slices):
132 def extract_input_slices(self,slices):
133 """Return as a string a set of input history slices.
133 """Return as a string a set of input history slices.
134
134
135 The set of slices is given as a list of strings (like ['1','4:8','9'],
135 The set of slices is given as a list of strings (like ['1','4:8','9'],
136 since this function is for use by magic functions which get their
136 since this function is for use by magic functions which get their
137 arguments as strings.
137 arguments as strings.
138
138
139 Note that slices can be called with two notations:
139 Note that slices can be called with two notations:
140
140
141 N:M -> standard python form, means including items N...(M-1).
141 N:M -> standard python form, means including items N...(M-1).
142
142
143 N-M -> include items N..M (closed endpoint)."""
143 N-M -> include items N..M (closed endpoint)."""
144
144
145 cmds = []
145 cmds = []
146 for chunk in slices:
146 for chunk in slices:
147 if ':' in chunk:
147 if ':' in chunk:
148 ini,fin = map(int,chunk.split(':'))
148 ini,fin = map(int,chunk.split(':'))
149 elif '-' in chunk:
149 elif '-' in chunk:
150 ini,fin = map(int,chunk.split('-'))
150 ini,fin = map(int,chunk.split('-'))
151 fin += 1
151 fin += 1
152 else:
152 else:
153 ini = int(chunk)
153 ini = int(chunk)
154 fin = ini+1
154 fin = ini+1
155 cmds.append(self.shell.input_hist[ini:fin])
155 cmds.append(self.shell.input_hist[ini:fin])
156 return cmds
156 return cmds
157
157
158 def _ofind(self,oname):
158 def _ofind(self,oname):
159 """Find an object in the available namespaces.
159 """Find an object in the available namespaces.
160
160
161 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
161 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
162
162
163 Has special code to detect magic functions.
163 Has special code to detect magic functions.
164 """
164 """
165
165
166 oname = oname.strip()
166 oname = oname.strip()
167
167
168 # Namespaces to search in:
168 # Namespaces to search in:
169 user_ns = self.shell.user_ns
169 user_ns = self.shell.user_ns
170 internal_ns = self.shell.internal_ns
170 internal_ns = self.shell.internal_ns
171 builtin_ns = __builtin__.__dict__
171 builtin_ns = __builtin__.__dict__
172 alias_ns = self.shell.alias_table
172 alias_ns = self.shell.alias_table
173
173
174 # Put them in a list. The order is important so that we find things in
174 # Put them in a list. The order is important so that we find things in
175 # the same order that Python finds them.
175 # the same order that Python finds them.
176 namespaces = [ ('Interactive',user_ns),
176 namespaces = [ ('Interactive',user_ns),
177 ('IPython internal',internal_ns),
177 ('IPython internal',internal_ns),
178 ('Python builtin',builtin_ns),
178 ('Python builtin',builtin_ns),
179 ('Alias',alias_ns),
179 ('Alias',alias_ns),
180 ]
180 ]
181
181
182 # initialize results to 'null'
182 # initialize results to 'null'
183 found = 0; obj = None; ospace = None; ds = None;
183 found = 0; obj = None; ospace = None; ds = None;
184 ismagic = 0; isalias = 0
184 ismagic = 0; isalias = 0
185
185
186 # Look for the given name by splitting it in parts. If the head is
186 # Look for the given name by splitting it in parts. If the head is
187 # found, then we look for all the remaining parts as members, and only
187 # found, then we look for all the remaining parts as members, and only
188 # declare success if we can find them all.
188 # declare success if we can find them all.
189 oname_parts = oname.split('.')
189 oname_parts = oname.split('.')
190 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
190 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
191 for nsname,ns in namespaces:
191 for nsname,ns in namespaces:
192 try:
192 try:
193 obj = ns[oname_head]
193 obj = ns[oname_head]
194 except KeyError:
194 except KeyError:
195 continue
195 continue
196 else:
196 else:
197 for part in oname_rest:
197 for part in oname_rest:
198 try:
198 try:
199 obj = getattr(obj,part)
199 obj = getattr(obj,part)
200 except:
200 except:
201 # Blanket except b/c some badly implemented objects
201 # Blanket except b/c some badly implemented objects
202 # allow __getattr__ to raise exceptions other than
202 # allow __getattr__ to raise exceptions other than
203 # AttributeError, which then crashes IPython.
203 # AttributeError, which then crashes IPython.
204 break
204 break
205 else:
205 else:
206 # If we finish the for loop (no break), we got all members
206 # If we finish the for loop (no break), we got all members
207 found = 1
207 found = 1
208 ospace = nsname
208 ospace = nsname
209 if ns == alias_ns:
209 if ns == alias_ns:
210 isalias = 1
210 isalias = 1
211 break # namespace loop
211 break # namespace loop
212
212
213 # Try to see if it's magic
213 # Try to see if it's magic
214 if not found:
214 if not found:
215 if oname.startswith(self.shell.ESC_MAGIC):
215 if oname.startswith(self.shell.ESC_MAGIC):
216 oname = oname[1:]
216 oname = oname[1:]
217 obj = getattr(self,'magic_'+oname,None)
217 obj = getattr(self,'magic_'+oname,None)
218 if obj is not None:
218 if obj is not None:
219 found = 1
219 found = 1
220 ospace = 'IPython internal'
220 ospace = 'IPython internal'
221 ismagic = 1
221 ismagic = 1
222
222
223 # Last try: special-case some literals like '', [], {}, etc:
223 # Last try: special-case some literals like '', [], {}, etc:
224 if not found and oname_head in ["''",'""','[]','{}','()']:
224 if not found and oname_head in ["''",'""','[]','{}','()']:
225 obj = eval(oname_head)
225 obj = eval(oname_head)
226 found = 1
226 found = 1
227 ospace = 'Interactive'
227 ospace = 'Interactive'
228
228
229 return {'found':found, 'obj':obj, 'namespace':ospace,
229 return {'found':found, 'obj':obj, 'namespace':ospace,
230 'ismagic':ismagic, 'isalias':isalias}
230 'ismagic':ismagic, 'isalias':isalias}
231
231
232 def arg_err(self,func):
232 def arg_err(self,func):
233 """Print docstring if incorrect arguments were passed"""
233 """Print docstring if incorrect arguments were passed"""
234 print 'Error in arguments:'
234 print 'Error in arguments:'
235 print OInspect.getdoc(func)
235 print OInspect.getdoc(func)
236
236
237 def format_latex(self,strng):
237 def format_latex(self,strng):
238 """Format a string for latex inclusion."""
238 """Format a string for latex inclusion."""
239
239
240 # Characters that need to be escaped for latex:
240 # Characters that need to be escaped for latex:
241 escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE)
241 escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE)
242 # Magic command names as headers:
242 # Magic command names as headers:
243 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
243 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
244 re.MULTILINE)
244 re.MULTILINE)
245 # Magic commands
245 # Magic commands
246 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
246 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
247 re.MULTILINE)
247 re.MULTILINE)
248 # Paragraph continue
248 # Paragraph continue
249 par_re = re.compile(r'\\$',re.MULTILINE)
249 par_re = re.compile(r'\\$',re.MULTILINE)
250
250
251 # The "\n" symbol
251 # The "\n" symbol
252 newline_re = re.compile(r'\\n')
252 newline_re = re.compile(r'\\n')
253
253
254 # Now build the string for output:
254 # Now build the string for output:
255 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
255 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
256 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
256 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
257 strng)
257 strng)
258 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
258 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
259 strng = par_re.sub(r'\\\\',strng)
259 strng = par_re.sub(r'\\\\',strng)
260 strng = escape_re.sub(r'\\\1',strng)
260 strng = escape_re.sub(r'\\\1',strng)
261 strng = newline_re.sub(r'\\textbackslash{}n',strng)
261 strng = newline_re.sub(r'\\textbackslash{}n',strng)
262 return strng
262 return strng
263
263
264 def format_screen(self,strng):
264 def format_screen(self,strng):
265 """Format a string for screen printing.
265 """Format a string for screen printing.
266
266
267 This removes some latex-type format codes."""
267 This removes some latex-type format codes."""
268 # Paragraph continue
268 # Paragraph continue
269 par_re = re.compile(r'\\$',re.MULTILINE)
269 par_re = re.compile(r'\\$',re.MULTILINE)
270 strng = par_re.sub('',strng)
270 strng = par_re.sub('',strng)
271 return strng
271 return strng
272
272
273 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
273 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
274 """Parse options passed to an argument string.
274 """Parse options passed to an argument string.
275
275
276 The interface is similar to that of getopt(), but it returns back a
276 The interface is similar to that of getopt(), but it returns back a
277 Struct with the options as keys and the stripped argument string still
277 Struct with the options as keys and the stripped argument string still
278 as a string.
278 as a string.
279
279
280 arg_str is quoted as a true sys.argv vector by using shlex.split.
280 arg_str is quoted as a true sys.argv vector by using shlex.split.
281 This allows us to easily expand variables, glob files, quote
281 This allows us to easily expand variables, glob files, quote
282 arguments, etc.
282 arguments, etc.
283
283
284 Options:
284 Options:
285 -mode: default 'string'. If given as 'list', the argument string is
285 -mode: default 'string'. If given as 'list', the argument string is
286 returned as a list (split on whitespace) instead of a string.
286 returned as a list (split on whitespace) instead of a string.
287
287
288 -list_all: put all option values in lists. Normally only options
288 -list_all: put all option values in lists. Normally only options
289 appearing more than once are put in a list."""
289 appearing more than once are put in a list."""
290
290
291 # inject default options at the beginning of the input line
291 # inject default options at the beginning of the input line
292 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
292 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
293 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
293 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
294
294
295 mode = kw.get('mode','string')
295 mode = kw.get('mode','string')
296 if mode not in ['string','list']:
296 if mode not in ['string','list']:
297 raise ValueError,'incorrect mode given: %s' % mode
297 raise ValueError,'incorrect mode given: %s' % mode
298 # Get options
298 # Get options
299 list_all = kw.get('list_all',0)
299 list_all = kw.get('list_all',0)
300
300
301 # Check if we have more than one argument to warrant extra processing:
301 # Check if we have more than one argument to warrant extra processing:
302 odict = {} # Dictionary with options
302 odict = {} # Dictionary with options
303 args = arg_str.split()
303 args = arg_str.split()
304 if len(args) >= 1:
304 if len(args) >= 1:
305 # If the list of inputs only has 0 or 1 thing in it, there's no
305 # If the list of inputs only has 0 or 1 thing in it, there's no
306 # need to look for options
306 # need to look for options
307 argv = shlex_split(arg_str)
307 argv = shlex_split(arg_str)
308 # Do regular option processing
308 # Do regular option processing
309 try:
309 try:
310 opts,args = getopt(argv,opt_str,*long_opts)
310 opts,args = getopt(argv,opt_str,*long_opts)
311 except GetoptError,e:
311 except GetoptError,e:
312 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
312 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
313 " ".join(long_opts)))
313 " ".join(long_opts)))
314 for o,a in opts:
314 for o,a in opts:
315 if o.startswith('--'):
315 if o.startswith('--'):
316 o = o[2:]
316 o = o[2:]
317 else:
317 else:
318 o = o[1:]
318 o = o[1:]
319 try:
319 try:
320 odict[o].append(a)
320 odict[o].append(a)
321 except AttributeError:
321 except AttributeError:
322 odict[o] = [odict[o],a]
322 odict[o] = [odict[o],a]
323 except KeyError:
323 except KeyError:
324 if list_all:
324 if list_all:
325 odict[o] = [a]
325 odict[o] = [a]
326 else:
326 else:
327 odict[o] = a
327 odict[o] = a
328
328
329 # Prepare opts,args for return
329 # Prepare opts,args for return
330 opts = Struct(odict)
330 opts = Struct(odict)
331 if mode == 'string':
331 if mode == 'string':
332 args = ' '.join(args)
332 args = ' '.join(args)
333
333
334 return opts,args
334 return opts,args
335
335
336 #......................................................................
336 #......................................................................
337 # And now the actual magic functions
337 # And now the actual magic functions
338
338
339 # Functions for IPython shell work (vars,funcs, config, etc)
339 # Functions for IPython shell work (vars,funcs, config, etc)
340 def magic_lsmagic(self, parameter_s = ''):
340 def magic_lsmagic(self, parameter_s = ''):
341 """List currently available magic functions."""
341 """List currently available magic functions."""
342 mesc = self.shell.ESC_MAGIC
342 mesc = self.shell.ESC_MAGIC
343 print 'Available magic functions:\n'+mesc+\
343 print 'Available magic functions:\n'+mesc+\
344 (' '+mesc).join(self.lsmagic())
344 (' '+mesc).join(self.lsmagic())
345 print '\n' + Magic.auto_status[self.shell.rc.automagic]
345 print '\n' + Magic.auto_status[self.shell.rc.automagic]
346 return None
346 return None
347
347
348 def magic_magic(self, parameter_s = ''):
348 def magic_magic(self, parameter_s = ''):
349 """Print information about the magic function system."""
349 """Print information about the magic function system."""
350
350
351 mode = ''
351 mode = ''
352 try:
352 try:
353 if parameter_s.split()[0] == '-latex':
353 if parameter_s.split()[0] == '-latex':
354 mode = 'latex'
354 mode = 'latex'
355 except:
355 except:
356 pass
356 pass
357
357
358 magic_docs = []
358 magic_docs = []
359 for fname in self.lsmagic():
359 for fname in self.lsmagic():
360 mname = 'magic_' + fname
360 mname = 'magic_' + fname
361 for space in (Magic,self,self.__class__):
361 for space in (Magic,self,self.__class__):
362 try:
362 try:
363 fn = space.__dict__[mname]
363 fn = space.__dict__[mname]
364 except KeyError:
364 except KeyError:
365 pass
365 pass
366 else:
366 else:
367 break
367 break
368 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
368 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
369 fname,fn.__doc__))
369 fname,fn.__doc__))
370 magic_docs = ''.join(magic_docs)
370 magic_docs = ''.join(magic_docs)
371
371
372 if mode == 'latex':
372 if mode == 'latex':
373 print self.format_latex(magic_docs)
373 print self.format_latex(magic_docs)
374 return
374 return
375 else:
375 else:
376 magic_docs = self.format_screen(magic_docs)
376 magic_docs = self.format_screen(magic_docs)
377
377
378 outmsg = """
378 outmsg = """
379 IPython's 'magic' functions
379 IPython's 'magic' functions
380 ===========================
380 ===========================
381
381
382 The magic function system provides a series of functions which allow you to
382 The magic function system provides a series of functions which allow you to
383 control the behavior of IPython itself, plus a lot of system-type
383 control the behavior of IPython itself, plus a lot of system-type
384 features. All these functions are prefixed with a % character, but parameters
384 features. All these functions are prefixed with a % character, but parameters
385 are given without parentheses or quotes.
385 are given without parentheses or quotes.
386
386
387 NOTE: If you have 'automagic' enabled (via the command line option or with the
387 NOTE: If you have 'automagic' enabled (via the command line option or with the
388 %automagic function), you don't need to type in the % explicitly. By default,
388 %automagic function), you don't need to type in the % explicitly. By default,
389 IPython ships with automagic on, so you should only rarely need the % escape.
389 IPython ships with automagic on, so you should only rarely need the % escape.
390
390
391 Example: typing '%cd mydir' (without the quotes) changes you working directory
391 Example: typing '%cd mydir' (without the quotes) changes you working directory
392 to 'mydir', if it exists.
392 to 'mydir', if it exists.
393
393
394 You can define your own magic functions to extend the system. See the supplied
394 You can define your own magic functions to extend the system. See the supplied
395 ipythonrc and example-magic.py files for details (in your ipython
395 ipythonrc and example-magic.py files for details (in your ipython
396 configuration directory, typically $HOME/.ipython/).
396 configuration directory, typically $HOME/.ipython/).
397
397
398 You can also define your own aliased names for magic functions. In your
398 You can also define your own aliased names for magic functions. In your
399 ipythonrc file, placing a line like:
399 ipythonrc file, placing a line like:
400
400
401 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
401 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
402
402
403 will define %pf as a new name for %profile.
403 will define %pf as a new name for %profile.
404
404
405 You can also call magics in code using the ipmagic() function, which IPython
405 You can also call magics in code using the ipmagic() function, which IPython
406 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
406 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
407
407
408 For a list of the available magic functions, use %lsmagic. For a description
408 For a list of the available magic functions, use %lsmagic. For a description
409 of any of them, type %magic_name?, e.g. '%cd?'.
409 of any of them, type %magic_name?, e.g. '%cd?'.
410
410
411 Currently the magic system has the following functions:\n"""
411 Currently the magic system has the following functions:\n"""
412
412
413 mesc = self.shell.ESC_MAGIC
413 mesc = self.shell.ESC_MAGIC
414 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
414 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
415 "\n\n%s%s\n\n%s" % (outmsg,
415 "\n\n%s%s\n\n%s" % (outmsg,
416 magic_docs,mesc,mesc,
416 magic_docs,mesc,mesc,
417 (' '+mesc).join(self.lsmagic()),
417 (' '+mesc).join(self.lsmagic()),
418 Magic.auto_status[self.shell.rc.automagic] ) )
418 Magic.auto_status[self.shell.rc.automagic] ) )
419
419
420 page(outmsg,screen_lines=self.shell.rc.screen_length)
420 page(outmsg,screen_lines=self.shell.rc.screen_length)
421
421
422 def magic_automagic(self, parameter_s = ''):
422 def magic_automagic(self, parameter_s = ''):
423 """Make magic functions callable without having to type the initial %.
423 """Make magic functions callable without having to type the initial %.
424
424
425 Toggles on/off (when off, you must call it as %automagic, of
425 Toggles on/off (when off, you must call it as %automagic, of
426 course). Note that magic functions have lowest priority, so if there's
426 course). Note that magic functions have lowest priority, so if there's
427 a variable whose name collides with that of a magic fn, automagic
427 a variable whose name collides with that of a magic fn, automagic
428 won't work for that function (you get the variable instead). However,
428 won't work for that function (you get the variable instead). However,
429 if you delete the variable (del var), the previously shadowed magic
429 if you delete the variable (del var), the previously shadowed magic
430 function becomes visible to automagic again."""
430 function becomes visible to automagic again."""
431
431
432 rc = self.shell.rc
432 rc = self.shell.rc
433 rc.automagic = not rc.automagic
433 rc.automagic = not rc.automagic
434 print '\n' + Magic.auto_status[rc.automagic]
434 print '\n' + Magic.auto_status[rc.automagic]
435
435
436 def magic_autocall(self, parameter_s = ''):
436 def magic_autocall(self, parameter_s = ''):
437 """Make functions callable without having to type parentheses.
437 """Make functions callable without having to type parentheses.
438
438
439 Usage:
439 Usage:
440
440
441 %autocall [mode]
441 %autocall [mode]
442
442
443 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
443 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
444 value is toggled on and off (remembering the previous state)."""
444 value is toggled on and off (remembering the previous state)."""
445
445
446 rc = self.shell.rc
446 rc = self.shell.rc
447
447
448 if parameter_s:
448 if parameter_s:
449 arg = int(parameter_s)
449 arg = int(parameter_s)
450 else:
450 else:
451 arg = 'toggle'
451 arg = 'toggle'
452
452
453 if not arg in (0,1,2,'toggle'):
453 if not arg in (0,1,2,'toggle'):
454 error('Valid modes: (0->Off, 1->Smart, 2->Full')
454 error('Valid modes: (0->Off, 1->Smart, 2->Full')
455 return
455 return
456
456
457 if arg in (0,1,2):
457 if arg in (0,1,2):
458 rc.autocall = arg
458 rc.autocall = arg
459 else: # toggle
459 else: # toggle
460 if rc.autocall:
460 if rc.autocall:
461 self._magic_state.autocall_save = rc.autocall
461 self._magic_state.autocall_save = rc.autocall
462 rc.autocall = 0
462 rc.autocall = 0
463 else:
463 else:
464 try:
464 try:
465 rc.autocall = self._magic_state.autocall_save
465 rc.autocall = self._magic_state.autocall_save
466 except AttributeError:
466 except AttributeError:
467 rc.autocall = self._magic_state.autocall_save = 1
467 rc.autocall = self._magic_state.autocall_save = 1
468
468
469 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
469 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
470
470
471 def magic_autoindent(self, parameter_s = ''):
471 def magic_autoindent(self, parameter_s = ''):
472 """Toggle autoindent on/off (if available)."""
472 """Toggle autoindent on/off (if available)."""
473
473
474 self.shell.set_autoindent()
474 self.shell.set_autoindent()
475 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
475 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
476
476
477 def magic_system_verbose(self, parameter_s = ''):
477 def magic_system_verbose(self, parameter_s = ''):
478 """Toggle verbose printing of system calls on/off."""
478 """Toggle verbose printing of system calls on/off."""
479
479
480 self.shell.rc_set_toggle('system_verbose')
480 self.shell.rc_set_toggle('system_verbose')
481 print "System verbose printing is:",\
481 print "System verbose printing is:",\
482 ['OFF','ON'][self.shell.rc.system_verbose]
482 ['OFF','ON'][self.shell.rc.system_verbose]
483
483
484 def magic_history(self, parameter_s = ''):
484 def magic_history(self, parameter_s = ''):
485 """Print input history (_i<n> variables), with most recent last.
485 """Print input history (_i<n> variables), with most recent last.
486
486
487 %history -> print at most 40 inputs (some may be multi-line)\\
487 %history -> print at most 40 inputs (some may be multi-line)\\
488 %history n -> print at most n inputs\\
488 %history n -> print at most n inputs\\
489 %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
489 %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
490
490
491 Each input's number <n> is shown, and is accessible as the
491 Each input's number <n> is shown, and is accessible as the
492 automatically generated variable _i<n>. Multi-line statements are
492 automatically generated variable _i<n>. Multi-line statements are
493 printed starting at a new line for easy copy/paste.
493 printed starting at a new line for easy copy/paste.
494
494
495
495
496 Options:
496 Options:
497
497
498 -n: do NOT print line numbers. This is useful if you want to get a
498 -n: do NOT print line numbers. This is useful if you want to get a
499 printout of many lines which can be directly pasted into a text
499 printout of many lines which can be directly pasted into a text
500 editor.
500 editor.
501
501
502 This feature is only available if numbered prompts are in use.
502 This feature is only available if numbered prompts are in use.
503
503
504 -r: print the 'raw' history. IPython filters your input and
504 -r: print the 'raw' history. IPython filters your input and
505 converts it all into valid Python source before executing it (things
505 converts it all into valid Python source before executing it (things
506 like magics or aliases are turned into function calls, for
506 like magics or aliases are turned into function calls, for
507 example). With this option, you'll see the unfiltered history
507 example). With this option, you'll see the unfiltered history
508 instead of the filtered version: '%cd /' will be seen as '%cd /'
508 instead of the filtered version: '%cd /' will be seen as '%cd /'
509 instead of '_ip.magic("%cd /")'.
509 instead of '_ip.magic("%cd /")'.
510 """
510 """
511
511
512 shell = self.shell
512 shell = self.shell
513 if not shell.outputcache.do_full_cache:
513 if not shell.outputcache.do_full_cache:
514 print 'This feature is only available if numbered prompts are in use.'
514 print 'This feature is only available if numbered prompts are in use.'
515 return
515 return
516 opts,args = self.parse_options(parameter_s,'nr',mode='list')
516 opts,args = self.parse_options(parameter_s,'nr',mode='list')
517
517
518 if opts.has_key('r'):
518 if opts.has_key('r'):
519 input_hist = shell.input_hist_raw
519 input_hist = shell.input_hist_raw
520 else:
520 else:
521 input_hist = shell.input_hist
521 input_hist = shell.input_hist
522
522
523 default_length = 40
523 default_length = 40
524 if len(args) == 0:
524 if len(args) == 0:
525 final = len(input_hist)
525 final = len(input_hist)
526 init = max(1,final-default_length)
526 init = max(1,final-default_length)
527 elif len(args) == 1:
527 elif len(args) == 1:
528 final = len(input_hist)
528 final = len(input_hist)
529 init = max(1,final-int(args[0]))
529 init = max(1,final-int(args[0]))
530 elif len(args) == 2:
530 elif len(args) == 2:
531 init,final = map(int,args)
531 init,final = map(int,args)
532 else:
532 else:
533 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
533 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
534 print self.magic_hist.__doc__
534 print self.magic_hist.__doc__
535 return
535 return
536 width = len(str(final))
536 width = len(str(final))
537 line_sep = ['','\n']
537 line_sep = ['','\n']
538 print_nums = not opts.has_key('n')
538 print_nums = not opts.has_key('n')
539 for in_num in range(init,final):
539 for in_num in range(init,final):
540 inline = input_hist[in_num]
540 inline = input_hist[in_num]
541 multiline = int(inline.count('\n') > 1)
541 multiline = int(inline.count('\n') > 1)
542 if print_nums:
542 if print_nums:
543 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
543 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
544 print inline,
544 print inline,
545
545
546 def magic_hist(self, parameter_s=''):
546 def magic_hist(self, parameter_s=''):
547 """Alternate name for %history."""
547 """Alternate name for %history."""
548 return self.magic_history(parameter_s)
548 return self.magic_history(parameter_s)
549
549
550 def magic_p(self, parameter_s=''):
550 def magic_p(self, parameter_s=''):
551 """Just a short alias for Python's 'print'."""
551 """Just a short alias for Python's 'print'."""
552 exec 'print ' + parameter_s in self.shell.user_ns
552 exec 'print ' + parameter_s in self.shell.user_ns
553
553
554 def magic_r(self, parameter_s=''):
554 def magic_r(self, parameter_s=''):
555 """Repeat previous input.
555 """Repeat previous input.
556
556
557 If given an argument, repeats the previous command which starts with
557 If given an argument, repeats the previous command which starts with
558 the same string, otherwise it just repeats the previous input.
558 the same string, otherwise it just repeats the previous input.
559
559
560 Shell escaped commands (with ! as first character) are not recognized
560 Shell escaped commands (with ! as first character) are not recognized
561 by this system, only pure python code and magic commands.
561 by this system, only pure python code and magic commands.
562 """
562 """
563
563
564 start = parameter_s.strip()
564 start = parameter_s.strip()
565 esc_magic = self.shell.ESC_MAGIC
565 esc_magic = self.shell.ESC_MAGIC
566 # Identify magic commands even if automagic is on (which means
566 # Identify magic commands even if automagic is on (which means
567 # the in-memory version is different from that typed by the user).
567 # the in-memory version is different from that typed by the user).
568 if self.shell.rc.automagic:
568 if self.shell.rc.automagic:
569 start_magic = esc_magic+start
569 start_magic = esc_magic+start
570 else:
570 else:
571 start_magic = start
571 start_magic = start
572 # Look through the input history in reverse
572 # Look through the input history in reverse
573 for n in range(len(self.shell.input_hist)-2,0,-1):
573 for n in range(len(self.shell.input_hist)-2,0,-1):
574 input = self.shell.input_hist[n]
574 input = self.shell.input_hist[n]
575 # skip plain 'r' lines so we don't recurse to infinity
575 # skip plain 'r' lines so we don't recurse to infinity
576 if input != '_ip.magic("r")\n' and \
576 if input != '_ip.magic("r")\n' and \
577 (input.startswith(start) or input.startswith(start_magic)):
577 (input.startswith(start) or input.startswith(start_magic)):
578 #print 'match',`input` # dbg
578 #print 'match',`input` # dbg
579 print 'Executing:',input,
579 print 'Executing:',input,
580 self.shell.runlines(input)
580 self.shell.runlines(input)
581 return
581 return
582 print 'No previous input matching `%s` found.' % start
582 print 'No previous input matching `%s` found.' % start
583
583
584 def magic_page(self, parameter_s=''):
584 def magic_page(self, parameter_s=''):
585 """Pretty print the object and display it through a pager.
585 """Pretty print the object and display it through a pager.
586
586
587 If no parameter is given, use _ (last output)."""
587 If no parameter is given, use _ (last output)."""
588 # After a function contributed by Olivier Aubert, slightly modified.
588 # After a function contributed by Olivier Aubert, slightly modified.
589
589
590 oname = parameter_s and parameter_s or '_'
590 oname = parameter_s and parameter_s or '_'
591 info = self._ofind(oname)
591 info = self._ofind(oname)
592 if info['found']:
592 if info['found']:
593 page(pformat(info['obj']))
593 page(pformat(info['obj']))
594 else:
594 else:
595 print 'Object `%s` not found' % oname
595 print 'Object `%s` not found' % oname
596
596
597 def magic_profile(self, parameter_s=''):
597 def magic_profile(self, parameter_s=''):
598 """Print your currently active IPyhton profile."""
598 """Print your currently active IPyhton profile."""
599 if self.shell.rc.profile:
599 if self.shell.rc.profile:
600 printpl('Current IPython profile: $self.shell.rc.profile.')
600 printpl('Current IPython profile: $self.shell.rc.profile.')
601 else:
601 else:
602 print 'No profile active.'
602 print 'No profile active.'
603
603
604 def _inspect(self,meth,oname,**kw):
604 def _inspect(self,meth,oname,**kw):
605 """Generic interface to the inspector system.
605 """Generic interface to the inspector system.
606
606
607 This function is meant to be called by pdef, pdoc & friends."""
607 This function is meant to be called by pdef, pdoc & friends."""
608
608
609 oname = oname.strip()
609 oname = oname.strip()
610 info = Struct(self._ofind(oname))
610 info = Struct(self._ofind(oname))
611 if info.found:
611 if info.found:
612 pmethod = getattr(self.shell.inspector,meth)
612 pmethod = getattr(self.shell.inspector,meth)
613 formatter = info.ismagic and self.format_screen or None
613 formatter = info.ismagic and self.format_screen or None
614 if meth == 'pdoc':
614 if meth == 'pdoc':
615 pmethod(info.obj,oname,formatter)
615 pmethod(info.obj,oname,formatter)
616 elif meth == 'pinfo':
616 elif meth == 'pinfo':
617 pmethod(info.obj,oname,formatter,info,**kw)
617 pmethod(info.obj,oname,formatter,info,**kw)
618 else:
618 else:
619 pmethod(info.obj,oname)
619 pmethod(info.obj,oname)
620 else:
620 else:
621 print 'Object `%s` not found.' % oname
621 print 'Object `%s` not found.' % oname
622 return 'not found' # so callers can take other action
622 return 'not found' # so callers can take other action
623
623
624 def magic_pdef(self, parameter_s=''):
624 def magic_pdef(self, parameter_s=''):
625 """Print the definition header for any callable object.
625 """Print the definition header for any callable object.
626
626
627 If the object is a class, print the constructor information."""
627 If the object is a class, print the constructor information."""
628 self._inspect('pdef',parameter_s)
628 self._inspect('pdef',parameter_s)
629
629
630 def magic_pdoc(self, parameter_s=''):
630 def magic_pdoc(self, parameter_s=''):
631 """Print the docstring for an object.
631 """Print the docstring for an object.
632
632
633 If the given object is a class, it will print both the class and the
633 If the given object is a class, it will print both the class and the
634 constructor docstrings."""
634 constructor docstrings."""
635 self._inspect('pdoc',parameter_s)
635 self._inspect('pdoc',parameter_s)
636
636
637 def magic_psource(self, parameter_s=''):
637 def magic_psource(self, parameter_s=''):
638 """Print (or run through pager) the source code for an object."""
638 """Print (or run through pager) the source code for an object."""
639 self._inspect('psource',parameter_s)
639 self._inspect('psource',parameter_s)
640
640
641 def magic_pfile(self, parameter_s=''):
641 def magic_pfile(self, parameter_s=''):
642 """Print (or run through pager) the file where an object is defined.
642 """Print (or run through pager) the file where an object is defined.
643
643
644 The file opens at the line where the object definition begins. IPython
644 The file opens at the line where the object definition begins. IPython
645 will honor the environment variable PAGER if set, and otherwise will
645 will honor the environment variable PAGER if set, and otherwise will
646 do its best to print the file in a convenient form.
646 do its best to print the file in a convenient form.
647
647
648 If the given argument is not an object currently defined, IPython will
648 If the given argument is not an object currently defined, IPython will
649 try to interpret it as a filename (automatically adding a .py extension
649 try to interpret it as a filename (automatically adding a .py extension
650 if needed). You can thus use %pfile as a syntax highlighting code
650 if needed). You can thus use %pfile as a syntax highlighting code
651 viewer."""
651 viewer."""
652
652
653 # first interpret argument as an object name
653 # first interpret argument as an object name
654 out = self._inspect('pfile',parameter_s)
654 out = self._inspect('pfile',parameter_s)
655 # if not, try the input as a filename
655 # if not, try the input as a filename
656 if out == 'not found':
656 if out == 'not found':
657 try:
657 try:
658 filename = get_py_filename(parameter_s)
658 filename = get_py_filename(parameter_s)
659 except IOError,msg:
659 except IOError,msg:
660 print msg
660 print msg
661 return
661 return
662 page(self.shell.inspector.format(file(filename).read()))
662 page(self.shell.inspector.format(file(filename).read()))
663
663
664 def magic_pinfo(self, parameter_s=''):
664 def magic_pinfo(self, parameter_s=''):
665 """Provide detailed information about an object.
665 """Provide detailed information about an object.
666
666
667 '%pinfo object' is just a synonym for object? or ?object."""
667 '%pinfo object' is just a synonym for object? or ?object."""
668
668
669 #print 'pinfo par: <%s>' % parameter_s # dbg
669 #print 'pinfo par: <%s>' % parameter_s # dbg
670
670
671 # detail_level: 0 -> obj? , 1 -> obj??
671 # detail_level: 0 -> obj? , 1 -> obj??
672 detail_level = 0
672 detail_level = 0
673 # We need to detect if we got called as 'pinfo pinfo foo', which can
673 # We need to detect if we got called as 'pinfo pinfo foo', which can
674 # happen if the user types 'pinfo foo?' at the cmd line.
674 # happen if the user types 'pinfo foo?' at the cmd line.
675 pinfo,qmark1,oname,qmark2 = \
675 pinfo,qmark1,oname,qmark2 = \
676 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
676 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
677 if pinfo or qmark1 or qmark2:
677 if pinfo or qmark1 or qmark2:
678 detail_level = 1
678 detail_level = 1
679 if "*" in oname:
679 if "*" in oname:
680 self.magic_psearch(oname)
680 self.magic_psearch(oname)
681 else:
681 else:
682 self._inspect('pinfo',oname,detail_level=detail_level)
682 self._inspect('pinfo',oname,detail_level=detail_level)
683
683
684 def magic_psearch(self, parameter_s=''):
684 def magic_psearch(self, parameter_s=''):
685 """Search for object in namespaces by wildcard.
685 """Search for object in namespaces by wildcard.
686
686
687 %psearch [options] PATTERN [OBJECT TYPE]
687 %psearch [options] PATTERN [OBJECT TYPE]
688
688
689 Note: ? can be used as a synonym for %psearch, at the beginning or at
689 Note: ? can be used as a synonym for %psearch, at the beginning or at
690 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
690 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
691 rest of the command line must be unchanged (options come first), so
691 rest of the command line must be unchanged (options come first), so
692 for example the following forms are equivalent
692 for example the following forms are equivalent
693
693
694 %psearch -i a* function
694 %psearch -i a* function
695 -i a* function?
695 -i a* function?
696 ?-i a* function
696 ?-i a* function
697
697
698 Arguments:
698 Arguments:
699
699
700 PATTERN
700 PATTERN
701
701
702 where PATTERN is a string containing * as a wildcard similar to its
702 where PATTERN is a string containing * as a wildcard similar to its
703 use in a shell. The pattern is matched in all namespaces on the
703 use in a shell. The pattern is matched in all namespaces on the
704 search path. By default objects starting with a single _ are not
704 search path. By default objects starting with a single _ are not
705 matched, many IPython generated objects have a single
705 matched, many IPython generated objects have a single
706 underscore. The default is case insensitive matching. Matching is
706 underscore. The default is case insensitive matching. Matching is
707 also done on the attributes of objects and not only on the objects
707 also done on the attributes of objects and not only on the objects
708 in a module.
708 in a module.
709
709
710 [OBJECT TYPE]
710 [OBJECT TYPE]
711
711
712 Is the name of a python type from the types module. The name is
712 Is the name of a python type from the types module. The name is
713 given in lowercase without the ending type, ex. StringType is
713 given in lowercase without the ending type, ex. StringType is
714 written string. By adding a type here only objects matching the
714 written string. By adding a type here only objects matching the
715 given type are matched. Using all here makes the pattern match all
715 given type are matched. Using all here makes the pattern match all
716 types (this is the default).
716 types (this is the default).
717
717
718 Options:
718 Options:
719
719
720 -a: makes the pattern match even objects whose names start with a
720 -a: makes the pattern match even objects whose names start with a
721 single underscore. These names are normally ommitted from the
721 single underscore. These names are normally ommitted from the
722 search.
722 search.
723
723
724 -i/-c: make the pattern case insensitive/sensitive. If neither of
724 -i/-c: make the pattern case insensitive/sensitive. If neither of
725 these options is given, the default is read from your ipythonrc
725 these options is given, the default is read from your ipythonrc
726 file. The option name which sets this value is
726 file. The option name which sets this value is
727 'wildcards_case_sensitive'. If this option is not specified in your
727 'wildcards_case_sensitive'. If this option is not specified in your
728 ipythonrc file, IPython's internal default is to do a case sensitive
728 ipythonrc file, IPython's internal default is to do a case sensitive
729 search.
729 search.
730
730
731 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
731 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
732 specifiy can be searched in any of the following namespaces:
732 specifiy can be searched in any of the following namespaces:
733 'builtin', 'user', 'user_global','internal', 'alias', where
733 'builtin', 'user', 'user_global','internal', 'alias', where
734 'builtin' and 'user' are the search defaults. Note that you should
734 'builtin' and 'user' are the search defaults. Note that you should
735 not use quotes when specifying namespaces.
735 not use quotes when specifying namespaces.
736
736
737 'Builtin' contains the python module builtin, 'user' contains all
737 'Builtin' contains the python module builtin, 'user' contains all
738 user data, 'alias' only contain the shell aliases and no python
738 user data, 'alias' only contain the shell aliases and no python
739 objects, 'internal' contains objects used by IPython. The
739 objects, 'internal' contains objects used by IPython. The
740 'user_global' namespace is only used by embedded IPython instances,
740 'user_global' namespace is only used by embedded IPython instances,
741 and it contains module-level globals. You can add namespaces to the
741 and it contains module-level globals. You can add namespaces to the
742 search with -s or exclude them with -e (these options can be given
742 search with -s or exclude them with -e (these options can be given
743 more than once).
743 more than once).
744
744
745 Examples:
745 Examples:
746
746
747 %psearch a* -> objects beginning with an a
747 %psearch a* -> objects beginning with an a
748 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
748 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
749 %psearch a* function -> all functions beginning with an a
749 %psearch a* function -> all functions beginning with an a
750 %psearch re.e* -> objects beginning with an e in module re
750 %psearch re.e* -> objects beginning with an e in module re
751 %psearch r*.e* -> objects that start with e in modules starting in r
751 %psearch r*.e* -> objects that start with e in modules starting in r
752 %psearch r*.* string -> all strings in modules beginning with r
752 %psearch r*.* string -> all strings in modules beginning with r
753
753
754 Case sensitve search:
754 Case sensitve search:
755
755
756 %psearch -c a* list all object beginning with lower case a
756 %psearch -c a* list all object beginning with lower case a
757
757
758 Show objects beginning with a single _:
758 Show objects beginning with a single _:
759
759
760 %psearch -a _* list objects beginning with a single underscore"""
760 %psearch -a _* list objects beginning with a single underscore"""
761
761
762 # default namespaces to be searched
762 # default namespaces to be searched
763 def_search = ['user','builtin']
763 def_search = ['user','builtin']
764
764
765 # Process options/args
765 # Process options/args
766 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
766 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
767 opt = opts.get
767 opt = opts.get
768 shell = self.shell
768 shell = self.shell
769 psearch = shell.inspector.psearch
769 psearch = shell.inspector.psearch
770
770
771 # select case options
771 # select case options
772 if opts.has_key('i'):
772 if opts.has_key('i'):
773 ignore_case = True
773 ignore_case = True
774 elif opts.has_key('c'):
774 elif opts.has_key('c'):
775 ignore_case = False
775 ignore_case = False
776 else:
776 else:
777 ignore_case = not shell.rc.wildcards_case_sensitive
777 ignore_case = not shell.rc.wildcards_case_sensitive
778
778
779 # Build list of namespaces to search from user options
779 # Build list of namespaces to search from user options
780 def_search.extend(opt('s',[]))
780 def_search.extend(opt('s',[]))
781 ns_exclude = ns_exclude=opt('e',[])
781 ns_exclude = ns_exclude=opt('e',[])
782 ns_search = [nm for nm in def_search if nm not in ns_exclude]
782 ns_search = [nm for nm in def_search if nm not in ns_exclude]
783
783
784 # Call the actual search
784 # Call the actual search
785 try:
785 try:
786 psearch(args,shell.ns_table,ns_search,
786 psearch(args,shell.ns_table,ns_search,
787 show_all=opt('a'),ignore_case=ignore_case)
787 show_all=opt('a'),ignore_case=ignore_case)
788 except:
788 except:
789 shell.showtraceback()
789 shell.showtraceback()
790
790
791 def magic_who_ls(self, parameter_s=''):
791 def magic_who_ls(self, parameter_s=''):
792 """Return a sorted list of all interactive variables.
792 """Return a sorted list of all interactive variables.
793
793
794 If arguments are given, only variables of types matching these
794 If arguments are given, only variables of types matching these
795 arguments are returned."""
795 arguments are returned."""
796
796
797 user_ns = self.shell.user_ns
797 user_ns = self.shell.user_ns
798 internal_ns = self.shell.internal_ns
798 internal_ns = self.shell.internal_ns
799 user_config_ns = self.shell.user_config_ns
799 user_config_ns = self.shell.user_config_ns
800 out = []
800 out = []
801 typelist = parameter_s.split()
801 typelist = parameter_s.split()
802
802
803 for i in user_ns:
803 for i in user_ns:
804 if not (i.startswith('_') or i.startswith('_i')) \
804 if not (i.startswith('_') or i.startswith('_i')) \
805 and not (i in internal_ns or i in user_config_ns):
805 and not (i in internal_ns or i in user_config_ns):
806 if typelist:
806 if typelist:
807 if type(user_ns[i]).__name__ in typelist:
807 if type(user_ns[i]).__name__ in typelist:
808 out.append(i)
808 out.append(i)
809 else:
809 else:
810 out.append(i)
810 out.append(i)
811 out.sort()
811 out.sort()
812 return out
812 return out
813
813
814 def magic_who(self, parameter_s=''):
814 def magic_who(self, parameter_s=''):
815 """Print all interactive variables, with some minimal formatting.
815 """Print all interactive variables, with some minimal formatting.
816
816
817 If any arguments are given, only variables whose type matches one of
817 If any arguments are given, only variables whose type matches one of
818 these are printed. For example:
818 these are printed. For example:
819
819
820 %who function str
820 %who function str
821
821
822 will only list functions and strings, excluding all other types of
822 will only list functions and strings, excluding all other types of
823 variables. To find the proper type names, simply use type(var) at a
823 variables. To find the proper type names, simply use type(var) at a
824 command line to see how python prints type names. For example:
824 command line to see how python prints type names. For example:
825
825
826 In [1]: type('hello')\\
826 In [1]: type('hello')\\
827 Out[1]: <type 'str'>
827 Out[1]: <type 'str'>
828
828
829 indicates that the type name for strings is 'str'.
829 indicates that the type name for strings is 'str'.
830
830
831 %who always excludes executed names loaded through your configuration
831 %who always excludes executed names loaded through your configuration
832 file and things which are internal to IPython.
832 file and things which are internal to IPython.
833
833
834 This is deliberate, as typically you may load many modules and the
834 This is deliberate, as typically you may load many modules and the
835 purpose of %who is to show you only what you've manually defined."""
835 purpose of %who is to show you only what you've manually defined."""
836
836
837 varlist = self.magic_who_ls(parameter_s)
837 varlist = self.magic_who_ls(parameter_s)
838 if not varlist:
838 if not varlist:
839 print 'Interactive namespace is empty.'
839 print 'Interactive namespace is empty.'
840 return
840 return
841
841
842 # if we have variables, move on...
842 # if we have variables, move on...
843
843
844 # stupid flushing problem: when prompts have no separators, stdout is
844 # stupid flushing problem: when prompts have no separators, stdout is
845 # getting lost. I'm starting to think this is a python bug. I'm having
845 # getting lost. I'm starting to think this is a python bug. I'm having
846 # to force a flush with a print because even a sys.stdout.flush
846 # to force a flush with a print because even a sys.stdout.flush
847 # doesn't seem to do anything!
847 # doesn't seem to do anything!
848
848
849 count = 0
849 count = 0
850 for i in varlist:
850 for i in varlist:
851 print i+'\t',
851 print i+'\t',
852 count += 1
852 count += 1
853 if count > 8:
853 if count > 8:
854 count = 0
854 count = 0
855 print
855 print
856 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
856 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
857
857
858 print # well, this does force a flush at the expense of an extra \n
858 print # well, this does force a flush at the expense of an extra \n
859
859
860 def magic_whos(self, parameter_s=''):
860 def magic_whos(self, parameter_s=''):
861 """Like %who, but gives some extra information about each variable.
861 """Like %who, but gives some extra information about each variable.
862
862
863 The same type filtering of %who can be applied here.
863 The same type filtering of %who can be applied here.
864
864
865 For all variables, the type is printed. Additionally it prints:
865 For all variables, the type is printed. Additionally it prints:
866
866
867 - For {},[],(): their length.
867 - For {},[],(): their length.
868
868
869 - For Numeric arrays, a summary with shape, number of elements,
869 - For Numeric arrays, a summary with shape, number of elements,
870 typecode and size in memory.
870 typecode and size in memory.
871
871
872 - Everything else: a string representation, snipping their middle if
872 - Everything else: a string representation, snipping their middle if
873 too long."""
873 too long."""
874
874
875 varnames = self.magic_who_ls(parameter_s)
875 varnames = self.magic_who_ls(parameter_s)
876 if not varnames:
876 if not varnames:
877 print 'Interactive namespace is empty.'
877 print 'Interactive namespace is empty.'
878 return
878 return
879
879
880 # if we have variables, move on...
880 # if we have variables, move on...
881
881
882 # for these types, show len() instead of data:
882 # for these types, show len() instead of data:
883 seq_types = [types.DictType,types.ListType,types.TupleType]
883 seq_types = [types.DictType,types.ListType,types.TupleType]
884
884
885 # for Numeric arrays, display summary info
885 # for Numeric arrays, display summary info
886 try:
886 try:
887 import Numeric
887 import Numeric
888 except ImportError:
888 except ImportError:
889 array_type = None
889 array_type = None
890 else:
890 else:
891 array_type = Numeric.ArrayType.__name__
891 array_type = Numeric.ArrayType.__name__
892
892
893 # Find all variable names and types so we can figure out column sizes
893 # Find all variable names and types so we can figure out column sizes
894 get_vars = lambda i: self.shell.user_ns[i]
894 get_vars = lambda i: self.shell.user_ns[i]
895 type_name = lambda v: type(v).__name__
895 type_name = lambda v: type(v).__name__
896 varlist = map(get_vars,varnames)
896 varlist = map(get_vars,varnames)
897
897
898 typelist = []
898 typelist = []
899 for vv in varlist:
899 for vv in varlist:
900 tt = type_name(vv)
900 tt = type_name(vv)
901 if tt=='instance':
901 if tt=='instance':
902 typelist.append(str(vv.__class__))
902 typelist.append(str(vv.__class__))
903 else:
903 else:
904 typelist.append(tt)
904 typelist.append(tt)
905
905
906 # column labels and # of spaces as separator
906 # column labels and # of spaces as separator
907 varlabel = 'Variable'
907 varlabel = 'Variable'
908 typelabel = 'Type'
908 typelabel = 'Type'
909 datalabel = 'Data/Info'
909 datalabel = 'Data/Info'
910 colsep = 3
910 colsep = 3
911 # variable format strings
911 # variable format strings
912 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
912 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
913 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
913 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
914 aformat = "%s: %s elems, type `%s`, %s bytes"
914 aformat = "%s: %s elems, type `%s`, %s bytes"
915 # find the size of the columns to format the output nicely
915 # find the size of the columns to format the output nicely
916 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
916 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
917 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
917 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
918 # table header
918 # table header
919 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
919 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
920 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
920 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
921 # and the table itself
921 # and the table itself
922 kb = 1024
922 kb = 1024
923 Mb = 1048576 # kb**2
923 Mb = 1048576 # kb**2
924 for vname,var,vtype in zip(varnames,varlist,typelist):
924 for vname,var,vtype in zip(varnames,varlist,typelist):
925 print itpl(vformat),
925 print itpl(vformat),
926 if vtype in seq_types:
926 if vtype in seq_types:
927 print len(var)
927 print len(var)
928 elif vtype==array_type:
928 elif vtype==array_type:
929 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
929 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
930 vsize = Numeric.size(var)
930 vsize = Numeric.size(var)
931 vbytes = vsize*var.itemsize()
931 vbytes = vsize*var.itemsize()
932 if vbytes < 100000:
932 if vbytes < 100000:
933 print aformat % (vshape,vsize,var.typecode(),vbytes)
933 print aformat % (vshape,vsize,var.typecode(),vbytes)
934 else:
934 else:
935 print aformat % (vshape,vsize,var.typecode(),vbytes),
935 print aformat % (vshape,vsize,var.typecode(),vbytes),
936 if vbytes < Mb:
936 if vbytes < Mb:
937 print '(%s kb)' % (vbytes/kb,)
937 print '(%s kb)' % (vbytes/kb,)
938 else:
938 else:
939 print '(%s Mb)' % (vbytes/Mb,)
939 print '(%s Mb)' % (vbytes/Mb,)
940 else:
940 else:
941 vstr = str(var).replace('\n','\\n')
941 vstr = str(var).replace('\n','\\n')
942 if len(vstr) < 50:
942 if len(vstr) < 50:
943 print vstr
943 print vstr
944 else:
944 else:
945 printpl(vfmt_short)
945 printpl(vfmt_short)
946
946
947 def magic_reset(self, parameter_s=''):
947 def magic_reset(self, parameter_s=''):
948 """Resets the namespace by removing all names defined by the user.
948 """Resets the namespace by removing all names defined by the user.
949
949
950 Input/Output history are left around in case you need them."""
950 Input/Output history are left around in case you need them."""
951
951
952 ans = raw_input(
952 ans = raw_input(
953 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
953 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
954 if not ans.lower() == 'y':
954 if not ans.lower() == 'y':
955 print 'Nothing done.'
955 print 'Nothing done.'
956 return
956 return
957 user_ns = self.shell.user_ns
957 user_ns = self.shell.user_ns
958 for i in self.magic_who_ls():
958 for i in self.magic_who_ls():
959 del(user_ns[i])
959 del(user_ns[i])
960
960
961 def magic_config(self,parameter_s=''):
961 def magic_config(self,parameter_s=''):
962 """Show IPython's internal configuration."""
962 """Show IPython's internal configuration."""
963
963
964 page('Current configuration structure:\n'+
964 page('Current configuration structure:\n'+
965 pformat(self.shell.rc.dict()))
965 pformat(self.shell.rc.dict()))
966
966
967 def magic_logstart(self,parameter_s=''):
967 def magic_logstart(self,parameter_s=''):
968 """Start logging anywhere in a session.
968 """Start logging anywhere in a session.
969
969
970 %logstart [-o|-t] [log_name [log_mode]]
970 %logstart [-o|-t] [log_name [log_mode]]
971
971
972 If no name is given, it defaults to a file named 'ipython_log.py' in your
972 If no name is given, it defaults to a file named 'ipython_log.py' in your
973 current directory, in 'rotate' mode (see below).
973 current directory, in 'rotate' mode (see below).
974
974
975 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
975 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
976 history up to that point and then continues logging.
976 history up to that point and then continues logging.
977
977
978 %logstart takes a second optional parameter: logging mode. This can be one
978 %logstart takes a second optional parameter: logging mode. This can be one
979 of (note that the modes are given unquoted):\\
979 of (note that the modes are given unquoted):\\
980 append: well, that says it.\\
980 append: well, that says it.\\
981 backup: rename (if exists) to name~ and start name.\\
981 backup: rename (if exists) to name~ and start name.\\
982 global: single logfile in your home dir, appended to.\\
982 global: single logfile in your home dir, appended to.\\
983 over : overwrite existing log.\\
983 over : overwrite existing log.\\
984 rotate: create rotating logs name.1~, name.2~, etc.
984 rotate: create rotating logs name.1~, name.2~, etc.
985
985
986 Options:
986 Options:
987
987
988 -o: log also IPython's output. In this mode, all commands which
988 -o: log also IPython's output. In this mode, all commands which
989 generate an Out[NN] prompt are recorded to the logfile, right after
989 generate an Out[NN] prompt are recorded to the logfile, right after
990 their corresponding input line. The output lines are always
990 their corresponding input line. The output lines are always
991 prepended with a '#[Out]# ' marker, so that the log remains valid
991 prepended with a '#[Out]# ' marker, so that the log remains valid
992 Python code.
992 Python code.
993
993
994 Since this marker is always the same, filtering only the output from
994 Since this marker is always the same, filtering only the output from
995 a log is very easy, using for example a simple awk call:
995 a log is very easy, using for example a simple awk call:
996
996
997 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
997 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
998
998
999 -t: put timestamps before each input line logged (these are put in
999 -t: put timestamps before each input line logged (these are put in
1000 comments)."""
1000 comments)."""
1001
1001
1002 opts,par = self.parse_options(parameter_s,'ot')
1002 opts,par = self.parse_options(parameter_s,'ot')
1003 log_output = 'o' in opts
1003 log_output = 'o' in opts
1004 timestamp = 't' in opts
1004 timestamp = 't' in opts
1005
1005
1006 rc = self.shell.rc
1006 rc = self.shell.rc
1007 logger = self.shell.logger
1007 logger = self.shell.logger
1008
1008
1009 # if no args are given, the defaults set in the logger constructor by
1009 # if no args are given, the defaults set in the logger constructor by
1010 # ipytohn remain valid
1010 # ipytohn remain valid
1011 if par:
1011 if par:
1012 try:
1012 try:
1013 logfname,logmode = par.split()
1013 logfname,logmode = par.split()
1014 except:
1014 except:
1015 logfname = par
1015 logfname = par
1016 logmode = 'backup'
1016 logmode = 'backup'
1017 else:
1017 else:
1018 logfname = logger.logfname
1018 logfname = logger.logfname
1019 logmode = logger.logmode
1019 logmode = logger.logmode
1020 # put logfname into rc struct as if it had been called on the command
1020 # put logfname into rc struct as if it had been called on the command
1021 # line, so it ends up saved in the log header Save it in case we need
1021 # line, so it ends up saved in the log header Save it in case we need
1022 # to restore it...
1022 # to restore it...
1023 old_logfile = rc.opts.get('logfile','')
1023 old_logfile = rc.opts.get('logfile','')
1024 if logfname:
1024 if logfname:
1025 logfname = os.path.expanduser(logfname)
1025 logfname = os.path.expanduser(logfname)
1026 rc.opts.logfile = logfname
1026 rc.opts.logfile = logfname
1027 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1027 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1028 try:
1028 try:
1029 started = logger.logstart(logfname,loghead,logmode,
1029 started = logger.logstart(logfname,loghead,logmode,
1030 log_output,timestamp)
1030 log_output,timestamp)
1031 except:
1031 except:
1032 rc.opts.logfile = old_logfile
1032 rc.opts.logfile = old_logfile
1033 warn("Couldn't start log: %s" % sys.exc_info()[1])
1033 warn("Couldn't start log: %s" % sys.exc_info()[1])
1034 else:
1034 else:
1035 # log input history up to this point, optionally interleaving
1035 # log input history up to this point, optionally interleaving
1036 # output if requested
1036 # output if requested
1037
1037
1038 if timestamp:
1038 if timestamp:
1039 # disable timestamping for the previous history, since we've
1039 # disable timestamping for the previous history, since we've
1040 # lost those already (no time machine here).
1040 # lost those already (no time machine here).
1041 logger.timestamp = False
1041 logger.timestamp = False
1042 if log_output:
1042 if log_output:
1043 log_write = logger.log_write
1043 log_write = logger.log_write
1044 input_hist = self.shell.input_hist
1044 input_hist = self.shell.input_hist
1045 output_hist = self.shell.output_hist
1045 output_hist = self.shell.output_hist
1046 for n in range(1,len(input_hist)-1):
1046 for n in range(1,len(input_hist)-1):
1047 log_write(input_hist[n].rstrip())
1047 log_write(input_hist[n].rstrip())
1048 if n in output_hist:
1048 if n in output_hist:
1049 log_write(repr(output_hist[n]),'output')
1049 log_write(repr(output_hist[n]),'output')
1050 else:
1050 else:
1051 logger.log_write(self.shell.input_hist[1:])
1051 logger.log_write(self.shell.input_hist[1:])
1052 if timestamp:
1052 if timestamp:
1053 # re-enable timestamping
1053 # re-enable timestamping
1054 logger.timestamp = True
1054 logger.timestamp = True
1055
1055
1056 print ('Activating auto-logging. '
1056 print ('Activating auto-logging. '
1057 'Current session state plus future input saved.')
1057 'Current session state plus future input saved.')
1058 logger.logstate()
1058 logger.logstate()
1059
1059
1060 def magic_logoff(self,parameter_s=''):
1060 def magic_logoff(self,parameter_s=''):
1061 """Temporarily stop logging.
1061 """Temporarily stop logging.
1062
1062
1063 You must have previously started logging."""
1063 You must have previously started logging."""
1064 self.shell.logger.switch_log(0)
1064 self.shell.logger.switch_log(0)
1065
1065
1066 def magic_logon(self,parameter_s=''):
1066 def magic_logon(self,parameter_s=''):
1067 """Restart logging.
1067 """Restart logging.
1068
1068
1069 This function is for restarting logging which you've temporarily
1069 This function is for restarting logging which you've temporarily
1070 stopped with %logoff. For starting logging for the first time, you
1070 stopped with %logoff. For starting logging for the first time, you
1071 must use the %logstart function, which allows you to specify an
1071 must use the %logstart function, which allows you to specify an
1072 optional log filename."""
1072 optional log filename."""
1073
1073
1074 self.shell.logger.switch_log(1)
1074 self.shell.logger.switch_log(1)
1075
1075
1076 def magic_logstate(self,parameter_s=''):
1076 def magic_logstate(self,parameter_s=''):
1077 """Print the status of the logging system."""
1077 """Print the status of the logging system."""
1078
1078
1079 self.shell.logger.logstate()
1079 self.shell.logger.logstate()
1080
1080
1081 def magic_pdb(self, parameter_s=''):
1081 def magic_pdb(self, parameter_s=''):
1082 """Control the calling of the pdb interactive debugger.
1082 """Control the calling of the pdb interactive debugger.
1083
1083
1084 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1084 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1085 argument it works as a toggle.
1085 argument it works as a toggle.
1086
1086
1087 When an exception is triggered, IPython can optionally call the
1087 When an exception is triggered, IPython can optionally call the
1088 interactive pdb debugger after the traceback printout. %pdb toggles
1088 interactive pdb debugger after the traceback printout. %pdb toggles
1089 this feature on and off."""
1089 this feature on and off."""
1090
1090
1091 par = parameter_s.strip().lower()
1091 par = parameter_s.strip().lower()
1092
1092
1093 if par:
1093 if par:
1094 try:
1094 try:
1095 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1095 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1096 except KeyError:
1096 except KeyError:
1097 print ('Incorrect argument. Use on/1, off/0, '
1097 print ('Incorrect argument. Use on/1, off/0, '
1098 'or nothing for a toggle.')
1098 'or nothing for a toggle.')
1099 return
1099 return
1100 else:
1100 else:
1101 # toggle
1101 # toggle
1102 new_pdb = not self.shell.InteractiveTB.call_pdb
1102 new_pdb = not self.shell.InteractiveTB.call_pdb
1103
1103
1104 # set on the shell
1104 # set on the shell
1105 self.shell.call_pdb = new_pdb
1105 self.shell.call_pdb = new_pdb
1106 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1106 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1107
1107
1108 def magic_prun(self, parameter_s ='',user_mode=1,
1108 def magic_prun(self, parameter_s ='',user_mode=1,
1109 opts=None,arg_lst=None,prog_ns=None):
1109 opts=None,arg_lst=None,prog_ns=None):
1110
1110
1111 """Run a statement through the python code profiler.
1111 """Run a statement through the python code profiler.
1112
1112
1113 Usage:\\
1113 Usage:\\
1114 %prun [options] statement
1114 %prun [options] statement
1115
1115
1116 The given statement (which doesn't require quote marks) is run via the
1116 The given statement (which doesn't require quote marks) is run via the
1117 python profiler in a manner similar to the profile.run() function.
1117 python profiler in a manner similar to the profile.run() function.
1118 Namespaces are internally managed to work correctly; profile.run
1118 Namespaces are internally managed to work correctly; profile.run
1119 cannot be used in IPython because it makes certain assumptions about
1119 cannot be used in IPython because it makes certain assumptions about
1120 namespaces which do not hold under IPython.
1120 namespaces which do not hold under IPython.
1121
1121
1122 Options:
1122 Options:
1123
1123
1124 -l <limit>: you can place restrictions on what or how much of the
1124 -l <limit>: you can place restrictions on what or how much of the
1125 profile gets printed. The limit value can be:
1125 profile gets printed. The limit value can be:
1126
1126
1127 * A string: only information for function names containing this string
1127 * A string: only information for function names containing this string
1128 is printed.
1128 is printed.
1129
1129
1130 * An integer: only these many lines are printed.
1130 * An integer: only these many lines are printed.
1131
1131
1132 * A float (between 0 and 1): this fraction of the report is printed
1132 * A float (between 0 and 1): this fraction of the report is printed
1133 (for example, use a limit of 0.4 to see the topmost 40% only).
1133 (for example, use a limit of 0.4 to see the topmost 40% only).
1134
1134
1135 You can combine several limits with repeated use of the option. For
1135 You can combine several limits with repeated use of the option. For
1136 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1136 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1137 information about class constructors.
1137 information about class constructors.
1138
1138
1139 -r: return the pstats.Stats object generated by the profiling. This
1139 -r: return the pstats.Stats object generated by the profiling. This
1140 object has all the information about the profile in it, and you can
1140 object has all the information about the profile in it, and you can
1141 later use it for further analysis or in other functions.
1141 later use it for further analysis or in other functions.
1142
1142
1143 Since magic functions have a particular form of calling which prevents
1143 Since magic functions have a particular form of calling which prevents
1144 you from writing something like:\\
1144 you from writing something like:\\
1145 In [1]: p = %prun -r print 4 # invalid!\\
1145 In [1]: p = %prun -r print 4 # invalid!\\
1146 you must instead use IPython's automatic variables to assign this:\\
1146 you must instead use IPython's automatic variables to assign this:\\
1147 In [1]: %prun -r print 4 \\
1147 In [1]: %prun -r print 4 \\
1148 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1148 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1149 In [2]: stats = _
1149 In [2]: stats = _
1150
1150
1151 If you really need to assign this value via an explicit function call,
1151 If you really need to assign this value via an explicit function call,
1152 you can always tap directly into the true name of the magic function
1152 you can always tap directly into the true name of the magic function
1153 by using the _ip.magic function:\\
1153 by using the _ip.magic function:\\
1154 In [3]: stats = _ip.magic('prun','-r print 4')
1154 In [3]: stats = _ip.magic('prun','-r print 4')
1155
1155
1156 You can type _ip.magic? for more details.
1156 You can type _ip.magic? for more details.
1157
1157
1158 -s <key>: sort profile by given key. You can provide more than one key
1158 -s <key>: sort profile by given key. You can provide more than one key
1159 by using the option several times: '-s key1 -s key2 -s key3...'. The
1159 by using the option several times: '-s key1 -s key2 -s key3...'. The
1160 default sorting key is 'time'.
1160 default sorting key is 'time'.
1161
1161
1162 The following is copied verbatim from the profile documentation
1162 The following is copied verbatim from the profile documentation
1163 referenced below:
1163 referenced below:
1164
1164
1165 When more than one key is provided, additional keys are used as
1165 When more than one key is provided, additional keys are used as
1166 secondary criteria when the there is equality in all keys selected
1166 secondary criteria when the there is equality in all keys selected
1167 before them.
1167 before them.
1168
1168
1169 Abbreviations can be used for any key names, as long as the
1169 Abbreviations can be used for any key names, as long as the
1170 abbreviation is unambiguous. The following are the keys currently
1170 abbreviation is unambiguous. The following are the keys currently
1171 defined:
1171 defined:
1172
1172
1173 Valid Arg Meaning\\
1173 Valid Arg Meaning\\
1174 "calls" call count\\
1174 "calls" call count\\
1175 "cumulative" cumulative time\\
1175 "cumulative" cumulative time\\
1176 "file" file name\\
1176 "file" file name\\
1177 "module" file name\\
1177 "module" file name\\
1178 "pcalls" primitive call count\\
1178 "pcalls" primitive call count\\
1179 "line" line number\\
1179 "line" line number\\
1180 "name" function name\\
1180 "name" function name\\
1181 "nfl" name/file/line\\
1181 "nfl" name/file/line\\
1182 "stdname" standard name\\
1182 "stdname" standard name\\
1183 "time" internal time
1183 "time" internal time
1184
1184
1185 Note that all sorts on statistics are in descending order (placing
1185 Note that all sorts on statistics are in descending order (placing
1186 most time consuming items first), where as name, file, and line number
1186 most time consuming items first), where as name, file, and line number
1187 searches are in ascending order (i.e., alphabetical). The subtle
1187 searches are in ascending order (i.e., alphabetical). The subtle
1188 distinction between "nfl" and "stdname" is that the standard name is a
1188 distinction between "nfl" and "stdname" is that the standard name is a
1189 sort of the name as printed, which means that the embedded line
1189 sort of the name as printed, which means that the embedded line
1190 numbers get compared in an odd way. For example, lines 3, 20, and 40
1190 numbers get compared in an odd way. For example, lines 3, 20, and 40
1191 would (if the file names were the same) appear in the string order
1191 would (if the file names were the same) appear in the string order
1192 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1192 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1193 line numbers. In fact, sort_stats("nfl") is the same as
1193 line numbers. In fact, sort_stats("nfl") is the same as
1194 sort_stats("name", "file", "line").
1194 sort_stats("name", "file", "line").
1195
1195
1196 -T <filename>: save profile results as shown on screen to a text
1196 -T <filename>: save profile results as shown on screen to a text
1197 file. The profile is still shown on screen.
1197 file. The profile is still shown on screen.
1198
1198
1199 -D <filename>: save (via dump_stats) profile statistics to given
1199 -D <filename>: save (via dump_stats) profile statistics to given
1200 filename. This data is in a format understod by the pstats module, and
1200 filename. This data is in a format understod by the pstats module, and
1201 is generated by a call to the dump_stats() method of profile
1201 is generated by a call to the dump_stats() method of profile
1202 objects. The profile is still shown on screen.
1202 objects. The profile is still shown on screen.
1203
1203
1204 If you want to run complete programs under the profiler's control, use
1204 If you want to run complete programs under the profiler's control, use
1205 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1205 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1206 contains profiler specific options as described here.
1206 contains profiler specific options as described here.
1207
1207
1208 You can read the complete documentation for the profile module with:\\
1208 You can read the complete documentation for the profile module with:\\
1209 In [1]: import profile; profile.help() """
1209 In [1]: import profile; profile.help() """
1210
1210
1211 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1211 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1212 # protect user quote marks
1212 # protect user quote marks
1213 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1213 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1214
1214
1215 if user_mode: # regular user call
1215 if user_mode: # regular user call
1216 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1216 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1217 list_all=1)
1217 list_all=1)
1218 namespace = self.shell.user_ns
1218 namespace = self.shell.user_ns
1219 else: # called to run a program by %run -p
1219 else: # called to run a program by %run -p
1220 try:
1220 try:
1221 filename = get_py_filename(arg_lst[0])
1221 filename = get_py_filename(arg_lst[0])
1222 except IOError,msg:
1222 except IOError,msg:
1223 error(msg)
1223 error(msg)
1224 return
1224 return
1225
1225
1226 arg_str = 'execfile(filename,prog_ns)'
1226 arg_str = 'execfile(filename,prog_ns)'
1227 namespace = locals()
1227 namespace = locals()
1228
1228
1229 opts.merge(opts_def)
1229 opts.merge(opts_def)
1230
1230
1231 prof = profile.Profile()
1231 prof = profile.Profile()
1232 try:
1232 try:
1233 prof = prof.runctx(arg_str,namespace,namespace)
1233 prof = prof.runctx(arg_str,namespace,namespace)
1234 sys_exit = ''
1234 sys_exit = ''
1235 except SystemExit:
1235 except SystemExit:
1236 sys_exit = """*** SystemExit exception caught in code being profiled."""
1236 sys_exit = """*** SystemExit exception caught in code being profiled."""
1237
1237
1238 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1238 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1239
1239
1240 lims = opts.l
1240 lims = opts.l
1241 if lims:
1241 if lims:
1242 lims = [] # rebuild lims with ints/floats/strings
1242 lims = [] # rebuild lims with ints/floats/strings
1243 for lim in opts.l:
1243 for lim in opts.l:
1244 try:
1244 try:
1245 lims.append(int(lim))
1245 lims.append(int(lim))
1246 except ValueError:
1246 except ValueError:
1247 try:
1247 try:
1248 lims.append(float(lim))
1248 lims.append(float(lim))
1249 except ValueError:
1249 except ValueError:
1250 lims.append(lim)
1250 lims.append(lim)
1251
1251
1252 # trap output
1252 # trap output
1253 sys_stdout = sys.stdout
1253 sys_stdout = sys.stdout
1254 stdout_trap = StringIO()
1254 stdout_trap = StringIO()
1255 try:
1255 try:
1256 sys.stdout = stdout_trap
1256 sys.stdout = stdout_trap
1257 stats.print_stats(*lims)
1257 stats.print_stats(*lims)
1258 finally:
1258 finally:
1259 sys.stdout = sys_stdout
1259 sys.stdout = sys_stdout
1260 output = stdout_trap.getvalue()
1260 output = stdout_trap.getvalue()
1261 output = output.rstrip()
1261 output = output.rstrip()
1262
1262
1263 page(output,screen_lines=self.shell.rc.screen_length)
1263 page(output,screen_lines=self.shell.rc.screen_length)
1264 print sys_exit,
1264 print sys_exit,
1265
1265
1266 dump_file = opts.D[0]
1266 dump_file = opts.D[0]
1267 text_file = opts.T[0]
1267 text_file = opts.T[0]
1268 if dump_file:
1268 if dump_file:
1269 prof.dump_stats(dump_file)
1269 prof.dump_stats(dump_file)
1270 print '\n*** Profile stats marshalled to file',\
1270 print '\n*** Profile stats marshalled to file',\
1271 `dump_file`+'.',sys_exit
1271 `dump_file`+'.',sys_exit
1272 if text_file:
1272 if text_file:
1273 file(text_file,'w').write(output)
1273 file(text_file,'w').write(output)
1274 print '\n*** Profile printout saved to text file',\
1274 print '\n*** Profile printout saved to text file',\
1275 `text_file`+'.',sys_exit
1275 `text_file`+'.',sys_exit
1276
1276
1277 if opts.has_key('r'):
1277 if opts.has_key('r'):
1278 return stats
1278 return stats
1279 else:
1279 else:
1280 return None
1280 return None
1281
1281
1282 def magic_run(self, parameter_s ='',runner=None):
1282 def magic_run(self, parameter_s ='',runner=None):
1283 """Run the named file inside IPython as a program.
1283 """Run the named file inside IPython as a program.
1284
1284
1285 Usage:\\
1285 Usage:\\
1286 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1286 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1287
1287
1288 Parameters after the filename are passed as command-line arguments to
1288 Parameters after the filename are passed as command-line arguments to
1289 the program (put in sys.argv). Then, control returns to IPython's
1289 the program (put in sys.argv). Then, control returns to IPython's
1290 prompt.
1290 prompt.
1291
1291
1292 This is similar to running at a system prompt:\\
1292 This is similar to running at a system prompt:\\
1293 $ python file args\\
1293 $ python file args\\
1294 but with the advantage of giving you IPython's tracebacks, and of
1294 but with the advantage of giving you IPython's tracebacks, and of
1295 loading all variables into your interactive namespace for further use
1295 loading all variables into your interactive namespace for further use
1296 (unless -p is used, see below).
1296 (unless -p is used, see below).
1297
1297
1298 The file is executed in a namespace initially consisting only of
1298 The file is executed in a namespace initially consisting only of
1299 __name__=='__main__' and sys.argv constructed as indicated. It thus
1299 __name__=='__main__' and sys.argv constructed as indicated. It thus
1300 sees its environment as if it were being run as a stand-alone
1300 sees its environment as if it were being run as a stand-alone
1301 program. But after execution, the IPython interactive namespace gets
1301 program. But after execution, the IPython interactive namespace gets
1302 updated with all variables defined in the program (except for __name__
1302 updated with all variables defined in the program (except for __name__
1303 and sys.argv). This allows for very convenient loading of code for
1303 and sys.argv). This allows for very convenient loading of code for
1304 interactive work, while giving each program a 'clean sheet' to run in.
1304 interactive work, while giving each program a 'clean sheet' to run in.
1305
1305
1306 Options:
1306 Options:
1307
1307
1308 -n: __name__ is NOT set to '__main__', but to the running file's name
1308 -n: __name__ is NOT set to '__main__', but to the running file's name
1309 without extension (as python does under import). This allows running
1309 without extension (as python does under import). This allows running
1310 scripts and reloading the definitions in them without calling code
1310 scripts and reloading the definitions in them without calling code
1311 protected by an ' if __name__ == "__main__" ' clause.
1311 protected by an ' if __name__ == "__main__" ' clause.
1312
1312
1313 -i: run the file in IPython's namespace instead of an empty one. This
1313 -i: run the file in IPython's namespace instead of an empty one. This
1314 is useful if you are experimenting with code written in a text editor
1314 is useful if you are experimenting with code written in a text editor
1315 which depends on variables defined interactively.
1315 which depends on variables defined interactively.
1316
1316
1317 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1317 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1318 being run. This is particularly useful if IPython is being used to
1318 being run. This is particularly useful if IPython is being used to
1319 run unittests, which always exit with a sys.exit() call. In such
1319 run unittests, which always exit with a sys.exit() call. In such
1320 cases you are interested in the output of the test results, not in
1320 cases you are interested in the output of the test results, not in
1321 seeing a traceback of the unittest module.
1321 seeing a traceback of the unittest module.
1322
1322
1323 -t: print timing information at the end of the run. IPython will give
1323 -t: print timing information at the end of the run. IPython will give
1324 you an estimated CPU time consumption for your script, which under
1324 you an estimated CPU time consumption for your script, which under
1325 Unix uses the resource module to avoid the wraparound problems of
1325 Unix uses the resource module to avoid the wraparound problems of
1326 time.clock(). Under Unix, an estimate of time spent on system tasks
1326 time.clock(). Under Unix, an estimate of time spent on system tasks
1327 is also given (for Windows platforms this is reported as 0.0).
1327 is also given (for Windows platforms this is reported as 0.0).
1328
1328
1329 If -t is given, an additional -N<N> option can be given, where <N>
1329 If -t is given, an additional -N<N> option can be given, where <N>
1330 must be an integer indicating how many times you want the script to
1330 must be an integer indicating how many times you want the script to
1331 run. The final timing report will include total and per run results.
1331 run. The final timing report will include total and per run results.
1332
1332
1333 For example (testing the script uniq_stable.py):
1333 For example (testing the script uniq_stable.py):
1334
1334
1335 In [1]: run -t uniq_stable
1335 In [1]: run -t uniq_stable
1336
1336
1337 IPython CPU timings (estimated):\\
1337 IPython CPU timings (estimated):\\
1338 User : 0.19597 s.\\
1338 User : 0.19597 s.\\
1339 System: 0.0 s.\\
1339 System: 0.0 s.\\
1340
1340
1341 In [2]: run -t -N5 uniq_stable
1341 In [2]: run -t -N5 uniq_stable
1342
1342
1343 IPython CPU timings (estimated):\\
1343 IPython CPU timings (estimated):\\
1344 Total runs performed: 5\\
1344 Total runs performed: 5\\
1345 Times : Total Per run\\
1345 Times : Total Per run\\
1346 User : 0.910862 s, 0.1821724 s.\\
1346 User : 0.910862 s, 0.1821724 s.\\
1347 System: 0.0 s, 0.0 s.
1347 System: 0.0 s, 0.0 s.
1348
1348
1349 -d: run your program under the control of pdb, the Python debugger.
1349 -d: run your program under the control of pdb, the Python debugger.
1350 This allows you to execute your program step by step, watch variables,
1350 This allows you to execute your program step by step, watch variables,
1351 etc. Internally, what IPython does is similar to calling:
1351 etc. Internally, what IPython does is similar to calling:
1352
1352
1353 pdb.run('execfile("YOURFILENAME")')
1353 pdb.run('execfile("YOURFILENAME")')
1354
1354
1355 with a breakpoint set on line 1 of your file. You can change the line
1355 with a breakpoint set on line 1 of your file. You can change the line
1356 number for this automatic breakpoint to be <N> by using the -bN option
1356 number for this automatic breakpoint to be <N> by using the -bN option
1357 (where N must be an integer). For example:
1357 (where N must be an integer). For example:
1358
1358
1359 %run -d -b40 myscript
1359 %run -d -b40 myscript
1360
1360
1361 will set the first breakpoint at line 40 in myscript.py. Note that
1361 will set the first breakpoint at line 40 in myscript.py. Note that
1362 the first breakpoint must be set on a line which actually does
1362 the first breakpoint must be set on a line which actually does
1363 something (not a comment or docstring) for it to stop execution.
1363 something (not a comment or docstring) for it to stop execution.
1364
1364
1365 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1365 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1366 first enter 'c' (without qoutes) to start execution up to the first
1366 first enter 'c' (without qoutes) to start execution up to the first
1367 breakpoint.
1367 breakpoint.
1368
1368
1369 Entering 'help' gives information about the use of the debugger. You
1369 Entering 'help' gives information about the use of the debugger. You
1370 can easily see pdb's full documentation with "import pdb;pdb.help()"
1370 can easily see pdb's full documentation with "import pdb;pdb.help()"
1371 at a prompt.
1371 at a prompt.
1372
1372
1373 -p: run program under the control of the Python profiler module (which
1373 -p: run program under the control of the Python profiler module (which
1374 prints a detailed report of execution times, function calls, etc).
1374 prints a detailed report of execution times, function calls, etc).
1375
1375
1376 You can pass other options after -p which affect the behavior of the
1376 You can pass other options after -p which affect the behavior of the
1377 profiler itself. See the docs for %prun for details.
1377 profiler itself. See the docs for %prun for details.
1378
1378
1379 In this mode, the program's variables do NOT propagate back to the
1379 In this mode, the program's variables do NOT propagate back to the
1380 IPython interactive namespace (because they remain in the namespace
1380 IPython interactive namespace (because they remain in the namespace
1381 where the profiler executes them).
1381 where the profiler executes them).
1382
1382
1383 Internally this triggers a call to %prun, see its documentation for
1383 Internally this triggers a call to %prun, see its documentation for
1384 details on the options available specifically for profiling."""
1384 details on the options available specifically for profiling."""
1385
1385
1386 # get arguments and set sys.argv for program to be run.
1386 # get arguments and set sys.argv for program to be run.
1387 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1387 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1388 mode='list',list_all=1)
1388 mode='list',list_all=1)
1389
1389
1390 try:
1390 try:
1391 filename = get_py_filename(arg_lst[0])
1391 filename = get_py_filename(arg_lst[0])
1392 except IndexError:
1392 except IndexError:
1393 warn('you must provide at least a filename.')
1393 warn('you must provide at least a filename.')
1394 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1394 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1395 return
1395 return
1396 except IOError,msg:
1396 except IOError,msg:
1397 error(msg)
1397 error(msg)
1398 return
1398 return
1399
1399
1400 # Control the response to exit() calls made by the script being run
1400 # Control the response to exit() calls made by the script being run
1401 exit_ignore = opts.has_key('e')
1401 exit_ignore = opts.has_key('e')
1402
1402
1403 # Make sure that the running script gets a proper sys.argv as if it
1403 # Make sure that the running script gets a proper sys.argv as if it
1404 # were run from a system shell.
1404 # were run from a system shell.
1405 save_argv = sys.argv # save it for later restoring
1405 save_argv = sys.argv # save it for later restoring
1406 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1406 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1407
1407
1408 if opts.has_key('i'):
1408 if opts.has_key('i'):
1409 prog_ns = self.shell.user_ns
1409 prog_ns = self.shell.user_ns
1410 __name__save = self.shell.user_ns['__name__']
1410 __name__save = self.shell.user_ns['__name__']
1411 prog_ns['__name__'] = '__main__'
1411 prog_ns['__name__'] = '__main__'
1412 else:
1412 else:
1413 if opts.has_key('n'):
1413 if opts.has_key('n'):
1414 name = os.path.splitext(os.path.basename(filename))[0]
1414 name = os.path.splitext(os.path.basename(filename))[0]
1415 else:
1415 else:
1416 name = '__main__'
1416 name = '__main__'
1417 prog_ns = {'__name__':name}
1417 prog_ns = {'__name__':name}
1418
1418
1419 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1419 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1420 # set the __file__ global in the script's namespace
1420 # set the __file__ global in the script's namespace
1421 prog_ns['__file__'] = filename
1421 prog_ns['__file__'] = filename
1422
1422
1423 # pickle fix. See iplib for an explanation. But we need to make sure
1423 # pickle fix. See iplib for an explanation. But we need to make sure
1424 # that, if we overwrite __main__, we replace it at the end
1424 # that, if we overwrite __main__, we replace it at the end
1425 if prog_ns['__name__'] == '__main__':
1425 if prog_ns['__name__'] == '__main__':
1426 restore_main = sys.modules['__main__']
1426 restore_main = sys.modules['__main__']
1427 else:
1427 else:
1428 restore_main = False
1428 restore_main = False
1429
1429
1430 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1430 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1431
1431
1432 stats = None
1432 stats = None
1433 try:
1433 try:
1434 if opts.has_key('p'):
1434 if opts.has_key('p'):
1435 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1435 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1436 else:
1436 else:
1437 if opts.has_key('d'):
1437 if opts.has_key('d'):
1438 deb = Debugger.Pdb(self.shell.rc.colors)
1438 deb = Debugger.Pdb(self.shell.rc.colors)
1439 # reset Breakpoint state, which is moronically kept
1439 # reset Breakpoint state, which is moronically kept
1440 # in a class
1440 # in a class
1441 bdb.Breakpoint.next = 1
1441 bdb.Breakpoint.next = 1
1442 bdb.Breakpoint.bplist = {}
1442 bdb.Breakpoint.bplist = {}
1443 bdb.Breakpoint.bpbynumber = [None]
1443 bdb.Breakpoint.bpbynumber = [None]
1444 # Set an initial breakpoint to stop execution
1444 # Set an initial breakpoint to stop execution
1445 maxtries = 10
1445 maxtries = 10
1446 bp = int(opts.get('b',[1])[0])
1446 bp = int(opts.get('b',[1])[0])
1447 checkline = deb.checkline(filename,bp)
1447 checkline = deb.checkline(filename,bp)
1448 if not checkline:
1448 if not checkline:
1449 for bp in range(bp+1,bp+maxtries+1):
1449 for bp in range(bp+1,bp+maxtries+1):
1450 if deb.checkline(filename,bp):
1450 if deb.checkline(filename,bp):
1451 break
1451 break
1452 else:
1452 else:
1453 msg = ("\nI failed to find a valid line to set "
1453 msg = ("\nI failed to find a valid line to set "
1454 "a breakpoint\n"
1454 "a breakpoint\n"
1455 "after trying up to line: %s.\n"
1455 "after trying up to line: %s.\n"
1456 "Please set a valid breakpoint manually "
1456 "Please set a valid breakpoint manually "
1457 "with the -b option." % bp)
1457 "with the -b option." % bp)
1458 error(msg)
1458 error(msg)
1459 return
1459 return
1460 # if we find a good linenumber, set the breakpoint
1460 # if we find a good linenumber, set the breakpoint
1461 deb.do_break('%s:%s' % (filename,bp))
1461 deb.do_break('%s:%s' % (filename,bp))
1462 # Start file run
1462 # Start file run
1463 print "NOTE: Enter 'c' at the",
1463 print "NOTE: Enter 'c' at the",
1464 print "ipdb> prompt to start your script."
1464 print "ipdb> prompt to start your script."
1465 try:
1465 try:
1466 deb.run('execfile("%s")' % filename,prog_ns)
1466 deb.run('execfile("%s")' % filename,prog_ns)
1467 except:
1467 except:
1468 etype, value, tb = sys.exc_info()
1468 etype, value, tb = sys.exc_info()
1469 # Skip three frames in the traceback: the %run one,
1469 # Skip three frames in the traceback: the %run one,
1470 # one inside bdb.py, and the command-line typed by the
1470 # one inside bdb.py, and the command-line typed by the
1471 # user (run by exec in pdb itself).
1471 # user (run by exec in pdb itself).
1472 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1472 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1473 else:
1473 else:
1474 if runner is None:
1474 if runner is None:
1475 runner = self.shell.safe_execfile
1475 runner = self.shell.safe_execfile
1476 if opts.has_key('t'):
1476 if opts.has_key('t'):
1477 try:
1477 try:
1478 nruns = int(opts['N'][0])
1478 nruns = int(opts['N'][0])
1479 if nruns < 1:
1479 if nruns < 1:
1480 error('Number of runs must be >=1')
1480 error('Number of runs must be >=1')
1481 return
1481 return
1482 except (KeyError):
1482 except (KeyError):
1483 nruns = 1
1483 nruns = 1
1484 if nruns == 1:
1484 if nruns == 1:
1485 t0 = clock2()
1485 t0 = clock2()
1486 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1486 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1487 t1 = clock2()
1487 t1 = clock2()
1488 t_usr = t1[0]-t0[0]
1488 t_usr = t1[0]-t0[0]
1489 t_sys = t1[1]-t1[1]
1489 t_sys = t1[1]-t1[1]
1490 print "\nIPython CPU timings (estimated):"
1490 print "\nIPython CPU timings (estimated):"
1491 print " User : %10s s." % t_usr
1491 print " User : %10s s." % t_usr
1492 print " System: %10s s." % t_sys
1492 print " System: %10s s." % t_sys
1493 else:
1493 else:
1494 runs = range(nruns)
1494 runs = range(nruns)
1495 t0 = clock2()
1495 t0 = clock2()
1496 for nr in runs:
1496 for nr in runs:
1497 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1497 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1498 t1 = clock2()
1498 t1 = clock2()
1499 t_usr = t1[0]-t0[0]
1499 t_usr = t1[0]-t0[0]
1500 t_sys = t1[1]-t1[1]
1500 t_sys = t1[1]-t1[1]
1501 print "\nIPython CPU timings (estimated):"
1501 print "\nIPython CPU timings (estimated):"
1502 print "Total runs performed:",nruns
1502 print "Total runs performed:",nruns
1503 print " Times : %10s %10s" % ('Total','Per run')
1503 print " Times : %10s %10s" % ('Total','Per run')
1504 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1504 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1505 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1505 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1506
1506
1507 else:
1507 else:
1508 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1508 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1509 if opts.has_key('i'):
1509 if opts.has_key('i'):
1510 self.shell.user_ns['__name__'] = __name__save
1510 self.shell.user_ns['__name__'] = __name__save
1511 else:
1511 else:
1512 # update IPython interactive namespace
1512 # update IPython interactive namespace
1513 del prog_ns['__name__']
1513 del prog_ns['__name__']
1514 self.shell.user_ns.update(prog_ns)
1514 self.shell.user_ns.update(prog_ns)
1515 finally:
1515 finally:
1516 sys.argv = save_argv
1516 sys.argv = save_argv
1517 if restore_main:
1517 if restore_main:
1518 sys.modules['__main__'] = restore_main
1518 sys.modules['__main__'] = restore_main
1519 return stats
1519 return stats
1520
1520
1521 def magic_runlog(self, parameter_s =''):
1521 def magic_runlog(self, parameter_s =''):
1522 """Run files as logs.
1522 """Run files as logs.
1523
1523
1524 Usage:\\
1524 Usage:\\
1525 %runlog file1 file2 ...
1525 %runlog file1 file2 ...
1526
1526
1527 Run the named files (treating them as log files) in sequence inside
1527 Run the named files (treating them as log files) in sequence inside
1528 the interpreter, and return to the prompt. This is much slower than
1528 the interpreter, and return to the prompt. This is much slower than
1529 %run because each line is executed in a try/except block, but it
1529 %run because each line is executed in a try/except block, but it
1530 allows running files with syntax errors in them.
1530 allows running files with syntax errors in them.
1531
1531
1532 Normally IPython will guess when a file is one of its own logfiles, so
1532 Normally IPython will guess when a file is one of its own logfiles, so
1533 you can typically use %run even for logs. This shorthand allows you to
1533 you can typically use %run even for logs. This shorthand allows you to
1534 force any file to be treated as a log file."""
1534 force any file to be treated as a log file."""
1535
1535
1536 for f in parameter_s.split():
1536 for f in parameter_s.split():
1537 self.shell.safe_execfile(f,self.shell.user_ns,
1537 self.shell.safe_execfile(f,self.shell.user_ns,
1538 self.shell.user_ns,islog=1)
1538 self.shell.user_ns,islog=1)
1539
1539
1540 def magic_time(self,parameter_s = ''):
1540 def magic_time(self,parameter_s = ''):
1541 """Time execution of a Python statement or expression.
1541 """Time execution of a Python statement or expression.
1542
1542
1543 The CPU and wall clock times are printed, and the value of the
1543 The CPU and wall clock times are printed, and the value of the
1544 expression (if any) is returned. Note that under Win32, system time
1544 expression (if any) is returned. Note that under Win32, system time
1545 is always reported as 0, since it can not be measured.
1545 is always reported as 0, since it can not be measured.
1546
1546
1547 This function provides very basic timing functionality. In Python
1547 This function provides very basic timing functionality. In Python
1548 2.3, the timeit module offers more control and sophistication, but for
1548 2.3, the timeit module offers more control and sophistication, but for
1549 now IPython supports Python 2.2, so we can not rely on timeit being
1549 now IPython supports Python 2.2, so we can not rely on timeit being
1550 present.
1550 present.
1551
1551
1552 Some examples:
1552 Some examples:
1553
1553
1554 In [1]: time 2**128
1554 In [1]: time 2**128
1555 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1555 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1556 Wall time: 0.00
1556 Wall time: 0.00
1557 Out[1]: 340282366920938463463374607431768211456L
1557 Out[1]: 340282366920938463463374607431768211456L
1558
1558
1559 In [2]: n = 1000000
1559 In [2]: n = 1000000
1560
1560
1561 In [3]: time sum(range(n))
1561 In [3]: time sum(range(n))
1562 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1562 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1563 Wall time: 1.37
1563 Wall time: 1.37
1564 Out[3]: 499999500000L
1564 Out[3]: 499999500000L
1565
1565
1566 In [4]: time print 'hello world'
1566 In [4]: time print 'hello world'
1567 hello world
1567 hello world
1568 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1568 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1569 Wall time: 0.00
1569 Wall time: 0.00
1570 """
1570 """
1571
1571
1572 # fail immediately if the given expression can't be compiled
1572 # fail immediately if the given expression can't be compiled
1573 try:
1573 try:
1574 mode = 'eval'
1574 mode = 'eval'
1575 code = compile(parameter_s,'<timed eval>',mode)
1575 code = compile(parameter_s,'<timed eval>',mode)
1576 except SyntaxError:
1576 except SyntaxError:
1577 mode = 'exec'
1577 mode = 'exec'
1578 code = compile(parameter_s,'<timed exec>',mode)
1578 code = compile(parameter_s,'<timed exec>',mode)
1579 # skew measurement as little as possible
1579 # skew measurement as little as possible
1580 glob = self.shell.user_ns
1580 glob = self.shell.user_ns
1581 clk = clock2
1581 clk = clock2
1582 wtime = time.time
1582 wtime = time.time
1583 # time execution
1583 # time execution
1584 wall_st = wtime()
1584 wall_st = wtime()
1585 if mode=='eval':
1585 if mode=='eval':
1586 st = clk()
1586 st = clk()
1587 out = eval(code,glob)
1587 out = eval(code,glob)
1588 end = clk()
1588 end = clk()
1589 else:
1589 else:
1590 st = clk()
1590 st = clk()
1591 exec code in glob
1591 exec code in glob
1592 end = clk()
1592 end = clk()
1593 out = None
1593 out = None
1594 wall_end = wtime()
1594 wall_end = wtime()
1595 # Compute actual times and report
1595 # Compute actual times and report
1596 wall_time = wall_end-wall_st
1596 wall_time = wall_end-wall_st
1597 cpu_user = end[0]-st[0]
1597 cpu_user = end[0]-st[0]
1598 cpu_sys = end[1]-st[1]
1598 cpu_sys = end[1]-st[1]
1599 cpu_tot = cpu_user+cpu_sys
1599 cpu_tot = cpu_user+cpu_sys
1600 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1600 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1601 (cpu_user,cpu_sys,cpu_tot)
1601 (cpu_user,cpu_sys,cpu_tot)
1602 print "Wall time: %.2f" % wall_time
1602 print "Wall time: %.2f" % wall_time
1603 return out
1603 return out
1604
1604
1605 def magic_macro(self,parameter_s = ''):
1605 def magic_macro(self,parameter_s = ''):
1606 """Define a set of input lines as a macro for future re-execution.
1606 """Define a set of input lines as a macro for future re-execution.
1607
1607
1608 Usage:\\
1608 Usage:\\
1609 %macro name n1-n2 n3-n4 ... n5 .. n6 ...
1609 %macro name n1-n2 n3-n4 ... n5 .. n6 ...
1610
1610
1611 This will define a global variable called `name` which is a string
1611 This will define a global variable called `name` which is a string
1612 made of joining the slices and lines you specify (n1,n2,... numbers
1612 made of joining the slices and lines you specify (n1,n2,... numbers
1613 above) from your input history into a single string. This variable
1613 above) from your input history into a single string. This variable
1614 acts like an automatic function which re-executes those lines as if
1614 acts like an automatic function which re-executes those lines as if
1615 you had typed them. You just type 'name' at the prompt and the code
1615 you had typed them. You just type 'name' at the prompt and the code
1616 executes.
1616 executes.
1617
1617
1618 The notation for indicating number ranges is: n1-n2 means 'use line
1618 The notation for indicating number ranges is: n1-n2 means 'use line
1619 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1619 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1620 using the lines numbered 5,6 and 7.
1620 using the lines numbered 5,6 and 7.
1621
1621
1622 Note: as a 'hidden' feature, you can also use traditional python slice
1622 Note: as a 'hidden' feature, you can also use traditional python slice
1623 notation, where N:M means numbers N through M-1.
1623 notation, where N:M means numbers N through M-1.
1624
1624
1625 For example, if your history contains (%hist prints it):
1625 For example, if your history contains (%hist prints it):
1626
1626
1627 44: x=1\\
1627 44: x=1\\
1628 45: y=3\\
1628 45: y=3\\
1629 46: z=x+y\\
1629 46: z=x+y\\
1630 47: print x\\
1630 47: print x\\
1631 48: a=5\\
1631 48: a=5\\
1632 49: print 'x',x,'y',y\\
1632 49: print 'x',x,'y',y\\
1633
1633
1634 you can create a macro with lines 44 through 47 (included) and line 49
1634 you can create a macro with lines 44 through 47 (included) and line 49
1635 called my_macro with:
1635 called my_macro with:
1636
1636
1637 In [51]: %macro my_macro 44-47 49
1637 In [51]: %macro my_macro 44-47 49
1638
1638
1639 Now, typing `my_macro` (without quotes) will re-execute all this code
1639 Now, typing `my_macro` (without quotes) will re-execute all this code
1640 in one pass.
1640 in one pass.
1641
1641
1642 You don't need to give the line-numbers in order, and any given line
1642 You don't need to give the line-numbers in order, and any given line
1643 number can appear multiple times. You can assemble macros with any
1643 number can appear multiple times. You can assemble macros with any
1644 lines from your input history in any order.
1644 lines from your input history in any order.
1645
1645
1646 The macro is a simple object which holds its value in an attribute,
1646 The macro is a simple object which holds its value in an attribute,
1647 but IPython's display system checks for macros and executes them as
1647 but IPython's display system checks for macros and executes them as
1648 code instead of printing them when you type their name.
1648 code instead of printing them when you type their name.
1649
1649
1650 You can view a macro's contents by explicitly printing it with:
1650 You can view a macro's contents by explicitly printing it with:
1651
1651
1652 'print macro_name'.
1652 'print macro_name'.
1653
1653
1654 For one-off cases which DON'T contain magic function calls in them you
1654 For one-off cases which DON'T contain magic function calls in them you
1655 can obtain similar results by explicitly executing slices from your
1655 can obtain similar results by explicitly executing slices from your
1656 input history with:
1656 input history with:
1657
1657
1658 In [60]: exec In[44:48]+In[49]"""
1658 In [60]: exec In[44:48]+In[49]"""
1659
1659
1660 args = parameter_s.split()
1660 args = parameter_s.split()
1661 name,ranges = args[0], args[1:]
1661 name,ranges = args[0], args[1:]
1662 #print 'rng',ranges # dbg
1662 #print 'rng',ranges # dbg
1663 lines = self.extract_input_slices(ranges)
1663 lines = self.extract_input_slices(ranges)
1664 macro = Macro(lines)
1664 macro = Macro(lines)
1665 self.shell.user_ns.update({name:macro})
1665 self.shell.user_ns.update({name:macro})
1666 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1666 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1667 print 'Macro contents:'
1667 print 'Macro contents:'
1668 print macro,
1668 print macro,
1669
1669
1670 def magic_save(self,parameter_s = ''):
1670 def magic_save(self,parameter_s = ''):
1671 """Save a set of lines to a given filename.
1671 """Save a set of lines to a given filename.
1672
1672
1673 Usage:\\
1673 Usage:\\
1674 %save filename n1-n2 n3-n4 ... n5 .. n6 ...
1674 %save filename n1-n2 n3-n4 ... n5 .. n6 ...
1675
1675
1676 This function uses the same syntax as %macro for line extraction, but
1676 This function uses the same syntax as %macro for line extraction, but
1677 instead of creating a macro it saves the resulting string to the
1677 instead of creating a macro it saves the resulting string to the
1678 filename you specify.
1678 filename you specify.
1679
1679
1680 It adds a '.py' extension to the file if you don't do so yourself, and
1680 It adds a '.py' extension to the file if you don't do so yourself, and
1681 it asks for confirmation before overwriting existing files."""
1681 it asks for confirmation before overwriting existing files."""
1682
1682
1683 args = parameter_s.split()
1683 args = parameter_s.split()
1684 fname,ranges = args[0], args[1:]
1684 fname,ranges = args[0], args[1:]
1685 if not fname.endswith('.py'):
1685 if not fname.endswith('.py'):
1686 fname += '.py'
1686 fname += '.py'
1687 if os.path.isfile(fname):
1687 if os.path.isfile(fname):
1688 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1688 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1689 if ans.lower() not in ['y','yes']:
1689 if ans.lower() not in ['y','yes']:
1690 print 'Operation cancelled.'
1690 print 'Operation cancelled.'
1691 return
1691 return
1692 cmds = ''.join(self.extract_input_slices(ranges))
1692 cmds = ''.join(self.extract_input_slices(ranges))
1693 f = file(fname,'w')
1693 f = file(fname,'w')
1694 f.write(cmds)
1694 f.write(cmds)
1695 f.close()
1695 f.close()
1696 print 'The following commands were written to file `%s`:' % fname
1696 print 'The following commands were written to file `%s`:' % fname
1697 print cmds
1697 print cmds
1698
1698
1699 def _edit_macro(self,mname,macro):
1699 def _edit_macro(self,mname,macro):
1700 """open an editor with the macro data in a file"""
1700 """open an editor with the macro data in a file"""
1701 filename = self.shell.mktempfile(macro.value)
1701 filename = self.shell.mktempfile(macro.value)
1702 self.shell.hooks.editor(filename)
1702 self.shell.hooks.editor(filename)
1703
1703
1704 # and make a new macro object, to replace the old one
1704 # and make a new macro object, to replace the old one
1705 mfile = open(filename)
1705 mfile = open(filename)
1706 mvalue = mfile.read()
1706 mvalue = mfile.read()
1707 mfile.close()
1707 mfile.close()
1708 self.shell.user_ns[mname] = Macro(mvalue)
1708 self.shell.user_ns[mname] = Macro(mvalue)
1709
1709
1710 def magic_ed(self,parameter_s=''):
1710 def magic_ed(self,parameter_s=''):
1711 """Alias to %edit."""
1711 """Alias to %edit."""
1712 return self.magic_edit(parameter_s)
1712 return self.magic_edit(parameter_s)
1713
1713
1714 def magic_edit(self,parameter_s='',last_call=['','']):
1714 def magic_edit(self,parameter_s='',last_call=['','']):
1715 """Bring up an editor and execute the resulting code.
1715 """Bring up an editor and execute the resulting code.
1716
1716
1717 Usage:
1717 Usage:
1718 %edit [options] [args]
1718 %edit [options] [args]
1719
1719
1720 %edit runs IPython's editor hook. The default version of this hook is
1720 %edit runs IPython's editor hook. The default version of this hook is
1721 set to call the __IPYTHON__.rc.editor command. This is read from your
1721 set to call the __IPYTHON__.rc.editor command. This is read from your
1722 environment variable $EDITOR. If this isn't found, it will default to
1722 environment variable $EDITOR. If this isn't found, it will default to
1723 vi under Linux/Unix and to notepad under Windows. See the end of this
1723 vi under Linux/Unix and to notepad under Windows. See the end of this
1724 docstring for how to change the editor hook.
1724 docstring for how to change the editor hook.
1725
1725
1726 You can also set the value of this editor via the command line option
1726 You can also set the value of this editor via the command line option
1727 '-editor' or in your ipythonrc file. This is useful if you wish to use
1727 '-editor' or in your ipythonrc file. This is useful if you wish to use
1728 specifically for IPython an editor different from your typical default
1728 specifically for IPython an editor different from your typical default
1729 (and for Windows users who typically don't set environment variables).
1729 (and for Windows users who typically don't set environment variables).
1730
1730
1731 This command allows you to conveniently edit multi-line code right in
1731 This command allows you to conveniently edit multi-line code right in
1732 your IPython session.
1732 your IPython session.
1733
1733
1734 If called without arguments, %edit opens up an empty editor with a
1734 If called without arguments, %edit opens up an empty editor with a
1735 temporary file and will execute the contents of this file when you
1735 temporary file and will execute the contents of this file when you
1736 close it (don't forget to save it!).
1736 close it (don't forget to save it!).
1737
1737
1738
1738
1739 Options:
1739 Options:
1740
1740
1741 -p: this will call the editor with the same data as the previous time
1741 -p: this will call the editor with the same data as the previous time
1742 it was used, regardless of how long ago (in your current session) it
1742 it was used, regardless of how long ago (in your current session) it
1743 was.
1743 was.
1744
1744
1745 -x: do not execute the edited code immediately upon exit. This is
1745 -x: do not execute the edited code immediately upon exit. This is
1746 mainly useful if you are editing programs which need to be called with
1746 mainly useful if you are editing programs which need to be called with
1747 command line arguments, which you can then do using %run.
1747 command line arguments, which you can then do using %run.
1748
1748
1749
1749
1750 Arguments:
1750 Arguments:
1751
1751
1752 If arguments are given, the following possibilites exist:
1752 If arguments are given, the following possibilites exist:
1753
1753
1754 - The arguments are numbers or pairs of colon-separated numbers (like
1754 - The arguments are numbers or pairs of colon-separated numbers (like
1755 1 4:8 9). These are interpreted as lines of previous input to be
1755 1 4:8 9). These are interpreted as lines of previous input to be
1756 loaded into the editor. The syntax is the same of the %macro command.
1756 loaded into the editor. The syntax is the same of the %macro command.
1757
1757
1758 - If the argument doesn't start with a number, it is evaluated as a
1758 - If the argument doesn't start with a number, it is evaluated as a
1759 variable and its contents loaded into the editor. You can thus edit
1759 variable and its contents loaded into the editor. You can thus edit
1760 any string which contains python code (including the result of
1760 any string which contains python code (including the result of
1761 previous edits).
1761 previous edits).
1762
1762
1763 - If the argument is the name of an object (other than a string),
1763 - If the argument is the name of an object (other than a string),
1764 IPython will try to locate the file where it was defined and open the
1764 IPython will try to locate the file where it was defined and open the
1765 editor at the point where it is defined. You can use `%edit function`
1765 editor at the point where it is defined. You can use `%edit function`
1766 to load an editor exactly at the point where 'function' is defined,
1766 to load an editor exactly at the point where 'function' is defined,
1767 edit it and have the file be executed automatically.
1767 edit it and have the file be executed automatically.
1768
1768
1769 If the object is a macro (see %macro for details), this opens up your
1769 If the object is a macro (see %macro for details), this opens up your
1770 specified editor with a temporary file containing the macro's data.
1770 specified editor with a temporary file containing the macro's data.
1771 Upon exit, the macro is reloaded with the contents of the file.
1771 Upon exit, the macro is reloaded with the contents of the file.
1772
1772
1773 Note: opening at an exact line is only supported under Unix, and some
1773 Note: opening at an exact line is only supported under Unix, and some
1774 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1774 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1775 '+NUMBER' parameter necessary for this feature. Good editors like
1775 '+NUMBER' parameter necessary for this feature. Good editors like
1776 (X)Emacs, vi, jed, pico and joe all do.
1776 (X)Emacs, vi, jed, pico and joe all do.
1777
1777
1778 - If the argument is not found as a variable, IPython will look for a
1778 - If the argument is not found as a variable, IPython will look for a
1779 file with that name (adding .py if necessary) and load it into the
1779 file with that name (adding .py if necessary) and load it into the
1780 editor. It will execute its contents with execfile() when you exit,
1780 editor. It will execute its contents with execfile() when you exit,
1781 loading any code in the file into your interactive namespace.
1781 loading any code in the file into your interactive namespace.
1782
1782
1783 After executing your code, %edit will return as output the code you
1783 After executing your code, %edit will return as output the code you
1784 typed in the editor (except when it was an existing file). This way
1784 typed in the editor (except when it was an existing file). This way
1785 you can reload the code in further invocations of %edit as a variable,
1785 you can reload the code in further invocations of %edit as a variable,
1786 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1786 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1787 the output.
1787 the output.
1788
1788
1789 Note that %edit is also available through the alias %ed.
1789 Note that %edit is also available through the alias %ed.
1790
1790
1791 This is an example of creating a simple function inside the editor and
1791 This is an example of creating a simple function inside the editor and
1792 then modifying it. First, start up the editor:
1792 then modifying it. First, start up the editor:
1793
1793
1794 In [1]: ed\\
1794 In [1]: ed\\
1795 Editing... done. Executing edited code...\\
1795 Editing... done. Executing edited code...\\
1796 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1796 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1797
1797
1798 We can then call the function foo():
1798 We can then call the function foo():
1799
1799
1800 In [2]: foo()\\
1800 In [2]: foo()\\
1801 foo() was defined in an editing session
1801 foo() was defined in an editing session
1802
1802
1803 Now we edit foo. IPython automatically loads the editor with the
1803 Now we edit foo. IPython automatically loads the editor with the
1804 (temporary) file where foo() was previously defined:
1804 (temporary) file where foo() was previously defined:
1805
1805
1806 In [3]: ed foo\\
1806 In [3]: ed foo\\
1807 Editing... done. Executing edited code...
1807 Editing... done. Executing edited code...
1808
1808
1809 And if we call foo() again we get the modified version:
1809 And if we call foo() again we get the modified version:
1810
1810
1811 In [4]: foo()\\
1811 In [4]: foo()\\
1812 foo() has now been changed!
1812 foo() has now been changed!
1813
1813
1814 Here is an example of how to edit a code snippet successive
1814 Here is an example of how to edit a code snippet successive
1815 times. First we call the editor:
1815 times. First we call the editor:
1816
1816
1817 In [8]: ed\\
1817 In [8]: ed\\
1818 Editing... done. Executing edited code...\\
1818 Editing... done. Executing edited code...\\
1819 hello\\
1819 hello\\
1820 Out[8]: "print 'hello'\\n"
1820 Out[8]: "print 'hello'\\n"
1821
1821
1822 Now we call it again with the previous output (stored in _):
1822 Now we call it again with the previous output (stored in _):
1823
1823
1824 In [9]: ed _\\
1824 In [9]: ed _\\
1825 Editing... done. Executing edited code...\\
1825 Editing... done. Executing edited code...\\
1826 hello world\\
1826 hello world\\
1827 Out[9]: "print 'hello world'\\n"
1827 Out[9]: "print 'hello world'\\n"
1828
1828
1829 Now we call it with the output #8 (stored in _8, also as Out[8]):
1829 Now we call it with the output #8 (stored in _8, also as Out[8]):
1830
1830
1831 In [10]: ed _8\\
1831 In [10]: ed _8\\
1832 Editing... done. Executing edited code...\\
1832 Editing... done. Executing edited code...\\
1833 hello again\\
1833 hello again\\
1834 Out[10]: "print 'hello again'\\n"
1834 Out[10]: "print 'hello again'\\n"
1835
1835
1836
1836
1837 Changing the default editor hook:
1837 Changing the default editor hook:
1838
1838
1839 If you wish to write your own editor hook, you can put it in a
1839 If you wish to write your own editor hook, you can put it in a
1840 configuration file which you load at startup time. The default hook
1840 configuration file which you load at startup time. The default hook
1841 is defined in the IPython.hooks module, and you can use that as a
1841 is defined in the IPython.hooks module, and you can use that as a
1842 starting example for further modifications. That file also has
1842 starting example for further modifications. That file also has
1843 general instructions on how to set a new hook for use once you've
1843 general instructions on how to set a new hook for use once you've
1844 defined it."""
1844 defined it."""
1845
1845
1846 # FIXME: This function has become a convoluted mess. It needs a
1846 # FIXME: This function has become a convoluted mess. It needs a
1847 # ground-up rewrite with clean, simple logic.
1847 # ground-up rewrite with clean, simple logic.
1848
1848
1849 def make_filename(arg):
1849 def make_filename(arg):
1850 "Make a filename from the given args"
1850 "Make a filename from the given args"
1851 try:
1851 try:
1852 filename = get_py_filename(arg)
1852 filename = get_py_filename(arg)
1853 except IOError:
1853 except IOError:
1854 if args.endswith('.py'):
1854 if args.endswith('.py'):
1855 filename = arg
1855 filename = arg
1856 else:
1856 else:
1857 filename = None
1857 filename = None
1858 return filename
1858 return filename
1859
1859
1860 # custom exceptions
1860 # custom exceptions
1861 class DataIsObject(Exception): pass
1861 class DataIsObject(Exception): pass
1862
1862
1863 opts,args = self.parse_options(parameter_s,'px')
1863 opts,args = self.parse_options(parameter_s,'px')
1864
1864
1865 # Default line number value
1865 # Default line number value
1866 lineno = None
1866 lineno = None
1867 if opts.has_key('p'):
1867 if opts.has_key('p'):
1868 args = '_%s' % last_call[0]
1868 args = '_%s' % last_call[0]
1869 if not self.shell.user_ns.has_key(args):
1869 if not self.shell.user_ns.has_key(args):
1870 args = last_call[1]
1870 args = last_call[1]
1871
1871
1872 # use last_call to remember the state of the previous call, but don't
1872 # use last_call to remember the state of the previous call, but don't
1873 # let it be clobbered by successive '-p' calls.
1873 # let it be clobbered by successive '-p' calls.
1874 try:
1874 try:
1875 last_call[0] = self.shell.outputcache.prompt_count
1875 last_call[0] = self.shell.outputcache.prompt_count
1876 if not opts.has_key('p'):
1876 if not opts.has_key('p'):
1877 last_call[1] = parameter_s
1877 last_call[1] = parameter_s
1878 except:
1878 except:
1879 pass
1879 pass
1880
1880
1881 # by default this is done with temp files, except when the given
1881 # by default this is done with temp files, except when the given
1882 # arg is a filename
1882 # arg is a filename
1883 use_temp = 1
1883 use_temp = 1
1884
1884
1885 if re.match(r'\d',args):
1885 if re.match(r'\d',args):
1886 # Mode where user specifies ranges of lines, like in %macro.
1886 # Mode where user specifies ranges of lines, like in %macro.
1887 # This means that you can't edit files whose names begin with
1887 # This means that you can't edit files whose names begin with
1888 # numbers this way. Tough.
1888 # numbers this way. Tough.
1889 ranges = args.split()
1889 ranges = args.split()
1890 data = ''.join(self.extract_input_slices(ranges))
1890 data = ''.join(self.extract_input_slices(ranges))
1891 elif args.endswith('.py'):
1891 elif args.endswith('.py'):
1892 filename = make_filename(args)
1892 filename = make_filename(args)
1893 data = ''
1893 data = ''
1894 use_temp = 0
1894 use_temp = 0
1895 elif args:
1895 elif args:
1896 try:
1896 try:
1897 # Load the parameter given as a variable. If not a string,
1897 # Load the parameter given as a variable. If not a string,
1898 # process it as an object instead (below)
1898 # process it as an object instead (below)
1899
1899
1900 #print '*** args',args,'type',type(args) # dbg
1900 #print '*** args',args,'type',type(args) # dbg
1901 data = eval(args,self.shell.user_ns)
1901 data = eval(args,self.shell.user_ns)
1902 if not type(data) in StringTypes:
1902 if not type(data) in StringTypes:
1903 raise DataIsObject
1903 raise DataIsObject
1904
1904
1905 except (NameError,SyntaxError):
1905 except (NameError,SyntaxError):
1906 # given argument is not a variable, try as a filename
1906 # given argument is not a variable, try as a filename
1907 filename = make_filename(args)
1907 filename = make_filename(args)
1908 if filename is None:
1908 if filename is None:
1909 warn("Argument given (%s) can't be found as a variable "
1909 warn("Argument given (%s) can't be found as a variable "
1910 "or as a filename." % args)
1910 "or as a filename." % args)
1911 return
1911 return
1912
1912
1913 data = ''
1913 data = ''
1914 use_temp = 0
1914 use_temp = 0
1915 except DataIsObject:
1915 except DataIsObject:
1916
1916
1917 # macros have a special edit function
1917 # macros have a special edit function
1918 if isinstance(data,Macro):
1918 if isinstance(data,Macro):
1919 self._edit_macro(args,data)
1919 self._edit_macro(args,data)
1920 return
1920 return
1921
1921
1922 # For objects, try to edit the file where they are defined
1922 # For objects, try to edit the file where they are defined
1923 try:
1923 try:
1924 filename = inspect.getabsfile(data)
1924 filename = inspect.getabsfile(data)
1925 datafile = 1
1925 datafile = 1
1926 except TypeError:
1926 except TypeError:
1927 filename = make_filename(args)
1927 filename = make_filename(args)
1928 datafile = 1
1928 datafile = 1
1929 warn('Could not find file where `%s` is defined.\n'
1929 warn('Could not find file where `%s` is defined.\n'
1930 'Opening a file named `%s`' % (args,filename))
1930 'Opening a file named `%s`' % (args,filename))
1931 # Now, make sure we can actually read the source (if it was in
1931 # Now, make sure we can actually read the source (if it was in
1932 # a temp file it's gone by now).
1932 # a temp file it's gone by now).
1933 if datafile:
1933 if datafile:
1934 try:
1934 try:
1935 lineno = inspect.getsourcelines(data)[1]
1935 lineno = inspect.getsourcelines(data)[1]
1936 except IOError:
1936 except IOError:
1937 filename = make_filename(args)
1937 filename = make_filename(args)
1938 if filename is None:
1938 if filename is None:
1939 warn('The file `%s` where `%s` was defined cannot '
1939 warn('The file `%s` where `%s` was defined cannot '
1940 'be read.' % (filename,data))
1940 'be read.' % (filename,data))
1941 return
1941 return
1942 use_temp = 0
1942 use_temp = 0
1943 else:
1943 else:
1944 data = ''
1944 data = ''
1945
1945
1946 if use_temp:
1946 if use_temp:
1947 filename = self.shell.mktempfile(data)
1947 filename = self.shell.mktempfile(data)
1948 print 'IPython will make a temporary file named:',filename
1948 print 'IPython will make a temporary file named:',filename
1949
1949
1950 # do actual editing here
1950 # do actual editing here
1951 print 'Editing...',
1951 print 'Editing...',
1952 sys.stdout.flush()
1952 sys.stdout.flush()
1953 self.shell.hooks.editor(filename,lineno)
1953 self.shell.hooks.editor(filename,lineno)
1954 if opts.has_key('x'): # -x prevents actual execution
1954 if opts.has_key('x'): # -x prevents actual execution
1955 print
1955 print
1956 else:
1956 else:
1957 print 'done. Executing edited code...'
1957 print 'done. Executing edited code...'
1958 self.shell.safe_execfile(filename,self.shell.user_ns)
1958 self.shell.safe_execfile(filename,self.shell.user_ns)
1959 if use_temp:
1959 if use_temp:
1960 try:
1960 try:
1961 return open(filename).read()
1961 return open(filename).read()
1962 except IOError,msg:
1962 except IOError,msg:
1963 if msg.filename == filename:
1963 if msg.filename == filename:
1964 warn('File not found. Did you forget to save?')
1964 warn('File not found. Did you forget to save?')
1965 return
1965 return
1966 else:
1966 else:
1967 self.shell.showtraceback()
1967 self.shell.showtraceback()
1968
1968
1969 def magic_xmode(self,parameter_s = ''):
1969 def magic_xmode(self,parameter_s = ''):
1970 """Switch modes for the exception handlers.
1970 """Switch modes for the exception handlers.
1971
1971
1972 Valid modes: Plain, Context and Verbose.
1972 Valid modes: Plain, Context and Verbose.
1973
1973
1974 If called without arguments, acts as a toggle."""
1974 If called without arguments, acts as a toggle."""
1975
1975
1976 def xmode_switch_err(name):
1976 def xmode_switch_err(name):
1977 warn('Error changing %s exception modes.\n%s' %
1977 warn('Error changing %s exception modes.\n%s' %
1978 (name,sys.exc_info()[1]))
1978 (name,sys.exc_info()[1]))
1979
1979
1980 shell = self.shell
1980 shell = self.shell
1981 new_mode = parameter_s.strip().capitalize()
1981 new_mode = parameter_s.strip().capitalize()
1982 try:
1982 try:
1983 shell.InteractiveTB.set_mode(mode=new_mode)
1983 shell.InteractiveTB.set_mode(mode=new_mode)
1984 print 'Exception reporting mode:',shell.InteractiveTB.mode
1984 print 'Exception reporting mode:',shell.InteractiveTB.mode
1985 except:
1985 except:
1986 xmode_switch_err('user')
1986 xmode_switch_err('user')
1987
1987
1988 # threaded shells use a special handler in sys.excepthook
1988 # threaded shells use a special handler in sys.excepthook
1989 if shell.isthreaded:
1989 if shell.isthreaded:
1990 try:
1990 try:
1991 shell.sys_excepthook.set_mode(mode=new_mode)
1991 shell.sys_excepthook.set_mode(mode=new_mode)
1992 except:
1992 except:
1993 xmode_switch_err('threaded')
1993 xmode_switch_err('threaded')
1994
1994
1995 def magic_colors(self,parameter_s = ''):
1995 def magic_colors(self,parameter_s = ''):
1996 """Switch color scheme for prompts, info system and exception handlers.
1996 """Switch color scheme for prompts, info system and exception handlers.
1997
1997
1998 Currently implemented schemes: NoColor, Linux, LightBG.
1998 Currently implemented schemes: NoColor, Linux, LightBG.
1999
1999
2000 Color scheme names are not case-sensitive."""
2000 Color scheme names are not case-sensitive."""
2001
2001
2002 def color_switch_err(name):
2002 def color_switch_err(name):
2003 warn('Error changing %s color schemes.\n%s' %
2003 warn('Error changing %s color schemes.\n%s' %
2004 (name,sys.exc_info()[1]))
2004 (name,sys.exc_info()[1]))
2005
2005
2006
2006
2007 new_scheme = parameter_s.strip()
2007 new_scheme = parameter_s.strip()
2008 if not new_scheme:
2008 if not new_scheme:
2009 print 'You must specify a color scheme.'
2009 print 'You must specify a color scheme.'
2010 return
2010 return
2011 import IPython.rlineimpl as readline
2011 import IPython.rlineimpl as readline
2012 if not readline.have_readline:
2012 if not readline.have_readline:
2013 msg = """\
2013 msg = """\
2014 Proper color support under MS Windows requires Gary Bishop's readline library.
2014 Proper color support under MS Windows requires Gary Bishop's readline library.
2015 You can find it at:
2015 You can find it at:
2016 http://sourceforge.net/projects/uncpythontools
2016 http://sourceforge.net/projects/uncpythontools
2017 Gary's readline needs the ctypes module, from:
2017 Gary's readline needs the ctypes module, from:
2018 http://starship.python.net/crew/theller/ctypes
2018 http://starship.python.net/crew/theller/ctypes
2019
2019
2020 Defaulting color scheme to 'NoColor'"""
2020 Defaulting color scheme to 'NoColor'"""
2021 new_scheme = 'NoColor'
2021 new_scheme = 'NoColor'
2022 warn(msg)
2022 warn(msg)
2023 # local shortcut
2023 # local shortcut
2024 shell = self.shell
2024 shell = self.shell
2025
2025
2026 # Set prompt colors
2026 # Set prompt colors
2027 try:
2027 try:
2028 shell.outputcache.set_colors(new_scheme)
2028 shell.outputcache.set_colors(new_scheme)
2029 except:
2029 except:
2030 color_switch_err('prompt')
2030 color_switch_err('prompt')
2031 else:
2031 else:
2032 shell.rc.colors = \
2032 shell.rc.colors = \
2033 shell.outputcache.color_table.active_scheme_name
2033 shell.outputcache.color_table.active_scheme_name
2034 # Set exception colors
2034 # Set exception colors
2035 try:
2035 try:
2036 shell.InteractiveTB.set_colors(scheme = new_scheme)
2036 shell.InteractiveTB.set_colors(scheme = new_scheme)
2037 shell.SyntaxTB.set_colors(scheme = new_scheme)
2037 shell.SyntaxTB.set_colors(scheme = new_scheme)
2038 except:
2038 except:
2039 color_switch_err('exception')
2039 color_switch_err('exception')
2040
2040
2041 # threaded shells use a verbose traceback in sys.excepthook
2041 # threaded shells use a verbose traceback in sys.excepthook
2042 if shell.isthreaded:
2042 if shell.isthreaded:
2043 try:
2043 try:
2044 shell.sys_excepthook.set_colors(scheme=new_scheme)
2044 shell.sys_excepthook.set_colors(scheme=new_scheme)
2045 except:
2045 except:
2046 color_switch_err('system exception handler')
2046 color_switch_err('system exception handler')
2047
2047
2048 # Set info (for 'object?') colors
2048 # Set info (for 'object?') colors
2049 if shell.rc.color_info:
2049 if shell.rc.color_info:
2050 try:
2050 try:
2051 shell.inspector.set_active_scheme(new_scheme)
2051 shell.inspector.set_active_scheme(new_scheme)
2052 except:
2052 except:
2053 color_switch_err('object inspector')
2053 color_switch_err('object inspector')
2054 else:
2054 else:
2055 shell.inspector.set_active_scheme('NoColor')
2055 shell.inspector.set_active_scheme('NoColor')
2056
2056
2057 def magic_color_info(self,parameter_s = ''):
2057 def magic_color_info(self,parameter_s = ''):
2058 """Toggle color_info.
2058 """Toggle color_info.
2059
2059
2060 The color_info configuration parameter controls whether colors are
2060 The color_info configuration parameter controls whether colors are
2061 used for displaying object details (by things like %psource, %pfile or
2061 used for displaying object details (by things like %psource, %pfile or
2062 the '?' system). This function toggles this value with each call.
2062 the '?' system). This function toggles this value with each call.
2063
2063
2064 Note that unless you have a fairly recent pager (less works better
2064 Note that unless you have a fairly recent pager (less works better
2065 than more) in your system, using colored object information displays
2065 than more) in your system, using colored object information displays
2066 will not work properly. Test it and see."""
2066 will not work properly. Test it and see."""
2067
2067
2068 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2068 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2069 self.magic_colors(self.shell.rc.colors)
2069 self.magic_colors(self.shell.rc.colors)
2070 print 'Object introspection functions have now coloring:',
2070 print 'Object introspection functions have now coloring:',
2071 print ['OFF','ON'][self.shell.rc.color_info]
2071 print ['OFF','ON'][self.shell.rc.color_info]
2072
2072
2073 def magic_Pprint(self, parameter_s=''):
2073 def magic_Pprint(self, parameter_s=''):
2074 """Toggle pretty printing on/off."""
2074 """Toggle pretty printing on/off."""
2075
2075
2076 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
2076 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
2077 print 'Pretty printing has been turned', \
2077 print 'Pretty printing has been turned', \
2078 ['OFF','ON'][self.shell.outputcache.Pprint]
2078 ['OFF','ON'][self.shell.outputcache.Pprint]
2079
2079
2080 def magic_exit(self, parameter_s=''):
2080 def magic_exit(self, parameter_s=''):
2081 """Exit IPython, confirming if configured to do so.
2081 """Exit IPython, confirming if configured to do so.
2082
2082
2083 You can configure whether IPython asks for confirmation upon exit by
2083 You can configure whether IPython asks for confirmation upon exit by
2084 setting the confirm_exit flag in the ipythonrc file."""
2084 setting the confirm_exit flag in the ipythonrc file."""
2085
2085
2086 self.shell.exit()
2086 self.shell.exit()
2087
2087
2088 def magic_quit(self, parameter_s=''):
2088 def magic_quit(self, parameter_s=''):
2089 """Exit IPython, confirming if configured to do so (like %exit)"""
2089 """Exit IPython, confirming if configured to do so (like %exit)"""
2090
2090
2091 self.shell.exit()
2091 self.shell.exit()
2092
2092
2093 def magic_Exit(self, parameter_s=''):
2093 def magic_Exit(self, parameter_s=''):
2094 """Exit IPython without confirmation."""
2094 """Exit IPython without confirmation."""
2095
2095
2096 self.shell.exit_now = True
2096 self.shell.exit_now = True
2097
2097
2098 def magic_Quit(self, parameter_s=''):
2098 def magic_Quit(self, parameter_s=''):
2099 """Exit IPython without confirmation (like %Exit)."""
2099 """Exit IPython without confirmation (like %Exit)."""
2100
2100
2101 self.shell.exit_now = True
2101 self.shell.exit_now = True
2102
2102
2103 #......................................................................
2103 #......................................................................
2104 # Functions to implement unix shell-type things
2104 # Functions to implement unix shell-type things
2105
2105
2106 def magic_alias(self, parameter_s = ''):
2106 def magic_alias(self, parameter_s = ''):
2107 """Define an alias for a system command.
2107 """Define an alias for a system command.
2108
2108
2109 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2109 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2110
2110
2111 Then, typing 'alias_name params' will execute the system command 'cmd
2111 Then, typing 'alias_name params' will execute the system command 'cmd
2112 params' (from your underlying operating system).
2112 params' (from your underlying operating system).
2113
2113
2114 Aliases have lower precedence than magic functions and Python normal
2114 Aliases have lower precedence than magic functions and Python normal
2115 variables, so if 'foo' is both a Python variable and an alias, the
2115 variables, so if 'foo' is both a Python variable and an alias, the
2116 alias can not be executed until 'del foo' removes the Python variable.
2116 alias can not be executed until 'del foo' removes the Python variable.
2117
2117
2118 You can use the %l specifier in an alias definition to represent the
2118 You can use the %l specifier in an alias definition to represent the
2119 whole line when the alias is called. For example:
2119 whole line when the alias is called. For example:
2120
2120
2121 In [2]: alias all echo "Input in brackets: <%l>"\\
2121 In [2]: alias all echo "Input in brackets: <%l>"\\
2122 In [3]: all hello world\\
2122 In [3]: all hello world\\
2123 Input in brackets: <hello world>
2123 Input in brackets: <hello world>
2124
2124
2125 You can also define aliases with parameters using %s specifiers (one
2125 You can also define aliases with parameters using %s specifiers (one
2126 per parameter):
2126 per parameter):
2127
2127
2128 In [1]: alias parts echo first %s second %s\\
2128 In [1]: alias parts echo first %s second %s\\
2129 In [2]: %parts A B\\
2129 In [2]: %parts A B\\
2130 first A second B\\
2130 first A second B\\
2131 In [3]: %parts A\\
2131 In [3]: %parts A\\
2132 Incorrect number of arguments: 2 expected.\\
2132 Incorrect number of arguments: 2 expected.\\
2133 parts is an alias to: 'echo first %s second %s'
2133 parts is an alias to: 'echo first %s second %s'
2134
2134
2135 Note that %l and %s are mutually exclusive. You can only use one or
2135 Note that %l and %s are mutually exclusive. You can only use one or
2136 the other in your aliases.
2136 the other in your aliases.
2137
2137
2138 Aliases expand Python variables just like system calls using ! or !!
2138 Aliases expand Python variables just like system calls using ! or !!
2139 do: all expressions prefixed with '$' get expanded. For details of
2139 do: all expressions prefixed with '$' get expanded. For details of
2140 the semantic rules, see PEP-215:
2140 the semantic rules, see PEP-215:
2141 http://www.python.org/peps/pep-0215.html. This is the library used by
2141 http://www.python.org/peps/pep-0215.html. This is the library used by
2142 IPython for variable expansion. If you want to access a true shell
2142 IPython for variable expansion. If you want to access a true shell
2143 variable, an extra $ is necessary to prevent its expansion by IPython:
2143 variable, an extra $ is necessary to prevent its expansion by IPython:
2144
2144
2145 In [6]: alias show echo\\
2145 In [6]: alias show echo\\
2146 In [7]: PATH='A Python string'\\
2146 In [7]: PATH='A Python string'\\
2147 In [8]: show $PATH\\
2147 In [8]: show $PATH\\
2148 A Python string\\
2148 A Python string\\
2149 In [9]: show $$PATH\\
2149 In [9]: show $$PATH\\
2150 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2150 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2151
2151
2152 You can use the alias facility to acess all of $PATH. See the %rehash
2152 You can use the alias facility to acess all of $PATH. See the %rehash
2153 and %rehashx functions, which automatically create aliases for the
2153 and %rehashx functions, which automatically create aliases for the
2154 contents of your $PATH.
2154 contents of your $PATH.
2155
2155
2156 If called with no parameters, %alias prints the current alias table."""
2156 If called with no parameters, %alias prints the current alias table."""
2157
2157
2158 par = parameter_s.strip()
2158 par = parameter_s.strip()
2159 if not par:
2159 if not par:
2160 if self.shell.rc.automagic:
2160 if self.shell.rc.automagic:
2161 prechar = ''
2161 prechar = ''
2162 else:
2162 else:
2163 prechar = self.shell.ESC_MAGIC
2163 prechar = self.shell.ESC_MAGIC
2164 #print 'Alias\t\tSystem Command\n'+'-'*30
2164 #print 'Alias\t\tSystem Command\n'+'-'*30
2165 atab = self.shell.alias_table
2165 atab = self.shell.alias_table
2166 aliases = atab.keys()
2166 aliases = atab.keys()
2167 aliases.sort()
2167 aliases.sort()
2168 res = []
2168 res = []
2169 for alias in aliases:
2169 for alias in aliases:
2170 res.append((alias, atab[alias][1]))
2170 res.append((alias, atab[alias][1]))
2171 print "Total number of aliases:",len(aliases)
2171 print "Total number of aliases:",len(aliases)
2172 return res
2172 return res
2173 try:
2173 try:
2174 alias,cmd = par.split(None,1)
2174 alias,cmd = par.split(None,1)
2175 except:
2175 except:
2176 print OInspect.getdoc(self.magic_alias)
2176 print OInspect.getdoc(self.magic_alias)
2177 else:
2177 else:
2178 nargs = cmd.count('%s')
2178 nargs = cmd.count('%s')
2179 if nargs>0 and cmd.find('%l')>=0:
2179 if nargs>0 and cmd.find('%l')>=0:
2180 error('The %s and %l specifiers are mutually exclusive '
2180 error('The %s and %l specifiers are mutually exclusive '
2181 'in alias definitions.')
2181 'in alias definitions.')
2182 else: # all looks OK
2182 else: # all looks OK
2183 self.shell.alias_table[alias] = (nargs,cmd)
2183 self.shell.alias_table[alias] = (nargs,cmd)
2184 self.shell.alias_table_validate(verbose=1)
2184 self.shell.alias_table_validate(verbose=1)
2185 # end magic_alias
2185 # end magic_alias
2186
2186
2187 def magic_unalias(self, parameter_s = ''):
2187 def magic_unalias(self, parameter_s = ''):
2188 """Remove an alias"""
2188 """Remove an alias"""
2189
2189
2190 aname = parameter_s.strip()
2190 aname = parameter_s.strip()
2191 if aname in self.shell.alias_table:
2191 if aname in self.shell.alias_table:
2192 del self.shell.alias_table[aname]
2192 del self.shell.alias_table[aname]
2193
2193
2194 def magic_rehash(self, parameter_s = ''):
2194 def magic_rehash(self, parameter_s = ''):
2195 """Update the alias table with all entries in $PATH.
2195 """Update the alias table with all entries in $PATH.
2196
2196
2197 This version does no checks on execute permissions or whether the
2197 This version does no checks on execute permissions or whether the
2198 contents of $PATH are truly files (instead of directories or something
2198 contents of $PATH are truly files (instead of directories or something
2199 else). For such a safer (but slower) version, use %rehashx."""
2199 else). For such a safer (but slower) version, use %rehashx."""
2200
2200
2201 # This function (and rehashx) manipulate the alias_table directly
2201 # This function (and rehashx) manipulate the alias_table directly
2202 # rather than calling magic_alias, for speed reasons. A rehash on a
2202 # rather than calling magic_alias, for speed reasons. A rehash on a
2203 # typical Linux box involves several thousand entries, so efficiency
2203 # typical Linux box involves several thousand entries, so efficiency
2204 # here is a top concern.
2204 # here is a top concern.
2205
2205
2206 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2206 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2207 alias_table = self.shell.alias_table
2207 alias_table = self.shell.alias_table
2208 for pdir in path:
2208 for pdir in path:
2209 for ff in os.listdir(pdir):
2209 for ff in os.listdir(pdir):
2210 # each entry in the alias table must be (N,name), where
2210 # each entry in the alias table must be (N,name), where
2211 # N is the number of positional arguments of the alias.
2211 # N is the number of positional arguments of the alias.
2212 alias_table[ff] = (0,ff)
2212 alias_table[ff] = (0,ff)
2213 # Make sure the alias table doesn't contain keywords or builtins
2213 # Make sure the alias table doesn't contain keywords or builtins
2214 self.shell.alias_table_validate()
2214 self.shell.alias_table_validate()
2215 # Call again init_auto_alias() so we get 'rm -i' and other modified
2215 # Call again init_auto_alias() so we get 'rm -i' and other modified
2216 # aliases since %rehash will probably clobber them
2216 # aliases since %rehash will probably clobber them
2217 self.shell.init_auto_alias()
2217 self.shell.init_auto_alias()
2218
2218
2219 def magic_rehashx(self, parameter_s = ''):
2219 def magic_rehashx(self, parameter_s = ''):
2220 """Update the alias table with all executable files in $PATH.
2220 """Update the alias table with all executable files in $PATH.
2221
2221
2222 This version explicitly checks that every entry in $PATH is a file
2222 This version explicitly checks that every entry in $PATH is a file
2223 with execute access (os.X_OK), so it is much slower than %rehash.
2223 with execute access (os.X_OK), so it is much slower than %rehash.
2224
2224
2225 Under Windows, it checks executability as a match agains a
2225 Under Windows, it checks executability as a match agains a
2226 '|'-separated string of extensions, stored in the IPython config
2226 '|'-separated string of extensions, stored in the IPython config
2227 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2227 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2228
2228
2229 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2229 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2230 alias_table = self.shell.alias_table
2230 alias_table = self.shell.alias_table
2231
2231
2232 if os.name == 'posix':
2232 if os.name == 'posix':
2233 isexec = lambda fname:os.path.isfile(fname) and \
2233 isexec = lambda fname:os.path.isfile(fname) and \
2234 os.access(fname,os.X_OK)
2234 os.access(fname,os.X_OK)
2235 else:
2235 else:
2236
2236
2237 try:
2237 try:
2238 winext = os.environ['pathext'].replace(';','|').replace('.','')
2238 winext = os.environ['pathext'].replace(';','|').replace('.','')
2239 except KeyError:
2239 except KeyError:
2240 winext = 'exe|com|bat'
2240 winext = 'exe|com|bat'
2241
2241
2242 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2242 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2243 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2243 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2244 savedir = os.getcwd()
2244 savedir = os.getcwd()
2245 try:
2245 try:
2246 # write the whole loop for posix/Windows so we don't have an if in
2246 # write the whole loop for posix/Windows so we don't have an if in
2247 # the innermost part
2247 # the innermost part
2248 if os.name == 'posix':
2248 if os.name == 'posix':
2249 for pdir in path:
2249 for pdir in path:
2250 os.chdir(pdir)
2250 os.chdir(pdir)
2251 for ff in os.listdir(pdir):
2251 for ff in os.listdir(pdir):
2252 if isexec(ff):
2252 if isexec(ff):
2253 # each entry in the alias table must be (N,name),
2253 # each entry in the alias table must be (N,name),
2254 # where N is the number of positional arguments of the
2254 # where N is the number of positional arguments of the
2255 # alias.
2255 # alias.
2256 alias_table[ff] = (0,ff)
2256 alias_table[ff] = (0,ff)
2257 else:
2257 else:
2258 for pdir in path:
2258 for pdir in path:
2259 os.chdir(pdir)
2259 os.chdir(pdir)
2260 for ff in os.listdir(pdir):
2260 for ff in os.listdir(pdir):
2261 if isexec(ff):
2261 if isexec(ff):
2262 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2262 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2263 # Make sure the alias table doesn't contain keywords or builtins
2263 # Make sure the alias table doesn't contain keywords or builtins
2264 self.shell.alias_table_validate()
2264 self.shell.alias_table_validate()
2265 # Call again init_auto_alias() so we get 'rm -i' and other
2265 # Call again init_auto_alias() so we get 'rm -i' and other
2266 # modified aliases since %rehashx will probably clobber them
2266 # modified aliases since %rehashx will probably clobber them
2267 self.shell.init_auto_alias()
2267 self.shell.init_auto_alias()
2268 finally:
2268 finally:
2269 os.chdir(savedir)
2269 os.chdir(savedir)
2270
2270
2271 def magic_pwd(self, parameter_s = ''):
2271 def magic_pwd(self, parameter_s = ''):
2272 """Return the current working directory path."""
2272 """Return the current working directory path."""
2273 return os.getcwd()
2273 return os.getcwd()
2274
2274
2275 def magic_cd(self, parameter_s=''):
2275 def magic_cd(self, parameter_s=''):
2276 """Change the current working directory.
2276 """Change the current working directory.
2277
2277
2278 This command automatically maintains an internal list of directories
2278 This command automatically maintains an internal list of directories
2279 you visit during your IPython session, in the variable _dh. The
2279 you visit during your IPython session, in the variable _dh. The
2280 command %dhist shows this history nicely formatted.
2280 command %dhist shows this history nicely formatted.
2281
2281
2282 Usage:
2282 Usage:
2283
2283
2284 cd 'dir': changes to directory 'dir'.
2284 cd 'dir': changes to directory 'dir'.
2285
2285
2286 cd -: changes to the last visited directory.
2286 cd -: changes to the last visited directory.
2287
2287
2288 cd -<n>: changes to the n-th directory in the directory history.
2288 cd -<n>: changes to the n-th directory in the directory history.
2289
2289
2290 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2290 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2291 (note: cd <bookmark_name> is enough if there is no
2291 (note: cd <bookmark_name> is enough if there is no
2292 directory <bookmark_name>, but a bookmark with the name exists.)
2292 directory <bookmark_name>, but a bookmark with the name exists.)
2293
2293
2294 Options:
2294 Options:
2295
2295
2296 -q: quiet. Do not print the working directory after the cd command is
2296 -q: quiet. Do not print the working directory after the cd command is
2297 executed. By default IPython's cd command does print this directory,
2297 executed. By default IPython's cd command does print this directory,
2298 since the default prompts do not display path information.
2298 since the default prompts do not display path information.
2299
2299
2300 Note that !cd doesn't work for this purpose because the shell where
2300 Note that !cd doesn't work for this purpose because the shell where
2301 !command runs is immediately discarded after executing 'command'."""
2301 !command runs is immediately discarded after executing 'command'."""
2302
2302
2303 parameter_s = parameter_s.strip()
2303 parameter_s = parameter_s.strip()
2304 #bkms = self.shell.persist.get("bookmarks",{})
2304 #bkms = self.shell.persist.get("bookmarks",{})
2305
2305
2306 numcd = re.match(r'(-)(\d+)$',parameter_s)
2306 numcd = re.match(r'(-)(\d+)$',parameter_s)
2307 # jump in directory history by number
2307 # jump in directory history by number
2308 if numcd:
2308 if numcd:
2309 nn = int(numcd.group(2))
2309 nn = int(numcd.group(2))
2310 try:
2310 try:
2311 ps = self.shell.user_ns['_dh'][nn]
2311 ps = self.shell.user_ns['_dh'][nn]
2312 except IndexError:
2312 except IndexError:
2313 print 'The requested directory does not exist in history.'
2313 print 'The requested directory does not exist in history.'
2314 return
2314 return
2315 else:
2315 else:
2316 opts = {}
2316 opts = {}
2317 else:
2317 else:
2318 #turn all non-space-escaping backslashes to slashes,
2318 #turn all non-space-escaping backslashes to slashes,
2319 # for c:\windows\directory\names\
2319 # for c:\windows\directory\names\
2320 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2320 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2321 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2321 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2322 # jump to previous
2322 # jump to previous
2323 if ps == '-':
2323 if ps == '-':
2324 try:
2324 try:
2325 ps = self.shell.user_ns['_dh'][-2]
2325 ps = self.shell.user_ns['_dh'][-2]
2326 except IndexError:
2326 except IndexError:
2327 print 'No previous directory to change to.'
2327 print 'No previous directory to change to.'
2328 return
2328 return
2329 # jump to bookmark if needed
2329 # jump to bookmark if needed
2330 else:
2330 else:
2331 if not os.path.isdir(ps) or opts.has_key('b'):
2331 if not os.path.isdir(ps) or opts.has_key('b'):
2332 bkms = self.db.get('bookmarks', {})
2332 bkms = self.db.get('bookmarks', {})
2333
2333
2334 if bkms.has_key(ps):
2334 if bkms.has_key(ps):
2335 target = bkms[ps]
2335 target = bkms[ps]
2336 print '(bookmark:%s) -> %s' % (ps,target)
2336 print '(bookmark:%s) -> %s' % (ps,target)
2337 ps = target
2337 ps = target
2338 else:
2338 else:
2339 if opts.has_key('b'):
2339 if opts.has_key('b'):
2340 error("Bookmark '%s' not found. "
2340 error("Bookmark '%s' not found. "
2341 "Use '%%bookmark -l' to see your bookmarks." % ps)
2341 "Use '%%bookmark -l' to see your bookmarks." % ps)
2342 return
2342 return
2343
2343
2344 # at this point ps should point to the target dir
2344 # at this point ps should point to the target dir
2345 if ps:
2345 if ps:
2346 try:
2346 try:
2347 os.chdir(os.path.expanduser(ps))
2347 os.chdir(os.path.expanduser(ps))
2348 ttitle = ("IPy:" + (
2348 ttitle = ("IPy:" + (
2349 os.getcwd() == '/' and '/' or os.path.basename(os.getcwd())))
2349 os.getcwd() == '/' and '/' or os.path.basename(os.getcwd())))
2350 platutils.set_term_title(ttitle)
2350 platutils.set_term_title(ttitle)
2351 except OSError:
2351 except OSError:
2352 print sys.exc_info()[1]
2352 print sys.exc_info()[1]
2353 else:
2353 else:
2354 self.shell.user_ns['_dh'].append(os.getcwd())
2354 self.shell.user_ns['_dh'].append(os.getcwd())
2355 else:
2355 else:
2356 os.chdir(self.shell.home_dir)
2356 os.chdir(self.shell.home_dir)
2357 platutils.set_term_title("IPy:~")
2357 platutils.set_term_title("IPy:~")
2358 self.shell.user_ns['_dh'].append(os.getcwd())
2358 self.shell.user_ns['_dh'].append(os.getcwd())
2359 if not 'q' in opts:
2359 if not 'q' in opts:
2360 print self.shell.user_ns['_dh'][-1]
2360 print self.shell.user_ns['_dh'][-1]
2361
2361
2362 def magic_dhist(self, parameter_s=''):
2362 def magic_dhist(self, parameter_s=''):
2363 """Print your history of visited directories.
2363 """Print your history of visited directories.
2364
2364
2365 %dhist -> print full history\\
2365 %dhist -> print full history\\
2366 %dhist n -> print last n entries only\\
2366 %dhist n -> print last n entries only\\
2367 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2367 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2368
2368
2369 This history is automatically maintained by the %cd command, and
2369 This history is automatically maintained by the %cd command, and
2370 always available as the global list variable _dh. You can use %cd -<n>
2370 always available as the global list variable _dh. You can use %cd -<n>
2371 to go to directory number <n>."""
2371 to go to directory number <n>."""
2372
2372
2373 dh = self.shell.user_ns['_dh']
2373 dh = self.shell.user_ns['_dh']
2374 if parameter_s:
2374 if parameter_s:
2375 try:
2375 try:
2376 args = map(int,parameter_s.split())
2376 args = map(int,parameter_s.split())
2377 except:
2377 except:
2378 self.arg_err(Magic.magic_dhist)
2378 self.arg_err(Magic.magic_dhist)
2379 return
2379 return
2380 if len(args) == 1:
2380 if len(args) == 1:
2381 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2381 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2382 elif len(args) == 2:
2382 elif len(args) == 2:
2383 ini,fin = args
2383 ini,fin = args
2384 else:
2384 else:
2385 self.arg_err(Magic.magic_dhist)
2385 self.arg_err(Magic.magic_dhist)
2386 return
2386 return
2387 else:
2387 else:
2388 ini,fin = 0,len(dh)
2388 ini,fin = 0,len(dh)
2389 nlprint(dh,
2389 nlprint(dh,
2390 header = 'Directory history (kept in _dh)',
2390 header = 'Directory history (kept in _dh)',
2391 start=ini,stop=fin)
2391 start=ini,stop=fin)
2392
2392
2393 def magic_env(self, parameter_s=''):
2393 def magic_env(self, parameter_s=''):
2394 """List environment variables."""
2394 """List environment variables."""
2395
2395
2396 return os.environ.data
2396 return os.environ.data
2397
2397
2398 def magic_pushd(self, parameter_s=''):
2398 def magic_pushd(self, parameter_s=''):
2399 """Place the current dir on stack and change directory.
2399 """Place the current dir on stack and change directory.
2400
2400
2401 Usage:\\
2401 Usage:\\
2402 %pushd ['dirname']
2402 %pushd ['dirname']
2403
2403
2404 %pushd with no arguments does a %pushd to your home directory.
2404 %pushd with no arguments does a %pushd to your home directory.
2405 """
2405 """
2406 if parameter_s == '': parameter_s = '~'
2406 if parameter_s == '': parameter_s = '~'
2407 dir_s = self.shell.dir_stack
2407 dir_s = self.shell.dir_stack
2408 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2408 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2409 os.path.expanduser(self.shell.dir_stack[0]):
2409 os.path.expanduser(self.shell.dir_stack[0]):
2410 try:
2410 try:
2411 self.magic_cd(parameter_s)
2411 self.magic_cd(parameter_s)
2412 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2412 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2413 self.magic_dirs()
2413 self.magic_dirs()
2414 except:
2414 except:
2415 print 'Invalid directory'
2415 print 'Invalid directory'
2416 else:
2416 else:
2417 print 'You are already there!'
2417 print 'You are already there!'
2418
2418
2419 def magic_popd(self, parameter_s=''):
2419 def magic_popd(self, parameter_s=''):
2420 """Change to directory popped off the top of the stack.
2420 """Change to directory popped off the top of the stack.
2421 """
2421 """
2422 if len (self.shell.dir_stack) > 1:
2422 if len (self.shell.dir_stack) > 1:
2423 self.shell.dir_stack.pop(0)
2423 self.shell.dir_stack.pop(0)
2424 self.magic_cd(self.shell.dir_stack[0])
2424 self.magic_cd(self.shell.dir_stack[0])
2425 print self.shell.dir_stack[0]
2425 print self.shell.dir_stack[0]
2426 else:
2426 else:
2427 print "You can't remove the starting directory from the stack:",\
2427 print "You can't remove the starting directory from the stack:",\
2428 self.shell.dir_stack
2428 self.shell.dir_stack
2429
2429
2430 def magic_dirs(self, parameter_s=''):
2430 def magic_dirs(self, parameter_s=''):
2431 """Return the current directory stack."""
2431 """Return the current directory stack."""
2432
2432
2433 return self.shell.dir_stack[:]
2433 return self.shell.dir_stack[:]
2434
2434
2435 def magic_sc(self, parameter_s=''):
2435 def magic_sc(self, parameter_s=''):
2436 """Shell capture - execute a shell command and capture its output.
2436 """Shell capture - execute a shell command and capture its output.
2437
2437
2438 DEPRECATED. Suboptimal, retained for backwards compatibility.
2438 DEPRECATED. Suboptimal, retained for backwards compatibility.
2439
2439
2440 You should use the form 'var = !command' instead. Example:
2440 You should use the form 'var = !command' instead. Example:
2441
2441
2442 "%sc -l myfiles = ls ~" should now be written as
2442 "%sc -l myfiles = ls ~" should now be written as
2443
2443
2444 "myfiles = !ls ~"
2444 "myfiles = !ls ~"
2445
2445
2446 myfiles.s, myfiles.l and myfiles.n still apply as documented
2446 myfiles.s, myfiles.l and myfiles.n still apply as documented
2447 below.
2447 below.
2448
2448
2449 --
2449 --
2450 %sc [options] varname=command
2450 %sc [options] varname=command
2451
2451
2452 IPython will run the given command using commands.getoutput(), and
2452 IPython will run the given command using commands.getoutput(), and
2453 will then update the user's interactive namespace with a variable
2453 will then update the user's interactive namespace with a variable
2454 called varname, containing the value of the call. Your command can
2454 called varname, containing the value of the call. Your command can
2455 contain shell wildcards, pipes, etc.
2455 contain shell wildcards, pipes, etc.
2456
2456
2457 The '=' sign in the syntax is mandatory, and the variable name you
2457 The '=' sign in the syntax is mandatory, and the variable name you
2458 supply must follow Python's standard conventions for valid names.
2458 supply must follow Python's standard conventions for valid names.
2459
2459
2460 (A special format without variable name exists for internal use)
2460 (A special format without variable name exists for internal use)
2461
2461
2462 Options:
2462 Options:
2463
2463
2464 -l: list output. Split the output on newlines into a list before
2464 -l: list output. Split the output on newlines into a list before
2465 assigning it to the given variable. By default the output is stored
2465 assigning it to the given variable. By default the output is stored
2466 as a single string.
2466 as a single string.
2467
2467
2468 -v: verbose. Print the contents of the variable.
2468 -v: verbose. Print the contents of the variable.
2469
2469
2470 In most cases you should not need to split as a list, because the
2470 In most cases you should not need to split as a list, because the
2471 returned value is a special type of string which can automatically
2471 returned value is a special type of string which can automatically
2472 provide its contents either as a list (split on newlines) or as a
2472 provide its contents either as a list (split on newlines) or as a
2473 space-separated string. These are convenient, respectively, either
2473 space-separated string. These are convenient, respectively, either
2474 for sequential processing or to be passed to a shell command.
2474 for sequential processing or to be passed to a shell command.
2475
2475
2476 For example:
2476 For example:
2477
2477
2478 # Capture into variable a
2478 # Capture into variable a
2479 In [9]: sc a=ls *py
2479 In [9]: sc a=ls *py
2480
2480
2481 # a is a string with embedded newlines
2481 # a is a string with embedded newlines
2482 In [10]: a
2482 In [10]: a
2483 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2483 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2484
2484
2485 # which can be seen as a list:
2485 # which can be seen as a list:
2486 In [11]: a.l
2486 In [11]: a.l
2487 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2487 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2488
2488
2489 # or as a whitespace-separated string:
2489 # or as a whitespace-separated string:
2490 In [12]: a.s
2490 In [12]: a.s
2491 Out[12]: 'setup.py win32_manual_post_install.py'
2491 Out[12]: 'setup.py win32_manual_post_install.py'
2492
2492
2493 # a.s is useful to pass as a single command line:
2493 # a.s is useful to pass as a single command line:
2494 In [13]: !wc -l $a.s
2494 In [13]: !wc -l $a.s
2495 146 setup.py
2495 146 setup.py
2496 130 win32_manual_post_install.py
2496 130 win32_manual_post_install.py
2497 276 total
2497 276 total
2498
2498
2499 # while the list form is useful to loop over:
2499 # while the list form is useful to loop over:
2500 In [14]: for f in a.l:
2500 In [14]: for f in a.l:
2501 ....: !wc -l $f
2501 ....: !wc -l $f
2502 ....:
2502 ....:
2503 146 setup.py
2503 146 setup.py
2504 130 win32_manual_post_install.py
2504 130 win32_manual_post_install.py
2505
2505
2506 Similiarly, the lists returned by the -l option are also special, in
2506 Similiarly, the lists returned by the -l option are also special, in
2507 the sense that you can equally invoke the .s attribute on them to
2507 the sense that you can equally invoke the .s attribute on them to
2508 automatically get a whitespace-separated string from their contents:
2508 automatically get a whitespace-separated string from their contents:
2509
2509
2510 In [1]: sc -l b=ls *py
2510 In [1]: sc -l b=ls *py
2511
2511
2512 In [2]: b
2512 In [2]: b
2513 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2513 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2514
2514
2515 In [3]: b.s
2515 In [3]: b.s
2516 Out[3]: 'setup.py win32_manual_post_install.py'
2516 Out[3]: 'setup.py win32_manual_post_install.py'
2517
2517
2518 In summary, both the lists and strings used for ouptut capture have
2518 In summary, both the lists and strings used for ouptut capture have
2519 the following special attributes:
2519 the following special attributes:
2520
2520
2521 .l (or .list) : value as list.
2521 .l (or .list) : value as list.
2522 .n (or .nlstr): value as newline-separated string.
2522 .n (or .nlstr): value as newline-separated string.
2523 .s (or .spstr): value as space-separated string.
2523 .s (or .spstr): value as space-separated string.
2524 """
2524 """
2525
2525
2526 opts,args = self.parse_options(parameter_s,'lv')
2526 opts,args = self.parse_options(parameter_s,'lv')
2527 # Try to get a variable name and command to run
2527 # Try to get a variable name and command to run
2528 try:
2528 try:
2529 # the variable name must be obtained from the parse_options
2529 # the variable name must be obtained from the parse_options
2530 # output, which uses shlex.split to strip options out.
2530 # output, which uses shlex.split to strip options out.
2531 var,_ = args.split('=',1)
2531 var,_ = args.split('=',1)
2532 var = var.strip()
2532 var = var.strip()
2533 # But the the command has to be extracted from the original input
2533 # But the the command has to be extracted from the original input
2534 # parameter_s, not on what parse_options returns, to avoid the
2534 # parameter_s, not on what parse_options returns, to avoid the
2535 # quote stripping which shlex.split performs on it.
2535 # quote stripping which shlex.split performs on it.
2536 _,cmd = parameter_s.split('=',1)
2536 _,cmd = parameter_s.split('=',1)
2537 except ValueError:
2537 except ValueError:
2538 var,cmd = '',''
2538 var,cmd = '',''
2539 # If all looks ok, proceed
2539 # If all looks ok, proceed
2540 out,err = self.shell.getoutputerror(cmd)
2540 out,err = self.shell.getoutputerror(cmd)
2541 if err:
2541 if err:
2542 print >> Term.cerr,err
2542 print >> Term.cerr,err
2543 if opts.has_key('l'):
2543 if opts.has_key('l'):
2544 out = SList(out.split('\n'))
2544 out = SList(out.split('\n'))
2545 else:
2545 else:
2546 out = LSString(out)
2546 out = LSString(out)
2547 if opts.has_key('v'):
2547 if opts.has_key('v'):
2548 print '%s ==\n%s' % (var,pformat(out))
2548 print '%s ==\n%s' % (var,pformat(out))
2549 if var:
2549 if var:
2550 self.shell.user_ns.update({var:out})
2550 self.shell.user_ns.update({var:out})
2551 else:
2551 else:
2552 return out
2552 return out
2553
2553
2554 def magic_sx(self, parameter_s=''):
2554 def magic_sx(self, parameter_s=''):
2555 """Shell execute - run a shell command and capture its output.
2555 """Shell execute - run a shell command and capture its output.
2556
2556
2557 %sx command
2557 %sx command
2558
2558
2559 IPython will run the given command using commands.getoutput(), and
2559 IPython will run the given command using commands.getoutput(), and
2560 return the result formatted as a list (split on '\\n'). Since the
2560 return the result formatted as a list (split on '\\n'). Since the
2561 output is _returned_, it will be stored in ipython's regular output
2561 output is _returned_, it will be stored in ipython's regular output
2562 cache Out[N] and in the '_N' automatic variables.
2562 cache Out[N] and in the '_N' automatic variables.
2563
2563
2564 Notes:
2564 Notes:
2565
2565
2566 1) If an input line begins with '!!', then %sx is automatically
2566 1) If an input line begins with '!!', then %sx is automatically
2567 invoked. That is, while:
2567 invoked. That is, while:
2568 !ls
2568 !ls
2569 causes ipython to simply issue system('ls'), typing
2569 causes ipython to simply issue system('ls'), typing
2570 !!ls
2570 !!ls
2571 is a shorthand equivalent to:
2571 is a shorthand equivalent to:
2572 %sx ls
2572 %sx ls
2573
2573
2574 2) %sx differs from %sc in that %sx automatically splits into a list,
2574 2) %sx differs from %sc in that %sx automatically splits into a list,
2575 like '%sc -l'. The reason for this is to make it as easy as possible
2575 like '%sc -l'. The reason for this is to make it as easy as possible
2576 to process line-oriented shell output via further python commands.
2576 to process line-oriented shell output via further python commands.
2577 %sc is meant to provide much finer control, but requires more
2577 %sc is meant to provide much finer control, but requires more
2578 typing.
2578 typing.
2579
2579
2580 3) Just like %sc -l, this is a list with special attributes:
2580 3) Just like %sc -l, this is a list with special attributes:
2581
2581
2582 .l (or .list) : value as list.
2582 .l (or .list) : value as list.
2583 .n (or .nlstr): value as newline-separated string.
2583 .n (or .nlstr): value as newline-separated string.
2584 .s (or .spstr): value as whitespace-separated string.
2584 .s (or .spstr): value as whitespace-separated string.
2585
2585
2586 This is very useful when trying to use such lists as arguments to
2586 This is very useful when trying to use such lists as arguments to
2587 system commands."""
2587 system commands."""
2588
2588
2589 if parameter_s:
2589 if parameter_s:
2590 out,err = self.shell.getoutputerror(parameter_s)
2590 out,err = self.shell.getoutputerror(parameter_s)
2591 if err:
2591 if err:
2592 print >> Term.cerr,err
2592 print >> Term.cerr,err
2593 return SList(out.split('\n'))
2593 return SList(out.split('\n'))
2594
2594
2595 def magic_bg(self, parameter_s=''):
2595 def magic_bg(self, parameter_s=''):
2596 """Run a job in the background, in a separate thread.
2596 """Run a job in the background, in a separate thread.
2597
2597
2598 For example,
2598 For example,
2599
2599
2600 %bg myfunc(x,y,z=1)
2600 %bg myfunc(x,y,z=1)
2601
2601
2602 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2602 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2603 execution starts, a message will be printed indicating the job
2603 execution starts, a message will be printed indicating the job
2604 number. If your job number is 5, you can use
2604 number. If your job number is 5, you can use
2605
2605
2606 myvar = jobs.result(5) or myvar = jobs[5].result
2606 myvar = jobs.result(5) or myvar = jobs[5].result
2607
2607
2608 to assign this result to variable 'myvar'.
2608 to assign this result to variable 'myvar'.
2609
2609
2610 IPython has a job manager, accessible via the 'jobs' object. You can
2610 IPython has a job manager, accessible via the 'jobs' object. You can
2611 type jobs? to get more information about it, and use jobs.<TAB> to see
2611 type jobs? to get more information about it, and use jobs.<TAB> to see
2612 its attributes. All attributes not starting with an underscore are
2612 its attributes. All attributes not starting with an underscore are
2613 meant for public use.
2613 meant for public use.
2614
2614
2615 In particular, look at the jobs.new() method, which is used to create
2615 In particular, look at the jobs.new() method, which is used to create
2616 new jobs. This magic %bg function is just a convenience wrapper
2616 new jobs. This magic %bg function is just a convenience wrapper
2617 around jobs.new(), for expression-based jobs. If you want to create a
2617 around jobs.new(), for expression-based jobs. If you want to create a
2618 new job with an explicit function object and arguments, you must call
2618 new job with an explicit function object and arguments, you must call
2619 jobs.new() directly.
2619 jobs.new() directly.
2620
2620
2621 The jobs.new docstring also describes in detail several important
2621 The jobs.new docstring also describes in detail several important
2622 caveats associated with a thread-based model for background job
2622 caveats associated with a thread-based model for background job
2623 execution. Type jobs.new? for details.
2623 execution. Type jobs.new? for details.
2624
2624
2625 You can check the status of all jobs with jobs.status().
2625 You can check the status of all jobs with jobs.status().
2626
2626
2627 The jobs variable is set by IPython into the Python builtin namespace.
2627 The jobs variable is set by IPython into the Python builtin namespace.
2628 If you ever declare a variable named 'jobs', you will shadow this
2628 If you ever declare a variable named 'jobs', you will shadow this
2629 name. You can either delete your global jobs variable to regain
2629 name. You can either delete your global jobs variable to regain
2630 access to the job manager, or make a new name and assign it manually
2630 access to the job manager, or make a new name and assign it manually
2631 to the manager (stored in IPython's namespace). For example, to
2631 to the manager (stored in IPython's namespace). For example, to
2632 assign the job manager to the Jobs name, use:
2632 assign the job manager to the Jobs name, use:
2633
2633
2634 Jobs = __builtins__.jobs"""
2634 Jobs = __builtins__.jobs"""
2635
2635
2636 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2636 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2637
2637
2638
2638
2639 def magic_bookmark(self, parameter_s=''):
2639 def magic_bookmark(self, parameter_s=''):
2640 """Manage IPython's bookmark system.
2640 """Manage IPython's bookmark system.
2641
2641
2642 %bookmark <name> - set bookmark to current dir
2642 %bookmark <name> - set bookmark to current dir
2643 %bookmark <name> <dir> - set bookmark to <dir>
2643 %bookmark <name> <dir> - set bookmark to <dir>
2644 %bookmark -l - list all bookmarks
2644 %bookmark -l - list all bookmarks
2645 %bookmark -d <name> - remove bookmark
2645 %bookmark -d <name> - remove bookmark
2646 %bookmark -r - remove all bookmarks
2646 %bookmark -r - remove all bookmarks
2647
2647
2648 You can later on access a bookmarked folder with:
2648 You can later on access a bookmarked folder with:
2649 %cd -b <name>
2649 %cd -b <name>
2650 or simply '%cd <name>' if there is no directory called <name> AND
2650 or simply '%cd <name>' if there is no directory called <name> AND
2651 there is such a bookmark defined.
2651 there is such a bookmark defined.
2652
2652
2653 Your bookmarks persist through IPython sessions, but they are
2653 Your bookmarks persist through IPython sessions, but they are
2654 associated with each profile."""
2654 associated with each profile."""
2655
2655
2656 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2656 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2657 if len(args) > 2:
2657 if len(args) > 2:
2658 error('You can only give at most two arguments')
2658 error('You can only give at most two arguments')
2659 return
2659 return
2660
2660
2661 bkms = self.db.get('bookmarks',{})
2661 bkms = self.db.get('bookmarks',{})
2662
2662
2663 if opts.has_key('d'):
2663 if opts.has_key('d'):
2664 try:
2664 try:
2665 todel = args[0]
2665 todel = args[0]
2666 except IndexError:
2666 except IndexError:
2667 error('You must provide a bookmark to delete')
2667 error('You must provide a bookmark to delete')
2668 else:
2668 else:
2669 try:
2669 try:
2670 del bkms[todel]
2670 del bkms[todel]
2671 except:
2671 except:
2672 error("Can't delete bookmark '%s'" % todel)
2672 error("Can't delete bookmark '%s'" % todel)
2673 elif opts.has_key('r'):
2673 elif opts.has_key('r'):
2674 bkms = {}
2674 bkms = {}
2675 elif opts.has_key('l'):
2675 elif opts.has_key('l'):
2676 bks = bkms.keys()
2676 bks = bkms.keys()
2677 bks.sort()
2677 bks.sort()
2678 if bks:
2678 if bks:
2679 size = max(map(len,bks))
2679 size = max(map(len,bks))
2680 else:
2680 else:
2681 size = 0
2681 size = 0
2682 fmt = '%-'+str(size)+'s -> %s'
2682 fmt = '%-'+str(size)+'s -> %s'
2683 print 'Current bookmarks:'
2683 print 'Current bookmarks:'
2684 for bk in bks:
2684 for bk in bks:
2685 print fmt % (bk,bkms[bk])
2685 print fmt % (bk,bkms[bk])
2686 else:
2686 else:
2687 if not args:
2687 if not args:
2688 error("You must specify the bookmark name")
2688 error("You must specify the bookmark name")
2689 elif len(args)==1:
2689 elif len(args)==1:
2690 bkms[args[0]] = os.getcwd()
2690 bkms[args[0]] = os.getcwd()
2691 elif len(args)==2:
2691 elif len(args)==2:
2692 bkms[args[0]] = args[1]
2692 bkms[args[0]] = args[1]
2693 self.db['bookmarks'] = bkms
2693 self.db['bookmarks'] = bkms
2694
2694
2695 def magic_pycat(self, parameter_s=''):
2695 def magic_pycat(self, parameter_s=''):
2696 """Show a syntax-highlighted file through a pager.
2696 """Show a syntax-highlighted file through a pager.
2697
2697
2698 This magic is similar to the cat utility, but it will assume the file
2698 This magic is similar to the cat utility, but it will assume the file
2699 to be Python source and will show it with syntax highlighting. """
2699 to be Python source and will show it with syntax highlighting. """
2700
2700
2701 filename = get_py_filename(parameter_s)
2701 try:
2702 page(self.shell.pycolorize(file_read(filename)),
2702 filename = get_py_filename(parameter_s)
2703 cont = file_read(filename)
2704 except IOError:
2705 try:
2706 cont = eval(parameter_s,self.user_ns)
2707 except NameError:
2708 cont = None
2709 if cont is None:
2710 print "Error: no such file or variable"
2711 return
2712
2713 page(self.shell.pycolorize(cont),
2703 screen_lines=self.shell.rc.screen_length)
2714 screen_lines=self.shell.rc.screen_length)
2704
2715
2705 def magic_cpaste(self, parameter_s=''):
2716 def magic_cpaste(self, parameter_s=''):
2706 """Allows you to paste & execute a pre-formatted code block from
2717 """Allows you to paste & execute a pre-formatted code block from
2707 clipboard.
2718 clipboard.
2708
2719
2709 You must terminate the block with '--' (two minus-signs) alone on the
2720 You must terminate the block with '--' (two minus-signs) alone on the
2710 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
2721 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
2711 is the new sentinel for this operation)
2722 is the new sentinel for this operation)
2712
2723
2713 The block is dedented prior to execution to enable execution of
2724 The block is dedented prior to execution to enable execution of
2714 method definitions. The executed block is also assigned to variable
2725 method definitions. The executed block is also assigned to variable
2715 named 'pasted_block' for later editing with '%edit pasted_block'.
2726 named 'pasted_block' for later editing with '%edit pasted_block'.
2716
2727
2717 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
2728 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
2718 This assigns the pasted block to variable 'foo' as string, without
2729 This assigns the pasted block to variable 'foo' as string, without
2719 dedenting or executing it.
2730 dedenting or executing it.
2720
2731
2721 Do not be alarmed by garbled output on Windows (it's a readline bug).
2732 Do not be alarmed by garbled output on Windows (it's a readline bug).
2722 Just press enter and type -- (and press enter again) and the block
2733 Just press enter and type -- (and press enter again) and the block
2723 will be what was just pasted.
2734 will be what was just pasted.
2724
2735
2725 IPython statements (magics, shell escapes) are not supported (yet).
2736 IPython statements (magics, shell escapes) are not supported (yet).
2726 """
2737 """
2727 opts,args = self.parse_options(parameter_s,'s:',mode='string')
2738 opts,args = self.parse_options(parameter_s,'s:',mode='string')
2728 par = args.strip()
2739 par = args.strip()
2729 sentinel = opts.get('s','--')
2740 sentinel = opts.get('s','--')
2730
2741
2731 from IPython import iplib
2742 from IPython import iplib
2732 lines = []
2743 lines = []
2733 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
2744 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
2734 while 1:
2745 while 1:
2735 l = iplib.raw_input_original(':')
2746 l = iplib.raw_input_original(':')
2736 if l ==sentinel:
2747 if l ==sentinel:
2737 break
2748 break
2738 lines.append(l)
2749 lines.append(l)
2739 block = "\n".join(lines) + '\n'
2750 block = "\n".join(lines) + '\n'
2740 #print "block:\n",block
2751 #print "block:\n",block
2741 if not par:
2752 if not par:
2742 b = textwrap.dedent(block)
2753 b = textwrap.dedent(block)
2743 exec b in self.user_ns
2754 exec b in self.user_ns
2744 self.user_ns['pasted_block'] = b
2755 self.user_ns['pasted_block'] = b
2745 else:
2756 else:
2746 self.user_ns[par] = block
2757 self.user_ns[par] = block
2747 print "Block assigned to '%s'" % par
2758 print "Block assigned to '%s'" % par
2748 def magic_quickref(self,arg):
2759 def magic_quickref(self,arg):
2749 import IPython.usage
2760 import IPython.usage
2750 page(IPython.usage.quick_reference)
2761 page(IPython.usage.quick_reference)
2751 del IPython.usage
2762 del IPython.usage
2752
2763
2753
2764
2754 # end Magic
2765 # end Magic
@@ -1,53 +1,65 b''
1 """ User configuration file for IPython
1 """ User configuration file for IPython
2
2
3 This is a more flexible and safe way to configure ipython than *rc files
3 This is a more flexible and safe way to configure ipython than *rc files
4 (ipythonrc, ipythonrc-pysh etc.)
4 (ipythonrc, ipythonrc-pysh etc.)
5
5
6 This file is always imported on ipython startup. You should import all the
6 This file is always imported on ipython startup. You can import the
7 ipython extensions you need here (see IPython/Extensions directory).
7 ipython extensions you need here (see IPython/Extensions directory).
8
8
9 Feel free to edit this file to customize your ipython experience. If
9 Feel free to edit this file to customize your ipython experience.
10 you wish to only use the old config system, it's perfectly ok to make this file
10
11 empty.
11 Note that as such this file does nothing, for backwards compatibility.
12 To enable this config file, uncomment the call to main() at the end.
13
14 Try it out!
12
15
13 """
16 """
14
17
15 # Most of your config files and extensions will probably start with this import
18 # Most of your config files and extensions will probably start with this import
16
19
17 from IPython import ipapi
20 from IPython import ipapi
18 ip = ipapi.get()
19 import os
21 import os
22 from IPython import Release
20
23
21 o = ip.options()
24 import sys
22 # autocall 1 ('smart') is default anyway, this is just an
23 # example on how to set an option
24 o.autocall = 1
25
25
26 if o.profile == 'pysh':
26
27 def main():
28 ip = ipapi.get()
29 o = ip.options()
30 # autocall to "full" mode (smart mode is default, I like full mode)
31
32 o.autocall = 1
33
27 # Jason Orendorff's path class is handy to have in user namespace
34 # Jason Orendorff's path class is handy to have in user namespace
28 # if you are doing shell-like stuff
35 # if you are doing shell-like stuff
29 try:
36 try:
30 ip.ex("from path import path" )
37 ip.ex("from path import path" )
31 except ImportError:
38 except ImportError:
32 pass
39 pass
40
41 # Get prompt with working dir
33
42
34 # Uncomment these lines to get pysh-like prompt for all profiles.
43 o.prompt_in1= '\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> '
35
44 o.prompt_in2= '\C_Green|\C_LightGreen\D\C_Green> '
36 #o.prompt_in1= '\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> '
45 o.prompt_out= '<\#> '
37 #o.prompt_in2= '\C_Green|\C_LightGreen\D\C_Green> '
46
38 #o.prompt_out= '<\#> '
47 # I like my banner minimal.
39
48 o.banner = "Py %s IPy %s\n" % (sys.version.split('\n')[0],Release.version)
40 # make 'd' an alias for ls -F
49
41
50 # make 'd' an alias for ls -F
42 ip.magic('alias d ls -F --color=auto')
51
43
52 ip.magic('alias d ls -F --color=auto')
44 # Make available all system commands through "rehashing" immediately.
53
45 # You can comment these lines out to speed up startup on very slow
54 # Make available all system commands through "rehashing" immediately.
46 # machines, and to conserve a bit of memory. Note that pysh profile does this
55 # You can comment these lines out to speed up startup on very slow
47 # automatically
56 # machines, and to conserve a bit of memory. Note that pysh profile does this
57 # automatically
58
59 #if os.name=='posix':
60 # ip.magic('rehash')
61 #else:
62 # #slightly slower, but better results esp. with Windows
63 # ip.magic('rehashx')
48
64
49 #if os.name=='posix':
65 #main() No newline at end of file
50 # ip.magic('rehash')
51 #else:
52 # #slightly slower, but better results esp. with Windows
53 # ip.magic('rehashx')
@@ -1,2252 +1,2256 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.3 or newer.
5 Requires Python 2.3 or newer.
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 1117 2006-01-31 21:02:45Z vivainio $
9 $Id: iplib.py 1121 2006-02-01 21:12:20Z vivainio $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #
18 #
19 # Note: this code originally subclassed code.InteractiveConsole from the
19 # Note: this code originally subclassed code.InteractiveConsole from the
20 # Python standard library. Over time, all of that class has been copied
20 # Python standard library. Over time, all of that class has been copied
21 # verbatim here for modifications which could not be accomplished by
21 # verbatim here for modifications which could not be accomplished by
22 # subclassing. At this point, there are no dependencies at all on the code
22 # subclassing. At this point, there are no dependencies at all on the code
23 # module anymore (it is not even imported). The Python License (sec. 2)
23 # module anymore (it is not even imported). The Python License (sec. 2)
24 # allows for this, but it's always nice to acknowledge credit where credit is
24 # allows for this, but it's always nice to acknowledge credit where credit is
25 # due.
25 # due.
26 #*****************************************************************************
26 #*****************************************************************************
27
27
28 #****************************************************************************
28 #****************************************************************************
29 # Modules and globals
29 # Modules and globals
30
30
31 from __future__ import generators # for 2.2 backwards-compatibility
31 from __future__ import generators # for 2.2 backwards-compatibility
32
32
33 from IPython import Release
33 from IPython import Release
34 __author__ = '%s <%s>\n%s <%s>' % \
34 __author__ = '%s <%s>\n%s <%s>' % \
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
36 __license__ = Release.license
36 __license__ = Release.license
37 __version__ = Release.version
37 __version__ = Release.version
38
38
39 # Python standard modules
39 # Python standard modules
40 import __main__
40 import __main__
41 import __builtin__
41 import __builtin__
42 import StringIO
42 import StringIO
43 import bdb
43 import bdb
44 import cPickle as pickle
44 import cPickle as pickle
45 import codeop
45 import codeop
46 import exceptions
46 import exceptions
47 import glob
47 import glob
48 import inspect
48 import inspect
49 import keyword
49 import keyword
50 import new
50 import new
51 import os
51 import os
52 import pdb
52 import pdb
53 import pydoc
53 import pydoc
54 import re
54 import re
55 import shutil
55 import shutil
56 import string
56 import string
57 import sys
57 import sys
58 import tempfile
58 import tempfile
59 import traceback
59 import traceback
60 import types
60 import types
61 import pickleshare
61 import pickleshare
62
62
63 from pprint import pprint, pformat
63 from pprint import pprint, pformat
64
64
65 # IPython's own modules
65 # IPython's own modules
66 import IPython
66 import IPython
67 from IPython import OInspect,PyColorize,ultraTB
67 from IPython import OInspect,PyColorize,ultraTB
68 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
68 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
69 from IPython.FakeModule import FakeModule
69 from IPython.FakeModule import FakeModule
70 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
70 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
71 from IPython.Logger import Logger
71 from IPython.Logger import Logger
72 from IPython.Magic import Magic
72 from IPython.Magic import Magic
73 from IPython.Prompts import CachedOutput
73 from IPython.Prompts import CachedOutput
74 from IPython.ipstruct import Struct
74 from IPython.ipstruct import Struct
75 from IPython.background_jobs import BackgroundJobManager
75 from IPython.background_jobs import BackgroundJobManager
76 from IPython.usage import cmd_line_usage,interactive_usage
76 from IPython.usage import cmd_line_usage,interactive_usage
77 from IPython.genutils import *
77 from IPython.genutils import *
78 import IPython.ipapi
78 import IPython.ipapi
79
79
80 # Globals
80 # Globals
81
81
82 # store the builtin raw_input globally, and use this always, in case user code
82 # store the builtin raw_input globally, and use this always, in case user code
83 # overwrites it (like wx.py.PyShell does)
83 # overwrites it (like wx.py.PyShell does)
84 raw_input_original = raw_input
84 raw_input_original = raw_input
85
85
86 # compiled regexps for autoindent management
86 # compiled regexps for autoindent management
87 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
87 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
88
88
89
89
90 #****************************************************************************
90 #****************************************************************************
91 # Some utility function definitions
91 # Some utility function definitions
92
92
93 ini_spaces_re = re.compile(r'^(\s+)')
93 ini_spaces_re = re.compile(r'^(\s+)')
94
94
95 def num_ini_spaces(strng):
95 def num_ini_spaces(strng):
96 """Return the number of initial spaces in a string"""
96 """Return the number of initial spaces in a string"""
97
97
98 ini_spaces = ini_spaces_re.match(strng)
98 ini_spaces = ini_spaces_re.match(strng)
99 if ini_spaces:
99 if ini_spaces:
100 return ini_spaces.end()
100 return ini_spaces.end()
101 else:
101 else:
102 return 0
102 return 0
103
103
104 def softspace(file, newvalue):
104 def softspace(file, newvalue):
105 """Copied from code.py, to remove the dependency"""
105 """Copied from code.py, to remove the dependency"""
106
106
107 oldvalue = 0
107 oldvalue = 0
108 try:
108 try:
109 oldvalue = file.softspace
109 oldvalue = file.softspace
110 except AttributeError:
110 except AttributeError:
111 pass
111 pass
112 try:
112 try:
113 file.softspace = newvalue
113 file.softspace = newvalue
114 except (AttributeError, TypeError):
114 except (AttributeError, TypeError):
115 # "attribute-less object" or "read-only attributes"
115 # "attribute-less object" or "read-only attributes"
116 pass
116 pass
117 return oldvalue
117 return oldvalue
118
118
119
119
120 #****************************************************************************
120 #****************************************************************************
121 # Local use exceptions
121 # Local use exceptions
122 class SpaceInInput(exceptions.Exception): pass
122 class SpaceInInput(exceptions.Exception): pass
123
123
124
124
125 #****************************************************************************
125 #****************************************************************************
126 # Local use classes
126 # Local use classes
127 class Bunch: pass
127 class Bunch: pass
128
128
129 class Undefined: pass
129 class Undefined: pass
130
130
131 class InputList(list):
131 class InputList(list):
132 """Class to store user input.
132 """Class to store user input.
133
133
134 It's basically a list, but slices return a string instead of a list, thus
134 It's basically a list, but slices return a string instead of a list, thus
135 allowing things like (assuming 'In' is an instance):
135 allowing things like (assuming 'In' is an instance):
136
136
137 exec In[4:7]
137 exec In[4:7]
138
138
139 or
139 or
140
140
141 exec In[5:9] + In[14] + In[21:25]"""
141 exec In[5:9] + In[14] + In[21:25]"""
142
142
143 def __getslice__(self,i,j):
143 def __getslice__(self,i,j):
144 return ''.join(list.__getslice__(self,i,j))
144 return ''.join(list.__getslice__(self,i,j))
145
145
146 class SyntaxTB(ultraTB.ListTB):
146 class SyntaxTB(ultraTB.ListTB):
147 """Extension which holds some state: the last exception value"""
147 """Extension which holds some state: the last exception value"""
148
148
149 def __init__(self,color_scheme = 'NoColor'):
149 def __init__(self,color_scheme = 'NoColor'):
150 ultraTB.ListTB.__init__(self,color_scheme)
150 ultraTB.ListTB.__init__(self,color_scheme)
151 self.last_syntax_error = None
151 self.last_syntax_error = None
152
152
153 def __call__(self, etype, value, elist):
153 def __call__(self, etype, value, elist):
154 self.last_syntax_error = value
154 self.last_syntax_error = value
155 ultraTB.ListTB.__call__(self,etype,value,elist)
155 ultraTB.ListTB.__call__(self,etype,value,elist)
156
156
157 def clear_err_state(self):
157 def clear_err_state(self):
158 """Return the current error state and clear it"""
158 """Return the current error state and clear it"""
159 e = self.last_syntax_error
159 e = self.last_syntax_error
160 self.last_syntax_error = None
160 self.last_syntax_error = None
161 return e
161 return e
162
162
163 #****************************************************************************
163 #****************************************************************************
164 # Main IPython class
164 # Main IPython class
165
165
166 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
166 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
167 # until a full rewrite is made. I've cleaned all cross-class uses of
167 # until a full rewrite is made. I've cleaned all cross-class uses of
168 # attributes and methods, but too much user code out there relies on the
168 # attributes and methods, but too much user code out there relies on the
169 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
169 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
170 #
170 #
171 # But at least now, all the pieces have been separated and we could, in
171 # But at least now, all the pieces have been separated and we could, in
172 # principle, stop using the mixin. This will ease the transition to the
172 # principle, stop using the mixin. This will ease the transition to the
173 # chainsaw branch.
173 # chainsaw branch.
174
174
175 # For reference, the following is the list of 'self.foo' uses in the Magic
175 # For reference, the following is the list of 'self.foo' uses in the Magic
176 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
176 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
177 # class, to prevent clashes.
177 # class, to prevent clashes.
178
178
179 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
179 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
180 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
180 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
181 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
181 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
182 # 'self.value']
182 # 'self.value']
183
183
184 class InteractiveShell(object,Magic):
184 class InteractiveShell(object,Magic):
185 """An enhanced console for Python."""
185 """An enhanced console for Python."""
186
186
187 # class attribute to indicate whether the class supports threads or not.
187 # class attribute to indicate whether the class supports threads or not.
188 # Subclasses with thread support should override this as needed.
188 # Subclasses with thread support should override this as needed.
189 isthreaded = False
189 isthreaded = False
190
190
191 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
191 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
192 user_ns = None,user_global_ns=None,banner2='',
192 user_ns = None,user_global_ns=None,banner2='',
193 custom_exceptions=((),None),embedded=False):
193 custom_exceptions=((),None),embedded=False):
194
194
195
195
196 # log system
196 # log system
197 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
197 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
198
198
199 # Produce a public API instance
199 # Produce a public API instance
200
200
201 self.api = IPython.ipapi.IPApi(self)
201 self.api = IPython.ipapi.IPApi(self)
202
202
203 # some minimal strict typechecks. For some core data structures, I
203 # some minimal strict typechecks. For some core data structures, I
204 # want actual basic python types, not just anything that looks like
204 # want actual basic python types, not just anything that looks like
205 # one. This is especially true for namespaces.
205 # one. This is especially true for namespaces.
206 for ns in (user_ns,user_global_ns):
206 for ns in (user_ns,user_global_ns):
207 if ns is not None and type(ns) != types.DictType:
207 if ns is not None and type(ns) != types.DictType:
208 raise TypeError,'namespace must be a dictionary'
208 raise TypeError,'namespace must be a dictionary'
209
209
210 # Job manager (for jobs run as background threads)
210 # Job manager (for jobs run as background threads)
211 self.jobs = BackgroundJobManager()
211 self.jobs = BackgroundJobManager()
212
212
213 # track which builtins we add, so we can clean up later
213 # track which builtins we add, so we can clean up later
214 self.builtins_added = {}
214 self.builtins_added = {}
215 # This method will add the necessary builtins for operation, but
215 # This method will add the necessary builtins for operation, but
216 # tracking what it did via the builtins_added dict.
216 # tracking what it did via the builtins_added dict.
217 self.add_builtins()
217 self.add_builtins()
218
218
219 # Do the intuitively correct thing for quit/exit: we remove the
219 # Do the intuitively correct thing for quit/exit: we remove the
220 # builtins if they exist, and our own magics will deal with this
220 # builtins if they exist, and our own magics will deal with this
221 try:
221 try:
222 del __builtin__.exit, __builtin__.quit
222 del __builtin__.exit, __builtin__.quit
223 except AttributeError:
223 except AttributeError:
224 pass
224 pass
225
225
226 # Store the actual shell's name
226 # Store the actual shell's name
227 self.name = name
227 self.name = name
228
228
229 # We need to know whether the instance is meant for embedding, since
229 # We need to know whether the instance is meant for embedding, since
230 # global/local namespaces need to be handled differently in that case
230 # global/local namespaces need to be handled differently in that case
231 self.embedded = embedded
231 self.embedded = embedded
232
232
233 # command compiler
233 # command compiler
234 self.compile = codeop.CommandCompiler()
234 self.compile = codeop.CommandCompiler()
235
235
236 # User input buffer
236 # User input buffer
237 self.buffer = []
237 self.buffer = []
238
238
239 # Default name given in compilation of code
239 # Default name given in compilation of code
240 self.filename = '<ipython console>'
240 self.filename = '<ipython console>'
241
241
242 # Make an empty namespace, which extension writers can rely on both
242 # Make an empty namespace, which extension writers can rely on both
243 # existing and NEVER being used by ipython itself. This gives them a
243 # existing and NEVER being used by ipython itself. This gives them a
244 # convenient location for storing additional information and state
244 # convenient location for storing additional information and state
245 # their extensions may require, without fear of collisions with other
245 # their extensions may require, without fear of collisions with other
246 # ipython names that may develop later.
246 # ipython names that may develop later.
247 self.meta = Struct()
247 self.meta = Struct()
248
248
249 # Create the namespace where the user will operate. user_ns is
249 # Create the namespace where the user will operate. user_ns is
250 # normally the only one used, and it is passed to the exec calls as
250 # normally the only one used, and it is passed to the exec calls as
251 # the locals argument. But we do carry a user_global_ns namespace
251 # the locals argument. But we do carry a user_global_ns namespace
252 # given as the exec 'globals' argument, This is useful in embedding
252 # given as the exec 'globals' argument, This is useful in embedding
253 # situations where the ipython shell opens in a context where the
253 # situations where the ipython shell opens in a context where the
254 # distinction between locals and globals is meaningful.
254 # distinction between locals and globals is meaningful.
255
255
256 # FIXME. For some strange reason, __builtins__ is showing up at user
256 # FIXME. For some strange reason, __builtins__ is showing up at user
257 # level as a dict instead of a module. This is a manual fix, but I
257 # level as a dict instead of a module. This is a manual fix, but I
258 # should really track down where the problem is coming from. Alex
258 # should really track down where the problem is coming from. Alex
259 # Schmolck reported this problem first.
259 # Schmolck reported this problem first.
260
260
261 # A useful post by Alex Martelli on this topic:
261 # A useful post by Alex Martelli on this topic:
262 # Re: inconsistent value from __builtins__
262 # Re: inconsistent value from __builtins__
263 # Von: Alex Martelli <aleaxit@yahoo.com>
263 # Von: Alex Martelli <aleaxit@yahoo.com>
264 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
264 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
265 # Gruppen: comp.lang.python
265 # Gruppen: comp.lang.python
266
266
267 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
267 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
268 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
268 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
269 # > <type 'dict'>
269 # > <type 'dict'>
270 # > >>> print type(__builtins__)
270 # > >>> print type(__builtins__)
271 # > <type 'module'>
271 # > <type 'module'>
272 # > Is this difference in return value intentional?
272 # > Is this difference in return value intentional?
273
273
274 # Well, it's documented that '__builtins__' can be either a dictionary
274 # Well, it's documented that '__builtins__' can be either a dictionary
275 # or a module, and it's been that way for a long time. Whether it's
275 # or a module, and it's been that way for a long time. Whether it's
276 # intentional (or sensible), I don't know. In any case, the idea is
276 # intentional (or sensible), I don't know. In any case, the idea is
277 # that if you need to access the built-in namespace directly, you
277 # that if you need to access the built-in namespace directly, you
278 # should start with "import __builtin__" (note, no 's') which will
278 # should start with "import __builtin__" (note, no 's') which will
279 # definitely give you a module. Yeah, it's somewhat confusing:-(.
279 # definitely give you a module. Yeah, it's somewhat confusing:-(.
280
280
281 if user_ns is None:
281 if user_ns is None:
282 # Set __name__ to __main__ to better match the behavior of the
282 # Set __name__ to __main__ to better match the behavior of the
283 # normal interpreter.
283 # normal interpreter.
284 user_ns = {'__name__' :'__main__',
284 user_ns = {'__name__' :'__main__',
285 '__builtins__' : __builtin__,
285 '__builtins__' : __builtin__,
286 }
286 }
287
287
288 if user_global_ns is None:
288 if user_global_ns is None:
289 user_global_ns = {}
289 user_global_ns = {}
290
290
291 # Assign namespaces
291 # Assign namespaces
292 # This is the namespace where all normal user variables live
292 # This is the namespace where all normal user variables live
293 self.user_ns = user_ns
293 self.user_ns = user_ns
294 # Embedded instances require a separate namespace for globals.
294 # Embedded instances require a separate namespace for globals.
295 # Normally this one is unused by non-embedded instances.
295 # Normally this one is unused by non-embedded instances.
296 self.user_global_ns = user_global_ns
296 self.user_global_ns = user_global_ns
297 # A namespace to keep track of internal data structures to prevent
297 # A namespace to keep track of internal data structures to prevent
298 # them from cluttering user-visible stuff. Will be updated later
298 # them from cluttering user-visible stuff. Will be updated later
299 self.internal_ns = {}
299 self.internal_ns = {}
300
300
301 # Namespace of system aliases. Each entry in the alias
301 # Namespace of system aliases. Each entry in the alias
302 # table must be a 2-tuple of the form (N,name), where N is the number
302 # table must be a 2-tuple of the form (N,name), where N is the number
303 # of positional arguments of the alias.
303 # of positional arguments of the alias.
304 self.alias_table = {}
304 self.alias_table = {}
305
305
306 # A table holding all the namespaces IPython deals with, so that
306 # A table holding all the namespaces IPython deals with, so that
307 # introspection facilities can search easily.
307 # introspection facilities can search easily.
308 self.ns_table = {'user':user_ns,
308 self.ns_table = {'user':user_ns,
309 'user_global':user_global_ns,
309 'user_global':user_global_ns,
310 'alias':self.alias_table,
310 'alias':self.alias_table,
311 'internal':self.internal_ns,
311 'internal':self.internal_ns,
312 'builtin':__builtin__.__dict__
312 'builtin':__builtin__.__dict__
313 }
313 }
314
314
315 # The user namespace MUST have a pointer to the shell itself.
315 # The user namespace MUST have a pointer to the shell itself.
316 self.user_ns[name] = self
316 self.user_ns[name] = self
317
317
318 # We need to insert into sys.modules something that looks like a
318 # We need to insert into sys.modules something that looks like a
319 # module but which accesses the IPython namespace, for shelve and
319 # module but which accesses the IPython namespace, for shelve and
320 # pickle to work interactively. Normally they rely on getting
320 # pickle to work interactively. Normally they rely on getting
321 # everything out of __main__, but for embedding purposes each IPython
321 # everything out of __main__, but for embedding purposes each IPython
322 # instance has its own private namespace, so we can't go shoving
322 # instance has its own private namespace, so we can't go shoving
323 # everything into __main__.
323 # everything into __main__.
324
324
325 # note, however, that we should only do this for non-embedded
325 # note, however, that we should only do this for non-embedded
326 # ipythons, which really mimic the __main__.__dict__ with their own
326 # ipythons, which really mimic the __main__.__dict__ with their own
327 # namespace. Embedded instances, on the other hand, should not do
327 # namespace. Embedded instances, on the other hand, should not do
328 # this because they need to manage the user local/global namespaces
328 # this because they need to manage the user local/global namespaces
329 # only, but they live within a 'normal' __main__ (meaning, they
329 # only, but they live within a 'normal' __main__ (meaning, they
330 # shouldn't overtake the execution environment of the script they're
330 # shouldn't overtake the execution environment of the script they're
331 # embedded in).
331 # embedded in).
332
332
333 if not embedded:
333 if not embedded:
334 try:
334 try:
335 main_name = self.user_ns['__name__']
335 main_name = self.user_ns['__name__']
336 except KeyError:
336 except KeyError:
337 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
337 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
338 else:
338 else:
339 #print "pickle hack in place" # dbg
339 #print "pickle hack in place" # dbg
340 #print 'main_name:',main_name # dbg
340 #print 'main_name:',main_name # dbg
341 sys.modules[main_name] = FakeModule(self.user_ns)
341 sys.modules[main_name] = FakeModule(self.user_ns)
342
342
343 # List of input with multi-line handling.
343 # List of input with multi-line handling.
344 # Fill its zero entry, user counter starts at 1
344 # Fill its zero entry, user counter starts at 1
345 self.input_hist = InputList(['\n'])
345 self.input_hist = InputList(['\n'])
346 # This one will hold the 'raw' input history, without any
346 # This one will hold the 'raw' input history, without any
347 # pre-processing. This will allow users to retrieve the input just as
347 # pre-processing. This will allow users to retrieve the input just as
348 # it was exactly typed in by the user, with %hist -r.
348 # it was exactly typed in by the user, with %hist -r.
349 self.input_hist_raw = InputList(['\n'])
349 self.input_hist_raw = InputList(['\n'])
350
350
351 # list of visited directories
351 # list of visited directories
352 try:
352 try:
353 self.dir_hist = [os.getcwd()]
353 self.dir_hist = [os.getcwd()]
354 except IOError, e:
354 except IOError, e:
355 self.dir_hist = []
355 self.dir_hist = []
356
356
357 # dict of output history
357 # dict of output history
358 self.output_hist = {}
358 self.output_hist = {}
359
359
360 # dict of things NOT to alias (keywords, builtins and some magics)
360 # dict of things NOT to alias (keywords, builtins and some magics)
361 no_alias = {}
361 no_alias = {}
362 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
362 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
363 for key in keyword.kwlist + no_alias_magics:
363 for key in keyword.kwlist + no_alias_magics:
364 no_alias[key] = 1
364 no_alias[key] = 1
365 no_alias.update(__builtin__.__dict__)
365 no_alias.update(__builtin__.__dict__)
366 self.no_alias = no_alias
366 self.no_alias = no_alias
367
367
368 # make global variables for user access to these
368 # make global variables for user access to these
369 self.user_ns['_ih'] = self.input_hist
369 self.user_ns['_ih'] = self.input_hist
370 self.user_ns['_oh'] = self.output_hist
370 self.user_ns['_oh'] = self.output_hist
371 self.user_ns['_dh'] = self.dir_hist
371 self.user_ns['_dh'] = self.dir_hist
372
372
373 # user aliases to input and output histories
373 # user aliases to input and output histories
374 self.user_ns['In'] = self.input_hist
374 self.user_ns['In'] = self.input_hist
375 self.user_ns['Out'] = self.output_hist
375 self.user_ns['Out'] = self.output_hist
376
376
377 # Object variable to store code object waiting execution. This is
377 # Object variable to store code object waiting execution. This is
378 # used mainly by the multithreaded shells, but it can come in handy in
378 # used mainly by the multithreaded shells, but it can come in handy in
379 # other situations. No need to use a Queue here, since it's a single
379 # other situations. No need to use a Queue here, since it's a single
380 # item which gets cleared once run.
380 # item which gets cleared once run.
381 self.code_to_run = None
381 self.code_to_run = None
382
382
383 # escapes for automatic behavior on the command line
383 # escapes for automatic behavior on the command line
384 self.ESC_SHELL = '!'
384 self.ESC_SHELL = '!'
385 self.ESC_HELP = '?'
385 self.ESC_HELP = '?'
386 self.ESC_MAGIC = '%'
386 self.ESC_MAGIC = '%'
387 self.ESC_QUOTE = ','
387 self.ESC_QUOTE = ','
388 self.ESC_QUOTE2 = ';'
388 self.ESC_QUOTE2 = ';'
389 self.ESC_PAREN = '/'
389 self.ESC_PAREN = '/'
390
390
391 # And their associated handlers
391 # And their associated handlers
392 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
392 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
393 self.ESC_QUOTE : self.handle_auto,
393 self.ESC_QUOTE : self.handle_auto,
394 self.ESC_QUOTE2 : self.handle_auto,
394 self.ESC_QUOTE2 : self.handle_auto,
395 self.ESC_MAGIC : self.handle_magic,
395 self.ESC_MAGIC : self.handle_magic,
396 self.ESC_HELP : self.handle_help,
396 self.ESC_HELP : self.handle_help,
397 self.ESC_SHELL : self.handle_shell_escape,
397 self.ESC_SHELL : self.handle_shell_escape,
398 }
398 }
399
399
400 # class initializations
400 # class initializations
401 Magic.__init__(self,self)
401 Magic.__init__(self,self)
402
402
403 # Python source parser/formatter for syntax highlighting
403 # Python source parser/formatter for syntax highlighting
404 pyformat = PyColorize.Parser().format
404 pyformat = PyColorize.Parser().format
405 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
405 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
406
406
407 # hooks holds pointers used for user-side customizations
407 # hooks holds pointers used for user-side customizations
408 self.hooks = Struct()
408 self.hooks = Struct()
409
409
410 # Set all default hooks, defined in the IPython.hooks module.
410 # Set all default hooks, defined in the IPython.hooks module.
411 hooks = IPython.hooks
411 hooks = IPython.hooks
412 for hook_name in hooks.__all__:
412 for hook_name in hooks.__all__:
413 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
413 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
414 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
414 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
415 #print "bound hook",hook_name
415 #print "bound hook",hook_name
416
416
417 # Flag to mark unconditional exit
417 # Flag to mark unconditional exit
418 self.exit_now = False
418 self.exit_now = False
419
419
420 self.usage_min = """\
420 self.usage_min = """\
421 An enhanced console for Python.
421 An enhanced console for Python.
422 Some of its features are:
422 Some of its features are:
423 - Readline support if the readline library is present.
423 - Readline support if the readline library is present.
424 - Tab completion in the local namespace.
424 - Tab completion in the local namespace.
425 - Logging of input, see command-line options.
425 - Logging of input, see command-line options.
426 - System shell escape via ! , eg !ls.
426 - System shell escape via ! , eg !ls.
427 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
427 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
428 - Keeps track of locally defined variables via %who, %whos.
428 - Keeps track of locally defined variables via %who, %whos.
429 - Show object information with a ? eg ?x or x? (use ?? for more info).
429 - Show object information with a ? eg ?x or x? (use ?? for more info).
430 """
430 """
431 if usage: self.usage = usage
431 if usage: self.usage = usage
432 else: self.usage = self.usage_min
432 else: self.usage = self.usage_min
433
433
434 # Storage
434 # Storage
435 self.rc = rc # This will hold all configuration information
435 self.rc = rc # This will hold all configuration information
436 self.pager = 'less'
436 self.pager = 'less'
437 # temporary files used for various purposes. Deleted at exit.
437 # temporary files used for various purposes. Deleted at exit.
438 self.tempfiles = []
438 self.tempfiles = []
439
439
440 # Keep track of readline usage (later set by init_readline)
440 # Keep track of readline usage (later set by init_readline)
441 self.has_readline = False
441 self.has_readline = False
442
442
443 # template for logfile headers. It gets resolved at runtime by the
443 # template for logfile headers. It gets resolved at runtime by the
444 # logstart method.
444 # logstart method.
445 self.loghead_tpl = \
445 self.loghead_tpl = \
446 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
446 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
447 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
447 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
448 #log# opts = %s
448 #log# opts = %s
449 #log# args = %s
449 #log# args = %s
450 #log# It is safe to make manual edits below here.
450 #log# It is safe to make manual edits below here.
451 #log#-----------------------------------------------------------------------
451 #log#-----------------------------------------------------------------------
452 """
452 """
453 # for pushd/popd management
453 # for pushd/popd management
454 try:
454 try:
455 self.home_dir = get_home_dir()
455 self.home_dir = get_home_dir()
456 except HomeDirError,msg:
456 except HomeDirError,msg:
457 fatal(msg)
457 fatal(msg)
458
458
459 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
459 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
460
460
461 # Functions to call the underlying shell.
461 # Functions to call the underlying shell.
462
462
463 # utility to expand user variables via Itpl
463 # utility to expand user variables via Itpl
464 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
464 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
465 self.user_ns))
465 self.user_ns))
466 # The first is similar to os.system, but it doesn't return a value,
466 # The first is similar to os.system, but it doesn't return a value,
467 # and it allows interpolation of variables in the user's namespace.
467 # and it allows interpolation of variables in the user's namespace.
468 self.system = lambda cmd: shell(self.var_expand(cmd),
468 self.system = lambda cmd: shell(self.var_expand(cmd),
469 header='IPython system call: ',
469 header='IPython system call: ',
470 verbose=self.rc.system_verbose)
470 verbose=self.rc.system_verbose)
471 # These are for getoutput and getoutputerror:
471 # These are for getoutput and getoutputerror:
472 self.getoutput = lambda cmd: \
472 self.getoutput = lambda cmd: \
473 getoutput(self.var_expand(cmd),
473 getoutput(self.var_expand(cmd),
474 header='IPython system call: ',
474 header='IPython system call: ',
475 verbose=self.rc.system_verbose)
475 verbose=self.rc.system_verbose)
476 self.getoutputerror = lambda cmd: \
476 self.getoutputerror = lambda cmd: \
477 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
477 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
478 self.user_ns)),
478 self.user_ns)),
479 header='IPython system call: ',
479 header='IPython system call: ',
480 verbose=self.rc.system_verbose)
480 verbose=self.rc.system_verbose)
481
481
482 # RegExp for splitting line contents into pre-char//first
482 # RegExp for splitting line contents into pre-char//first
483 # word-method//rest. For clarity, each group in on one line.
483 # word-method//rest. For clarity, each group in on one line.
484
484
485 # WARNING: update the regexp if the above escapes are changed, as they
485 # WARNING: update the regexp if the above escapes are changed, as they
486 # are hardwired in.
486 # are hardwired in.
487
487
488 # Don't get carried away with trying to make the autocalling catch too
488 # Don't get carried away with trying to make the autocalling catch too
489 # much: it's better to be conservative rather than to trigger hidden
489 # much: it's better to be conservative rather than to trigger hidden
490 # evals() somewhere and end up causing side effects.
490 # evals() somewhere and end up causing side effects.
491
491
492 self.line_split = re.compile(r'^([\s*,;/])'
492 self.line_split = re.compile(r'^([\s*,;/])'
493 r'([\?\w\.]+\w*\s*)'
493 r'([\?\w\.]+\w*\s*)'
494 r'(\(?.*$)')
494 r'(\(?.*$)')
495
495
496 # Original re, keep around for a while in case changes break something
496 # Original re, keep around for a while in case changes break something
497 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
497 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
498 # r'(\s*[\?\w\.]+\w*\s*)'
498 # r'(\s*[\?\w\.]+\w*\s*)'
499 # r'(\(?.*$)')
499 # r'(\(?.*$)')
500
500
501 # RegExp to identify potential function names
501 # RegExp to identify potential function names
502 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
502 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
503
503
504 # RegExp to exclude strings with this start from autocalling. In
504 # RegExp to exclude strings with this start from autocalling. In
505 # particular, all binary operators should be excluded, so that if foo
505 # particular, all binary operators should be excluded, so that if foo
506 # is callable, foo OP bar doesn't become foo(OP bar), which is
506 # is callable, foo OP bar doesn't become foo(OP bar), which is
507 # invalid. The characters '!=()' don't need to be checked for, as the
507 # invalid. The characters '!=()' don't need to be checked for, as the
508 # _prefilter routine explicitely does so, to catch direct calls and
508 # _prefilter routine explicitely does so, to catch direct calls and
509 # rebindings of existing names.
509 # rebindings of existing names.
510
510
511 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
511 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
512 # it affects the rest of the group in square brackets.
512 # it affects the rest of the group in square brackets.
513 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
513 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
514 '|^is |^not |^in |^and |^or ')
514 '|^is |^not |^in |^and |^or ')
515
515
516 # try to catch also methods for stuff in lists/tuples/dicts: off
516 # try to catch also methods for stuff in lists/tuples/dicts: off
517 # (experimental). For this to work, the line_split regexp would need
517 # (experimental). For this to work, the line_split regexp would need
518 # to be modified so it wouldn't break things at '['. That line is
518 # to be modified so it wouldn't break things at '['. That line is
519 # nasty enough that I shouldn't change it until I can test it _well_.
519 # nasty enough that I shouldn't change it until I can test it _well_.
520 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
520 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
521
521
522 # keep track of where we started running (mainly for crash post-mortem)
522 # keep track of where we started running (mainly for crash post-mortem)
523 self.starting_dir = os.getcwd()
523 self.starting_dir = os.getcwd()
524
524
525 # Various switches which can be set
525 # Various switches which can be set
526 self.CACHELENGTH = 5000 # this is cheap, it's just text
526 self.CACHELENGTH = 5000 # this is cheap, it's just text
527 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
527 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
528 self.banner2 = banner2
528 self.banner2 = banner2
529
529
530 # TraceBack handlers:
530 # TraceBack handlers:
531
531
532 # Syntax error handler.
532 # Syntax error handler.
533 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
533 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
534
534
535 # The interactive one is initialized with an offset, meaning we always
535 # The interactive one is initialized with an offset, meaning we always
536 # want to remove the topmost item in the traceback, which is our own
536 # want to remove the topmost item in the traceback, which is our own
537 # internal code. Valid modes: ['Plain','Context','Verbose']
537 # internal code. Valid modes: ['Plain','Context','Verbose']
538 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
538 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
539 color_scheme='NoColor',
539 color_scheme='NoColor',
540 tb_offset = 1)
540 tb_offset = 1)
541
541
542 # IPython itself shouldn't crash. This will produce a detailed
542 # IPython itself shouldn't crash. This will produce a detailed
543 # post-mortem if it does. But we only install the crash handler for
543 # post-mortem if it does. But we only install the crash handler for
544 # non-threaded shells, the threaded ones use a normal verbose reporter
544 # non-threaded shells, the threaded ones use a normal verbose reporter
545 # and lose the crash handler. This is because exceptions in the main
545 # and lose the crash handler. This is because exceptions in the main
546 # thread (such as in GUI code) propagate directly to sys.excepthook,
546 # thread (such as in GUI code) propagate directly to sys.excepthook,
547 # and there's no point in printing crash dumps for every user exception.
547 # and there's no point in printing crash dumps for every user exception.
548 if self.isthreaded:
548 if self.isthreaded:
549 sys.excepthook = ultraTB.FormattedTB()
549 sys.excepthook = ultraTB.FormattedTB()
550 else:
550 else:
551 from IPython import CrashHandler
551 from IPython import CrashHandler
552 sys.excepthook = CrashHandler.CrashHandler(self)
552 sys.excepthook = CrashHandler.CrashHandler(self)
553
553
554 # The instance will store a pointer to this, so that runtime code
554 # The instance will store a pointer to this, so that runtime code
555 # (such as magics) can access it. This is because during the
555 # (such as magics) can access it. This is because during the
556 # read-eval loop, it gets temporarily overwritten (to deal with GUI
556 # read-eval loop, it gets temporarily overwritten (to deal with GUI
557 # frameworks).
557 # frameworks).
558 self.sys_excepthook = sys.excepthook
558 self.sys_excepthook = sys.excepthook
559
559
560 # and add any custom exception handlers the user may have specified
560 # and add any custom exception handlers the user may have specified
561 self.set_custom_exc(*custom_exceptions)
561 self.set_custom_exc(*custom_exceptions)
562
562
563 # Object inspector
563 # Object inspector
564 self.inspector = OInspect.Inspector(OInspect.InspectColors,
564 self.inspector = OInspect.Inspector(OInspect.InspectColors,
565 PyColorize.ANSICodeColors,
565 PyColorize.ANSICodeColors,
566 'NoColor')
566 'NoColor')
567 # indentation management
567 # indentation management
568 self.autoindent = False
568 self.autoindent = False
569 self.indent_current_nsp = 0
569 self.indent_current_nsp = 0
570
570
571 # Make some aliases automatically
571 # Make some aliases automatically
572 # Prepare list of shell aliases to auto-define
572 # Prepare list of shell aliases to auto-define
573 if os.name == 'posix':
573 if os.name == 'posix':
574 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
574 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
575 'mv mv -i','rm rm -i','cp cp -i',
575 'mv mv -i','rm rm -i','cp cp -i',
576 'cat cat','less less','clear clear',
576 'cat cat','less less','clear clear',
577 # a better ls
577 # a better ls
578 'ls ls -F',
578 'ls ls -F',
579 # long ls
579 # long ls
580 'll ls -lF',
580 'll ls -lF',
581 # color ls
581 # color ls
582 'lc ls -F -o --color',
582 'lc ls -F -o --color',
583 # ls normal files only
583 # ls normal files only
584 'lf ls -F -o --color %l | grep ^-',
584 'lf ls -F -o --color %l | grep ^-',
585 # ls symbolic links
585 # ls symbolic links
586 'lk ls -F -o --color %l | grep ^l',
586 'lk ls -F -o --color %l | grep ^l',
587 # directories or links to directories,
587 # directories or links to directories,
588 'ldir ls -F -o --color %l | grep /$',
588 'ldir ls -F -o --color %l | grep /$',
589 # things which are executable
589 # things which are executable
590 'lx ls -F -o --color %l | grep ^-..x',
590 'lx ls -F -o --color %l | grep ^-..x',
591 )
591 )
592 elif os.name in ['nt','dos']:
592 elif os.name in ['nt','dos']:
593 auto_alias = ('dir dir /on', 'ls dir /on',
593 auto_alias = ('dir dir /on', 'ls dir /on',
594 'ddir dir /ad /on', 'ldir dir /ad /on',
594 'ddir dir /ad /on', 'ldir dir /ad /on',
595 'mkdir mkdir','rmdir rmdir','echo echo',
595 'mkdir mkdir','rmdir rmdir','echo echo',
596 'ren ren','cls cls','copy copy')
596 'ren ren','cls cls','copy copy')
597 else:
597 else:
598 auto_alias = ()
598 auto_alias = ()
599 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
599 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
600 # Call the actual (public) initializer
600 # Call the actual (public) initializer
601 self.init_auto_alias()
601 self.init_auto_alias()
602 # end __init__
602 # end __init__
603
603
604 def post_config_initialization(self):
604 def post_config_initialization(self):
605 """Post configuration init method
605 """Post configuration init method
606
606
607 This is called after the configuration files have been processed to
607 This is called after the configuration files have been processed to
608 'finalize' the initialization."""
608 'finalize' the initialization."""
609
609
610 rc = self.rc
610 rc = self.rc
611
611
612 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
612 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
613 # Load readline proper
613 # Load readline proper
614 if rc.readline:
614 if rc.readline:
615 self.init_readline()
615 self.init_readline()
616
616
617 # local shortcut, this is used a LOT
617 # local shortcut, this is used a LOT
618 self.log = self.logger.log
618 self.log = self.logger.log
619
619
620 # Initialize cache, set in/out prompts and printing system
620 # Initialize cache, set in/out prompts and printing system
621 self.outputcache = CachedOutput(self,
621 self.outputcache = CachedOutput(self,
622 rc.cache_size,
622 rc.cache_size,
623 rc.pprint,
623 rc.pprint,
624 input_sep = rc.separate_in,
624 input_sep = rc.separate_in,
625 output_sep = rc.separate_out,
625 output_sep = rc.separate_out,
626 output_sep2 = rc.separate_out2,
626 output_sep2 = rc.separate_out2,
627 ps1 = rc.prompt_in1,
627 ps1 = rc.prompt_in1,
628 ps2 = rc.prompt_in2,
628 ps2 = rc.prompt_in2,
629 ps_out = rc.prompt_out,
629 ps_out = rc.prompt_out,
630 pad_left = rc.prompts_pad_left)
630 pad_left = rc.prompts_pad_left)
631
631
632 # user may have over-ridden the default print hook:
632 # user may have over-ridden the default print hook:
633 try:
633 try:
634 self.outputcache.__class__.display = self.hooks.display
634 self.outputcache.__class__.display = self.hooks.display
635 except AttributeError:
635 except AttributeError:
636 pass
636 pass
637
637
638 # I don't like assigning globally to sys, because it means when embedding
638 # I don't like assigning globally to sys, because it means when embedding
639 # instances, each embedded instance overrides the previous choice. But
639 # instances, each embedded instance overrides the previous choice. But
640 # sys.displayhook seems to be called internally by exec, so I don't see a
640 # sys.displayhook seems to be called internally by exec, so I don't see a
641 # way around it.
641 # way around it.
642 sys.displayhook = self.outputcache
642 sys.displayhook = self.outputcache
643
643
644 # Set user colors (don't do it in the constructor above so that it
644 # Set user colors (don't do it in the constructor above so that it
645 # doesn't crash if colors option is invalid)
645 # doesn't crash if colors option is invalid)
646 self.magic_colors(rc.colors)
646 self.magic_colors(rc.colors)
647
647
648 # Set calling of pdb on exceptions
648 # Set calling of pdb on exceptions
649 self.call_pdb = rc.pdb
649 self.call_pdb = rc.pdb
650
650
651 # Load user aliases
651 # Load user aliases
652 for alias in rc.alias:
652 for alias in rc.alias:
653 self.magic_alias(alias)
653 self.magic_alias(alias)
654 self.hooks.late_startup_hook()
654 self.hooks.late_startup_hook()
655
655
656
656
657 def add_builtins(self):
657 def add_builtins(self):
658 """Store ipython references into the builtin namespace.
658 """Store ipython references into the builtin namespace.
659
659
660 Some parts of ipython operate via builtins injected here, which hold a
660 Some parts of ipython operate via builtins injected here, which hold a
661 reference to IPython itself."""
661 reference to IPython itself."""
662
662
663 # TODO: deprecate all except _ip; 'jobs' should be installed
663 # TODO: deprecate all except _ip; 'jobs' should be installed
664 # by an extension and the rest are under _ip, ipalias is redundant
664 # by an extension and the rest are under _ip, ipalias is redundant
665 builtins_new = dict(__IPYTHON__ = self,
665 builtins_new = dict(__IPYTHON__ = self,
666 ip_set_hook = self.set_hook,
666 ip_set_hook = self.set_hook,
667 jobs = self.jobs,
667 jobs = self.jobs,
668 ipmagic = self.ipmagic,
668 ipmagic = self.ipmagic,
669 ipalias = self.ipalias,
669 ipalias = self.ipalias,
670 ipsystem = self.ipsystem,
670 ipsystem = self.ipsystem,
671 _ip = self.api
671 _ip = self.api
672 )
672 )
673 for biname,bival in builtins_new.items():
673 for biname,bival in builtins_new.items():
674 try:
674 try:
675 # store the orignal value so we can restore it
675 # store the orignal value so we can restore it
676 self.builtins_added[biname] = __builtin__.__dict__[biname]
676 self.builtins_added[biname] = __builtin__.__dict__[biname]
677 except KeyError:
677 except KeyError:
678 # or mark that it wasn't defined, and we'll just delete it at
678 # or mark that it wasn't defined, and we'll just delete it at
679 # cleanup
679 # cleanup
680 self.builtins_added[biname] = Undefined
680 self.builtins_added[biname] = Undefined
681 __builtin__.__dict__[biname] = bival
681 __builtin__.__dict__[biname] = bival
682
682
683 # Keep in the builtins a flag for when IPython is active. We set it
683 # Keep in the builtins a flag for when IPython is active. We set it
684 # with setdefault so that multiple nested IPythons don't clobber one
684 # with setdefault so that multiple nested IPythons don't clobber one
685 # another. Each will increase its value by one upon being activated,
685 # another. Each will increase its value by one upon being activated,
686 # which also gives us a way to determine the nesting level.
686 # which also gives us a way to determine the nesting level.
687 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
687 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
688
688
689 def clean_builtins(self):
689 def clean_builtins(self):
690 """Remove any builtins which might have been added by add_builtins, or
690 """Remove any builtins which might have been added by add_builtins, or
691 restore overwritten ones to their previous values."""
691 restore overwritten ones to their previous values."""
692 for biname,bival in self.builtins_added.items():
692 for biname,bival in self.builtins_added.items():
693 if bival is Undefined:
693 if bival is Undefined:
694 del __builtin__.__dict__[biname]
694 del __builtin__.__dict__[biname]
695 else:
695 else:
696 __builtin__.__dict__[biname] = bival
696 __builtin__.__dict__[biname] = bival
697 self.builtins_added.clear()
697 self.builtins_added.clear()
698
698
699 def set_hook(self,name,hook, priority = 50):
699 def set_hook(self,name,hook, priority = 50):
700 """set_hook(name,hook) -> sets an internal IPython hook.
700 """set_hook(name,hook) -> sets an internal IPython hook.
701
701
702 IPython exposes some of its internal API as user-modifiable hooks. By
702 IPython exposes some of its internal API as user-modifiable hooks. By
703 adding your function to one of these hooks, you can modify IPython's
703 adding your function to one of these hooks, you can modify IPython's
704 behavior to call at runtime your own routines."""
704 behavior to call at runtime your own routines."""
705
705
706 # At some point in the future, this should validate the hook before it
706 # At some point in the future, this should validate the hook before it
707 # accepts it. Probably at least check that the hook takes the number
707 # accepts it. Probably at least check that the hook takes the number
708 # of args it's supposed to.
708 # of args it's supposed to.
709 dp = getattr(self.hooks, name, None)
709 dp = getattr(self.hooks, name, None)
710 if name not in IPython.hooks.__all__:
710 if name not in IPython.hooks.__all__:
711 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
711 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
712 if not dp:
712 if not dp:
713 dp = IPython.hooks.CommandChainDispatcher()
713 dp = IPython.hooks.CommandChainDispatcher()
714
714
715 f = new.instancemethod(hook,self,self.__class__)
715 f = new.instancemethod(hook,self,self.__class__)
716 try:
716 try:
717 dp.add(f,priority)
717 dp.add(f,priority)
718 except AttributeError:
718 except AttributeError:
719 # it was not commandchain, plain old func - replace
719 # it was not commandchain, plain old func - replace
720 dp = f
720 dp = f
721
721
722 setattr(self.hooks,name, dp)
722 setattr(self.hooks,name, dp)
723
723
724
724
725 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
725 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
726
726
727 def set_custom_exc(self,exc_tuple,handler):
727 def set_custom_exc(self,exc_tuple,handler):
728 """set_custom_exc(exc_tuple,handler)
728 """set_custom_exc(exc_tuple,handler)
729
729
730 Set a custom exception handler, which will be called if any of the
730 Set a custom exception handler, which will be called if any of the
731 exceptions in exc_tuple occur in the mainloop (specifically, in the
731 exceptions in exc_tuple occur in the mainloop (specifically, in the
732 runcode() method.
732 runcode() method.
733
733
734 Inputs:
734 Inputs:
735
735
736 - exc_tuple: a *tuple* of valid exceptions to call the defined
736 - exc_tuple: a *tuple* of valid exceptions to call the defined
737 handler for. It is very important that you use a tuple, and NOT A
737 handler for. It is very important that you use a tuple, and NOT A
738 LIST here, because of the way Python's except statement works. If
738 LIST here, because of the way Python's except statement works. If
739 you only want to trap a single exception, use a singleton tuple:
739 you only want to trap a single exception, use a singleton tuple:
740
740
741 exc_tuple == (MyCustomException,)
741 exc_tuple == (MyCustomException,)
742
742
743 - handler: this must be defined as a function with the following
743 - handler: this must be defined as a function with the following
744 basic interface: def my_handler(self,etype,value,tb).
744 basic interface: def my_handler(self,etype,value,tb).
745
745
746 This will be made into an instance method (via new.instancemethod)
746 This will be made into an instance method (via new.instancemethod)
747 of IPython itself, and it will be called if any of the exceptions
747 of IPython itself, and it will be called if any of the exceptions
748 listed in the exc_tuple are caught. If the handler is None, an
748 listed in the exc_tuple are caught. If the handler is None, an
749 internal basic one is used, which just prints basic info.
749 internal basic one is used, which just prints basic info.
750
750
751 WARNING: by putting in your own exception handler into IPython's main
751 WARNING: by putting in your own exception handler into IPython's main
752 execution loop, you run a very good chance of nasty crashes. This
752 execution loop, you run a very good chance of nasty crashes. This
753 facility should only be used if you really know what you are doing."""
753 facility should only be used if you really know what you are doing."""
754
754
755 assert type(exc_tuple)==type(()) , \
755 assert type(exc_tuple)==type(()) , \
756 "The custom exceptions must be given AS A TUPLE."
756 "The custom exceptions must be given AS A TUPLE."
757
757
758 def dummy_handler(self,etype,value,tb):
758 def dummy_handler(self,etype,value,tb):
759 print '*** Simple custom exception handler ***'
759 print '*** Simple custom exception handler ***'
760 print 'Exception type :',etype
760 print 'Exception type :',etype
761 print 'Exception value:',value
761 print 'Exception value:',value
762 print 'Traceback :',tb
762 print 'Traceback :',tb
763 print 'Source code :','\n'.join(self.buffer)
763 print 'Source code :','\n'.join(self.buffer)
764
764
765 if handler is None: handler = dummy_handler
765 if handler is None: handler = dummy_handler
766
766
767 self.CustomTB = new.instancemethod(handler,self,self.__class__)
767 self.CustomTB = new.instancemethod(handler,self,self.__class__)
768 self.custom_exceptions = exc_tuple
768 self.custom_exceptions = exc_tuple
769
769
770 def set_custom_completer(self,completer,pos=0):
770 def set_custom_completer(self,completer,pos=0):
771 """set_custom_completer(completer,pos=0)
771 """set_custom_completer(completer,pos=0)
772
772
773 Adds a new custom completer function.
773 Adds a new custom completer function.
774
774
775 The position argument (defaults to 0) is the index in the completers
775 The position argument (defaults to 0) is the index in the completers
776 list where you want the completer to be inserted."""
776 list where you want the completer to be inserted."""
777
777
778 newcomp = new.instancemethod(completer,self.Completer,
778 newcomp = new.instancemethod(completer,self.Completer,
779 self.Completer.__class__)
779 self.Completer.__class__)
780 self.Completer.matchers.insert(pos,newcomp)
780 self.Completer.matchers.insert(pos,newcomp)
781
781
782 def _get_call_pdb(self):
782 def _get_call_pdb(self):
783 return self._call_pdb
783 return self._call_pdb
784
784
785 def _set_call_pdb(self,val):
785 def _set_call_pdb(self,val):
786
786
787 if val not in (0,1,False,True):
787 if val not in (0,1,False,True):
788 raise ValueError,'new call_pdb value must be boolean'
788 raise ValueError,'new call_pdb value must be boolean'
789
789
790 # store value in instance
790 # store value in instance
791 self._call_pdb = val
791 self._call_pdb = val
792
792
793 # notify the actual exception handlers
793 # notify the actual exception handlers
794 self.InteractiveTB.call_pdb = val
794 self.InteractiveTB.call_pdb = val
795 if self.isthreaded:
795 if self.isthreaded:
796 try:
796 try:
797 self.sys_excepthook.call_pdb = val
797 self.sys_excepthook.call_pdb = val
798 except:
798 except:
799 warn('Failed to activate pdb for threaded exception handler')
799 warn('Failed to activate pdb for threaded exception handler')
800
800
801 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
801 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
802 'Control auto-activation of pdb at exceptions')
802 'Control auto-activation of pdb at exceptions')
803
803
804
804
805 # These special functions get installed in the builtin namespace, to
805 # These special functions get installed in the builtin namespace, to
806 # provide programmatic (pure python) access to magics, aliases and system
806 # provide programmatic (pure python) access to magics, aliases and system
807 # calls. This is important for logging, user scripting, and more.
807 # calls. This is important for logging, user scripting, and more.
808
808
809 # We are basically exposing, via normal python functions, the three
809 # We are basically exposing, via normal python functions, the three
810 # mechanisms in which ipython offers special call modes (magics for
810 # mechanisms in which ipython offers special call modes (magics for
811 # internal control, aliases for direct system access via pre-selected
811 # internal control, aliases for direct system access via pre-selected
812 # names, and !cmd for calling arbitrary system commands).
812 # names, and !cmd for calling arbitrary system commands).
813
813
814 def ipmagic(self,arg_s):
814 def ipmagic(self,arg_s):
815 """Call a magic function by name.
815 """Call a magic function by name.
816
816
817 Input: a string containing the name of the magic function to call and any
817 Input: a string containing the name of the magic function to call and any
818 additional arguments to be passed to the magic.
818 additional arguments to be passed to the magic.
819
819
820 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
820 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
821 prompt:
821 prompt:
822
822
823 In[1]: %name -opt foo bar
823 In[1]: %name -opt foo bar
824
824
825 To call a magic without arguments, simply use ipmagic('name').
825 To call a magic without arguments, simply use ipmagic('name').
826
826
827 This provides a proper Python function to call IPython's magics in any
827 This provides a proper Python function to call IPython's magics in any
828 valid Python code you can type at the interpreter, including loops and
828 valid Python code you can type at the interpreter, including loops and
829 compound statements. It is added by IPython to the Python builtin
829 compound statements. It is added by IPython to the Python builtin
830 namespace upon initialization."""
830 namespace upon initialization."""
831
831
832 args = arg_s.split(' ',1)
832 args = arg_s.split(' ',1)
833 magic_name = args[0]
833 magic_name = args[0]
834 magic_name = magic_name.lstrip(self.ESC_MAGIC)
834 magic_name = magic_name.lstrip(self.ESC_MAGIC)
835
835
836 try:
836 try:
837 magic_args = args[1]
837 magic_args = args[1]
838 except IndexError:
838 except IndexError:
839 magic_args = ''
839 magic_args = ''
840 fn = getattr(self,'magic_'+magic_name,None)
840 fn = getattr(self,'magic_'+magic_name,None)
841 if fn is None:
841 if fn is None:
842 error("Magic function `%s` not found." % magic_name)
842 error("Magic function `%s` not found." % magic_name)
843 else:
843 else:
844 magic_args = self.var_expand(magic_args)
844 magic_args = self.var_expand(magic_args)
845 return fn(magic_args)
845 return fn(magic_args)
846
846
847 def ipalias(self,arg_s):
847 def ipalias(self,arg_s):
848 """Call an alias by name.
848 """Call an alias by name.
849
849
850 Input: a string containing the name of the alias to call and any
850 Input: a string containing the name of the alias to call and any
851 additional arguments to be passed to the magic.
851 additional arguments to be passed to the magic.
852
852
853 ipalias('name -opt foo bar') is equivalent to typing at the ipython
853 ipalias('name -opt foo bar') is equivalent to typing at the ipython
854 prompt:
854 prompt:
855
855
856 In[1]: name -opt foo bar
856 In[1]: name -opt foo bar
857
857
858 To call an alias without arguments, simply use ipalias('name').
858 To call an alias without arguments, simply use ipalias('name').
859
859
860 This provides a proper Python function to call IPython's aliases in any
860 This provides a proper Python function to call IPython's aliases in any
861 valid Python code you can type at the interpreter, including loops and
861 valid Python code you can type at the interpreter, including loops and
862 compound statements. It is added by IPython to the Python builtin
862 compound statements. It is added by IPython to the Python builtin
863 namespace upon initialization."""
863 namespace upon initialization."""
864
864
865 args = arg_s.split(' ',1)
865 args = arg_s.split(' ',1)
866 alias_name = args[0]
866 alias_name = args[0]
867 try:
867 try:
868 alias_args = args[1]
868 alias_args = args[1]
869 except IndexError:
869 except IndexError:
870 alias_args = ''
870 alias_args = ''
871 if alias_name in self.alias_table:
871 if alias_name in self.alias_table:
872 self.call_alias(alias_name,alias_args)
872 self.call_alias(alias_name,alias_args)
873 else:
873 else:
874 error("Alias `%s` not found." % alias_name)
874 error("Alias `%s` not found." % alias_name)
875
875
876 def ipsystem(self,arg_s):
876 def ipsystem(self,arg_s):
877 """Make a system call, using IPython."""
877 """Make a system call, using IPython."""
878
878
879 self.system(arg_s)
879 self.system(arg_s)
880
880
881 def complete(self,text):
881 def complete(self,text):
882 """Return a sorted list of all possible completions on text.
882 """Return a sorted list of all possible completions on text.
883
883
884 Inputs:
884 Inputs:
885
885
886 - text: a string of text to be completed on.
886 - text: a string of text to be completed on.
887
887
888 This is a wrapper around the completion mechanism, similar to what
888 This is a wrapper around the completion mechanism, similar to what
889 readline does at the command line when the TAB key is hit. By
889 readline does at the command line when the TAB key is hit. By
890 exposing it as a method, it can be used by other non-readline
890 exposing it as a method, it can be used by other non-readline
891 environments (such as GUIs) for text completion.
891 environments (such as GUIs) for text completion.
892
892
893 Simple usage example:
893 Simple usage example:
894
894
895 In [1]: x = 'hello'
895 In [1]: x = 'hello'
896
896
897 In [2]: __IP.complete('x.l')
897 In [2]: __IP.complete('x.l')
898 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
898 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
899
899
900 complete = self.Completer.complete
900 complete = self.Completer.complete
901 state = 0
901 state = 0
902 # use a dict so we get unique keys, since ipyhton's multiple
902 # use a dict so we get unique keys, since ipyhton's multiple
903 # completers can return duplicates.
903 # completers can return duplicates.
904 comps = {}
904 comps = {}
905 while True:
905 while True:
906 newcomp = complete(text,state)
906 newcomp = complete(text,state)
907 if newcomp is None:
907 if newcomp is None:
908 break
908 break
909 comps[newcomp] = 1
909 comps[newcomp] = 1
910 state += 1
910 state += 1
911 outcomps = comps.keys()
911 outcomps = comps.keys()
912 outcomps.sort()
912 outcomps.sort()
913 return outcomps
913 return outcomps
914
914
915 def set_completer_frame(self, frame=None):
915 def set_completer_frame(self, frame=None):
916 if frame:
916 if frame:
917 self.Completer.namespace = frame.f_locals
917 self.Completer.namespace = frame.f_locals
918 self.Completer.global_namespace = frame.f_globals
918 self.Completer.global_namespace = frame.f_globals
919 else:
919 else:
920 self.Completer.namespace = self.user_ns
920 self.Completer.namespace = self.user_ns
921 self.Completer.global_namespace = self.user_global_ns
921 self.Completer.global_namespace = self.user_global_ns
922
922
923 def init_auto_alias(self):
923 def init_auto_alias(self):
924 """Define some aliases automatically.
924 """Define some aliases automatically.
925
925
926 These are ALL parameter-less aliases"""
926 These are ALL parameter-less aliases"""
927
927
928 for alias,cmd in self.auto_alias:
928 for alias,cmd in self.auto_alias:
929 self.alias_table[alias] = (0,cmd)
929 self.alias_table[alias] = (0,cmd)
930
930
931 def alias_table_validate(self,verbose=0):
931 def alias_table_validate(self,verbose=0):
932 """Update information about the alias table.
932 """Update information about the alias table.
933
933
934 In particular, make sure no Python keywords/builtins are in it."""
934 In particular, make sure no Python keywords/builtins are in it."""
935
935
936 no_alias = self.no_alias
936 no_alias = self.no_alias
937 for k in self.alias_table.keys():
937 for k in self.alias_table.keys():
938 if k in no_alias:
938 if k in no_alias:
939 del self.alias_table[k]
939 del self.alias_table[k]
940 if verbose:
940 if verbose:
941 print ("Deleting alias <%s>, it's a Python "
941 print ("Deleting alias <%s>, it's a Python "
942 "keyword or builtin." % k)
942 "keyword or builtin." % k)
943
943
944 def set_autoindent(self,value=None):
944 def set_autoindent(self,value=None):
945 """Set the autoindent flag, checking for readline support.
945 """Set the autoindent flag, checking for readline support.
946
946
947 If called with no arguments, it acts as a toggle."""
947 If called with no arguments, it acts as a toggle."""
948
948
949 if not self.has_readline:
949 if not self.has_readline:
950 if os.name == 'posix':
950 if os.name == 'posix':
951 warn("The auto-indent feature requires the readline library")
951 warn("The auto-indent feature requires the readline library")
952 self.autoindent = 0
952 self.autoindent = 0
953 return
953 return
954 if value is None:
954 if value is None:
955 self.autoindent = not self.autoindent
955 self.autoindent = not self.autoindent
956 else:
956 else:
957 self.autoindent = value
957 self.autoindent = value
958
958
959 def rc_set_toggle(self,rc_field,value=None):
959 def rc_set_toggle(self,rc_field,value=None):
960 """Set or toggle a field in IPython's rc config. structure.
960 """Set or toggle a field in IPython's rc config. structure.
961
961
962 If called with no arguments, it acts as a toggle.
962 If called with no arguments, it acts as a toggle.
963
963
964 If called with a non-existent field, the resulting AttributeError
964 If called with a non-existent field, the resulting AttributeError
965 exception will propagate out."""
965 exception will propagate out."""
966
966
967 rc_val = getattr(self.rc,rc_field)
967 rc_val = getattr(self.rc,rc_field)
968 if value is None:
968 if value is None:
969 value = not rc_val
969 value = not rc_val
970 setattr(self.rc,rc_field,value)
970 setattr(self.rc,rc_field,value)
971
971
972 def user_setup(self,ipythondir,rc_suffix,mode='install'):
972 def user_setup(self,ipythondir,rc_suffix,mode='install'):
973 """Install the user configuration directory.
973 """Install the user configuration directory.
974
974
975 Can be called when running for the first time or to upgrade the user's
975 Can be called when running for the first time or to upgrade the user's
976 .ipython/ directory with the mode parameter. Valid modes are 'install'
976 .ipython/ directory with the mode parameter. Valid modes are 'install'
977 and 'upgrade'."""
977 and 'upgrade'."""
978
978
979 def wait():
979 def wait():
980 try:
980 try:
981 raw_input("Please press <RETURN> to start IPython.")
981 raw_input("Please press <RETURN> to start IPython.")
982 except EOFError:
982 except EOFError:
983 print >> Term.cout
983 print >> Term.cout
984 print '*'*70
984 print '*'*70
985
985
986 cwd = os.getcwd() # remember where we started
986 cwd = os.getcwd() # remember where we started
987 glb = glob.glob
987 glb = glob.glob
988 print '*'*70
988 print '*'*70
989 if mode == 'install':
989 if mode == 'install':
990 print \
990 print \
991 """Welcome to IPython. I will try to create a personal configuration directory
991 """Welcome to IPython. I will try to create a personal configuration directory
992 where you can customize many aspects of IPython's functionality in:\n"""
992 where you can customize many aspects of IPython's functionality in:\n"""
993 else:
993 else:
994 print 'I am going to upgrade your configuration in:'
994 print 'I am going to upgrade your configuration in:'
995
995
996 print ipythondir
996 print ipythondir
997
997
998 rcdirend = os.path.join('IPython','UserConfig')
998 rcdirend = os.path.join('IPython','UserConfig')
999 cfg = lambda d: os.path.join(d,rcdirend)
999 cfg = lambda d: os.path.join(d,rcdirend)
1000 try:
1000 try:
1001 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1001 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1002 except IOError:
1002 except IOError:
1003 warning = """
1003 warning = """
1004 Installation error. IPython's directory was not found.
1004 Installation error. IPython's directory was not found.
1005
1005
1006 Check the following:
1006 Check the following:
1007
1007
1008 The ipython/IPython directory should be in a directory belonging to your
1008 The ipython/IPython directory should be in a directory belonging to your
1009 PYTHONPATH environment variable (that is, it should be in a directory
1009 PYTHONPATH environment variable (that is, it should be in a directory
1010 belonging to sys.path). You can copy it explicitly there or just link to it.
1010 belonging to sys.path). You can copy it explicitly there or just link to it.
1011
1011
1012 IPython will proceed with builtin defaults.
1012 IPython will proceed with builtin defaults.
1013 """
1013 """
1014 warn(warning)
1014 warn(warning)
1015 wait()
1015 wait()
1016 return
1016 return
1017
1017
1018 if mode == 'install':
1018 if mode == 'install':
1019 try:
1019 try:
1020 shutil.copytree(rcdir,ipythondir)
1020 shutil.copytree(rcdir,ipythondir)
1021 os.chdir(ipythondir)
1021 os.chdir(ipythondir)
1022 rc_files = glb("ipythonrc*")
1022 rc_files = glb("ipythonrc*")
1023 for rc_file in rc_files:
1023 for rc_file in rc_files:
1024 os.rename(rc_file,rc_file+rc_suffix)
1024 os.rename(rc_file,rc_file+rc_suffix)
1025 except:
1025 except:
1026 warning = """
1026 warning = """
1027
1027
1028 There was a problem with the installation:
1028 There was a problem with the installation:
1029 %s
1029 %s
1030 Try to correct it or contact the developers if you think it's a bug.
1030 Try to correct it or contact the developers if you think it's a bug.
1031 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1031 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1032 warn(warning)
1032 warn(warning)
1033 wait()
1033 wait()
1034 return
1034 return
1035
1035
1036 elif mode == 'upgrade':
1036 elif mode == 'upgrade':
1037 try:
1037 try:
1038 os.chdir(ipythondir)
1038 os.chdir(ipythondir)
1039 except:
1039 except:
1040 print """
1040 print """
1041 Can not upgrade: changing to directory %s failed. Details:
1041 Can not upgrade: changing to directory %s failed. Details:
1042 %s
1042 %s
1043 """ % (ipythondir,sys.exc_info()[1])
1043 """ % (ipythondir,sys.exc_info()[1])
1044 wait()
1044 wait()
1045 return
1045 return
1046 else:
1046 else:
1047 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1047 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1048 for new_full_path in sources:
1048 for new_full_path in sources:
1049 new_filename = os.path.basename(new_full_path)
1049 new_filename = os.path.basename(new_full_path)
1050 if new_filename.startswith('ipythonrc'):
1050 if new_filename.startswith('ipythonrc'):
1051 new_filename = new_filename + rc_suffix
1051 new_filename = new_filename + rc_suffix
1052 # The config directory should only contain files, skip any
1052 # The config directory should only contain files, skip any
1053 # directories which may be there (like CVS)
1053 # directories which may be there (like CVS)
1054 if os.path.isdir(new_full_path):
1054 if os.path.isdir(new_full_path):
1055 continue
1055 continue
1056 if os.path.exists(new_filename):
1056 if os.path.exists(new_filename):
1057 old_file = new_filename+'.old'
1057 old_file = new_filename+'.old'
1058 if os.path.exists(old_file):
1058 if os.path.exists(old_file):
1059 os.remove(old_file)
1059 os.remove(old_file)
1060 os.rename(new_filename,old_file)
1060 os.rename(new_filename,old_file)
1061 shutil.copy(new_full_path,new_filename)
1061 shutil.copy(new_full_path,new_filename)
1062 else:
1062 else:
1063 raise ValueError,'unrecognized mode for install:',`mode`
1063 raise ValueError,'unrecognized mode for install:',`mode`
1064
1064
1065 # Fix line-endings to those native to each platform in the config
1065 # Fix line-endings to those native to each platform in the config
1066 # directory.
1066 # directory.
1067 try:
1067 try:
1068 os.chdir(ipythondir)
1068 os.chdir(ipythondir)
1069 except:
1069 except:
1070 print """
1070 print """
1071 Problem: changing to directory %s failed.
1071 Problem: changing to directory %s failed.
1072 Details:
1072 Details:
1073 %s
1073 %s
1074
1074
1075 Some configuration files may have incorrect line endings. This should not
1075 Some configuration files may have incorrect line endings. This should not
1076 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1076 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1077 wait()
1077 wait()
1078 else:
1078 else:
1079 for fname in glb('ipythonrc*'):
1079 for fname in glb('ipythonrc*'):
1080 try:
1080 try:
1081 native_line_ends(fname,backup=0)
1081 native_line_ends(fname,backup=0)
1082 except IOError:
1082 except IOError:
1083 pass
1083 pass
1084
1084
1085 if mode == 'install':
1085 if mode == 'install':
1086 print """
1086 print """
1087 Successful installation!
1087 Successful installation!
1088
1088
1089 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1089 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1090 IPython manual (there are both HTML and PDF versions supplied with the
1090 IPython manual (there are both HTML and PDF versions supplied with the
1091 distribution) to make sure that your system environment is properly configured
1091 distribution) to make sure that your system environment is properly configured
1092 to take advantage of IPython's features.
1092 to take advantage of IPython's features.
1093
1093
1094 Important note: the configuration system has changed! The old system is
1094 Important note: the configuration system has changed! The old system is
1095 still in place, but its setting may be partly overridden by the settings in
1095 still in place, but its setting may be partly overridden by the settings in
1096 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1096 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1097 if some of the new settings bother you.
1097 if some of the new settings bother you.
1098
1098
1099 """
1099 """
1100 else:
1100 else:
1101 print """
1101 print """
1102 Successful upgrade!
1102 Successful upgrade!
1103
1103
1104 All files in your directory:
1104 All files in your directory:
1105 %(ipythondir)s
1105 %(ipythondir)s
1106 which would have been overwritten by the upgrade were backed up with a .old
1106 which would have been overwritten by the upgrade were backed up with a .old
1107 extension. If you had made particular customizations in those files you may
1107 extension. If you had made particular customizations in those files you may
1108 want to merge them back into the new files.""" % locals()
1108 want to merge them back into the new files.""" % locals()
1109 wait()
1109 wait()
1110 os.chdir(cwd)
1110 os.chdir(cwd)
1111 # end user_setup()
1111 # end user_setup()
1112
1112
1113 def atexit_operations(self):
1113 def atexit_operations(self):
1114 """This will be executed at the time of exit.
1114 """This will be executed at the time of exit.
1115
1115
1116 Saving of persistent data should be performed here. """
1116 Saving of persistent data should be performed here. """
1117
1117
1118 #print '*** IPython exit cleanup ***' # dbg
1118 #print '*** IPython exit cleanup ***' # dbg
1119 # input history
1119 # input history
1120 self.savehist()
1120 self.savehist()
1121
1121
1122 # Cleanup all tempfiles left around
1122 # Cleanup all tempfiles left around
1123 for tfile in self.tempfiles:
1123 for tfile in self.tempfiles:
1124 try:
1124 try:
1125 os.unlink(tfile)
1125 os.unlink(tfile)
1126 except OSError:
1126 except OSError:
1127 pass
1127 pass
1128
1128
1129 # save the "persistent data" catch-all dictionary
1129 # save the "persistent data" catch-all dictionary
1130 self.hooks.shutdown_hook()
1130 self.hooks.shutdown_hook()
1131
1131
1132 def savehist(self):
1132 def savehist(self):
1133 """Save input history to a file (via readline library)."""
1133 """Save input history to a file (via readline library)."""
1134 try:
1134 try:
1135 self.readline.write_history_file(self.histfile)
1135 self.readline.write_history_file(self.histfile)
1136 except:
1136 except:
1137 print 'Unable to save IPython command history to file: ' + \
1137 print 'Unable to save IPython command history to file: ' + \
1138 `self.histfile`
1138 `self.histfile`
1139
1139
1140 def pre_readline(self):
1140 def pre_readline(self):
1141 """readline hook to be used at the start of each line.
1141 """readline hook to be used at the start of each line.
1142
1142
1143 Currently it handles auto-indent only."""
1143 Currently it handles auto-indent only."""
1144
1144
1145 #debugx('self.indent_current_nsp','pre_readline:')
1145 #debugx('self.indent_current_nsp','pre_readline:')
1146 self.readline.insert_text(self.indent_current_str())
1146 self.readline.insert_text(self.indent_current_str())
1147
1147
1148 def init_readline(self):
1148 def init_readline(self):
1149 """Command history completion/saving/reloading."""
1149 """Command history completion/saving/reloading."""
1150
1150
1151 import IPython.rlineimpl as readline
1151 import IPython.rlineimpl as readline
1152 if not readline.have_readline:
1152 if not readline.have_readline:
1153 self.has_readline = 0
1153 self.has_readline = 0
1154 self.readline = None
1154 self.readline = None
1155 # no point in bugging windows users with this every time:
1155 # no point in bugging windows users with this every time:
1156 warn('Readline services not available on this platform.')
1156 warn('Readline services not available on this platform.')
1157 else:
1157 else:
1158 sys.modules['readline'] = readline
1158 sys.modules['readline'] = readline
1159 import atexit
1159 import atexit
1160 from IPython.completer import IPCompleter
1160 from IPython.completer import IPCompleter
1161 self.Completer = IPCompleter(self,
1161 self.Completer = IPCompleter(self,
1162 self.user_ns,
1162 self.user_ns,
1163 self.user_global_ns,
1163 self.user_global_ns,
1164 self.rc.readline_omit__names,
1164 self.rc.readline_omit__names,
1165 self.alias_table)
1165 self.alias_table)
1166
1166
1167 # Platform-specific configuration
1167 # Platform-specific configuration
1168 if os.name == 'nt':
1168 if os.name == 'nt':
1169 self.readline_startup_hook = readline.set_pre_input_hook
1169 self.readline_startup_hook = readline.set_pre_input_hook
1170 else:
1170 else:
1171 self.readline_startup_hook = readline.set_startup_hook
1171 self.readline_startup_hook = readline.set_startup_hook
1172
1172
1173 # Load user's initrc file (readline config)
1173 # Load user's initrc file (readline config)
1174 inputrc_name = os.environ.get('INPUTRC')
1174 inputrc_name = os.environ.get('INPUTRC')
1175 if inputrc_name is None:
1175 if inputrc_name is None:
1176 home_dir = get_home_dir()
1176 home_dir = get_home_dir()
1177 if home_dir is not None:
1177 if home_dir is not None:
1178 inputrc_name = os.path.join(home_dir,'.inputrc')
1178 inputrc_name = os.path.join(home_dir,'.inputrc')
1179 if os.path.isfile(inputrc_name):
1179 if os.path.isfile(inputrc_name):
1180 try:
1180 try:
1181 readline.read_init_file(inputrc_name)
1181 readline.read_init_file(inputrc_name)
1182 except:
1182 except:
1183 warn('Problems reading readline initialization file <%s>'
1183 warn('Problems reading readline initialization file <%s>'
1184 % inputrc_name)
1184 % inputrc_name)
1185
1185
1186 self.has_readline = 1
1186 self.has_readline = 1
1187 self.readline = readline
1187 self.readline = readline
1188 # save this in sys so embedded copies can restore it properly
1188 # save this in sys so embedded copies can restore it properly
1189 sys.ipcompleter = self.Completer.complete
1189 sys.ipcompleter = self.Completer.complete
1190 readline.set_completer(self.Completer.complete)
1190 readline.set_completer(self.Completer.complete)
1191
1191
1192 # Configure readline according to user's prefs
1192 # Configure readline according to user's prefs
1193 for rlcommand in self.rc.readline_parse_and_bind:
1193 for rlcommand in self.rc.readline_parse_and_bind:
1194 readline.parse_and_bind(rlcommand)
1194 readline.parse_and_bind(rlcommand)
1195
1195
1196 # remove some chars from the delimiters list
1196 # remove some chars from the delimiters list
1197 delims = readline.get_completer_delims()
1197 delims = readline.get_completer_delims()
1198 delims = delims.translate(string._idmap,
1198 delims = delims.translate(string._idmap,
1199 self.rc.readline_remove_delims)
1199 self.rc.readline_remove_delims)
1200 readline.set_completer_delims(delims)
1200 readline.set_completer_delims(delims)
1201 # otherwise we end up with a monster history after a while:
1201 # otherwise we end up with a monster history after a while:
1202 readline.set_history_length(1000)
1202 readline.set_history_length(1000)
1203 try:
1203 try:
1204 #print '*** Reading readline history' # dbg
1204 #print '*** Reading readline history' # dbg
1205 readline.read_history_file(self.histfile)
1205 readline.read_history_file(self.histfile)
1206 except IOError:
1206 except IOError:
1207 pass # It doesn't exist yet.
1207 pass # It doesn't exist yet.
1208
1208
1209 atexit.register(self.atexit_operations)
1209 atexit.register(self.atexit_operations)
1210 del atexit
1210 del atexit
1211
1211
1212 # Configure auto-indent for all platforms
1212 # Configure auto-indent for all platforms
1213 self.set_autoindent(self.rc.autoindent)
1213 self.set_autoindent(self.rc.autoindent)
1214
1214
1215 def _should_recompile(self,e):
1215 def _should_recompile(self,e):
1216 """Utility routine for edit_syntax_error"""
1216 """Utility routine for edit_syntax_error"""
1217
1217
1218 if e.filename in ('<ipython console>','<input>','<string>',
1218 if e.filename in ('<ipython console>','<input>','<string>',
1219 '<console>',None):
1219 '<console>',None):
1220
1220
1221 return False
1221 return False
1222 try:
1222 try:
1223 if (self.rc.autoedit_syntax and
1223 if (self.rc.autoedit_syntax and
1224 not ask_yes_no('Return to editor to correct syntax error? '
1224 not ask_yes_no('Return to editor to correct syntax error? '
1225 '[Y/n] ','y')):
1225 '[Y/n] ','y')):
1226 return False
1226 return False
1227 except EOFError:
1227 except EOFError:
1228 return False
1228 return False
1229
1229
1230 def int0(x):
1230 def int0(x):
1231 try:
1231 try:
1232 return int(x)
1232 return int(x)
1233 except TypeError:
1233 except TypeError:
1234 return 0
1234 return 0
1235 # always pass integer line and offset values to editor hook
1235 # always pass integer line and offset values to editor hook
1236 self.hooks.fix_error_editor(e.filename,
1236 self.hooks.fix_error_editor(e.filename,
1237 int0(e.lineno),int0(e.offset),e.msg)
1237 int0(e.lineno),int0(e.offset),e.msg)
1238 return True
1238 return True
1239
1239
1240 def edit_syntax_error(self):
1240 def edit_syntax_error(self):
1241 """The bottom half of the syntax error handler called in the main loop.
1241 """The bottom half of the syntax error handler called in the main loop.
1242
1242
1243 Loop until syntax error is fixed or user cancels.
1243 Loop until syntax error is fixed or user cancels.
1244 """
1244 """
1245
1245
1246 while self.SyntaxTB.last_syntax_error:
1246 while self.SyntaxTB.last_syntax_error:
1247 # copy and clear last_syntax_error
1247 # copy and clear last_syntax_error
1248 err = self.SyntaxTB.clear_err_state()
1248 err = self.SyntaxTB.clear_err_state()
1249 if not self._should_recompile(err):
1249 if not self._should_recompile(err):
1250 return
1250 return
1251 try:
1251 try:
1252 # may set last_syntax_error again if a SyntaxError is raised
1252 # may set last_syntax_error again if a SyntaxError is raised
1253 self.safe_execfile(err.filename,self.shell.user_ns)
1253 self.safe_execfile(err.filename,self.shell.user_ns)
1254 except:
1254 except:
1255 self.showtraceback()
1255 self.showtraceback()
1256 else:
1256 else:
1257 f = file(err.filename)
1257 f = file(err.filename)
1258 try:
1258 try:
1259 sys.displayhook(f.read())
1259 sys.displayhook(f.read())
1260 finally:
1260 finally:
1261 f.close()
1261 f.close()
1262
1262
1263 def showsyntaxerror(self, filename=None):
1263 def showsyntaxerror(self, filename=None):
1264 """Display the syntax error that just occurred.
1264 """Display the syntax error that just occurred.
1265
1265
1266 This doesn't display a stack trace because there isn't one.
1266 This doesn't display a stack trace because there isn't one.
1267
1267
1268 If a filename is given, it is stuffed in the exception instead
1268 If a filename is given, it is stuffed in the exception instead
1269 of what was there before (because Python's parser always uses
1269 of what was there before (because Python's parser always uses
1270 "<string>" when reading from a string).
1270 "<string>" when reading from a string).
1271 """
1271 """
1272 etype, value, last_traceback = sys.exc_info()
1272 etype, value, last_traceback = sys.exc_info()
1273 if filename and etype is SyntaxError:
1273 if filename and etype is SyntaxError:
1274 # Work hard to stuff the correct filename in the exception
1274 # Work hard to stuff the correct filename in the exception
1275 try:
1275 try:
1276 msg, (dummy_filename, lineno, offset, line) = value
1276 msg, (dummy_filename, lineno, offset, line) = value
1277 except:
1277 except:
1278 # Not the format we expect; leave it alone
1278 # Not the format we expect; leave it alone
1279 pass
1279 pass
1280 else:
1280 else:
1281 # Stuff in the right filename
1281 # Stuff in the right filename
1282 try:
1282 try:
1283 # Assume SyntaxError is a class exception
1283 # Assume SyntaxError is a class exception
1284 value = SyntaxError(msg, (filename, lineno, offset, line))
1284 value = SyntaxError(msg, (filename, lineno, offset, line))
1285 except:
1285 except:
1286 # If that failed, assume SyntaxError is a string
1286 # If that failed, assume SyntaxError is a string
1287 value = msg, (filename, lineno, offset, line)
1287 value = msg, (filename, lineno, offset, line)
1288 self.SyntaxTB(etype,value,[])
1288 self.SyntaxTB(etype,value,[])
1289
1289
1290 def debugger(self):
1290 def debugger(self):
1291 """Call the pdb debugger."""
1291 """Call the pdb debugger."""
1292
1292
1293 if not self.rc.pdb:
1293 if not self.rc.pdb:
1294 return
1294 return
1295 pdb.pm()
1295 pdb.pm()
1296
1296
1297 def showtraceback(self,exc_tuple = None,filename=None):
1297 def showtraceback(self,exc_tuple = None,filename=None):
1298 """Display the exception that just occurred."""
1298 """Display the exception that just occurred."""
1299
1299
1300 # Though this won't be called by syntax errors in the input line,
1300 # Though this won't be called by syntax errors in the input line,
1301 # there may be SyntaxError cases whith imported code.
1301 # there may be SyntaxError cases whith imported code.
1302 if exc_tuple is None:
1302 if exc_tuple is None:
1303 type, value, tb = sys.exc_info()
1303 type, value, tb = sys.exc_info()
1304 else:
1304 else:
1305 type, value, tb = exc_tuple
1305 type, value, tb = exc_tuple
1306 if type is SyntaxError:
1306 if type is SyntaxError:
1307 self.showsyntaxerror(filename)
1307 self.showsyntaxerror(filename)
1308 else:
1308 else:
1309 self.InteractiveTB()
1309 self.InteractiveTB()
1310 if self.InteractiveTB.call_pdb and self.has_readline:
1310 if self.InteractiveTB.call_pdb and self.has_readline:
1311 # pdb mucks up readline, fix it back
1311 # pdb mucks up readline, fix it back
1312 self.readline.set_completer(self.Completer.complete)
1312 self.readline.set_completer(self.Completer.complete)
1313
1313
1314 def mainloop(self,banner=None):
1314 def mainloop(self,banner=None):
1315 """Creates the local namespace and starts the mainloop.
1315 """Creates the local namespace and starts the mainloop.
1316
1316
1317 If an optional banner argument is given, it will override the
1317 If an optional banner argument is given, it will override the
1318 internally created default banner."""
1318 internally created default banner."""
1319
1319
1320 if self.rc.c: # Emulate Python's -c option
1320 if self.rc.c: # Emulate Python's -c option
1321 self.exec_init_cmd()
1321 self.exec_init_cmd()
1322 if banner is None:
1322 if banner is None:
1323 if self.rc.banner:
1323 if not self.rc.banner:
1324 banner = self.BANNER+self.banner2
1325 else:
1326 banner = ''
1324 banner = ''
1325 # banner is string? Use it directly!
1326 elif isinstance(self.rc.banner,basestring):
1327 banner = self.rc.banner
1328 else:
1329 banner = self.BANNER+self.banner2
1330
1327 self.interact(banner)
1331 self.interact(banner)
1328
1332
1329 def exec_init_cmd(self):
1333 def exec_init_cmd(self):
1330 """Execute a command given at the command line.
1334 """Execute a command given at the command line.
1331
1335
1332 This emulates Python's -c option."""
1336 This emulates Python's -c option."""
1333
1337
1334 #sys.argv = ['-c']
1338 #sys.argv = ['-c']
1335 self.push(self.rc.c)
1339 self.push(self.rc.c)
1336
1340
1337 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1341 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1338 """Embeds IPython into a running python program.
1342 """Embeds IPython into a running python program.
1339
1343
1340 Input:
1344 Input:
1341
1345
1342 - header: An optional header message can be specified.
1346 - header: An optional header message can be specified.
1343
1347
1344 - local_ns, global_ns: working namespaces. If given as None, the
1348 - local_ns, global_ns: working namespaces. If given as None, the
1345 IPython-initialized one is updated with __main__.__dict__, so that
1349 IPython-initialized one is updated with __main__.__dict__, so that
1346 program variables become visible but user-specific configuration
1350 program variables become visible but user-specific configuration
1347 remains possible.
1351 remains possible.
1348
1352
1349 - stack_depth: specifies how many levels in the stack to go to
1353 - stack_depth: specifies how many levels in the stack to go to
1350 looking for namespaces (when local_ns and global_ns are None). This
1354 looking for namespaces (when local_ns and global_ns are None). This
1351 allows an intermediate caller to make sure that this function gets
1355 allows an intermediate caller to make sure that this function gets
1352 the namespace from the intended level in the stack. By default (0)
1356 the namespace from the intended level in the stack. By default (0)
1353 it will get its locals and globals from the immediate caller.
1357 it will get its locals and globals from the immediate caller.
1354
1358
1355 Warning: it's possible to use this in a program which is being run by
1359 Warning: it's possible to use this in a program which is being run by
1356 IPython itself (via %run), but some funny things will happen (a few
1360 IPython itself (via %run), but some funny things will happen (a few
1357 globals get overwritten). In the future this will be cleaned up, as
1361 globals get overwritten). In the future this will be cleaned up, as
1358 there is no fundamental reason why it can't work perfectly."""
1362 there is no fundamental reason why it can't work perfectly."""
1359
1363
1360 # Get locals and globals from caller
1364 # Get locals and globals from caller
1361 if local_ns is None or global_ns is None:
1365 if local_ns is None or global_ns is None:
1362 call_frame = sys._getframe(stack_depth).f_back
1366 call_frame = sys._getframe(stack_depth).f_back
1363
1367
1364 if local_ns is None:
1368 if local_ns is None:
1365 local_ns = call_frame.f_locals
1369 local_ns = call_frame.f_locals
1366 if global_ns is None:
1370 if global_ns is None:
1367 global_ns = call_frame.f_globals
1371 global_ns = call_frame.f_globals
1368
1372
1369 # Update namespaces and fire up interpreter
1373 # Update namespaces and fire up interpreter
1370
1374
1371 # The global one is easy, we can just throw it in
1375 # The global one is easy, we can just throw it in
1372 self.user_global_ns = global_ns
1376 self.user_global_ns = global_ns
1373
1377
1374 # but the user/local one is tricky: ipython needs it to store internal
1378 # but the user/local one is tricky: ipython needs it to store internal
1375 # data, but we also need the locals. We'll copy locals in the user
1379 # data, but we also need the locals. We'll copy locals in the user
1376 # one, but will track what got copied so we can delete them at exit.
1380 # one, but will track what got copied so we can delete them at exit.
1377 # This is so that a later embedded call doesn't see locals from a
1381 # This is so that a later embedded call doesn't see locals from a
1378 # previous call (which most likely existed in a separate scope).
1382 # previous call (which most likely existed in a separate scope).
1379 local_varnames = local_ns.keys()
1383 local_varnames = local_ns.keys()
1380 self.user_ns.update(local_ns)
1384 self.user_ns.update(local_ns)
1381
1385
1382 # Patch for global embedding to make sure that things don't overwrite
1386 # Patch for global embedding to make sure that things don't overwrite
1383 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1387 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1384 # FIXME. Test this a bit more carefully (the if.. is new)
1388 # FIXME. Test this a bit more carefully (the if.. is new)
1385 if local_ns is None and global_ns is None:
1389 if local_ns is None and global_ns is None:
1386 self.user_global_ns.update(__main__.__dict__)
1390 self.user_global_ns.update(__main__.__dict__)
1387
1391
1388 # make sure the tab-completer has the correct frame information, so it
1392 # make sure the tab-completer has the correct frame information, so it
1389 # actually completes using the frame's locals/globals
1393 # actually completes using the frame's locals/globals
1390 self.set_completer_frame()
1394 self.set_completer_frame()
1391
1395
1392 # before activating the interactive mode, we need to make sure that
1396 # before activating the interactive mode, we need to make sure that
1393 # all names in the builtin namespace needed by ipython point to
1397 # all names in the builtin namespace needed by ipython point to
1394 # ourselves, and not to other instances.
1398 # ourselves, and not to other instances.
1395 self.add_builtins()
1399 self.add_builtins()
1396
1400
1397 self.interact(header)
1401 self.interact(header)
1398
1402
1399 # now, purge out the user namespace from anything we might have added
1403 # now, purge out the user namespace from anything we might have added
1400 # from the caller's local namespace
1404 # from the caller's local namespace
1401 delvar = self.user_ns.pop
1405 delvar = self.user_ns.pop
1402 for var in local_varnames:
1406 for var in local_varnames:
1403 delvar(var,None)
1407 delvar(var,None)
1404 # and clean builtins we may have overridden
1408 # and clean builtins we may have overridden
1405 self.clean_builtins()
1409 self.clean_builtins()
1406
1410
1407 def interact(self, banner=None):
1411 def interact(self, banner=None):
1408 """Closely emulate the interactive Python console.
1412 """Closely emulate the interactive Python console.
1409
1413
1410 The optional banner argument specify the banner to print
1414 The optional banner argument specify the banner to print
1411 before the first interaction; by default it prints a banner
1415 before the first interaction; by default it prints a banner
1412 similar to the one printed by the real Python interpreter,
1416 similar to the one printed by the real Python interpreter,
1413 followed by the current class name in parentheses (so as not
1417 followed by the current class name in parentheses (so as not
1414 to confuse this with the real interpreter -- since it's so
1418 to confuse this with the real interpreter -- since it's so
1415 close!).
1419 close!).
1416
1420
1417 """
1421 """
1418 cprt = 'Type "copyright", "credits" or "license" for more information.'
1422 cprt = 'Type "copyright", "credits" or "license" for more information.'
1419 if banner is None:
1423 if banner is None:
1420 self.write("Python %s on %s\n%s\n(%s)\n" %
1424 self.write("Python %s on %s\n%s\n(%s)\n" %
1421 (sys.version, sys.platform, cprt,
1425 (sys.version, sys.platform, cprt,
1422 self.__class__.__name__))
1426 self.__class__.__name__))
1423 else:
1427 else:
1424 self.write(banner)
1428 self.write(banner)
1425
1429
1426 more = 0
1430 more = 0
1427
1431
1428 # Mark activity in the builtins
1432 # Mark activity in the builtins
1429 __builtin__.__dict__['__IPYTHON__active'] += 1
1433 __builtin__.__dict__['__IPYTHON__active'] += 1
1430
1434
1431 # exit_now is set by a call to %Exit or %Quit
1435 # exit_now is set by a call to %Exit or %Quit
1432 self.exit_now = False
1436 self.exit_now = False
1433 while not self.exit_now:
1437 while not self.exit_now:
1434 if more:
1438 if more:
1435 prompt = self.outputcache.prompt2
1439 prompt = self.outputcache.prompt2
1436 if self.autoindent:
1440 if self.autoindent:
1437 self.readline_startup_hook(self.pre_readline)
1441 self.readline_startup_hook(self.pre_readline)
1438 else:
1442 else:
1439 prompt = self.outputcache.prompt1
1443 prompt = self.outputcache.prompt1
1440 try:
1444 try:
1441 line = self.raw_input(prompt,more)
1445 line = self.raw_input(prompt,more)
1442 if self.autoindent:
1446 if self.autoindent:
1443 self.readline_startup_hook(None)
1447 self.readline_startup_hook(None)
1444 except KeyboardInterrupt:
1448 except KeyboardInterrupt:
1445 self.write('\nKeyboardInterrupt\n')
1449 self.write('\nKeyboardInterrupt\n')
1446 self.resetbuffer()
1450 self.resetbuffer()
1447 # keep cache in sync with the prompt counter:
1451 # keep cache in sync with the prompt counter:
1448 self.outputcache.prompt_count -= 1
1452 self.outputcache.prompt_count -= 1
1449
1453
1450 if self.autoindent:
1454 if self.autoindent:
1451 self.indent_current_nsp = 0
1455 self.indent_current_nsp = 0
1452 more = 0
1456 more = 0
1453 except EOFError:
1457 except EOFError:
1454 if self.autoindent:
1458 if self.autoindent:
1455 self.readline_startup_hook(None)
1459 self.readline_startup_hook(None)
1456 self.write('\n')
1460 self.write('\n')
1457 self.exit()
1461 self.exit()
1458 except bdb.BdbQuit:
1462 except bdb.BdbQuit:
1459 warn('The Python debugger has exited with a BdbQuit exception.\n'
1463 warn('The Python debugger has exited with a BdbQuit exception.\n'
1460 'Because of how pdb handles the stack, it is impossible\n'
1464 'Because of how pdb handles the stack, it is impossible\n'
1461 'for IPython to properly format this particular exception.\n'
1465 'for IPython to properly format this particular exception.\n'
1462 'IPython will resume normal operation.')
1466 'IPython will resume normal operation.')
1463 except:
1467 except:
1464 # exceptions here are VERY RARE, but they can be triggered
1468 # exceptions here are VERY RARE, but they can be triggered
1465 # asynchronously by signal handlers, for example.
1469 # asynchronously by signal handlers, for example.
1466 self.showtraceback()
1470 self.showtraceback()
1467 else:
1471 else:
1468 more = self.push(line)
1472 more = self.push(line)
1469 if (self.SyntaxTB.last_syntax_error and
1473 if (self.SyntaxTB.last_syntax_error and
1470 self.rc.autoedit_syntax):
1474 self.rc.autoedit_syntax):
1471 self.edit_syntax_error()
1475 self.edit_syntax_error()
1472
1476
1473 # We are off again...
1477 # We are off again...
1474 __builtin__.__dict__['__IPYTHON__active'] -= 1
1478 __builtin__.__dict__['__IPYTHON__active'] -= 1
1475
1479
1476 def excepthook(self, type, value, tb):
1480 def excepthook(self, type, value, tb):
1477 """One more defense for GUI apps that call sys.excepthook.
1481 """One more defense for GUI apps that call sys.excepthook.
1478
1482
1479 GUI frameworks like wxPython trap exceptions and call
1483 GUI frameworks like wxPython trap exceptions and call
1480 sys.excepthook themselves. I guess this is a feature that
1484 sys.excepthook themselves. I guess this is a feature that
1481 enables them to keep running after exceptions that would
1485 enables them to keep running after exceptions that would
1482 otherwise kill their mainloop. This is a bother for IPython
1486 otherwise kill their mainloop. This is a bother for IPython
1483 which excepts to catch all of the program exceptions with a try:
1487 which excepts to catch all of the program exceptions with a try:
1484 except: statement.
1488 except: statement.
1485
1489
1486 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1490 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1487 any app directly invokes sys.excepthook, it will look to the user like
1491 any app directly invokes sys.excepthook, it will look to the user like
1488 IPython crashed. In order to work around this, we can disable the
1492 IPython crashed. In order to work around this, we can disable the
1489 CrashHandler and replace it with this excepthook instead, which prints a
1493 CrashHandler and replace it with this excepthook instead, which prints a
1490 regular traceback using our InteractiveTB. In this fashion, apps which
1494 regular traceback using our InteractiveTB. In this fashion, apps which
1491 call sys.excepthook will generate a regular-looking exception from
1495 call sys.excepthook will generate a regular-looking exception from
1492 IPython, and the CrashHandler will only be triggered by real IPython
1496 IPython, and the CrashHandler will only be triggered by real IPython
1493 crashes.
1497 crashes.
1494
1498
1495 This hook should be used sparingly, only in places which are not likely
1499 This hook should be used sparingly, only in places which are not likely
1496 to be true IPython errors.
1500 to be true IPython errors.
1497 """
1501 """
1498
1502
1499 self.InteractiveTB(type, value, tb, tb_offset=0)
1503 self.InteractiveTB(type, value, tb, tb_offset=0)
1500 if self.InteractiveTB.call_pdb and self.has_readline:
1504 if self.InteractiveTB.call_pdb and self.has_readline:
1501 self.readline.set_completer(self.Completer.complete)
1505 self.readline.set_completer(self.Completer.complete)
1502
1506
1503 def transform_alias(self, alias,rest=''):
1507 def transform_alias(self, alias,rest=''):
1504 """ Transform alias to system command string
1508 """ Transform alias to system command string
1505
1509
1506 """
1510 """
1507 nargs,cmd = self.alias_table[alias]
1511 nargs,cmd = self.alias_table[alias]
1508 # Expand the %l special to be the user's input line
1512 # Expand the %l special to be the user's input line
1509 if cmd.find('%l') >= 0:
1513 if cmd.find('%l') >= 0:
1510 cmd = cmd.replace('%l',rest)
1514 cmd = cmd.replace('%l',rest)
1511 rest = ''
1515 rest = ''
1512 if nargs==0:
1516 if nargs==0:
1513 # Simple, argument-less aliases
1517 # Simple, argument-less aliases
1514 cmd = '%s %s' % (cmd,rest)
1518 cmd = '%s %s' % (cmd,rest)
1515 else:
1519 else:
1516 # Handle aliases with positional arguments
1520 # Handle aliases with positional arguments
1517 args = rest.split(None,nargs)
1521 args = rest.split(None,nargs)
1518 if len(args)< nargs:
1522 if len(args)< nargs:
1519 error('Alias <%s> requires %s arguments, %s given.' %
1523 error('Alias <%s> requires %s arguments, %s given.' %
1520 (alias,nargs,len(args)))
1524 (alias,nargs,len(args)))
1521 return None
1525 return None
1522 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1526 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1523 # Now call the macro, evaluating in the user's namespace
1527 # Now call the macro, evaluating in the user's namespace
1524
1528
1525 return cmd
1529 return cmd
1526
1530
1527 def call_alias(self,alias,rest=''):
1531 def call_alias(self,alias,rest=''):
1528 """Call an alias given its name and the rest of the line.
1532 """Call an alias given its name and the rest of the line.
1529
1533
1530 This is only used to provide backwards compatibility for users of
1534 This is only used to provide backwards compatibility for users of
1531 ipalias(), use of which is not recommended for anymore."""
1535 ipalias(), use of which is not recommended for anymore."""
1532
1536
1533 # Now call the macro, evaluating in the user's namespace
1537 # Now call the macro, evaluating in the user's namespace
1534 cmd = self.transform_alias(alias, rest)
1538 cmd = self.transform_alias(alias, rest)
1535 try:
1539 try:
1536 self.system(cmd)
1540 self.system(cmd)
1537 except:
1541 except:
1538 self.showtraceback()
1542 self.showtraceback()
1539
1543
1540 def indent_current_str(self):
1544 def indent_current_str(self):
1541 """return the current level of indentation as a string"""
1545 """return the current level of indentation as a string"""
1542 return self.indent_current_nsp * ' '
1546 return self.indent_current_nsp * ' '
1543
1547
1544 def autoindent_update(self,line):
1548 def autoindent_update(self,line):
1545 """Keep track of the indent level."""
1549 """Keep track of the indent level."""
1546
1550
1547 #debugx('line')
1551 #debugx('line')
1548 #debugx('self.indent_current_nsp')
1552 #debugx('self.indent_current_nsp')
1549 if self.autoindent:
1553 if self.autoindent:
1550 if line:
1554 if line:
1551 inisp = num_ini_spaces(line)
1555 inisp = num_ini_spaces(line)
1552 if inisp < self.indent_current_nsp:
1556 if inisp < self.indent_current_nsp:
1553 self.indent_current_nsp = inisp
1557 self.indent_current_nsp = inisp
1554
1558
1555 if line[-1] == ':':
1559 if line[-1] == ':':
1556 self.indent_current_nsp += 4
1560 self.indent_current_nsp += 4
1557 elif dedent_re.match(line):
1561 elif dedent_re.match(line):
1558 self.indent_current_nsp -= 4
1562 self.indent_current_nsp -= 4
1559 else:
1563 else:
1560 self.indent_current_nsp = 0
1564 self.indent_current_nsp = 0
1561
1565
1562 def runlines(self,lines):
1566 def runlines(self,lines):
1563 """Run a string of one or more lines of source.
1567 """Run a string of one or more lines of source.
1564
1568
1565 This method is capable of running a string containing multiple source
1569 This method is capable of running a string containing multiple source
1566 lines, as if they had been entered at the IPython prompt. Since it
1570 lines, as if they had been entered at the IPython prompt. Since it
1567 exposes IPython's processing machinery, the given strings can contain
1571 exposes IPython's processing machinery, the given strings can contain
1568 magic calls (%magic), special shell access (!cmd), etc."""
1572 magic calls (%magic), special shell access (!cmd), etc."""
1569
1573
1570 # We must start with a clean buffer, in case this is run from an
1574 # We must start with a clean buffer, in case this is run from an
1571 # interactive IPython session (via a magic, for example).
1575 # interactive IPython session (via a magic, for example).
1572 self.resetbuffer()
1576 self.resetbuffer()
1573 lines = lines.split('\n')
1577 lines = lines.split('\n')
1574 more = 0
1578 more = 0
1575 for line in lines:
1579 for line in lines:
1576 # skip blank lines so we don't mess up the prompt counter, but do
1580 # skip blank lines so we don't mess up the prompt counter, but do
1577 # NOT skip even a blank line if we are in a code block (more is
1581 # NOT skip even a blank line if we are in a code block (more is
1578 # true)
1582 # true)
1579 if line or more:
1583 if line or more:
1580 more = self.push(self.prefilter(line,more))
1584 more = self.push(self.prefilter(line,more))
1581 # IPython's runsource returns None if there was an error
1585 # IPython's runsource returns None if there was an error
1582 # compiling the code. This allows us to stop processing right
1586 # compiling the code. This allows us to stop processing right
1583 # away, so the user gets the error message at the right place.
1587 # away, so the user gets the error message at the right place.
1584 if more is None:
1588 if more is None:
1585 break
1589 break
1586 # final newline in case the input didn't have it, so that the code
1590 # final newline in case the input didn't have it, so that the code
1587 # actually does get executed
1591 # actually does get executed
1588 if more:
1592 if more:
1589 self.push('\n')
1593 self.push('\n')
1590
1594
1591 def runsource(self, source, filename='<input>', symbol='single'):
1595 def runsource(self, source, filename='<input>', symbol='single'):
1592 """Compile and run some source in the interpreter.
1596 """Compile and run some source in the interpreter.
1593
1597
1594 Arguments are as for compile_command().
1598 Arguments are as for compile_command().
1595
1599
1596 One several things can happen:
1600 One several things can happen:
1597
1601
1598 1) The input is incorrect; compile_command() raised an
1602 1) The input is incorrect; compile_command() raised an
1599 exception (SyntaxError or OverflowError). A syntax traceback
1603 exception (SyntaxError or OverflowError). A syntax traceback
1600 will be printed by calling the showsyntaxerror() method.
1604 will be printed by calling the showsyntaxerror() method.
1601
1605
1602 2) The input is incomplete, and more input is required;
1606 2) The input is incomplete, and more input is required;
1603 compile_command() returned None. Nothing happens.
1607 compile_command() returned None. Nothing happens.
1604
1608
1605 3) The input is complete; compile_command() returned a code
1609 3) The input is complete; compile_command() returned a code
1606 object. The code is executed by calling self.runcode() (which
1610 object. The code is executed by calling self.runcode() (which
1607 also handles run-time exceptions, except for SystemExit).
1611 also handles run-time exceptions, except for SystemExit).
1608
1612
1609 The return value is:
1613 The return value is:
1610
1614
1611 - True in case 2
1615 - True in case 2
1612
1616
1613 - False in the other cases, unless an exception is raised, where
1617 - False in the other cases, unless an exception is raised, where
1614 None is returned instead. This can be used by external callers to
1618 None is returned instead. This can be used by external callers to
1615 know whether to continue feeding input or not.
1619 know whether to continue feeding input or not.
1616
1620
1617 The return value can be used to decide whether to use sys.ps1 or
1621 The return value can be used to decide whether to use sys.ps1 or
1618 sys.ps2 to prompt the next line."""
1622 sys.ps2 to prompt the next line."""
1619
1623
1620 try:
1624 try:
1621 code = self.compile(source,filename,symbol)
1625 code = self.compile(source,filename,symbol)
1622 except (OverflowError, SyntaxError, ValueError):
1626 except (OverflowError, SyntaxError, ValueError):
1623 # Case 1
1627 # Case 1
1624 self.showsyntaxerror(filename)
1628 self.showsyntaxerror(filename)
1625 return None
1629 return None
1626
1630
1627 if code is None:
1631 if code is None:
1628 # Case 2
1632 # Case 2
1629 return True
1633 return True
1630
1634
1631 # Case 3
1635 # Case 3
1632 # We store the code object so that threaded shells and
1636 # We store the code object so that threaded shells and
1633 # custom exception handlers can access all this info if needed.
1637 # custom exception handlers can access all this info if needed.
1634 # The source corresponding to this can be obtained from the
1638 # The source corresponding to this can be obtained from the
1635 # buffer attribute as '\n'.join(self.buffer).
1639 # buffer attribute as '\n'.join(self.buffer).
1636 self.code_to_run = code
1640 self.code_to_run = code
1637 # now actually execute the code object
1641 # now actually execute the code object
1638 if self.runcode(code) == 0:
1642 if self.runcode(code) == 0:
1639 return False
1643 return False
1640 else:
1644 else:
1641 return None
1645 return None
1642
1646
1643 def runcode(self,code_obj):
1647 def runcode(self,code_obj):
1644 """Execute a code object.
1648 """Execute a code object.
1645
1649
1646 When an exception occurs, self.showtraceback() is called to display a
1650 When an exception occurs, self.showtraceback() is called to display a
1647 traceback.
1651 traceback.
1648
1652
1649 Return value: a flag indicating whether the code to be run completed
1653 Return value: a flag indicating whether the code to be run completed
1650 successfully:
1654 successfully:
1651
1655
1652 - 0: successful execution.
1656 - 0: successful execution.
1653 - 1: an error occurred.
1657 - 1: an error occurred.
1654 """
1658 """
1655
1659
1656 # Set our own excepthook in case the user code tries to call it
1660 # Set our own excepthook in case the user code tries to call it
1657 # directly, so that the IPython crash handler doesn't get triggered
1661 # directly, so that the IPython crash handler doesn't get triggered
1658 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1662 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1659
1663
1660 # we save the original sys.excepthook in the instance, in case config
1664 # we save the original sys.excepthook in the instance, in case config
1661 # code (such as magics) needs access to it.
1665 # code (such as magics) needs access to it.
1662 self.sys_excepthook = old_excepthook
1666 self.sys_excepthook = old_excepthook
1663 outflag = 1 # happens in more places, so it's easier as default
1667 outflag = 1 # happens in more places, so it's easier as default
1664 try:
1668 try:
1665 try:
1669 try:
1666 # Embedded instances require separate global/local namespaces
1670 # Embedded instances require separate global/local namespaces
1667 # so they can see both the surrounding (local) namespace and
1671 # so they can see both the surrounding (local) namespace and
1668 # the module-level globals when called inside another function.
1672 # the module-level globals when called inside another function.
1669 if self.embedded:
1673 if self.embedded:
1670 exec code_obj in self.user_global_ns, self.user_ns
1674 exec code_obj in self.user_global_ns, self.user_ns
1671 # Normal (non-embedded) instances should only have a single
1675 # Normal (non-embedded) instances should only have a single
1672 # namespace for user code execution, otherwise functions won't
1676 # namespace for user code execution, otherwise functions won't
1673 # see interactive top-level globals.
1677 # see interactive top-level globals.
1674 else:
1678 else:
1675 exec code_obj in self.user_ns
1679 exec code_obj in self.user_ns
1676 finally:
1680 finally:
1677 # Reset our crash handler in place
1681 # Reset our crash handler in place
1678 sys.excepthook = old_excepthook
1682 sys.excepthook = old_excepthook
1679 except SystemExit:
1683 except SystemExit:
1680 self.resetbuffer()
1684 self.resetbuffer()
1681 self.showtraceback()
1685 self.showtraceback()
1682 warn("Type exit or quit to exit IPython "
1686 warn("Type exit or quit to exit IPython "
1683 "(%Exit or %Quit do so unconditionally).",level=1)
1687 "(%Exit or %Quit do so unconditionally).",level=1)
1684 except self.custom_exceptions:
1688 except self.custom_exceptions:
1685 etype,value,tb = sys.exc_info()
1689 etype,value,tb = sys.exc_info()
1686 self.CustomTB(etype,value,tb)
1690 self.CustomTB(etype,value,tb)
1687 except:
1691 except:
1688 self.showtraceback()
1692 self.showtraceback()
1689 else:
1693 else:
1690 outflag = 0
1694 outflag = 0
1691 if softspace(sys.stdout, 0):
1695 if softspace(sys.stdout, 0):
1692 print
1696 print
1693 # Flush out code object which has been run (and source)
1697 # Flush out code object which has been run (and source)
1694 self.code_to_run = None
1698 self.code_to_run = None
1695 return outflag
1699 return outflag
1696
1700
1697 def push(self, line):
1701 def push(self, line):
1698 """Push a line to the interpreter.
1702 """Push a line to the interpreter.
1699
1703
1700 The line should not have a trailing newline; it may have
1704 The line should not have a trailing newline; it may have
1701 internal newlines. The line is appended to a buffer and the
1705 internal newlines. The line is appended to a buffer and the
1702 interpreter's runsource() method is called with the
1706 interpreter's runsource() method is called with the
1703 concatenated contents of the buffer as source. If this
1707 concatenated contents of the buffer as source. If this
1704 indicates that the command was executed or invalid, the buffer
1708 indicates that the command was executed or invalid, the buffer
1705 is reset; otherwise, the command is incomplete, and the buffer
1709 is reset; otherwise, the command is incomplete, and the buffer
1706 is left as it was after the line was appended. The return
1710 is left as it was after the line was appended. The return
1707 value is 1 if more input is required, 0 if the line was dealt
1711 value is 1 if more input is required, 0 if the line was dealt
1708 with in some way (this is the same as runsource()).
1712 with in some way (this is the same as runsource()).
1709 """
1713 """
1710
1714
1711 # autoindent management should be done here, and not in the
1715 # autoindent management should be done here, and not in the
1712 # interactive loop, since that one is only seen by keyboard input. We
1716 # interactive loop, since that one is only seen by keyboard input. We
1713 # need this done correctly even for code run via runlines (which uses
1717 # need this done correctly even for code run via runlines (which uses
1714 # push).
1718 # push).
1715
1719
1716 #print 'push line: <%s>' % line # dbg
1720 #print 'push line: <%s>' % line # dbg
1717 self.autoindent_update(line)
1721 self.autoindent_update(line)
1718
1722
1719 self.buffer.append(line)
1723 self.buffer.append(line)
1720 more = self.runsource('\n'.join(self.buffer), self.filename)
1724 more = self.runsource('\n'.join(self.buffer), self.filename)
1721 if not more:
1725 if not more:
1722 self.resetbuffer()
1726 self.resetbuffer()
1723 return more
1727 return more
1724
1728
1725 def resetbuffer(self):
1729 def resetbuffer(self):
1726 """Reset the input buffer."""
1730 """Reset the input buffer."""
1727 self.buffer[:] = []
1731 self.buffer[:] = []
1728
1732
1729 def raw_input(self,prompt='',continue_prompt=False):
1733 def raw_input(self,prompt='',continue_prompt=False):
1730 """Write a prompt and read a line.
1734 """Write a prompt and read a line.
1731
1735
1732 The returned line does not include the trailing newline.
1736 The returned line does not include the trailing newline.
1733 When the user enters the EOF key sequence, EOFError is raised.
1737 When the user enters the EOF key sequence, EOFError is raised.
1734
1738
1735 Optional inputs:
1739 Optional inputs:
1736
1740
1737 - prompt(''): a string to be printed to prompt the user.
1741 - prompt(''): a string to be printed to prompt the user.
1738
1742
1739 - continue_prompt(False): whether this line is the first one or a
1743 - continue_prompt(False): whether this line is the first one or a
1740 continuation in a sequence of inputs.
1744 continuation in a sequence of inputs.
1741 """
1745 """
1742
1746
1743 line = raw_input_original(prompt)
1747 line = raw_input_original(prompt)
1744
1748
1745 # Try to be reasonably smart about not re-indenting pasted input more
1749 # Try to be reasonably smart about not re-indenting pasted input more
1746 # than necessary. We do this by trimming out the auto-indent initial
1750 # than necessary. We do this by trimming out the auto-indent initial
1747 # spaces, if the user's actual input started itself with whitespace.
1751 # spaces, if the user's actual input started itself with whitespace.
1748 #debugx('self.buffer[-1]')
1752 #debugx('self.buffer[-1]')
1749
1753
1750 if self.autoindent:
1754 if self.autoindent:
1751 if num_ini_spaces(line) > self.indent_current_nsp:
1755 if num_ini_spaces(line) > self.indent_current_nsp:
1752 line = line[self.indent_current_nsp:]
1756 line = line[self.indent_current_nsp:]
1753 self.indent_current_nsp = 0
1757 self.indent_current_nsp = 0
1754
1758
1755 # store the unfiltered input before the user has any chance to modify
1759 # store the unfiltered input before the user has any chance to modify
1756 # it.
1760 # it.
1757 if line.strip():
1761 if line.strip():
1758 if continue_prompt:
1762 if continue_prompt:
1759 self.input_hist_raw[-1] += '%s\n' % line
1763 self.input_hist_raw[-1] += '%s\n' % line
1760 else:
1764 else:
1761 self.input_hist_raw.append('%s\n' % line)
1765 self.input_hist_raw.append('%s\n' % line)
1762
1766
1763 lineout = self.prefilter(line,continue_prompt)
1767 lineout = self.prefilter(line,continue_prompt)
1764 return lineout
1768 return lineout
1765
1769
1766 def split_user_input(self,line):
1770 def split_user_input(self,line):
1767 """Split user input into pre-char, function part and rest."""
1771 """Split user input into pre-char, function part and rest."""
1768
1772
1769 lsplit = self.line_split.match(line)
1773 lsplit = self.line_split.match(line)
1770 if lsplit is None: # no regexp match returns None
1774 if lsplit is None: # no regexp match returns None
1771 try:
1775 try:
1772 iFun,theRest = line.split(None,1)
1776 iFun,theRest = line.split(None,1)
1773 except ValueError:
1777 except ValueError:
1774 iFun,theRest = line,''
1778 iFun,theRest = line,''
1775 pre = re.match('^(\s*)(.*)',line).groups()[0]
1779 pre = re.match('^(\s*)(.*)',line).groups()[0]
1776 else:
1780 else:
1777 pre,iFun,theRest = lsplit.groups()
1781 pre,iFun,theRest = lsplit.groups()
1778
1782
1779 #print 'line:<%s>' % line # dbg
1783 #print 'line:<%s>' % line # dbg
1780 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1784 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1781 return pre,iFun.strip(),theRest
1785 return pre,iFun.strip(),theRest
1782
1786
1783 def _prefilter(self, line, continue_prompt):
1787 def _prefilter(self, line, continue_prompt):
1784 """Calls different preprocessors, depending on the form of line."""
1788 """Calls different preprocessors, depending on the form of line."""
1785
1789
1786 # All handlers *must* return a value, even if it's blank ('').
1790 # All handlers *must* return a value, even if it's blank ('').
1787
1791
1788 # Lines are NOT logged here. Handlers should process the line as
1792 # Lines are NOT logged here. Handlers should process the line as
1789 # needed, update the cache AND log it (so that the input cache array
1793 # needed, update the cache AND log it (so that the input cache array
1790 # stays synced).
1794 # stays synced).
1791
1795
1792 # This function is _very_ delicate, and since it's also the one which
1796 # This function is _very_ delicate, and since it's also the one which
1793 # determines IPython's response to user input, it must be as efficient
1797 # determines IPython's response to user input, it must be as efficient
1794 # as possible. For this reason it has _many_ returns in it, trying
1798 # as possible. For this reason it has _many_ returns in it, trying
1795 # always to exit as quickly as it can figure out what it needs to do.
1799 # always to exit as quickly as it can figure out what it needs to do.
1796
1800
1797 # This function is the main responsible for maintaining IPython's
1801 # This function is the main responsible for maintaining IPython's
1798 # behavior respectful of Python's semantics. So be _very_ careful if
1802 # behavior respectful of Python's semantics. So be _very_ careful if
1799 # making changes to anything here.
1803 # making changes to anything here.
1800
1804
1801 #.....................................................................
1805 #.....................................................................
1802 # Code begins
1806 # Code begins
1803
1807
1804 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1808 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1805
1809
1806 # save the line away in case we crash, so the post-mortem handler can
1810 # save the line away in case we crash, so the post-mortem handler can
1807 # record it
1811 # record it
1808 self._last_input_line = line
1812 self._last_input_line = line
1809
1813
1810 #print '***line: <%s>' % line # dbg
1814 #print '***line: <%s>' % line # dbg
1811
1815
1812 # the input history needs to track even empty lines
1816 # the input history needs to track even empty lines
1813 stripped = line.strip()
1817 stripped = line.strip()
1814
1818
1815 if not stripped:
1819 if not stripped:
1816 if not continue_prompt:
1820 if not continue_prompt:
1817 self.outputcache.prompt_count -= 1
1821 self.outputcache.prompt_count -= 1
1818 return self.handle_normal(line,continue_prompt)
1822 return self.handle_normal(line,continue_prompt)
1819 #return self.handle_normal('',continue_prompt)
1823 #return self.handle_normal('',continue_prompt)
1820
1824
1821 # print '***cont',continue_prompt # dbg
1825 # print '***cont',continue_prompt # dbg
1822 # special handlers are only allowed for single line statements
1826 # special handlers are only allowed for single line statements
1823 if continue_prompt and not self.rc.multi_line_specials:
1827 if continue_prompt and not self.rc.multi_line_specials:
1824 return self.handle_normal(line,continue_prompt)
1828 return self.handle_normal(line,continue_prompt)
1825
1829
1826
1830
1827 # For the rest, we need the structure of the input
1831 # For the rest, we need the structure of the input
1828 pre,iFun,theRest = self.split_user_input(line)
1832 pre,iFun,theRest = self.split_user_input(line)
1829
1833
1830 # See whether any pre-existing handler can take care of it
1834 # See whether any pre-existing handler can take care of it
1831
1835
1832 rewritten = self.hooks.input_prefilter(stripped)
1836 rewritten = self.hooks.input_prefilter(stripped)
1833 if rewritten != stripped: # ok, some prefilter did something
1837 if rewritten != stripped: # ok, some prefilter did something
1834 rewritten = pre + rewritten # add indentation
1838 rewritten = pre + rewritten # add indentation
1835 return self.handle_normal(rewritten)
1839 return self.handle_normal(rewritten)
1836
1840
1837
1841
1838
1842
1839
1843
1840 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1844 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1841
1845
1842 # First check for explicit escapes in the last/first character
1846 # First check for explicit escapes in the last/first character
1843 handler = None
1847 handler = None
1844 if line[-1] == self.ESC_HELP:
1848 if line[-1] == self.ESC_HELP:
1845 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1849 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1846 if handler is None:
1850 if handler is None:
1847 # look at the first character of iFun, NOT of line, so we skip
1851 # look at the first character of iFun, NOT of line, so we skip
1848 # leading whitespace in multiline input
1852 # leading whitespace in multiline input
1849 handler = self.esc_handlers.get(iFun[0:1])
1853 handler = self.esc_handlers.get(iFun[0:1])
1850 if handler is not None:
1854 if handler is not None:
1851 return handler(line,continue_prompt,pre,iFun,theRest)
1855 return handler(line,continue_prompt,pre,iFun,theRest)
1852 # Emacs ipython-mode tags certain input lines
1856 # Emacs ipython-mode tags certain input lines
1853 if line.endswith('# PYTHON-MODE'):
1857 if line.endswith('# PYTHON-MODE'):
1854 return self.handle_emacs(line,continue_prompt)
1858 return self.handle_emacs(line,continue_prompt)
1855
1859
1856 # Next, check if we can automatically execute this thing
1860 # Next, check if we can automatically execute this thing
1857
1861
1858 # Allow ! in multi-line statements if multi_line_specials is on:
1862 # Allow ! in multi-line statements if multi_line_specials is on:
1859 if continue_prompt and self.rc.multi_line_specials and \
1863 if continue_prompt and self.rc.multi_line_specials and \
1860 iFun.startswith(self.ESC_SHELL):
1864 iFun.startswith(self.ESC_SHELL):
1861 return self.handle_shell_escape(line,continue_prompt,
1865 return self.handle_shell_escape(line,continue_prompt,
1862 pre=pre,iFun=iFun,
1866 pre=pre,iFun=iFun,
1863 theRest=theRest)
1867 theRest=theRest)
1864
1868
1865 # Let's try to find if the input line is a magic fn
1869 # Let's try to find if the input line is a magic fn
1866 oinfo = None
1870 oinfo = None
1867 if hasattr(self,'magic_'+iFun):
1871 if hasattr(self,'magic_'+iFun):
1868 # WARNING: _ofind uses getattr(), so it can consume generators and
1872 # WARNING: _ofind uses getattr(), so it can consume generators and
1869 # cause other side effects.
1873 # cause other side effects.
1870 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1874 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1871 if oinfo['ismagic']:
1875 if oinfo['ismagic']:
1872 # Be careful not to call magics when a variable assignment is
1876 # Be careful not to call magics when a variable assignment is
1873 # being made (ls='hi', for example)
1877 # being made (ls='hi', for example)
1874 if self.rc.automagic and \
1878 if self.rc.automagic and \
1875 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1879 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1876 (self.rc.multi_line_specials or not continue_prompt):
1880 (self.rc.multi_line_specials or not continue_prompt):
1877 return self.handle_magic(line,continue_prompt,
1881 return self.handle_magic(line,continue_prompt,
1878 pre,iFun,theRest)
1882 pre,iFun,theRest)
1879 else:
1883 else:
1880 return self.handle_normal(line,continue_prompt)
1884 return self.handle_normal(line,continue_prompt)
1881
1885
1882 # If the rest of the line begins with an (in)equality, assginment or
1886 # If the rest of the line begins with an (in)equality, assginment or
1883 # function call, we should not call _ofind but simply execute it.
1887 # function call, we should not call _ofind but simply execute it.
1884 # This avoids spurious geattr() accesses on objects upon assignment.
1888 # This avoids spurious geattr() accesses on objects upon assignment.
1885 #
1889 #
1886 # It also allows users to assign to either alias or magic names true
1890 # It also allows users to assign to either alias or magic names true
1887 # python variables (the magic/alias systems always take second seat to
1891 # python variables (the magic/alias systems always take second seat to
1888 # true python code).
1892 # true python code).
1889 if theRest and theRest[0] in '!=()':
1893 if theRest and theRest[0] in '!=()':
1890 return self.handle_normal(line,continue_prompt)
1894 return self.handle_normal(line,continue_prompt)
1891
1895
1892 if oinfo is None:
1896 if oinfo is None:
1893 # let's try to ensure that _oinfo is ONLY called when autocall is
1897 # let's try to ensure that _oinfo is ONLY called when autocall is
1894 # on. Since it has inevitable potential side effects, at least
1898 # on. Since it has inevitable potential side effects, at least
1895 # having autocall off should be a guarantee to the user that no
1899 # having autocall off should be a guarantee to the user that no
1896 # weird things will happen.
1900 # weird things will happen.
1897
1901
1898 if self.rc.autocall:
1902 if self.rc.autocall:
1899 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1903 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1900 else:
1904 else:
1901 # in this case, all that's left is either an alias or
1905 # in this case, all that's left is either an alias or
1902 # processing the line normally.
1906 # processing the line normally.
1903 if iFun in self.alias_table:
1907 if iFun in self.alias_table:
1904 return self.handle_alias(line,continue_prompt,
1908 return self.handle_alias(line,continue_prompt,
1905 pre,iFun,theRest)
1909 pre,iFun,theRest)
1906
1910
1907 else:
1911 else:
1908 return self.handle_normal(line,continue_prompt)
1912 return self.handle_normal(line,continue_prompt)
1909
1913
1910 if not oinfo['found']:
1914 if not oinfo['found']:
1911 return self.handle_normal(line,continue_prompt)
1915 return self.handle_normal(line,continue_prompt)
1912 else:
1916 else:
1913 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1917 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1914 if oinfo['isalias']:
1918 if oinfo['isalias']:
1915 return self.handle_alias(line,continue_prompt,
1919 return self.handle_alias(line,continue_prompt,
1916 pre,iFun,theRest)
1920 pre,iFun,theRest)
1917
1921
1918 if (self.rc.autocall
1922 if (self.rc.autocall
1919 and
1923 and
1920 (
1924 (
1921 #only consider exclusion re if not "," or ";" autoquoting
1925 #only consider exclusion re if not "," or ";" autoquoting
1922 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
1926 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
1923 or pre == self.ESC_PAREN) or
1927 or pre == self.ESC_PAREN) or
1924 (not self.re_exclude_auto.match(theRest)))
1928 (not self.re_exclude_auto.match(theRest)))
1925 and
1929 and
1926 self.re_fun_name.match(iFun) and
1930 self.re_fun_name.match(iFun) and
1927 callable(oinfo['obj'])) :
1931 callable(oinfo['obj'])) :
1928 #print 'going auto' # dbg
1932 #print 'going auto' # dbg
1929 return self.handle_auto(line,continue_prompt,
1933 return self.handle_auto(line,continue_prompt,
1930 pre,iFun,theRest,oinfo['obj'])
1934 pre,iFun,theRest,oinfo['obj'])
1931 else:
1935 else:
1932 #print 'was callable?', callable(oinfo['obj']) # dbg
1936 #print 'was callable?', callable(oinfo['obj']) # dbg
1933 return self.handle_normal(line,continue_prompt)
1937 return self.handle_normal(line,continue_prompt)
1934
1938
1935 # If we get here, we have a normal Python line. Log and return.
1939 # If we get here, we have a normal Python line. Log and return.
1936 return self.handle_normal(line,continue_prompt)
1940 return self.handle_normal(line,continue_prompt)
1937
1941
1938 def _prefilter_dumb(self, line, continue_prompt):
1942 def _prefilter_dumb(self, line, continue_prompt):
1939 """simple prefilter function, for debugging"""
1943 """simple prefilter function, for debugging"""
1940 return self.handle_normal(line,continue_prompt)
1944 return self.handle_normal(line,continue_prompt)
1941
1945
1942 # Set the default prefilter() function (this can be user-overridden)
1946 # Set the default prefilter() function (this can be user-overridden)
1943 prefilter = _prefilter
1947 prefilter = _prefilter
1944
1948
1945 def handle_normal(self,line,continue_prompt=None,
1949 def handle_normal(self,line,continue_prompt=None,
1946 pre=None,iFun=None,theRest=None):
1950 pre=None,iFun=None,theRest=None):
1947 """Handle normal input lines. Use as a template for handlers."""
1951 """Handle normal input lines. Use as a template for handlers."""
1948
1952
1949 # With autoindent on, we need some way to exit the input loop, and I
1953 # With autoindent on, we need some way to exit the input loop, and I
1950 # don't want to force the user to have to backspace all the way to
1954 # don't want to force the user to have to backspace all the way to
1951 # clear the line. The rule will be in this case, that either two
1955 # clear the line. The rule will be in this case, that either two
1952 # lines of pure whitespace in a row, or a line of pure whitespace but
1956 # lines of pure whitespace in a row, or a line of pure whitespace but
1953 # of a size different to the indent level, will exit the input loop.
1957 # of a size different to the indent level, will exit the input loop.
1954
1958
1955 if (continue_prompt and self.autoindent and line.isspace() and
1959 if (continue_prompt and self.autoindent and line.isspace() and
1956 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
1960 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
1957 (self.buffer[-1]).isspace() )):
1961 (self.buffer[-1]).isspace() )):
1958 line = ''
1962 line = ''
1959
1963
1960 self.log(line,continue_prompt)
1964 self.log(line,continue_prompt)
1961 return line
1965 return line
1962
1966
1963 def handle_alias(self,line,continue_prompt=None,
1967 def handle_alias(self,line,continue_prompt=None,
1964 pre=None,iFun=None,theRest=None):
1968 pre=None,iFun=None,theRest=None):
1965 """Handle alias input lines. """
1969 """Handle alias input lines. """
1966
1970
1967 # pre is needed, because it carries the leading whitespace. Otherwise
1971 # pre is needed, because it carries the leading whitespace. Otherwise
1968 # aliases won't work in indented sections.
1972 # aliases won't work in indented sections.
1969 transformed = self.transform_alias(iFun, theRest)
1973 transformed = self.transform_alias(iFun, theRest)
1970 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
1974 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
1971 self.log(line_out,continue_prompt)
1975 self.log(line_out,continue_prompt)
1972 return line_out
1976 return line_out
1973
1977
1974 def handle_shell_escape(self, line, continue_prompt=None,
1978 def handle_shell_escape(self, line, continue_prompt=None,
1975 pre=None,iFun=None,theRest=None):
1979 pre=None,iFun=None,theRest=None):
1976 """Execute the line in a shell, empty return value"""
1980 """Execute the line in a shell, empty return value"""
1977
1981
1978 #print 'line in :', `line` # dbg
1982 #print 'line in :', `line` # dbg
1979 # Example of a special handler. Others follow a similar pattern.
1983 # Example of a special handler. Others follow a similar pattern.
1980 if line.lstrip().startswith('!!'):
1984 if line.lstrip().startswith('!!'):
1981 # rewrite iFun/theRest to properly hold the call to %sx and
1985 # rewrite iFun/theRest to properly hold the call to %sx and
1982 # the actual command to be executed, so handle_magic can work
1986 # the actual command to be executed, so handle_magic can work
1983 # correctly
1987 # correctly
1984 theRest = '%s %s' % (iFun[2:],theRest)
1988 theRest = '%s %s' % (iFun[2:],theRest)
1985 iFun = 'sx'
1989 iFun = 'sx'
1986 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
1990 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
1987 line.lstrip()[2:]),
1991 line.lstrip()[2:]),
1988 continue_prompt,pre,iFun,theRest)
1992 continue_prompt,pre,iFun,theRest)
1989 else:
1993 else:
1990 cmd=line.lstrip().lstrip('!')
1994 cmd=line.lstrip().lstrip('!')
1991 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
1995 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
1992 # update cache/log and return
1996 # update cache/log and return
1993 self.log(line_out,continue_prompt)
1997 self.log(line_out,continue_prompt)
1994 return line_out
1998 return line_out
1995
1999
1996 def handle_magic(self, line, continue_prompt=None,
2000 def handle_magic(self, line, continue_prompt=None,
1997 pre=None,iFun=None,theRest=None):
2001 pre=None,iFun=None,theRest=None):
1998 """Execute magic functions."""
2002 """Execute magic functions."""
1999
2003
2000
2004
2001 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2005 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2002 self.log(cmd,continue_prompt)
2006 self.log(cmd,continue_prompt)
2003 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2007 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2004 return cmd
2008 return cmd
2005
2009
2006 def handle_auto(self, line, continue_prompt=None,
2010 def handle_auto(self, line, continue_prompt=None,
2007 pre=None,iFun=None,theRest=None,obj=None):
2011 pre=None,iFun=None,theRest=None,obj=None):
2008 """Hande lines which can be auto-executed, quoting if requested."""
2012 """Hande lines which can be auto-executed, quoting if requested."""
2009
2013
2010 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2014 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2011
2015
2012 # This should only be active for single-line input!
2016 # This should only be active for single-line input!
2013 if continue_prompt:
2017 if continue_prompt:
2014 self.log(line,continue_prompt)
2018 self.log(line,continue_prompt)
2015 return line
2019 return line
2016
2020
2017 auto_rewrite = True
2021 auto_rewrite = True
2018
2022
2019 if pre == self.ESC_QUOTE:
2023 if pre == self.ESC_QUOTE:
2020 # Auto-quote splitting on whitespace
2024 # Auto-quote splitting on whitespace
2021 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2025 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2022 elif pre == self.ESC_QUOTE2:
2026 elif pre == self.ESC_QUOTE2:
2023 # Auto-quote whole string
2027 # Auto-quote whole string
2024 newcmd = '%s("%s")' % (iFun,theRest)
2028 newcmd = '%s("%s")' % (iFun,theRest)
2025 elif pre == self.ESC_PAREN:
2029 elif pre == self.ESC_PAREN:
2026 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2030 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2027 else:
2031 else:
2028 # Auto-paren.
2032 # Auto-paren.
2029 # We only apply it to argument-less calls if the autocall
2033 # We only apply it to argument-less calls if the autocall
2030 # parameter is set to 2. We only need to check that autocall is <
2034 # parameter is set to 2. We only need to check that autocall is <
2031 # 2, since this function isn't called unless it's at least 1.
2035 # 2, since this function isn't called unless it's at least 1.
2032 if not theRest and (self.rc.autocall < 2):
2036 if not theRest and (self.rc.autocall < 2):
2033 newcmd = '%s %s' % (iFun,theRest)
2037 newcmd = '%s %s' % (iFun,theRest)
2034 auto_rewrite = False
2038 auto_rewrite = False
2035 else:
2039 else:
2036 if theRest.startswith('['):
2040 if theRest.startswith('['):
2037 if hasattr(obj,'__getitem__'):
2041 if hasattr(obj,'__getitem__'):
2038 # Don't autocall in this case: item access for an object
2042 # Don't autocall in this case: item access for an object
2039 # which is BOTH callable and implements __getitem__.
2043 # which is BOTH callable and implements __getitem__.
2040 newcmd = '%s %s' % (iFun,theRest)
2044 newcmd = '%s %s' % (iFun,theRest)
2041 auto_rewrite = False
2045 auto_rewrite = False
2042 else:
2046 else:
2043 # if the object doesn't support [] access, go ahead and
2047 # if the object doesn't support [] access, go ahead and
2044 # autocall
2048 # autocall
2045 newcmd = '%s(%s)' % (iFun.rstrip(),",".join(theRest.split()))
2049 newcmd = '%s(%s)' % (iFun.rstrip(),",".join(theRest.split()))
2046 elif theRest.endswith(';'):
2050 elif theRest.endswith(';'):
2047 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2051 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2048 else:
2052 else:
2049 newcmd = '%s(%s)' % (iFun.rstrip(),",".join(theRest.split()))
2053 newcmd = '%s(%s)' % (iFun.rstrip(),",".join(theRest.split()))
2050
2054
2051 if auto_rewrite:
2055 if auto_rewrite:
2052 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2056 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2053 # log what is now valid Python, not the actual user input (without the
2057 # log what is now valid Python, not the actual user input (without the
2054 # final newline)
2058 # final newline)
2055 self.log(newcmd,continue_prompt)
2059 self.log(newcmd,continue_prompt)
2056 return newcmd
2060 return newcmd
2057
2061
2058 def handle_help(self, line, continue_prompt=None,
2062 def handle_help(self, line, continue_prompt=None,
2059 pre=None,iFun=None,theRest=None):
2063 pre=None,iFun=None,theRest=None):
2060 """Try to get some help for the object.
2064 """Try to get some help for the object.
2061
2065
2062 obj? or ?obj -> basic information.
2066 obj? or ?obj -> basic information.
2063 obj?? or ??obj -> more details.
2067 obj?? or ??obj -> more details.
2064 """
2068 """
2065
2069
2066 # We need to make sure that we don't process lines which would be
2070 # We need to make sure that we don't process lines which would be
2067 # otherwise valid python, such as "x=1 # what?"
2071 # otherwise valid python, such as "x=1 # what?"
2068 try:
2072 try:
2069 codeop.compile_command(line)
2073 codeop.compile_command(line)
2070 except SyntaxError:
2074 except SyntaxError:
2071 # We should only handle as help stuff which is NOT valid syntax
2075 # We should only handle as help stuff which is NOT valid syntax
2072 if line[0]==self.ESC_HELP:
2076 if line[0]==self.ESC_HELP:
2073 line = line[1:]
2077 line = line[1:]
2074 elif line[-1]==self.ESC_HELP:
2078 elif line[-1]==self.ESC_HELP:
2075 line = line[:-1]
2079 line = line[:-1]
2076 self.log('#?'+line)
2080 self.log('#?'+line)
2077 if line:
2081 if line:
2078 self.magic_pinfo(line)
2082 self.magic_pinfo(line)
2079 else:
2083 else:
2080 page(self.usage,screen_lines=self.rc.screen_length)
2084 page(self.usage,screen_lines=self.rc.screen_length)
2081 return '' # Empty string is needed here!
2085 return '' # Empty string is needed here!
2082 except:
2086 except:
2083 # Pass any other exceptions through to the normal handler
2087 # Pass any other exceptions through to the normal handler
2084 return self.handle_normal(line,continue_prompt)
2088 return self.handle_normal(line,continue_prompt)
2085 else:
2089 else:
2086 # If the code compiles ok, we should handle it normally
2090 # If the code compiles ok, we should handle it normally
2087 return self.handle_normal(line,continue_prompt)
2091 return self.handle_normal(line,continue_prompt)
2088
2092
2089 def getapi(self):
2093 def getapi(self):
2090 """ Get an IPApi object for this shell instance
2094 """ Get an IPApi object for this shell instance
2091
2095
2092 Getting an IPApi object is always preferable to accessing the shell
2096 Getting an IPApi object is always preferable to accessing the shell
2093 directly, but this holds true especially for extensions.
2097 directly, but this holds true especially for extensions.
2094
2098
2095 It should always be possible to implement an extension with IPApi
2099 It should always be possible to implement an extension with IPApi
2096 alone. If not, contact maintainer to request an addition.
2100 alone. If not, contact maintainer to request an addition.
2097
2101
2098 """
2102 """
2099 return self.api
2103 return self.api
2100
2104
2101 def handle_emacs(self,line,continue_prompt=None,
2105 def handle_emacs(self,line,continue_prompt=None,
2102 pre=None,iFun=None,theRest=None):
2106 pre=None,iFun=None,theRest=None):
2103 """Handle input lines marked by python-mode."""
2107 """Handle input lines marked by python-mode."""
2104
2108
2105 # Currently, nothing is done. Later more functionality can be added
2109 # Currently, nothing is done. Later more functionality can be added
2106 # here if needed.
2110 # here if needed.
2107
2111
2108 # The input cache shouldn't be updated
2112 # The input cache shouldn't be updated
2109
2113
2110 return line
2114 return line
2111
2115
2112 def mktempfile(self,data=None):
2116 def mktempfile(self,data=None):
2113 """Make a new tempfile and return its filename.
2117 """Make a new tempfile and return its filename.
2114
2118
2115 This makes a call to tempfile.mktemp, but it registers the created
2119 This makes a call to tempfile.mktemp, but it registers the created
2116 filename internally so ipython cleans it up at exit time.
2120 filename internally so ipython cleans it up at exit time.
2117
2121
2118 Optional inputs:
2122 Optional inputs:
2119
2123
2120 - data(None): if data is given, it gets written out to the temp file
2124 - data(None): if data is given, it gets written out to the temp file
2121 immediately, and the file is closed again."""
2125 immediately, and the file is closed again."""
2122
2126
2123 filename = tempfile.mktemp('.py','ipython_edit_')
2127 filename = tempfile.mktemp('.py','ipython_edit_')
2124 self.tempfiles.append(filename)
2128 self.tempfiles.append(filename)
2125
2129
2126 if data:
2130 if data:
2127 tmp_file = open(filename,'w')
2131 tmp_file = open(filename,'w')
2128 tmp_file.write(data)
2132 tmp_file.write(data)
2129 tmp_file.close()
2133 tmp_file.close()
2130 return filename
2134 return filename
2131
2135
2132 def write(self,data):
2136 def write(self,data):
2133 """Write a string to the default output"""
2137 """Write a string to the default output"""
2134 Term.cout.write(data)
2138 Term.cout.write(data)
2135
2139
2136 def write_err(self,data):
2140 def write_err(self,data):
2137 """Write a string to the default error output"""
2141 """Write a string to the default error output"""
2138 Term.cerr.write(data)
2142 Term.cerr.write(data)
2139
2143
2140 def exit(self):
2144 def exit(self):
2141 """Handle interactive exit.
2145 """Handle interactive exit.
2142
2146
2143 This method sets the exit_now attribute."""
2147 This method sets the exit_now attribute."""
2144
2148
2145 if self.rc.confirm_exit:
2149 if self.rc.confirm_exit:
2146 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2150 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2147 self.exit_now = True
2151 self.exit_now = True
2148 else:
2152 else:
2149 self.exit_now = True
2153 self.exit_now = True
2150 return self.exit_now
2154 return self.exit_now
2151
2155
2152 def safe_execfile(self,fname,*where,**kw):
2156 def safe_execfile(self,fname,*where,**kw):
2153 fname = os.path.expanduser(fname)
2157 fname = os.path.expanduser(fname)
2154
2158
2155 # find things also in current directory
2159 # find things also in current directory
2156 dname = os.path.dirname(fname)
2160 dname = os.path.dirname(fname)
2157 if not sys.path.count(dname):
2161 if not sys.path.count(dname):
2158 sys.path.append(dname)
2162 sys.path.append(dname)
2159
2163
2160 try:
2164 try:
2161 xfile = open(fname)
2165 xfile = open(fname)
2162 except:
2166 except:
2163 print >> Term.cerr, \
2167 print >> Term.cerr, \
2164 'Could not open file <%s> for safe execution.' % fname
2168 'Could not open file <%s> for safe execution.' % fname
2165 return None
2169 return None
2166
2170
2167 kw.setdefault('islog',0)
2171 kw.setdefault('islog',0)
2168 kw.setdefault('quiet',1)
2172 kw.setdefault('quiet',1)
2169 kw.setdefault('exit_ignore',0)
2173 kw.setdefault('exit_ignore',0)
2170 first = xfile.readline()
2174 first = xfile.readline()
2171 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2175 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2172 xfile.close()
2176 xfile.close()
2173 # line by line execution
2177 # line by line execution
2174 if first.startswith(loghead) or kw['islog']:
2178 if first.startswith(loghead) or kw['islog']:
2175 print 'Loading log file <%s> one line at a time...' % fname
2179 print 'Loading log file <%s> one line at a time...' % fname
2176 if kw['quiet']:
2180 if kw['quiet']:
2177 stdout_save = sys.stdout
2181 stdout_save = sys.stdout
2178 sys.stdout = StringIO.StringIO()
2182 sys.stdout = StringIO.StringIO()
2179 try:
2183 try:
2180 globs,locs = where[0:2]
2184 globs,locs = where[0:2]
2181 except:
2185 except:
2182 try:
2186 try:
2183 globs = locs = where[0]
2187 globs = locs = where[0]
2184 except:
2188 except:
2185 globs = locs = globals()
2189 globs = locs = globals()
2186 badblocks = []
2190 badblocks = []
2187
2191
2188 # we also need to identify indented blocks of code when replaying
2192 # we also need to identify indented blocks of code when replaying
2189 # logs and put them together before passing them to an exec
2193 # logs and put them together before passing them to an exec
2190 # statement. This takes a bit of regexp and look-ahead work in the
2194 # statement. This takes a bit of regexp and look-ahead work in the
2191 # file. It's easiest if we swallow the whole thing in memory
2195 # file. It's easiest if we swallow the whole thing in memory
2192 # first, and manually walk through the lines list moving the
2196 # first, and manually walk through the lines list moving the
2193 # counter ourselves.
2197 # counter ourselves.
2194 indent_re = re.compile('\s+\S')
2198 indent_re = re.compile('\s+\S')
2195 xfile = open(fname)
2199 xfile = open(fname)
2196 filelines = xfile.readlines()
2200 filelines = xfile.readlines()
2197 xfile.close()
2201 xfile.close()
2198 nlines = len(filelines)
2202 nlines = len(filelines)
2199 lnum = 0
2203 lnum = 0
2200 while lnum < nlines:
2204 while lnum < nlines:
2201 line = filelines[lnum]
2205 line = filelines[lnum]
2202 lnum += 1
2206 lnum += 1
2203 # don't re-insert logger status info into cache
2207 # don't re-insert logger status info into cache
2204 if line.startswith('#log#'):
2208 if line.startswith('#log#'):
2205 continue
2209 continue
2206 else:
2210 else:
2207 # build a block of code (maybe a single line) for execution
2211 # build a block of code (maybe a single line) for execution
2208 block = line
2212 block = line
2209 try:
2213 try:
2210 next = filelines[lnum] # lnum has already incremented
2214 next = filelines[lnum] # lnum has already incremented
2211 except:
2215 except:
2212 next = None
2216 next = None
2213 while next and indent_re.match(next):
2217 while next and indent_re.match(next):
2214 block += next
2218 block += next
2215 lnum += 1
2219 lnum += 1
2216 try:
2220 try:
2217 next = filelines[lnum]
2221 next = filelines[lnum]
2218 except:
2222 except:
2219 next = None
2223 next = None
2220 # now execute the block of one or more lines
2224 # now execute the block of one or more lines
2221 try:
2225 try:
2222 exec block in globs,locs
2226 exec block in globs,locs
2223 except SystemExit:
2227 except SystemExit:
2224 pass
2228 pass
2225 except:
2229 except:
2226 badblocks.append(block.rstrip())
2230 badblocks.append(block.rstrip())
2227 if kw['quiet']: # restore stdout
2231 if kw['quiet']: # restore stdout
2228 sys.stdout.close()
2232 sys.stdout.close()
2229 sys.stdout = stdout_save
2233 sys.stdout = stdout_save
2230 print 'Finished replaying log file <%s>' % fname
2234 print 'Finished replaying log file <%s>' % fname
2231 if badblocks:
2235 if badblocks:
2232 print >> sys.stderr, ('\nThe following lines/blocks in file '
2236 print >> sys.stderr, ('\nThe following lines/blocks in file '
2233 '<%s> reported errors:' % fname)
2237 '<%s> reported errors:' % fname)
2234
2238
2235 for badline in badblocks:
2239 for badline in badblocks:
2236 print >> sys.stderr, badline
2240 print >> sys.stderr, badline
2237 else: # regular file execution
2241 else: # regular file execution
2238 try:
2242 try:
2239 execfile(fname,*where)
2243 execfile(fname,*where)
2240 except SyntaxError:
2244 except SyntaxError:
2241 etype,evalue = sys.exc_info()[:2]
2245 etype,evalue = sys.exc_info()[:2]
2242 self.SyntaxTB(etype,evalue,[])
2246 self.SyntaxTB(etype,evalue,[])
2243 warn('Failure executing file: <%s>' % fname)
2247 warn('Failure executing file: <%s>' % fname)
2244 except SystemExit,status:
2248 except SystemExit,status:
2245 if not kw['exit_ignore']:
2249 if not kw['exit_ignore']:
2246 self.InteractiveTB()
2250 self.InteractiveTB()
2247 warn('Failure executing file: <%s>' % fname)
2251 warn('Failure executing file: <%s>' % fname)
2248 except:
2252 except:
2249 self.InteractiveTB()
2253 self.InteractiveTB()
2250 warn('Failure executing file: <%s>' % fname)
2254 warn('Failure executing file: <%s>' % fname)
2251
2255
2252 #************************* end of file <iplib.py> *****************************
2256 #************************* end of file <iplib.py> *****************************
@@ -1,5152 +1,5161 b''
1 2006-02-01 Ville Vainio <vivainio@gmail.com>
1 2006-02-01 Ville Vainio <vivainio@gmail.com>
2
2
3 * easy_install ipython==dev works correctly now.
3 * setup.py, eggsetup.py: easy_install ipython==dev works
4 correctly now (on Linux)
5
6 * ipy_user_conf,ipmaker: user config changes, removed spurious
7 warnings
8
9 * iplib: if rc.banner is string, use it as is.
10
11 * Magic: %pycat accepts a string argument and pages it's contents.
12
4
13
5 2006-01-30 Ville Vainio <vivainio@gmail.com>
14 2006-01-30 Ville Vainio <vivainio@gmail.com>
6
15
7 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
16 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
8 Now %store and bookmarks work through PickleShare, meaning that
17 Now %store and bookmarks work through PickleShare, meaning that
9 concurrent access is possible and all ipython sessions see the
18 concurrent access is possible and all ipython sessions see the
10 same database situation all the time, instead of snapshot of
19 same database situation all the time, instead of snapshot of
11 the situation when the session was started. Hence, %bookmark
20 the situation when the session was started. Hence, %bookmark
12 results are immediately accessible from othes sessions. The database
21 results are immediately accessible from othes sessions. The database
13 is also available for use by user extensions. See:
22 is also available for use by user extensions. See:
14 http://www.python.org/pypi/pickleshare
23 http://www.python.org/pypi/pickleshare
15
24
16 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
25 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
17
26
18 * aliases can now be %store'd
27 * aliases can now be %store'd
19
28
20 * path.py move to Extensions so that pickleshare does not need
29 * path.py move to Extensions so that pickleshare does not need
21 IPython-specific import. Extensions added to pythonpath right
30 IPython-specific import. Extensions added to pythonpath right
22 at __init__.
31 at __init__.
23
32
24 * iplib.py: ipalias deprecated/redundant; aliases are converted and
33 * iplib.py: ipalias deprecated/redundant; aliases are converted and
25 called with _ip.system and the pre-transformed command string.
34 called with _ip.system and the pre-transformed command string.
26
35
27 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
36 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
28
37
29 * IPython/iplib.py (interact): Fix that we were not catching
38 * IPython/iplib.py (interact): Fix that we were not catching
30 KeyboardInterrupt exceptions properly. I'm not quite sure why the
39 KeyboardInterrupt exceptions properly. I'm not quite sure why the
31 logic here had to change, but it's fixed now.
40 logic here had to change, but it's fixed now.
32
41
33 2006-01-29 Ville Vainio <vivainio@gmail.com>
42 2006-01-29 Ville Vainio <vivainio@gmail.com>
34
43
35 * iplib.py: Try to import pyreadline on Windows.
44 * iplib.py: Try to import pyreadline on Windows.
36
45
37 2006-01-27 Ville Vainio <vivainio@gmail.com>
46 2006-01-27 Ville Vainio <vivainio@gmail.com>
38
47
39 * iplib.py: Expose ipapi as _ip in builtin namespace.
48 * iplib.py: Expose ipapi as _ip in builtin namespace.
40 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
49 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
41 and ip_set_hook (-> _ip.set_hook) redundant. % and !
50 and ip_set_hook (-> _ip.set_hook) redundant. % and !
42 syntax now produce _ip.* variant of the commands.
51 syntax now produce _ip.* variant of the commands.
43
52
44 * "_ip.options().autoedit_syntax = 2" automatically throws
53 * "_ip.options().autoedit_syntax = 2" automatically throws
45 user to editor for syntax error correction without prompting.
54 user to editor for syntax error correction without prompting.
46
55
47 2006-01-27 Ville Vainio <vivainio@gmail.com>
56 2006-01-27 Ville Vainio <vivainio@gmail.com>
48
57
49 * ipmaker.py: Give "realistic" sys.argv for scripts (without
58 * ipmaker.py: Give "realistic" sys.argv for scripts (without
50 'ipython' at argv[0]) executed through command line.
59 'ipython' at argv[0]) executed through command line.
51 NOTE: this DEPRECATES calling ipython with multiple scripts
60 NOTE: this DEPRECATES calling ipython with multiple scripts
52 ("ipython a.py b.py c.py")
61 ("ipython a.py b.py c.py")
53
62
54 * iplib.py, hooks.py: Added configurable input prefilter,
63 * iplib.py, hooks.py: Added configurable input prefilter,
55 named 'input_prefilter'. See ext_rescapture.py for example
64 named 'input_prefilter'. See ext_rescapture.py for example
56 usage.
65 usage.
57
66
58 * ext_rescapture.py, Magic.py: Better system command output capture
67 * ext_rescapture.py, Magic.py: Better system command output capture
59 through 'var = !ls' (deprecates user-visible %sc). Same notation
68 through 'var = !ls' (deprecates user-visible %sc). Same notation
60 applies for magics, 'var = %alias' assigns alias list to var.
69 applies for magics, 'var = %alias' assigns alias list to var.
61
70
62 * ipapi.py: added meta() for accessing extension-usable data store.
71 * ipapi.py: added meta() for accessing extension-usable data store.
63
72
64 * iplib.py: added InteractiveShell.getapi(). New magics should be
73 * iplib.py: added InteractiveShell.getapi(). New magics should be
65 written doing self.getapi() instead of using the shell directly.
74 written doing self.getapi() instead of using the shell directly.
66
75
67 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
76 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
68 %store foo >> ~/myfoo.txt to store variables to files (in clean
77 %store foo >> ~/myfoo.txt to store variables to files (in clean
69 textual form, not a restorable pickle).
78 textual form, not a restorable pickle).
70
79
71 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
80 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
72
81
73 * usage.py, Magic.py: added %quickref
82 * usage.py, Magic.py: added %quickref
74
83
75 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
84 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
76
85
77 * GetoptErrors when invoking magics etc. with wrong args
86 * GetoptErrors when invoking magics etc. with wrong args
78 are now more helpful:
87 are now more helpful:
79 GetoptError: option -l not recognized (allowed: "qb" )
88 GetoptError: option -l not recognized (allowed: "qb" )
80
89
81 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
90 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
82
91
83 * IPython/demo.py (Demo.show): Flush stdout after each block, so
92 * IPython/demo.py (Demo.show): Flush stdout after each block, so
84 computationally intensive blocks don't appear to stall the demo.
93 computationally intensive blocks don't appear to stall the demo.
85
94
86 2006-01-24 Ville Vainio <vivainio@gmail.com>
95 2006-01-24 Ville Vainio <vivainio@gmail.com>
87
96
88 * iplib.py, hooks.py: 'result_display' hook can return a non-None
97 * iplib.py, hooks.py: 'result_display' hook can return a non-None
89 value to manipulate resulting history entry.
98 value to manipulate resulting history entry.
90
99
91 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
100 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
92 to instance methods of IPApi class, to make extending an embedded
101 to instance methods of IPApi class, to make extending an embedded
93 IPython feasible. See ext_rehashdir.py for example usage.
102 IPython feasible. See ext_rehashdir.py for example usage.
94
103
95 * Merged 1071-1076 from banches/0.7.1
104 * Merged 1071-1076 from banches/0.7.1
96
105
97
106
98 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
107 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
99
108
100 * tools/release (daystamp): Fix build tools to use the new
109 * tools/release (daystamp): Fix build tools to use the new
101 eggsetup.py script to build lightweight eggs.
110 eggsetup.py script to build lightweight eggs.
102
111
103 * Applied changesets 1062 and 1064 before 0.7.1 release.
112 * Applied changesets 1062 and 1064 before 0.7.1 release.
104
113
105 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
114 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
106 see the raw input history (without conversions like %ls ->
115 see the raw input history (without conversions like %ls ->
107 ipmagic("ls")). After a request from W. Stein, SAGE
116 ipmagic("ls")). After a request from W. Stein, SAGE
108 (http://modular.ucsd.edu/sage) developer. This information is
117 (http://modular.ucsd.edu/sage) developer. This information is
109 stored in the input_hist_raw attribute of the IPython instance, so
118 stored in the input_hist_raw attribute of the IPython instance, so
110 developers can access it if needed (it's an InputList instance).
119 developers can access it if needed (it's an InputList instance).
111
120
112 * Versionstring = 0.7.2.svn
121 * Versionstring = 0.7.2.svn
113
122
114 * eggsetup.py: A separate script for constructing eggs, creates
123 * eggsetup.py: A separate script for constructing eggs, creates
115 proper launch scripts even on Windows (an .exe file in
124 proper launch scripts even on Windows (an .exe file in
116 \python24\scripts).
125 \python24\scripts).
117
126
118 * ipapi.py: launch_new_instance, launch entry point needed for the
127 * ipapi.py: launch_new_instance, launch entry point needed for the
119 egg.
128 egg.
120
129
121 2006-01-23 Ville Vainio <vivainio@gmail.com>
130 2006-01-23 Ville Vainio <vivainio@gmail.com>
122
131
123 * Added %cpaste magic for pasting python code
132 * Added %cpaste magic for pasting python code
124
133
125 2006-01-22 Ville Vainio <vivainio@gmail.com>
134 2006-01-22 Ville Vainio <vivainio@gmail.com>
126
135
127 * Merge from branches/0.7.1 into trunk, revs 1052-1057
136 * Merge from branches/0.7.1 into trunk, revs 1052-1057
128
137
129 * Versionstring = 0.7.2.svn
138 * Versionstring = 0.7.2.svn
130
139
131 * eggsetup.py: A separate script for constructing eggs, creates
140 * eggsetup.py: A separate script for constructing eggs, creates
132 proper launch scripts even on Windows (an .exe file in
141 proper launch scripts even on Windows (an .exe file in
133 \python24\scripts).
142 \python24\scripts).
134
143
135 * ipapi.py: launch_new_instance, launch entry point needed for the
144 * ipapi.py: launch_new_instance, launch entry point needed for the
136 egg.
145 egg.
137
146
138 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
147 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
139
148
140 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
149 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
141 %pfile foo would print the file for foo even if it was a binary.
150 %pfile foo would print the file for foo even if it was a binary.
142 Now, extensions '.so' and '.dll' are skipped.
151 Now, extensions '.so' and '.dll' are skipped.
143
152
144 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
153 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
145 bug, where macros would fail in all threaded modes. I'm not 100%
154 bug, where macros would fail in all threaded modes. I'm not 100%
146 sure, so I'm going to put out an rc instead of making a release
155 sure, so I'm going to put out an rc instead of making a release
147 today, and wait for feedback for at least a few days.
156 today, and wait for feedback for at least a few days.
148
157
149 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
158 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
150 it...) the handling of pasting external code with autoindent on.
159 it...) the handling of pasting external code with autoindent on.
151 To get out of a multiline input, the rule will appear for most
160 To get out of a multiline input, the rule will appear for most
152 users unchanged: two blank lines or change the indent level
161 users unchanged: two blank lines or change the indent level
153 proposed by IPython. But there is a twist now: you can
162 proposed by IPython. But there is a twist now: you can
154 add/subtract only *one or two spaces*. If you add/subtract three
163 add/subtract only *one or two spaces*. If you add/subtract three
155 or more (unless you completely delete the line), IPython will
164 or more (unless you completely delete the line), IPython will
156 accept that line, and you'll need to enter a second one of pure
165 accept that line, and you'll need to enter a second one of pure
157 whitespace. I know it sounds complicated, but I can't find a
166 whitespace. I know it sounds complicated, but I can't find a
158 different solution that covers all the cases, with the right
167 different solution that covers all the cases, with the right
159 heuristics. Hopefully in actual use, nobody will really notice
168 heuristics. Hopefully in actual use, nobody will really notice
160 all these strange rules and things will 'just work'.
169 all these strange rules and things will 'just work'.
161
170
162 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
171 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
163
172
164 * IPython/iplib.py (interact): catch exceptions which can be
173 * IPython/iplib.py (interact): catch exceptions which can be
165 triggered asynchronously by signal handlers. Thanks to an
174 triggered asynchronously by signal handlers. Thanks to an
166 automatic crash report, submitted by Colin Kingsley
175 automatic crash report, submitted by Colin Kingsley
167 <tercel-AT-gentoo.org>.
176 <tercel-AT-gentoo.org>.
168
177
169 2006-01-20 Ville Vainio <vivainio@gmail.com>
178 2006-01-20 Ville Vainio <vivainio@gmail.com>
170
179
171 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
180 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
172 (%rehashdir, very useful, try it out) of how to extend ipython
181 (%rehashdir, very useful, try it out) of how to extend ipython
173 with new magics. Also added Extensions dir to pythonpath to make
182 with new magics. Also added Extensions dir to pythonpath to make
174 importing extensions easy.
183 importing extensions easy.
175
184
176 * %store now complains when trying to store interactively declared
185 * %store now complains when trying to store interactively declared
177 classes / instances of those classes.
186 classes / instances of those classes.
178
187
179 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
188 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
180 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
189 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
181 if they exist, and ipy_user_conf.py with some defaults is created for
190 if they exist, and ipy_user_conf.py with some defaults is created for
182 the user.
191 the user.
183
192
184 * Startup rehashing done by the config file, not InterpreterExec.
193 * Startup rehashing done by the config file, not InterpreterExec.
185 This means system commands are available even without selecting the
194 This means system commands are available even without selecting the
186 pysh profile. It's the sensible default after all.
195 pysh profile. It's the sensible default after all.
187
196
188 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
197 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
189
198
190 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
199 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
191 multiline code with autoindent on working. But I am really not
200 multiline code with autoindent on working. But I am really not
192 sure, so this needs more testing. Will commit a debug-enabled
201 sure, so this needs more testing. Will commit a debug-enabled
193 version for now, while I test it some more, so that Ville and
202 version for now, while I test it some more, so that Ville and
194 others may also catch any problems. Also made
203 others may also catch any problems. Also made
195 self.indent_current_str() a method, to ensure that there's no
204 self.indent_current_str() a method, to ensure that there's no
196 chance of the indent space count and the corresponding string
205 chance of the indent space count and the corresponding string
197 falling out of sync. All code needing the string should just call
206 falling out of sync. All code needing the string should just call
198 the method.
207 the method.
199
208
200 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
209 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
201
210
202 * IPython/Magic.py (magic_edit): fix check for when users don't
211 * IPython/Magic.py (magic_edit): fix check for when users don't
203 save their output files, the try/except was in the wrong section.
212 save their output files, the try/except was in the wrong section.
204
213
205 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
214 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
206
215
207 * IPython/Magic.py (magic_run): fix __file__ global missing from
216 * IPython/Magic.py (magic_run): fix __file__ global missing from
208 script's namespace when executed via %run. After a report by
217 script's namespace when executed via %run. After a report by
209 Vivian.
218 Vivian.
210
219
211 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
220 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
212 when using python 2.4. The parent constructor changed in 2.4, and
221 when using python 2.4. The parent constructor changed in 2.4, and
213 we need to track it directly (we can't call it, as it messes up
222 we need to track it directly (we can't call it, as it messes up
214 readline and tab-completion inside our pdb would stop working).
223 readline and tab-completion inside our pdb would stop working).
215 After a bug report by R. Bernstein <rocky-AT-panix.com>.
224 After a bug report by R. Bernstein <rocky-AT-panix.com>.
216
225
217 2006-01-16 Ville Vainio <vivainio@gmail.com>
226 2006-01-16 Ville Vainio <vivainio@gmail.com>
218
227
219 * Ipython/magic.py:Reverted back to old %edit functionality
228 * Ipython/magic.py:Reverted back to old %edit functionality
220 that returns file contents on exit.
229 that returns file contents on exit.
221
230
222 * IPython/path.py: Added Jason Orendorff's "path" module to
231 * IPython/path.py: Added Jason Orendorff's "path" module to
223 IPython tree, http://www.jorendorff.com/articles/python/path/.
232 IPython tree, http://www.jorendorff.com/articles/python/path/.
224 You can get path objects conveniently through %sc, and !!, e.g.:
233 You can get path objects conveniently through %sc, and !!, e.g.:
225 sc files=ls
234 sc files=ls
226 for p in files.paths: # or files.p
235 for p in files.paths: # or files.p
227 print p,p.mtime
236 print p,p.mtime
228
237
229 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
238 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
230 now work again without considering the exclusion regexp -
239 now work again without considering the exclusion regexp -
231 hence, things like ',foo my/path' turn to 'foo("my/path")'
240 hence, things like ',foo my/path' turn to 'foo("my/path")'
232 instead of syntax error.
241 instead of syntax error.
233
242
234
243
235 2006-01-14 Ville Vainio <vivainio@gmail.com>
244 2006-01-14 Ville Vainio <vivainio@gmail.com>
236
245
237 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
246 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
238 ipapi decorators for python 2.4 users, options() provides access to rc
247 ipapi decorators for python 2.4 users, options() provides access to rc
239 data.
248 data.
240
249
241 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
250 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
242 as path separators (even on Linux ;-). Space character after
251 as path separators (even on Linux ;-). Space character after
243 backslash (as yielded by tab completer) is still space;
252 backslash (as yielded by tab completer) is still space;
244 "%cd long\ name" works as expected.
253 "%cd long\ name" works as expected.
245
254
246 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
255 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
247 as "chain of command", with priority. API stays the same,
256 as "chain of command", with priority. API stays the same,
248 TryNext exception raised by a hook function signals that
257 TryNext exception raised by a hook function signals that
249 current hook failed and next hook should try handling it, as
258 current hook failed and next hook should try handling it, as
250 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
259 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
251 requested configurable display hook, which is now implemented.
260 requested configurable display hook, which is now implemented.
252
261
253 2006-01-13 Ville Vainio <vivainio@gmail.com>
262 2006-01-13 Ville Vainio <vivainio@gmail.com>
254
263
255 * IPython/platutils*.py: platform specific utility functions,
264 * IPython/platutils*.py: platform specific utility functions,
256 so far only set_term_title is implemented (change terminal
265 so far only set_term_title is implemented (change terminal
257 label in windowing systems). %cd now changes the title to
266 label in windowing systems). %cd now changes the title to
258 current dir.
267 current dir.
259
268
260 * IPython/Release.py: Added myself to "authors" list,
269 * IPython/Release.py: Added myself to "authors" list,
261 had to create new files.
270 had to create new files.
262
271
263 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
272 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
264 shell escape; not a known bug but had potential to be one in the
273 shell escape; not a known bug but had potential to be one in the
265 future.
274 future.
266
275
267 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
276 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
268 extension API for IPython! See the module for usage example. Fix
277 extension API for IPython! See the module for usage example. Fix
269 OInspect for docstring-less magic functions.
278 OInspect for docstring-less magic functions.
270
279
271
280
272 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
281 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
273
282
274 * IPython/iplib.py (raw_input): temporarily deactivate all
283 * IPython/iplib.py (raw_input): temporarily deactivate all
275 attempts at allowing pasting of code with autoindent on. It
284 attempts at allowing pasting of code with autoindent on. It
276 introduced bugs (reported by Prabhu) and I can't seem to find a
285 introduced bugs (reported by Prabhu) and I can't seem to find a
277 robust combination which works in all cases. Will have to revisit
286 robust combination which works in all cases. Will have to revisit
278 later.
287 later.
279
288
280 * IPython/genutils.py: remove isspace() function. We've dropped
289 * IPython/genutils.py: remove isspace() function. We've dropped
281 2.2 compatibility, so it's OK to use the string method.
290 2.2 compatibility, so it's OK to use the string method.
282
291
283 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
292 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
284
293
285 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
294 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
286 matching what NOT to autocall on, to include all python binary
295 matching what NOT to autocall on, to include all python binary
287 operators (including things like 'and', 'or', 'is' and 'in').
296 operators (including things like 'and', 'or', 'is' and 'in').
288 Prompted by a bug report on 'foo & bar', but I realized we had
297 Prompted by a bug report on 'foo & bar', but I realized we had
289 many more potential bug cases with other operators. The regexp is
298 many more potential bug cases with other operators. The regexp is
290 self.re_exclude_auto, it's fairly commented.
299 self.re_exclude_auto, it's fairly commented.
291
300
292 2006-01-12 Ville Vainio <vivainio@gmail.com>
301 2006-01-12 Ville Vainio <vivainio@gmail.com>
293
302
294 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
303 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
295 Prettified and hardened string/backslash quoting with ipsystem(),
304 Prettified and hardened string/backslash quoting with ipsystem(),
296 ipalias() and ipmagic(). Now even \ characters are passed to
305 ipalias() and ipmagic(). Now even \ characters are passed to
297 %magics, !shell escapes and aliases exactly as they are in the
306 %magics, !shell escapes and aliases exactly as they are in the
298 ipython command line. Should improve backslash experience,
307 ipython command line. Should improve backslash experience,
299 particularly in Windows (path delimiter for some commands that
308 particularly in Windows (path delimiter for some commands that
300 won't understand '/'), but Unix benefits as well (regexps). %cd
309 won't understand '/'), but Unix benefits as well (regexps). %cd
301 magic still doesn't support backslash path delimiters, though. Also
310 magic still doesn't support backslash path delimiters, though. Also
302 deleted all pretense of supporting multiline command strings in
311 deleted all pretense of supporting multiline command strings in
303 !system or %magic commands. Thanks to Jerry McRae for suggestions.
312 !system or %magic commands. Thanks to Jerry McRae for suggestions.
304
313
305 * doc/build_doc_instructions.txt added. Documentation on how to
314 * doc/build_doc_instructions.txt added. Documentation on how to
306 use doc/update_manual.py, added yesterday. Both files contributed
315 use doc/update_manual.py, added yesterday. Both files contributed
307 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
316 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
308 doc/*.sh for deprecation at a later date.
317 doc/*.sh for deprecation at a later date.
309
318
310 * /ipython.py Added ipython.py to root directory for
319 * /ipython.py Added ipython.py to root directory for
311 zero-installation (tar xzvf ipython.tgz; cd ipython; python
320 zero-installation (tar xzvf ipython.tgz; cd ipython; python
312 ipython.py) and development convenience (no need to kee doing
321 ipython.py) and development convenience (no need to kee doing
313 "setup.py install" between changes).
322 "setup.py install" between changes).
314
323
315 * Made ! and !! shell escapes work (again) in multiline expressions:
324 * Made ! and !! shell escapes work (again) in multiline expressions:
316 if 1:
325 if 1:
317 !ls
326 !ls
318 !!ls
327 !!ls
319
328
320 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
329 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
321
330
322 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
331 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
323 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
332 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
324 module in case-insensitive installation. Was causing crashes
333 module in case-insensitive installation. Was causing crashes
325 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
334 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
326
335
327 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
336 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
328 <marienz-AT-gentoo.org>, closes
337 <marienz-AT-gentoo.org>, closes
329 http://www.scipy.net/roundup/ipython/issue51.
338 http://www.scipy.net/roundup/ipython/issue51.
330
339
331 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
340 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
332
341
333 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
342 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
334 problem of excessive CPU usage under *nix and keyboard lag under
343 problem of excessive CPU usage under *nix and keyboard lag under
335 win32.
344 win32.
336
345
337 2006-01-10 *** Released version 0.7.0
346 2006-01-10 *** Released version 0.7.0
338
347
339 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
348 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
340
349
341 * IPython/Release.py (revision): tag version number to 0.7.0,
350 * IPython/Release.py (revision): tag version number to 0.7.0,
342 ready for release.
351 ready for release.
343
352
344 * IPython/Magic.py (magic_edit): Add print statement to %edit so
353 * IPython/Magic.py (magic_edit): Add print statement to %edit so
345 it informs the user of the name of the temp. file used. This can
354 it informs the user of the name of the temp. file used. This can
346 help if you decide later to reuse that same file, so you know
355 help if you decide later to reuse that same file, so you know
347 where to copy the info from.
356 where to copy the info from.
348
357
349 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
358 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
350
359
351 * setup_bdist_egg.py: little script to build an egg. Added
360 * setup_bdist_egg.py: little script to build an egg. Added
352 support in the release tools as well.
361 support in the release tools as well.
353
362
354 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
363 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
355
364
356 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
365 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
357 version selection (new -wxversion command line and ipythonrc
366 version selection (new -wxversion command line and ipythonrc
358 parameter). Patch contributed by Arnd Baecker
367 parameter). Patch contributed by Arnd Baecker
359 <arnd.baecker-AT-web.de>.
368 <arnd.baecker-AT-web.de>.
360
369
361 * IPython/iplib.py (embed_mainloop): fix tab-completion in
370 * IPython/iplib.py (embed_mainloop): fix tab-completion in
362 embedded instances, for variables defined at the interactive
371 embedded instances, for variables defined at the interactive
363 prompt of the embedded ipython. Reported by Arnd.
372 prompt of the embedded ipython. Reported by Arnd.
364
373
365 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
374 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
366 it can be used as a (stateful) toggle, or with a direct parameter.
375 it can be used as a (stateful) toggle, or with a direct parameter.
367
376
368 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
377 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
369 could be triggered in certain cases and cause the traceback
378 could be triggered in certain cases and cause the traceback
370 printer not to work.
379 printer not to work.
371
380
372 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
381 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
373
382
374 * IPython/iplib.py (_should_recompile): Small fix, closes
383 * IPython/iplib.py (_should_recompile): Small fix, closes
375 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
384 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
376
385
377 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
386 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
378
387
379 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
388 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
380 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
389 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
381 Moad for help with tracking it down.
390 Moad for help with tracking it down.
382
391
383 * IPython/iplib.py (handle_auto): fix autocall handling for
392 * IPython/iplib.py (handle_auto): fix autocall handling for
384 objects which support BOTH __getitem__ and __call__ (so that f [x]
393 objects which support BOTH __getitem__ and __call__ (so that f [x]
385 is left alone, instead of becoming f([x]) automatically).
394 is left alone, instead of becoming f([x]) automatically).
386
395
387 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
396 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
388 Ville's patch.
397 Ville's patch.
389
398
390 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
399 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
391
400
392 * IPython/iplib.py (handle_auto): changed autocall semantics to
401 * IPython/iplib.py (handle_auto): changed autocall semantics to
393 include 'smart' mode, where the autocall transformation is NOT
402 include 'smart' mode, where the autocall transformation is NOT
394 applied if there are no arguments on the line. This allows you to
403 applied if there are no arguments on the line. This allows you to
395 just type 'foo' if foo is a callable to see its internal form,
404 just type 'foo' if foo is a callable to see its internal form,
396 instead of having it called with no arguments (typically a
405 instead of having it called with no arguments (typically a
397 mistake). The old 'full' autocall still exists: for that, you
406 mistake). The old 'full' autocall still exists: for that, you
398 need to set the 'autocall' parameter to 2 in your ipythonrc file.
407 need to set the 'autocall' parameter to 2 in your ipythonrc file.
399
408
400 * IPython/completer.py (Completer.attr_matches): add
409 * IPython/completer.py (Completer.attr_matches): add
401 tab-completion support for Enthoughts' traits. After a report by
410 tab-completion support for Enthoughts' traits. After a report by
402 Arnd and a patch by Prabhu.
411 Arnd and a patch by Prabhu.
403
412
404 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
413 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
405
414
406 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
415 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
407 Schmolck's patch to fix inspect.getinnerframes().
416 Schmolck's patch to fix inspect.getinnerframes().
408
417
409 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
418 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
410 for embedded instances, regarding handling of namespaces and items
419 for embedded instances, regarding handling of namespaces and items
411 added to the __builtin__ one. Multiple embedded instances and
420 added to the __builtin__ one. Multiple embedded instances and
412 recursive embeddings should work better now (though I'm not sure
421 recursive embeddings should work better now (though I'm not sure
413 I've got all the corner cases fixed, that code is a bit of a brain
422 I've got all the corner cases fixed, that code is a bit of a brain
414 twister).
423 twister).
415
424
416 * IPython/Magic.py (magic_edit): added support to edit in-memory
425 * IPython/Magic.py (magic_edit): added support to edit in-memory
417 macros (automatically creates the necessary temp files). %edit
426 macros (automatically creates the necessary temp files). %edit
418 also doesn't return the file contents anymore, it's just noise.
427 also doesn't return the file contents anymore, it's just noise.
419
428
420 * IPython/completer.py (Completer.attr_matches): revert change to
429 * IPython/completer.py (Completer.attr_matches): revert change to
421 complete only on attributes listed in __all__. I realized it
430 complete only on attributes listed in __all__. I realized it
422 cripples the tab-completion system as a tool for exploring the
431 cripples the tab-completion system as a tool for exploring the
423 internals of unknown libraries (it renders any non-__all__
432 internals of unknown libraries (it renders any non-__all__
424 attribute off-limits). I got bit by this when trying to see
433 attribute off-limits). I got bit by this when trying to see
425 something inside the dis module.
434 something inside the dis module.
426
435
427 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
436 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
428
437
429 * IPython/iplib.py (InteractiveShell.__init__): add .meta
438 * IPython/iplib.py (InteractiveShell.__init__): add .meta
430 namespace for users and extension writers to hold data in. This
439 namespace for users and extension writers to hold data in. This
431 follows the discussion in
440 follows the discussion in
432 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
441 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
433
442
434 * IPython/completer.py (IPCompleter.complete): small patch to help
443 * IPython/completer.py (IPCompleter.complete): small patch to help
435 tab-completion under Emacs, after a suggestion by John Barnard
444 tab-completion under Emacs, after a suggestion by John Barnard
436 <barnarj-AT-ccf.org>.
445 <barnarj-AT-ccf.org>.
437
446
438 * IPython/Magic.py (Magic.extract_input_slices): added support for
447 * IPython/Magic.py (Magic.extract_input_slices): added support for
439 the slice notation in magics to use N-M to represent numbers N...M
448 the slice notation in magics to use N-M to represent numbers N...M
440 (closed endpoints). This is used by %macro and %save.
449 (closed endpoints). This is used by %macro and %save.
441
450
442 * IPython/completer.py (Completer.attr_matches): for modules which
451 * IPython/completer.py (Completer.attr_matches): for modules which
443 define __all__, complete only on those. After a patch by Jeffrey
452 define __all__, complete only on those. After a patch by Jeffrey
444 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
453 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
445 speed up this routine.
454 speed up this routine.
446
455
447 * IPython/Logger.py (Logger.log): fix a history handling bug. I
456 * IPython/Logger.py (Logger.log): fix a history handling bug. I
448 don't know if this is the end of it, but the behavior now is
457 don't know if this is the end of it, but the behavior now is
449 certainly much more correct. Note that coupled with macros,
458 certainly much more correct. Note that coupled with macros,
450 slightly surprising (at first) behavior may occur: a macro will in
459 slightly surprising (at first) behavior may occur: a macro will in
451 general expand to multiple lines of input, so upon exiting, the
460 general expand to multiple lines of input, so upon exiting, the
452 in/out counters will both be bumped by the corresponding amount
461 in/out counters will both be bumped by the corresponding amount
453 (as if the macro's contents had been typed interactively). Typing
462 (as if the macro's contents had been typed interactively). Typing
454 %hist will reveal the intermediate (silently processed) lines.
463 %hist will reveal the intermediate (silently processed) lines.
455
464
456 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
465 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
457 pickle to fail (%run was overwriting __main__ and not restoring
466 pickle to fail (%run was overwriting __main__ and not restoring
458 it, but pickle relies on __main__ to operate).
467 it, but pickle relies on __main__ to operate).
459
468
460 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
469 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
461 using properties, but forgot to make the main InteractiveShell
470 using properties, but forgot to make the main InteractiveShell
462 class a new-style class. Properties fail silently, and
471 class a new-style class. Properties fail silently, and
463 misteriously, with old-style class (getters work, but
472 misteriously, with old-style class (getters work, but
464 setters don't do anything).
473 setters don't do anything).
465
474
466 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
475 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
467
476
468 * IPython/Magic.py (magic_history): fix history reporting bug (I
477 * IPython/Magic.py (magic_history): fix history reporting bug (I
469 know some nasties are still there, I just can't seem to find a
478 know some nasties are still there, I just can't seem to find a
470 reproducible test case to track them down; the input history is
479 reproducible test case to track them down; the input history is
471 falling out of sync...)
480 falling out of sync...)
472
481
473 * IPython/iplib.py (handle_shell_escape): fix bug where both
482 * IPython/iplib.py (handle_shell_escape): fix bug where both
474 aliases and system accesses where broken for indented code (such
483 aliases and system accesses where broken for indented code (such
475 as loops).
484 as loops).
476
485
477 * IPython/genutils.py (shell): fix small but critical bug for
486 * IPython/genutils.py (shell): fix small but critical bug for
478 win32 system access.
487 win32 system access.
479
488
480 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
489 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
481
490
482 * IPython/iplib.py (showtraceback): remove use of the
491 * IPython/iplib.py (showtraceback): remove use of the
483 sys.last_{type/value/traceback} structures, which are non
492 sys.last_{type/value/traceback} structures, which are non
484 thread-safe.
493 thread-safe.
485 (_prefilter): change control flow to ensure that we NEVER
494 (_prefilter): change control flow to ensure that we NEVER
486 introspect objects when autocall is off. This will guarantee that
495 introspect objects when autocall is off. This will guarantee that
487 having an input line of the form 'x.y', where access to attribute
496 having an input line of the form 'x.y', where access to attribute
488 'y' has side effects, doesn't trigger the side effect TWICE. It
497 'y' has side effects, doesn't trigger the side effect TWICE. It
489 is important to note that, with autocall on, these side effects
498 is important to note that, with autocall on, these side effects
490 can still happen.
499 can still happen.
491 (ipsystem): new builtin, to complete the ip{magic/alias/system}
500 (ipsystem): new builtin, to complete the ip{magic/alias/system}
492 trio. IPython offers these three kinds of special calls which are
501 trio. IPython offers these three kinds of special calls which are
493 not python code, and it's a good thing to have their call method
502 not python code, and it's a good thing to have their call method
494 be accessible as pure python functions (not just special syntax at
503 be accessible as pure python functions (not just special syntax at
495 the command line). It gives us a better internal implementation
504 the command line). It gives us a better internal implementation
496 structure, as well as exposing these for user scripting more
505 structure, as well as exposing these for user scripting more
497 cleanly.
506 cleanly.
498
507
499 * IPython/macro.py (Macro.__init__): moved macros to a standalone
508 * IPython/macro.py (Macro.__init__): moved macros to a standalone
500 file. Now that they'll be more likely to be used with the
509 file. Now that they'll be more likely to be used with the
501 persistance system (%store), I want to make sure their module path
510 persistance system (%store), I want to make sure their module path
502 doesn't change in the future, so that we don't break things for
511 doesn't change in the future, so that we don't break things for
503 users' persisted data.
512 users' persisted data.
504
513
505 * IPython/iplib.py (autoindent_update): move indentation
514 * IPython/iplib.py (autoindent_update): move indentation
506 management into the _text_ processing loop, not the keyboard
515 management into the _text_ processing loop, not the keyboard
507 interactive one. This is necessary to correctly process non-typed
516 interactive one. This is necessary to correctly process non-typed
508 multiline input (such as macros).
517 multiline input (such as macros).
509
518
510 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
519 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
511 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
520 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
512 which was producing problems in the resulting manual.
521 which was producing problems in the resulting manual.
513 (magic_whos): improve reporting of instances (show their class,
522 (magic_whos): improve reporting of instances (show their class,
514 instead of simply printing 'instance' which isn't terribly
523 instead of simply printing 'instance' which isn't terribly
515 informative).
524 informative).
516
525
517 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
526 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
518 (minor mods) to support network shares under win32.
527 (minor mods) to support network shares under win32.
519
528
520 * IPython/winconsole.py (get_console_size): add new winconsole
529 * IPython/winconsole.py (get_console_size): add new winconsole
521 module and fixes to page_dumb() to improve its behavior under
530 module and fixes to page_dumb() to improve its behavior under
522 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
531 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
523
532
524 * IPython/Magic.py (Macro): simplified Macro class to just
533 * IPython/Magic.py (Macro): simplified Macro class to just
525 subclass list. We've had only 2.2 compatibility for a very long
534 subclass list. We've had only 2.2 compatibility for a very long
526 time, yet I was still avoiding subclassing the builtin types. No
535 time, yet I was still avoiding subclassing the builtin types. No
527 more (I'm also starting to use properties, though I won't shift to
536 more (I'm also starting to use properties, though I won't shift to
528 2.3-specific features quite yet).
537 2.3-specific features quite yet).
529 (magic_store): added Ville's patch for lightweight variable
538 (magic_store): added Ville's patch for lightweight variable
530 persistence, after a request on the user list by Matt Wilkie
539 persistence, after a request on the user list by Matt Wilkie
531 <maphew-AT-gmail.com>. The new %store magic's docstring has full
540 <maphew-AT-gmail.com>. The new %store magic's docstring has full
532 details.
541 details.
533
542
534 * IPython/iplib.py (InteractiveShell.post_config_initialization):
543 * IPython/iplib.py (InteractiveShell.post_config_initialization):
535 changed the default logfile name from 'ipython.log' to
544 changed the default logfile name from 'ipython.log' to
536 'ipython_log.py'. These logs are real python files, and now that
545 'ipython_log.py'. These logs are real python files, and now that
537 we have much better multiline support, people are more likely to
546 we have much better multiline support, people are more likely to
538 want to use them as such. Might as well name them correctly.
547 want to use them as such. Might as well name them correctly.
539
548
540 * IPython/Magic.py: substantial cleanup. While we can't stop
549 * IPython/Magic.py: substantial cleanup. While we can't stop
541 using magics as mixins, due to the existing customizations 'out
550 using magics as mixins, due to the existing customizations 'out
542 there' which rely on the mixin naming conventions, at least I
551 there' which rely on the mixin naming conventions, at least I
543 cleaned out all cross-class name usage. So once we are OK with
552 cleaned out all cross-class name usage. So once we are OK with
544 breaking compatibility, the two systems can be separated.
553 breaking compatibility, the two systems can be separated.
545
554
546 * IPython/Logger.py: major cleanup. This one is NOT a mixin
555 * IPython/Logger.py: major cleanup. This one is NOT a mixin
547 anymore, and the class is a fair bit less hideous as well. New
556 anymore, and the class is a fair bit less hideous as well. New
548 features were also introduced: timestamping of input, and logging
557 features were also introduced: timestamping of input, and logging
549 of output results. These are user-visible with the -t and -o
558 of output results. These are user-visible with the -t and -o
550 options to %logstart. Closes
559 options to %logstart. Closes
551 http://www.scipy.net/roundup/ipython/issue11 and a request by
560 http://www.scipy.net/roundup/ipython/issue11 and a request by
552 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
561 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
553
562
554 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
563 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
555
564
556 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
565 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
557 better hadnle backslashes in paths. See the thread 'More Windows
566 better hadnle backslashes in paths. See the thread 'More Windows
558 questions part 2 - \/ characters revisited' on the iypthon user
567 questions part 2 - \/ characters revisited' on the iypthon user
559 list:
568 list:
560 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
569 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
561
570
562 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
571 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
563
572
564 (InteractiveShell.__init__): change threaded shells to not use the
573 (InteractiveShell.__init__): change threaded shells to not use the
565 ipython crash handler. This was causing more problems than not,
574 ipython crash handler. This was causing more problems than not,
566 as exceptions in the main thread (GUI code, typically) would
575 as exceptions in the main thread (GUI code, typically) would
567 always show up as a 'crash', when they really weren't.
576 always show up as a 'crash', when they really weren't.
568
577
569 The colors and exception mode commands (%colors/%xmode) have been
578 The colors and exception mode commands (%colors/%xmode) have been
570 synchronized to also take this into account, so users can get
579 synchronized to also take this into account, so users can get
571 verbose exceptions for their threaded code as well. I also added
580 verbose exceptions for their threaded code as well. I also added
572 support for activating pdb inside this exception handler as well,
581 support for activating pdb inside this exception handler as well,
573 so now GUI authors can use IPython's enhanced pdb at runtime.
582 so now GUI authors can use IPython's enhanced pdb at runtime.
574
583
575 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
584 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
576 true by default, and add it to the shipped ipythonrc file. Since
585 true by default, and add it to the shipped ipythonrc file. Since
577 this asks the user before proceeding, I think it's OK to make it
586 this asks the user before proceeding, I think it's OK to make it
578 true by default.
587 true by default.
579
588
580 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
589 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
581 of the previous special-casing of input in the eval loop. I think
590 of the previous special-casing of input in the eval loop. I think
582 this is cleaner, as they really are commands and shouldn't have
591 this is cleaner, as they really are commands and shouldn't have
583 a special role in the middle of the core code.
592 a special role in the middle of the core code.
584
593
585 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
594 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
586
595
587 * IPython/iplib.py (edit_syntax_error): added support for
596 * IPython/iplib.py (edit_syntax_error): added support for
588 automatically reopening the editor if the file had a syntax error
597 automatically reopening the editor if the file had a syntax error
589 in it. Thanks to scottt who provided the patch at:
598 in it. Thanks to scottt who provided the patch at:
590 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
599 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
591 version committed).
600 version committed).
592
601
593 * IPython/iplib.py (handle_normal): add suport for multi-line
602 * IPython/iplib.py (handle_normal): add suport for multi-line
594 input with emtpy lines. This fixes
603 input with emtpy lines. This fixes
595 http://www.scipy.net/roundup/ipython/issue43 and a similar
604 http://www.scipy.net/roundup/ipython/issue43 and a similar
596 discussion on the user list.
605 discussion on the user list.
597
606
598 WARNING: a behavior change is necessarily introduced to support
607 WARNING: a behavior change is necessarily introduced to support
599 blank lines: now a single blank line with whitespace does NOT
608 blank lines: now a single blank line with whitespace does NOT
600 break the input loop, which means that when autoindent is on, by
609 break the input loop, which means that when autoindent is on, by
601 default hitting return on the next (indented) line does NOT exit.
610 default hitting return on the next (indented) line does NOT exit.
602
611
603 Instead, to exit a multiline input you can either have:
612 Instead, to exit a multiline input you can either have:
604
613
605 - TWO whitespace lines (just hit return again), or
614 - TWO whitespace lines (just hit return again), or
606 - a single whitespace line of a different length than provided
615 - a single whitespace line of a different length than provided
607 by the autoindent (add or remove a space).
616 by the autoindent (add or remove a space).
608
617
609 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
618 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
610 module to better organize all readline-related functionality.
619 module to better organize all readline-related functionality.
611 I've deleted FlexCompleter and put all completion clases here.
620 I've deleted FlexCompleter and put all completion clases here.
612
621
613 * IPython/iplib.py (raw_input): improve indentation management.
622 * IPython/iplib.py (raw_input): improve indentation management.
614 It is now possible to paste indented code with autoindent on, and
623 It is now possible to paste indented code with autoindent on, and
615 the code is interpreted correctly (though it still looks bad on
624 the code is interpreted correctly (though it still looks bad on
616 screen, due to the line-oriented nature of ipython).
625 screen, due to the line-oriented nature of ipython).
617 (MagicCompleter.complete): change behavior so that a TAB key on an
626 (MagicCompleter.complete): change behavior so that a TAB key on an
618 otherwise empty line actually inserts a tab, instead of completing
627 otherwise empty line actually inserts a tab, instead of completing
619 on the entire global namespace. This makes it easier to use the
628 on the entire global namespace. This makes it easier to use the
620 TAB key for indentation. After a request by Hans Meine
629 TAB key for indentation. After a request by Hans Meine
621 <hans_meine-AT-gmx.net>
630 <hans_meine-AT-gmx.net>
622 (_prefilter): add support so that typing plain 'exit' or 'quit'
631 (_prefilter): add support so that typing plain 'exit' or 'quit'
623 does a sensible thing. Originally I tried to deviate as little as
632 does a sensible thing. Originally I tried to deviate as little as
624 possible from the default python behavior, but even that one may
633 possible from the default python behavior, but even that one may
625 change in this direction (thread on python-dev to that effect).
634 change in this direction (thread on python-dev to that effect).
626 Regardless, ipython should do the right thing even if CPython's
635 Regardless, ipython should do the right thing even if CPython's
627 '>>>' prompt doesn't.
636 '>>>' prompt doesn't.
628 (InteractiveShell): removed subclassing code.InteractiveConsole
637 (InteractiveShell): removed subclassing code.InteractiveConsole
629 class. By now we'd overridden just about all of its methods: I've
638 class. By now we'd overridden just about all of its methods: I've
630 copied the remaining two over, and now ipython is a standalone
639 copied the remaining two over, and now ipython is a standalone
631 class. This will provide a clearer picture for the chainsaw
640 class. This will provide a clearer picture for the chainsaw
632 branch refactoring.
641 branch refactoring.
633
642
634 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
643 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
635
644
636 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
645 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
637 failures for objects which break when dir() is called on them.
646 failures for objects which break when dir() is called on them.
638
647
639 * IPython/FlexCompleter.py (Completer.__init__): Added support for
648 * IPython/FlexCompleter.py (Completer.__init__): Added support for
640 distinct local and global namespaces in the completer API. This
649 distinct local and global namespaces in the completer API. This
641 change allows us top properly handle completion with distinct
650 change allows us top properly handle completion with distinct
642 scopes, including in embedded instances (this had never really
651 scopes, including in embedded instances (this had never really
643 worked correctly).
652 worked correctly).
644
653
645 Note: this introduces a change in the constructor for
654 Note: this introduces a change in the constructor for
646 MagicCompleter, as a new global_namespace parameter is now the
655 MagicCompleter, as a new global_namespace parameter is now the
647 second argument (the others were bumped one position).
656 second argument (the others were bumped one position).
648
657
649 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
658 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
650
659
651 * IPython/iplib.py (embed_mainloop): fix tab-completion in
660 * IPython/iplib.py (embed_mainloop): fix tab-completion in
652 embedded instances (which can be done now thanks to Vivian's
661 embedded instances (which can be done now thanks to Vivian's
653 frame-handling fixes for pdb).
662 frame-handling fixes for pdb).
654 (InteractiveShell.__init__): Fix namespace handling problem in
663 (InteractiveShell.__init__): Fix namespace handling problem in
655 embedded instances. We were overwriting __main__ unconditionally,
664 embedded instances. We were overwriting __main__ unconditionally,
656 and this should only be done for 'full' (non-embedded) IPython;
665 and this should only be done for 'full' (non-embedded) IPython;
657 embedded instances must respect the caller's __main__. Thanks to
666 embedded instances must respect the caller's __main__. Thanks to
658 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
667 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
659
668
660 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
669 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
661
670
662 * setup.py: added download_url to setup(). This registers the
671 * setup.py: added download_url to setup(). This registers the
663 download address at PyPI, which is not only useful to humans
672 download address at PyPI, which is not only useful to humans
664 browsing the site, but is also picked up by setuptools (the Eggs
673 browsing the site, but is also picked up by setuptools (the Eggs
665 machinery). Thanks to Ville and R. Kern for the info/discussion
674 machinery). Thanks to Ville and R. Kern for the info/discussion
666 on this.
675 on this.
667
676
668 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
677 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
669
678
670 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
679 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
671 This brings a lot of nice functionality to the pdb mode, which now
680 This brings a lot of nice functionality to the pdb mode, which now
672 has tab-completion, syntax highlighting, and better stack handling
681 has tab-completion, syntax highlighting, and better stack handling
673 than before. Many thanks to Vivian De Smedt
682 than before. Many thanks to Vivian De Smedt
674 <vivian-AT-vdesmedt.com> for the original patches.
683 <vivian-AT-vdesmedt.com> for the original patches.
675
684
676 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
685 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
677
686
678 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
687 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
679 sequence to consistently accept the banner argument. The
688 sequence to consistently accept the banner argument. The
680 inconsistency was tripping SAGE, thanks to Gary Zablackis
689 inconsistency was tripping SAGE, thanks to Gary Zablackis
681 <gzabl-AT-yahoo.com> for the report.
690 <gzabl-AT-yahoo.com> for the report.
682
691
683 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
692 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
684
693
685 * IPython/iplib.py (InteractiveShell.post_config_initialization):
694 * IPython/iplib.py (InteractiveShell.post_config_initialization):
686 Fix bug where a naked 'alias' call in the ipythonrc file would
695 Fix bug where a naked 'alias' call in the ipythonrc file would
687 cause a crash. Bug reported by Jorgen Stenarson.
696 cause a crash. Bug reported by Jorgen Stenarson.
688
697
689 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
698 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
690
699
691 * IPython/ipmaker.py (make_IPython): cleanups which should improve
700 * IPython/ipmaker.py (make_IPython): cleanups which should improve
692 startup time.
701 startup time.
693
702
694 * IPython/iplib.py (runcode): my globals 'fix' for embedded
703 * IPython/iplib.py (runcode): my globals 'fix' for embedded
695 instances had introduced a bug with globals in normal code. Now
704 instances had introduced a bug with globals in normal code. Now
696 it's working in all cases.
705 it's working in all cases.
697
706
698 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
707 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
699 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
708 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
700 has been introduced to set the default case sensitivity of the
709 has been introduced to set the default case sensitivity of the
701 searches. Users can still select either mode at runtime on a
710 searches. Users can still select either mode at runtime on a
702 per-search basis.
711 per-search basis.
703
712
704 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
713 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
705
714
706 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
715 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
707 attributes in wildcard searches for subclasses. Modified version
716 attributes in wildcard searches for subclasses. Modified version
708 of a patch by Jorgen.
717 of a patch by Jorgen.
709
718
710 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
719 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
711
720
712 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
721 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
713 embedded instances. I added a user_global_ns attribute to the
722 embedded instances. I added a user_global_ns attribute to the
714 InteractiveShell class to handle this.
723 InteractiveShell class to handle this.
715
724
716 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
725 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
717
726
718 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
727 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
719 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
728 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
720 (reported under win32, but may happen also in other platforms).
729 (reported under win32, but may happen also in other platforms).
721 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
730 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
722
731
723 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
732 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
724
733
725 * IPython/Magic.py (magic_psearch): new support for wildcard
734 * IPython/Magic.py (magic_psearch): new support for wildcard
726 patterns. Now, typing ?a*b will list all names which begin with a
735 patterns. Now, typing ?a*b will list all names which begin with a
727 and end in b, for example. The %psearch magic has full
736 and end in b, for example. The %psearch magic has full
728 docstrings. Many thanks to JΓΆrgen Stenarson
737 docstrings. Many thanks to JΓΆrgen Stenarson
729 <jorgen.stenarson-AT-bostream.nu>, author of the patches
738 <jorgen.stenarson-AT-bostream.nu>, author of the patches
730 implementing this functionality.
739 implementing this functionality.
731
740
732 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
741 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
733
742
734 * Manual: fixed long-standing annoyance of double-dashes (as in
743 * Manual: fixed long-standing annoyance of double-dashes (as in
735 --prefix=~, for example) being stripped in the HTML version. This
744 --prefix=~, for example) being stripped in the HTML version. This
736 is a latex2html bug, but a workaround was provided. Many thanks
745 is a latex2html bug, but a workaround was provided. Many thanks
737 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
746 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
738 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
747 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
739 rolling. This seemingly small issue had tripped a number of users
748 rolling. This seemingly small issue had tripped a number of users
740 when first installing, so I'm glad to see it gone.
749 when first installing, so I'm glad to see it gone.
741
750
742 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
751 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
743
752
744 * IPython/Extensions/numeric_formats.py: fix missing import,
753 * IPython/Extensions/numeric_formats.py: fix missing import,
745 reported by Stephen Walton.
754 reported by Stephen Walton.
746
755
747 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
756 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
748
757
749 * IPython/demo.py: finish demo module, fully documented now.
758 * IPython/demo.py: finish demo module, fully documented now.
750
759
751 * IPython/genutils.py (file_read): simple little utility to read a
760 * IPython/genutils.py (file_read): simple little utility to read a
752 file and ensure it's closed afterwards.
761 file and ensure it's closed afterwards.
753
762
754 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
763 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
755
764
756 * IPython/demo.py (Demo.__init__): added support for individually
765 * IPython/demo.py (Demo.__init__): added support for individually
757 tagging blocks for automatic execution.
766 tagging blocks for automatic execution.
758
767
759 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
768 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
760 syntax-highlighted python sources, requested by John.
769 syntax-highlighted python sources, requested by John.
761
770
762 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
771 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
763
772
764 * IPython/demo.py (Demo.again): fix bug where again() blocks after
773 * IPython/demo.py (Demo.again): fix bug where again() blocks after
765 finishing.
774 finishing.
766
775
767 * IPython/genutils.py (shlex_split): moved from Magic to here,
776 * IPython/genutils.py (shlex_split): moved from Magic to here,
768 where all 2.2 compatibility stuff lives. I needed it for demo.py.
777 where all 2.2 compatibility stuff lives. I needed it for demo.py.
769
778
770 * IPython/demo.py (Demo.__init__): added support for silent
779 * IPython/demo.py (Demo.__init__): added support for silent
771 blocks, improved marks as regexps, docstrings written.
780 blocks, improved marks as regexps, docstrings written.
772 (Demo.__init__): better docstring, added support for sys.argv.
781 (Demo.__init__): better docstring, added support for sys.argv.
773
782
774 * IPython/genutils.py (marquee): little utility used by the demo
783 * IPython/genutils.py (marquee): little utility used by the demo
775 code, handy in general.
784 code, handy in general.
776
785
777 * IPython/demo.py (Demo.__init__): new class for interactive
786 * IPython/demo.py (Demo.__init__): new class for interactive
778 demos. Not documented yet, I just wrote it in a hurry for
787 demos. Not documented yet, I just wrote it in a hurry for
779 scipy'05. Will docstring later.
788 scipy'05. Will docstring later.
780
789
781 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
790 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
782
791
783 * IPython/Shell.py (sigint_handler): Drastic simplification which
792 * IPython/Shell.py (sigint_handler): Drastic simplification which
784 also seems to make Ctrl-C work correctly across threads! This is
793 also seems to make Ctrl-C work correctly across threads! This is
785 so simple, that I can't beleive I'd missed it before. Needs more
794 so simple, that I can't beleive I'd missed it before. Needs more
786 testing, though.
795 testing, though.
787 (KBINT): Never mind, revert changes. I'm sure I'd tried something
796 (KBINT): Never mind, revert changes. I'm sure I'd tried something
788 like this before...
797 like this before...
789
798
790 * IPython/genutils.py (get_home_dir): add protection against
799 * IPython/genutils.py (get_home_dir): add protection against
791 non-dirs in win32 registry.
800 non-dirs in win32 registry.
792
801
793 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
802 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
794 bug where dict was mutated while iterating (pysh crash).
803 bug where dict was mutated while iterating (pysh crash).
795
804
796 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
805 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
797
806
798 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
807 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
799 spurious newlines added by this routine. After a report by
808 spurious newlines added by this routine. After a report by
800 F. Mantegazza.
809 F. Mantegazza.
801
810
802 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
811 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
803
812
804 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
813 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
805 calls. These were a leftover from the GTK 1.x days, and can cause
814 calls. These were a leftover from the GTK 1.x days, and can cause
806 problems in certain cases (after a report by John Hunter).
815 problems in certain cases (after a report by John Hunter).
807
816
808 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
817 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
809 os.getcwd() fails at init time. Thanks to patch from David Remahl
818 os.getcwd() fails at init time. Thanks to patch from David Remahl
810 <chmod007-AT-mac.com>.
819 <chmod007-AT-mac.com>.
811 (InteractiveShell.__init__): prevent certain special magics from
820 (InteractiveShell.__init__): prevent certain special magics from
812 being shadowed by aliases. Closes
821 being shadowed by aliases. Closes
813 http://www.scipy.net/roundup/ipython/issue41.
822 http://www.scipy.net/roundup/ipython/issue41.
814
823
815 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
824 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
816
825
817 * IPython/iplib.py (InteractiveShell.complete): Added new
826 * IPython/iplib.py (InteractiveShell.complete): Added new
818 top-level completion method to expose the completion mechanism
827 top-level completion method to expose the completion mechanism
819 beyond readline-based environments.
828 beyond readline-based environments.
820
829
821 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
830 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
822
831
823 * tools/ipsvnc (svnversion): fix svnversion capture.
832 * tools/ipsvnc (svnversion): fix svnversion capture.
824
833
825 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
834 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
826 attribute to self, which was missing. Before, it was set by a
835 attribute to self, which was missing. Before, it was set by a
827 routine which in certain cases wasn't being called, so the
836 routine which in certain cases wasn't being called, so the
828 instance could end up missing the attribute. This caused a crash.
837 instance could end up missing the attribute. This caused a crash.
829 Closes http://www.scipy.net/roundup/ipython/issue40.
838 Closes http://www.scipy.net/roundup/ipython/issue40.
830
839
831 2005-08-16 Fernando Perez <fperez@colorado.edu>
840 2005-08-16 Fernando Perez <fperez@colorado.edu>
832
841
833 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
842 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
834 contains non-string attribute. Closes
843 contains non-string attribute. Closes
835 http://www.scipy.net/roundup/ipython/issue38.
844 http://www.scipy.net/roundup/ipython/issue38.
836
845
837 2005-08-14 Fernando Perez <fperez@colorado.edu>
846 2005-08-14 Fernando Perez <fperez@colorado.edu>
838
847
839 * tools/ipsvnc: Minor improvements, to add changeset info.
848 * tools/ipsvnc: Minor improvements, to add changeset info.
840
849
841 2005-08-12 Fernando Perez <fperez@colorado.edu>
850 2005-08-12 Fernando Perez <fperez@colorado.edu>
842
851
843 * IPython/iplib.py (runsource): remove self.code_to_run_src
852 * IPython/iplib.py (runsource): remove self.code_to_run_src
844 attribute. I realized this is nothing more than
853 attribute. I realized this is nothing more than
845 '\n'.join(self.buffer), and having the same data in two different
854 '\n'.join(self.buffer), and having the same data in two different
846 places is just asking for synchronization bugs. This may impact
855 places is just asking for synchronization bugs. This may impact
847 people who have custom exception handlers, so I need to warn
856 people who have custom exception handlers, so I need to warn
848 ipython-dev about it (F. Mantegazza may use them).
857 ipython-dev about it (F. Mantegazza may use them).
849
858
850 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
859 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
851
860
852 * IPython/genutils.py: fix 2.2 compatibility (generators)
861 * IPython/genutils.py: fix 2.2 compatibility (generators)
853
862
854 2005-07-18 Fernando Perez <fperez@colorado.edu>
863 2005-07-18 Fernando Perez <fperez@colorado.edu>
855
864
856 * IPython/genutils.py (get_home_dir): fix to help users with
865 * IPython/genutils.py (get_home_dir): fix to help users with
857 invalid $HOME under win32.
866 invalid $HOME under win32.
858
867
859 2005-07-17 Fernando Perez <fperez@colorado.edu>
868 2005-07-17 Fernando Perez <fperez@colorado.edu>
860
869
861 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
870 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
862 some old hacks and clean up a bit other routines; code should be
871 some old hacks and clean up a bit other routines; code should be
863 simpler and a bit faster.
872 simpler and a bit faster.
864
873
865 * IPython/iplib.py (interact): removed some last-resort attempts
874 * IPython/iplib.py (interact): removed some last-resort attempts
866 to survive broken stdout/stderr. That code was only making it
875 to survive broken stdout/stderr. That code was only making it
867 harder to abstract out the i/o (necessary for gui integration),
876 harder to abstract out the i/o (necessary for gui integration),
868 and the crashes it could prevent were extremely rare in practice
877 and the crashes it could prevent were extremely rare in practice
869 (besides being fully user-induced in a pretty violent manner).
878 (besides being fully user-induced in a pretty violent manner).
870
879
871 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
880 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
872 Nothing major yet, but the code is simpler to read; this should
881 Nothing major yet, but the code is simpler to read; this should
873 make it easier to do more serious modifications in the future.
882 make it easier to do more serious modifications in the future.
874
883
875 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
884 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
876 which broke in .15 (thanks to a report by Ville).
885 which broke in .15 (thanks to a report by Ville).
877
886
878 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
887 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
879 be quite correct, I know next to nothing about unicode). This
888 be quite correct, I know next to nothing about unicode). This
880 will allow unicode strings to be used in prompts, amongst other
889 will allow unicode strings to be used in prompts, amongst other
881 cases. It also will prevent ipython from crashing when unicode
890 cases. It also will prevent ipython from crashing when unicode
882 shows up unexpectedly in many places. If ascii encoding fails, we
891 shows up unexpectedly in many places. If ascii encoding fails, we
883 assume utf_8. Currently the encoding is not a user-visible
892 assume utf_8. Currently the encoding is not a user-visible
884 setting, though it could be made so if there is demand for it.
893 setting, though it could be made so if there is demand for it.
885
894
886 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
895 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
887
896
888 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
897 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
889
898
890 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
899 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
891
900
892 * IPython/genutils.py: Add 2.2 compatibility here, so all other
901 * IPython/genutils.py: Add 2.2 compatibility here, so all other
893 code can work transparently for 2.2/2.3.
902 code can work transparently for 2.2/2.3.
894
903
895 2005-07-16 Fernando Perez <fperez@colorado.edu>
904 2005-07-16 Fernando Perez <fperez@colorado.edu>
896
905
897 * IPython/ultraTB.py (ExceptionColors): Make a global variable
906 * IPython/ultraTB.py (ExceptionColors): Make a global variable
898 out of the color scheme table used for coloring exception
907 out of the color scheme table used for coloring exception
899 tracebacks. This allows user code to add new schemes at runtime.
908 tracebacks. This allows user code to add new schemes at runtime.
900 This is a minimally modified version of the patch at
909 This is a minimally modified version of the patch at
901 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
910 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
902 for the contribution.
911 for the contribution.
903
912
904 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
913 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
905 slightly modified version of the patch in
914 slightly modified version of the patch in
906 http://www.scipy.net/roundup/ipython/issue34, which also allows me
915 http://www.scipy.net/roundup/ipython/issue34, which also allows me
907 to remove the previous try/except solution (which was costlier).
916 to remove the previous try/except solution (which was costlier).
908 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
917 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
909
918
910 2005-06-08 Fernando Perez <fperez@colorado.edu>
919 2005-06-08 Fernando Perez <fperez@colorado.edu>
911
920
912 * IPython/iplib.py (write/write_err): Add methods to abstract all
921 * IPython/iplib.py (write/write_err): Add methods to abstract all
913 I/O a bit more.
922 I/O a bit more.
914
923
915 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
924 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
916 warning, reported by Aric Hagberg, fix by JD Hunter.
925 warning, reported by Aric Hagberg, fix by JD Hunter.
917
926
918 2005-06-02 *** Released version 0.6.15
927 2005-06-02 *** Released version 0.6.15
919
928
920 2005-06-01 Fernando Perez <fperez@colorado.edu>
929 2005-06-01 Fernando Perez <fperez@colorado.edu>
921
930
922 * IPython/iplib.py (MagicCompleter.file_matches): Fix
931 * IPython/iplib.py (MagicCompleter.file_matches): Fix
923 tab-completion of filenames within open-quoted strings. Note that
932 tab-completion of filenames within open-quoted strings. Note that
924 this requires that in ~/.ipython/ipythonrc, users change the
933 this requires that in ~/.ipython/ipythonrc, users change the
925 readline delimiters configuration to read:
934 readline delimiters configuration to read:
926
935
927 readline_remove_delims -/~
936 readline_remove_delims -/~
928
937
929
938
930 2005-05-31 *** Released version 0.6.14
939 2005-05-31 *** Released version 0.6.14
931
940
932 2005-05-29 Fernando Perez <fperez@colorado.edu>
941 2005-05-29 Fernando Perez <fperez@colorado.edu>
933
942
934 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
943 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
935 with files not on the filesystem. Reported by Eliyahu Sandler
944 with files not on the filesystem. Reported by Eliyahu Sandler
936 <eli@gondolin.net>
945 <eli@gondolin.net>
937
946
938 2005-05-22 Fernando Perez <fperez@colorado.edu>
947 2005-05-22 Fernando Perez <fperez@colorado.edu>
939
948
940 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
949 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
941 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
950 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
942
951
943 2005-05-19 Fernando Perez <fperez@colorado.edu>
952 2005-05-19 Fernando Perez <fperez@colorado.edu>
944
953
945 * IPython/iplib.py (safe_execfile): close a file which could be
954 * IPython/iplib.py (safe_execfile): close a file which could be
946 left open (causing problems in win32, which locks open files).
955 left open (causing problems in win32, which locks open files).
947 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
956 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
948
957
949 2005-05-18 Fernando Perez <fperez@colorado.edu>
958 2005-05-18 Fernando Perez <fperez@colorado.edu>
950
959
951 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
960 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
952 keyword arguments correctly to safe_execfile().
961 keyword arguments correctly to safe_execfile().
953
962
954 2005-05-13 Fernando Perez <fperez@colorado.edu>
963 2005-05-13 Fernando Perez <fperez@colorado.edu>
955
964
956 * ipython.1: Added info about Qt to manpage, and threads warning
965 * ipython.1: Added info about Qt to manpage, and threads warning
957 to usage page (invoked with --help).
966 to usage page (invoked with --help).
958
967
959 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
968 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
960 new matcher (it goes at the end of the priority list) to do
969 new matcher (it goes at the end of the priority list) to do
961 tab-completion on named function arguments. Submitted by George
970 tab-completion on named function arguments. Submitted by George
962 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
971 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
963 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
972 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
964 for more details.
973 for more details.
965
974
966 * IPython/Magic.py (magic_run): Added new -e flag to ignore
975 * IPython/Magic.py (magic_run): Added new -e flag to ignore
967 SystemExit exceptions in the script being run. Thanks to a report
976 SystemExit exceptions in the script being run. Thanks to a report
968 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
977 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
969 producing very annoying behavior when running unit tests.
978 producing very annoying behavior when running unit tests.
970
979
971 2005-05-12 Fernando Perez <fperez@colorado.edu>
980 2005-05-12 Fernando Perez <fperez@colorado.edu>
972
981
973 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
982 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
974 which I'd broken (again) due to a changed regexp. In the process,
983 which I'd broken (again) due to a changed regexp. In the process,
975 added ';' as an escape to auto-quote the whole line without
984 added ';' as an escape to auto-quote the whole line without
976 splitting its arguments. Thanks to a report by Jerry McRae
985 splitting its arguments. Thanks to a report by Jerry McRae
977 <qrs0xyc02-AT-sneakemail.com>.
986 <qrs0xyc02-AT-sneakemail.com>.
978
987
979 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
988 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
980 possible crashes caused by a TokenError. Reported by Ed Schofield
989 possible crashes caused by a TokenError. Reported by Ed Schofield
981 <schofield-AT-ftw.at>.
990 <schofield-AT-ftw.at>.
982
991
983 2005-05-06 Fernando Perez <fperez@colorado.edu>
992 2005-05-06 Fernando Perez <fperez@colorado.edu>
984
993
985 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
994 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
986
995
987 2005-04-29 Fernando Perez <fperez@colorado.edu>
996 2005-04-29 Fernando Perez <fperez@colorado.edu>
988
997
989 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
998 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
990 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
999 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
991 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
1000 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
992 which provides support for Qt interactive usage (similar to the
1001 which provides support for Qt interactive usage (similar to the
993 existing one for WX and GTK). This had been often requested.
1002 existing one for WX and GTK). This had been often requested.
994
1003
995 2005-04-14 *** Released version 0.6.13
1004 2005-04-14 *** Released version 0.6.13
996
1005
997 2005-04-08 Fernando Perez <fperez@colorado.edu>
1006 2005-04-08 Fernando Perez <fperez@colorado.edu>
998
1007
999 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
1008 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
1000 from _ofind, which gets called on almost every input line. Now,
1009 from _ofind, which gets called on almost every input line. Now,
1001 we only try to get docstrings if they are actually going to be
1010 we only try to get docstrings if they are actually going to be
1002 used (the overhead of fetching unnecessary docstrings can be
1011 used (the overhead of fetching unnecessary docstrings can be
1003 noticeable for certain objects, such as Pyro proxies).
1012 noticeable for certain objects, such as Pyro proxies).
1004
1013
1005 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
1014 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
1006 for completers. For some reason I had been passing them the state
1015 for completers. For some reason I had been passing them the state
1007 variable, which completers never actually need, and was in
1016 variable, which completers never actually need, and was in
1008 conflict with the rlcompleter API. Custom completers ONLY need to
1017 conflict with the rlcompleter API. Custom completers ONLY need to
1009 take the text parameter.
1018 take the text parameter.
1010
1019
1011 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
1020 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
1012 work correctly in pysh. I've also moved all the logic which used
1021 work correctly in pysh. I've also moved all the logic which used
1013 to be in pysh.py here, which will prevent problems with future
1022 to be in pysh.py here, which will prevent problems with future
1014 upgrades. However, this time I must warn users to update their
1023 upgrades. However, this time I must warn users to update their
1015 pysh profile to include the line
1024 pysh profile to include the line
1016
1025
1017 import_all IPython.Extensions.InterpreterExec
1026 import_all IPython.Extensions.InterpreterExec
1018
1027
1019 because otherwise things won't work for them. They MUST also
1028 because otherwise things won't work for them. They MUST also
1020 delete pysh.py and the line
1029 delete pysh.py and the line
1021
1030
1022 execfile pysh.py
1031 execfile pysh.py
1023
1032
1024 from their ipythonrc-pysh.
1033 from their ipythonrc-pysh.
1025
1034
1026 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
1035 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
1027 robust in the face of objects whose dir() returns non-strings
1036 robust in the face of objects whose dir() returns non-strings
1028 (which it shouldn't, but some broken libs like ITK do). Thanks to
1037 (which it shouldn't, but some broken libs like ITK do). Thanks to
1029 a patch by John Hunter (implemented differently, though). Also
1038 a patch by John Hunter (implemented differently, though). Also
1030 minor improvements by using .extend instead of + on lists.
1039 minor improvements by using .extend instead of + on lists.
1031
1040
1032 * pysh.py:
1041 * pysh.py:
1033
1042
1034 2005-04-06 Fernando Perez <fperez@colorado.edu>
1043 2005-04-06 Fernando Perez <fperez@colorado.edu>
1035
1044
1036 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
1045 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
1037 by default, so that all users benefit from it. Those who don't
1046 by default, so that all users benefit from it. Those who don't
1038 want it can still turn it off.
1047 want it can still turn it off.
1039
1048
1040 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
1049 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
1041 config file, I'd forgotten about this, so users were getting it
1050 config file, I'd forgotten about this, so users were getting it
1042 off by default.
1051 off by default.
1043
1052
1044 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
1053 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
1045 consistency. Now magics can be called in multiline statements,
1054 consistency. Now magics can be called in multiline statements,
1046 and python variables can be expanded in magic calls via $var.
1055 and python variables can be expanded in magic calls via $var.
1047 This makes the magic system behave just like aliases or !system
1056 This makes the magic system behave just like aliases or !system
1048 calls.
1057 calls.
1049
1058
1050 2005-03-28 Fernando Perez <fperez@colorado.edu>
1059 2005-03-28 Fernando Perez <fperez@colorado.edu>
1051
1060
1052 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
1061 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
1053 expensive string additions for building command. Add support for
1062 expensive string additions for building command. Add support for
1054 trailing ';' when autocall is used.
1063 trailing ';' when autocall is used.
1055
1064
1056 2005-03-26 Fernando Perez <fperez@colorado.edu>
1065 2005-03-26 Fernando Perez <fperez@colorado.edu>
1057
1066
1058 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
1067 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
1059 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
1068 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
1060 ipython.el robust against prompts with any number of spaces
1069 ipython.el robust against prompts with any number of spaces
1061 (including 0) after the ':' character.
1070 (including 0) after the ':' character.
1062
1071
1063 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
1072 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
1064 continuation prompt, which misled users to think the line was
1073 continuation prompt, which misled users to think the line was
1065 already indented. Closes debian Bug#300847, reported to me by
1074 already indented. Closes debian Bug#300847, reported to me by
1066 Norbert Tretkowski <tretkowski-AT-inittab.de>.
1075 Norbert Tretkowski <tretkowski-AT-inittab.de>.
1067
1076
1068 2005-03-23 Fernando Perez <fperez@colorado.edu>
1077 2005-03-23 Fernando Perez <fperez@colorado.edu>
1069
1078
1070 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
1079 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
1071 properly aligned if they have embedded newlines.
1080 properly aligned if they have embedded newlines.
1072
1081
1073 * IPython/iplib.py (runlines): Add a public method to expose
1082 * IPython/iplib.py (runlines): Add a public method to expose
1074 IPython's code execution machinery, so that users can run strings
1083 IPython's code execution machinery, so that users can run strings
1075 as if they had been typed at the prompt interactively.
1084 as if they had been typed at the prompt interactively.
1076 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
1085 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
1077 methods which can call the system shell, but with python variable
1086 methods which can call the system shell, but with python variable
1078 expansion. The three such methods are: __IPYTHON__.system,
1087 expansion. The three such methods are: __IPYTHON__.system,
1079 .getoutput and .getoutputerror. These need to be documented in a
1088 .getoutput and .getoutputerror. These need to be documented in a
1080 'public API' section (to be written) of the manual.
1089 'public API' section (to be written) of the manual.
1081
1090
1082 2005-03-20 Fernando Perez <fperez@colorado.edu>
1091 2005-03-20 Fernando Perez <fperez@colorado.edu>
1083
1092
1084 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
1093 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
1085 for custom exception handling. This is quite powerful, and it
1094 for custom exception handling. This is quite powerful, and it
1086 allows for user-installable exception handlers which can trap
1095 allows for user-installable exception handlers which can trap
1087 custom exceptions at runtime and treat them separately from
1096 custom exceptions at runtime and treat them separately from
1088 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1097 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1089 Mantegazza <mantegazza-AT-ill.fr>.
1098 Mantegazza <mantegazza-AT-ill.fr>.
1090 (InteractiveShell.set_custom_completer): public API function to
1099 (InteractiveShell.set_custom_completer): public API function to
1091 add new completers at runtime.
1100 add new completers at runtime.
1092
1101
1093 2005-03-19 Fernando Perez <fperez@colorado.edu>
1102 2005-03-19 Fernando Perez <fperez@colorado.edu>
1094
1103
1095 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1104 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1096 allow objects which provide their docstrings via non-standard
1105 allow objects which provide their docstrings via non-standard
1097 mechanisms (like Pyro proxies) to still be inspected by ipython's
1106 mechanisms (like Pyro proxies) to still be inspected by ipython's
1098 ? system.
1107 ? system.
1099
1108
1100 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1109 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1101 automatic capture system. I tried quite hard to make it work
1110 automatic capture system. I tried quite hard to make it work
1102 reliably, and simply failed. I tried many combinations with the
1111 reliably, and simply failed. I tried many combinations with the
1103 subprocess module, but eventually nothing worked in all needed
1112 subprocess module, but eventually nothing worked in all needed
1104 cases (not blocking stdin for the child, duplicating stdout
1113 cases (not blocking stdin for the child, duplicating stdout
1105 without blocking, etc). The new %sc/%sx still do capture to these
1114 without blocking, etc). The new %sc/%sx still do capture to these
1106 magical list/string objects which make shell use much more
1115 magical list/string objects which make shell use much more
1107 conveninent, so not all is lost.
1116 conveninent, so not all is lost.
1108
1117
1109 XXX - FIX MANUAL for the change above!
1118 XXX - FIX MANUAL for the change above!
1110
1119
1111 (runsource): I copied code.py's runsource() into ipython to modify
1120 (runsource): I copied code.py's runsource() into ipython to modify
1112 it a bit. Now the code object and source to be executed are
1121 it a bit. Now the code object and source to be executed are
1113 stored in ipython. This makes this info accessible to third-party
1122 stored in ipython. This makes this info accessible to third-party
1114 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
1123 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
1115 Mantegazza <mantegazza-AT-ill.fr>.
1124 Mantegazza <mantegazza-AT-ill.fr>.
1116
1125
1117 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
1126 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
1118 history-search via readline (like C-p/C-n). I'd wanted this for a
1127 history-search via readline (like C-p/C-n). I'd wanted this for a
1119 long time, but only recently found out how to do it. For users
1128 long time, but only recently found out how to do it. For users
1120 who already have their ipythonrc files made and want this, just
1129 who already have their ipythonrc files made and want this, just
1121 add:
1130 add:
1122
1131
1123 readline_parse_and_bind "\e[A": history-search-backward
1132 readline_parse_and_bind "\e[A": history-search-backward
1124 readline_parse_and_bind "\e[B": history-search-forward
1133 readline_parse_and_bind "\e[B": history-search-forward
1125
1134
1126 2005-03-18 Fernando Perez <fperez@colorado.edu>
1135 2005-03-18 Fernando Perez <fperez@colorado.edu>
1127
1136
1128 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
1137 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
1129 LSString and SList classes which allow transparent conversions
1138 LSString and SList classes which allow transparent conversions
1130 between list mode and whitespace-separated string.
1139 between list mode and whitespace-separated string.
1131 (magic_r): Fix recursion problem in %r.
1140 (magic_r): Fix recursion problem in %r.
1132
1141
1133 * IPython/genutils.py (LSString): New class to be used for
1142 * IPython/genutils.py (LSString): New class to be used for
1134 automatic storage of the results of all alias/system calls in _o
1143 automatic storage of the results of all alias/system calls in _o
1135 and _e (stdout/err). These provide a .l/.list attribute which
1144 and _e (stdout/err). These provide a .l/.list attribute which
1136 does automatic splitting on newlines. This means that for most
1145 does automatic splitting on newlines. This means that for most
1137 uses, you'll never need to do capturing of output with %sc/%sx
1146 uses, you'll never need to do capturing of output with %sc/%sx
1138 anymore, since ipython keeps this always done for you. Note that
1147 anymore, since ipython keeps this always done for you. Note that
1139 only the LAST results are stored, the _o/e variables are
1148 only the LAST results are stored, the _o/e variables are
1140 overwritten on each call. If you need to save their contents
1149 overwritten on each call. If you need to save their contents
1141 further, simply bind them to any other name.
1150 further, simply bind them to any other name.
1142
1151
1143 2005-03-17 Fernando Perez <fperez@colorado.edu>
1152 2005-03-17 Fernando Perez <fperez@colorado.edu>
1144
1153
1145 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
1154 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
1146 prompt namespace handling.
1155 prompt namespace handling.
1147
1156
1148 2005-03-16 Fernando Perez <fperez@colorado.edu>
1157 2005-03-16 Fernando Perez <fperez@colorado.edu>
1149
1158
1150 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
1159 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
1151 classic prompts to be '>>> ' (final space was missing, and it
1160 classic prompts to be '>>> ' (final space was missing, and it
1152 trips the emacs python mode).
1161 trips the emacs python mode).
1153 (BasePrompt.__str__): Added safe support for dynamic prompt
1162 (BasePrompt.__str__): Added safe support for dynamic prompt
1154 strings. Now you can set your prompt string to be '$x', and the
1163 strings. Now you can set your prompt string to be '$x', and the
1155 value of x will be printed from your interactive namespace. The
1164 value of x will be printed from your interactive namespace. The
1156 interpolation syntax includes the full Itpl support, so
1165 interpolation syntax includes the full Itpl support, so
1157 ${foo()+x+bar()} is a valid prompt string now, and the function
1166 ${foo()+x+bar()} is a valid prompt string now, and the function
1158 calls will be made at runtime.
1167 calls will be made at runtime.
1159
1168
1160 2005-03-15 Fernando Perez <fperez@colorado.edu>
1169 2005-03-15 Fernando Perez <fperez@colorado.edu>
1161
1170
1162 * IPython/Magic.py (magic_history): renamed %hist to %history, to
1171 * IPython/Magic.py (magic_history): renamed %hist to %history, to
1163 avoid name clashes in pylab. %hist still works, it just forwards
1172 avoid name clashes in pylab. %hist still works, it just forwards
1164 the call to %history.
1173 the call to %history.
1165
1174
1166 2005-03-02 *** Released version 0.6.12
1175 2005-03-02 *** Released version 0.6.12
1167
1176
1168 2005-03-02 Fernando Perez <fperez@colorado.edu>
1177 2005-03-02 Fernando Perez <fperez@colorado.edu>
1169
1178
1170 * IPython/iplib.py (handle_magic): log magic calls properly as
1179 * IPython/iplib.py (handle_magic): log magic calls properly as
1171 ipmagic() function calls.
1180 ipmagic() function calls.
1172
1181
1173 * IPython/Magic.py (magic_time): Improved %time to support
1182 * IPython/Magic.py (magic_time): Improved %time to support
1174 statements and provide wall-clock as well as CPU time.
1183 statements and provide wall-clock as well as CPU time.
1175
1184
1176 2005-02-27 Fernando Perez <fperez@colorado.edu>
1185 2005-02-27 Fernando Perez <fperez@colorado.edu>
1177
1186
1178 * IPython/hooks.py: New hooks module, to expose user-modifiable
1187 * IPython/hooks.py: New hooks module, to expose user-modifiable
1179 IPython functionality in a clean manner. For now only the editor
1188 IPython functionality in a clean manner. For now only the editor
1180 hook is actually written, and other thigns which I intend to turn
1189 hook is actually written, and other thigns which I intend to turn
1181 into proper hooks aren't yet there. The display and prefilter
1190 into proper hooks aren't yet there. The display and prefilter
1182 stuff, for example, should be hooks. But at least now the
1191 stuff, for example, should be hooks. But at least now the
1183 framework is in place, and the rest can be moved here with more
1192 framework is in place, and the rest can be moved here with more
1184 time later. IPython had had a .hooks variable for a long time for
1193 time later. IPython had had a .hooks variable for a long time for
1185 this purpose, but I'd never actually used it for anything.
1194 this purpose, but I'd never actually used it for anything.
1186
1195
1187 2005-02-26 Fernando Perez <fperez@colorado.edu>
1196 2005-02-26 Fernando Perez <fperez@colorado.edu>
1188
1197
1189 * IPython/ipmaker.py (make_IPython): make the default ipython
1198 * IPython/ipmaker.py (make_IPython): make the default ipython
1190 directory be called _ipython under win32, to follow more the
1199 directory be called _ipython under win32, to follow more the
1191 naming peculiarities of that platform (where buggy software like
1200 naming peculiarities of that platform (where buggy software like
1192 Visual Sourcesafe breaks with .named directories). Reported by
1201 Visual Sourcesafe breaks with .named directories). Reported by
1193 Ville Vainio.
1202 Ville Vainio.
1194
1203
1195 2005-02-23 Fernando Perez <fperez@colorado.edu>
1204 2005-02-23 Fernando Perez <fperez@colorado.edu>
1196
1205
1197 * IPython/iplib.py (InteractiveShell.__init__): removed a few
1206 * IPython/iplib.py (InteractiveShell.__init__): removed a few
1198 auto_aliases for win32 which were causing problems. Users can
1207 auto_aliases for win32 which were causing problems. Users can
1199 define the ones they personally like.
1208 define the ones they personally like.
1200
1209
1201 2005-02-21 Fernando Perez <fperez@colorado.edu>
1210 2005-02-21 Fernando Perez <fperez@colorado.edu>
1202
1211
1203 * IPython/Magic.py (magic_time): new magic to time execution of
1212 * IPython/Magic.py (magic_time): new magic to time execution of
1204 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
1213 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
1205
1214
1206 2005-02-19 Fernando Perez <fperez@colorado.edu>
1215 2005-02-19 Fernando Perez <fperez@colorado.edu>
1207
1216
1208 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
1217 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
1209 into keys (for prompts, for example).
1218 into keys (for prompts, for example).
1210
1219
1211 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
1220 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
1212 prompts in case users want them. This introduces a small behavior
1221 prompts in case users want them. This introduces a small behavior
1213 change: ipython does not automatically add a space to all prompts
1222 change: ipython does not automatically add a space to all prompts
1214 anymore. To get the old prompts with a space, users should add it
1223 anymore. To get the old prompts with a space, users should add it
1215 manually to their ipythonrc file, so for example prompt_in1 should
1224 manually to their ipythonrc file, so for example prompt_in1 should
1216 now read 'In [\#]: ' instead of 'In [\#]:'.
1225 now read 'In [\#]: ' instead of 'In [\#]:'.
1217 (BasePrompt.__init__): New option prompts_pad_left (only in rc
1226 (BasePrompt.__init__): New option prompts_pad_left (only in rc
1218 file) to control left-padding of secondary prompts.
1227 file) to control left-padding of secondary prompts.
1219
1228
1220 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
1229 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
1221 the profiler can't be imported. Fix for Debian, which removed
1230 the profiler can't be imported. Fix for Debian, which removed
1222 profile.py because of License issues. I applied a slightly
1231 profile.py because of License issues. I applied a slightly
1223 modified version of the original Debian patch at
1232 modified version of the original Debian patch at
1224 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
1233 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
1225
1234
1226 2005-02-17 Fernando Perez <fperez@colorado.edu>
1235 2005-02-17 Fernando Perez <fperez@colorado.edu>
1227
1236
1228 * IPython/genutils.py (native_line_ends): Fix bug which would
1237 * IPython/genutils.py (native_line_ends): Fix bug which would
1229 cause improper line-ends under win32 b/c I was not opening files
1238 cause improper line-ends under win32 b/c I was not opening files
1230 in binary mode. Bug report and fix thanks to Ville.
1239 in binary mode. Bug report and fix thanks to Ville.
1231
1240
1232 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
1241 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
1233 trying to catch spurious foo[1] autocalls. My fix actually broke
1242 trying to catch spurious foo[1] autocalls. My fix actually broke
1234 ',/' autoquote/call with explicit escape (bad regexp).
1243 ',/' autoquote/call with explicit escape (bad regexp).
1235
1244
1236 2005-02-15 *** Released version 0.6.11
1245 2005-02-15 *** Released version 0.6.11
1237
1246
1238 2005-02-14 Fernando Perez <fperez@colorado.edu>
1247 2005-02-14 Fernando Perez <fperez@colorado.edu>
1239
1248
1240 * IPython/background_jobs.py: New background job management
1249 * IPython/background_jobs.py: New background job management
1241 subsystem. This is implemented via a new set of classes, and
1250 subsystem. This is implemented via a new set of classes, and
1242 IPython now provides a builtin 'jobs' object for background job
1251 IPython now provides a builtin 'jobs' object for background job
1243 execution. A convenience %bg magic serves as a lightweight
1252 execution. A convenience %bg magic serves as a lightweight
1244 frontend for starting the more common type of calls. This was
1253 frontend for starting the more common type of calls. This was
1245 inspired by discussions with B. Granger and the BackgroundCommand
1254 inspired by discussions with B. Granger and the BackgroundCommand
1246 class described in the book Python Scripting for Computational
1255 class described in the book Python Scripting for Computational
1247 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
1256 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
1248 (although ultimately no code from this text was used, as IPython's
1257 (although ultimately no code from this text was used, as IPython's
1249 system is a separate implementation).
1258 system is a separate implementation).
1250
1259
1251 * IPython/iplib.py (MagicCompleter.python_matches): add new option
1260 * IPython/iplib.py (MagicCompleter.python_matches): add new option
1252 to control the completion of single/double underscore names
1261 to control the completion of single/double underscore names
1253 separately. As documented in the example ipytonrc file, the
1262 separately. As documented in the example ipytonrc file, the
1254 readline_omit__names variable can now be set to 2, to omit even
1263 readline_omit__names variable can now be set to 2, to omit even
1255 single underscore names. Thanks to a patch by Brian Wong
1264 single underscore names. Thanks to a patch by Brian Wong
1256 <BrianWong-AT-AirgoNetworks.Com>.
1265 <BrianWong-AT-AirgoNetworks.Com>.
1257 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
1266 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
1258 be autocalled as foo([1]) if foo were callable. A problem for
1267 be autocalled as foo([1]) if foo were callable. A problem for
1259 things which are both callable and implement __getitem__.
1268 things which are both callable and implement __getitem__.
1260 (init_readline): Fix autoindentation for win32. Thanks to a patch
1269 (init_readline): Fix autoindentation for win32. Thanks to a patch
1261 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
1270 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
1262
1271
1263 2005-02-12 Fernando Perez <fperez@colorado.edu>
1272 2005-02-12 Fernando Perez <fperez@colorado.edu>
1264
1273
1265 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
1274 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
1266 which I had written long ago to sort out user error messages which
1275 which I had written long ago to sort out user error messages which
1267 may occur during startup. This seemed like a good idea initially,
1276 may occur during startup. This seemed like a good idea initially,
1268 but it has proven a disaster in retrospect. I don't want to
1277 but it has proven a disaster in retrospect. I don't want to
1269 change much code for now, so my fix is to set the internal 'debug'
1278 change much code for now, so my fix is to set the internal 'debug'
1270 flag to true everywhere, whose only job was precisely to control
1279 flag to true everywhere, whose only job was precisely to control
1271 this subsystem. This closes issue 28 (as well as avoiding all
1280 this subsystem. This closes issue 28 (as well as avoiding all
1272 sorts of strange hangups which occur from time to time).
1281 sorts of strange hangups which occur from time to time).
1273
1282
1274 2005-02-07 Fernando Perez <fperez@colorado.edu>
1283 2005-02-07 Fernando Perez <fperez@colorado.edu>
1275
1284
1276 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1285 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1277 previous call produced a syntax error.
1286 previous call produced a syntax error.
1278
1287
1279 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1288 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1280 classes without constructor.
1289 classes without constructor.
1281
1290
1282 2005-02-06 Fernando Perez <fperez@colorado.edu>
1291 2005-02-06 Fernando Perez <fperez@colorado.edu>
1283
1292
1284 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1293 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1285 completions with the results of each matcher, so we return results
1294 completions with the results of each matcher, so we return results
1286 to the user from all namespaces. This breaks with ipython
1295 to the user from all namespaces. This breaks with ipython
1287 tradition, but I think it's a nicer behavior. Now you get all
1296 tradition, but I think it's a nicer behavior. Now you get all
1288 possible completions listed, from all possible namespaces (python,
1297 possible completions listed, from all possible namespaces (python,
1289 filesystem, magics...) After a request by John Hunter
1298 filesystem, magics...) After a request by John Hunter
1290 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1299 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1291
1300
1292 2005-02-05 Fernando Perez <fperez@colorado.edu>
1301 2005-02-05 Fernando Perez <fperez@colorado.edu>
1293
1302
1294 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1303 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1295 the call had quote characters in it (the quotes were stripped).
1304 the call had quote characters in it (the quotes were stripped).
1296
1305
1297 2005-01-31 Fernando Perez <fperez@colorado.edu>
1306 2005-01-31 Fernando Perez <fperez@colorado.edu>
1298
1307
1299 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1308 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1300 Itpl.itpl() to make the code more robust against psyco
1309 Itpl.itpl() to make the code more robust against psyco
1301 optimizations.
1310 optimizations.
1302
1311
1303 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1312 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1304 of causing an exception. Quicker, cleaner.
1313 of causing an exception. Quicker, cleaner.
1305
1314
1306 2005-01-28 Fernando Perez <fperez@colorado.edu>
1315 2005-01-28 Fernando Perez <fperez@colorado.edu>
1307
1316
1308 * scripts/ipython_win_post_install.py (install): hardcode
1317 * scripts/ipython_win_post_install.py (install): hardcode
1309 sys.prefix+'python.exe' as the executable path. It turns out that
1318 sys.prefix+'python.exe' as the executable path. It turns out that
1310 during the post-installation run, sys.executable resolves to the
1319 during the post-installation run, sys.executable resolves to the
1311 name of the binary installer! I should report this as a distutils
1320 name of the binary installer! I should report this as a distutils
1312 bug, I think. I updated the .10 release with this tiny fix, to
1321 bug, I think. I updated the .10 release with this tiny fix, to
1313 avoid annoying the lists further.
1322 avoid annoying the lists further.
1314
1323
1315 2005-01-27 *** Released version 0.6.10
1324 2005-01-27 *** Released version 0.6.10
1316
1325
1317 2005-01-27 Fernando Perez <fperez@colorado.edu>
1326 2005-01-27 Fernando Perez <fperez@colorado.edu>
1318
1327
1319 * IPython/numutils.py (norm): Added 'inf' as optional name for
1328 * IPython/numutils.py (norm): Added 'inf' as optional name for
1320 L-infinity norm, included references to mathworld.com for vector
1329 L-infinity norm, included references to mathworld.com for vector
1321 norm definitions.
1330 norm definitions.
1322 (amin/amax): added amin/amax for array min/max. Similar to what
1331 (amin/amax): added amin/amax for array min/max. Similar to what
1323 pylab ships with after the recent reorganization of names.
1332 pylab ships with after the recent reorganization of names.
1324 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1333 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1325
1334
1326 * ipython.el: committed Alex's recent fixes and improvements.
1335 * ipython.el: committed Alex's recent fixes and improvements.
1327 Tested with python-mode from CVS, and it looks excellent. Since
1336 Tested with python-mode from CVS, and it looks excellent. Since
1328 python-mode hasn't released anything in a while, I'm temporarily
1337 python-mode hasn't released anything in a while, I'm temporarily
1329 putting a copy of today's CVS (v 4.70) of python-mode in:
1338 putting a copy of today's CVS (v 4.70) of python-mode in:
1330 http://ipython.scipy.org/tmp/python-mode.el
1339 http://ipython.scipy.org/tmp/python-mode.el
1331
1340
1332 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1341 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1333 sys.executable for the executable name, instead of assuming it's
1342 sys.executable for the executable name, instead of assuming it's
1334 called 'python.exe' (the post-installer would have produced broken
1343 called 'python.exe' (the post-installer would have produced broken
1335 setups on systems with a differently named python binary).
1344 setups on systems with a differently named python binary).
1336
1345
1337 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1346 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1338 references to os.linesep, to make the code more
1347 references to os.linesep, to make the code more
1339 platform-independent. This is also part of the win32 coloring
1348 platform-independent. This is also part of the win32 coloring
1340 fixes.
1349 fixes.
1341
1350
1342 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1351 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1343 lines, which actually cause coloring bugs because the length of
1352 lines, which actually cause coloring bugs because the length of
1344 the line is very difficult to correctly compute with embedded
1353 the line is very difficult to correctly compute with embedded
1345 escapes. This was the source of all the coloring problems under
1354 escapes. This was the source of all the coloring problems under
1346 Win32. I think that _finally_, Win32 users have a properly
1355 Win32. I think that _finally_, Win32 users have a properly
1347 working ipython in all respects. This would never have happened
1356 working ipython in all respects. This would never have happened
1348 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1357 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1349
1358
1350 2005-01-26 *** Released version 0.6.9
1359 2005-01-26 *** Released version 0.6.9
1351
1360
1352 2005-01-25 Fernando Perez <fperez@colorado.edu>
1361 2005-01-25 Fernando Perez <fperez@colorado.edu>
1353
1362
1354 * setup.py: finally, we have a true Windows installer, thanks to
1363 * setup.py: finally, we have a true Windows installer, thanks to
1355 the excellent work of Viktor Ransmayr
1364 the excellent work of Viktor Ransmayr
1356 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1365 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1357 Windows users. The setup routine is quite a bit cleaner thanks to
1366 Windows users. The setup routine is quite a bit cleaner thanks to
1358 this, and the post-install script uses the proper functions to
1367 this, and the post-install script uses the proper functions to
1359 allow a clean de-installation using the standard Windows Control
1368 allow a clean de-installation using the standard Windows Control
1360 Panel.
1369 Panel.
1361
1370
1362 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1371 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1363 environment variable under all OSes (including win32) if
1372 environment variable under all OSes (including win32) if
1364 available. This will give consistency to win32 users who have set
1373 available. This will give consistency to win32 users who have set
1365 this variable for any reason. If os.environ['HOME'] fails, the
1374 this variable for any reason. If os.environ['HOME'] fails, the
1366 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1375 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1367
1376
1368 2005-01-24 Fernando Perez <fperez@colorado.edu>
1377 2005-01-24 Fernando Perez <fperez@colorado.edu>
1369
1378
1370 * IPython/numutils.py (empty_like): add empty_like(), similar to
1379 * IPython/numutils.py (empty_like): add empty_like(), similar to
1371 zeros_like() but taking advantage of the new empty() Numeric routine.
1380 zeros_like() but taking advantage of the new empty() Numeric routine.
1372
1381
1373 2005-01-23 *** Released version 0.6.8
1382 2005-01-23 *** Released version 0.6.8
1374
1383
1375 2005-01-22 Fernando Perez <fperez@colorado.edu>
1384 2005-01-22 Fernando Perez <fperez@colorado.edu>
1376
1385
1377 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1386 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1378 automatic show() calls. After discussing things with JDH, it
1387 automatic show() calls. After discussing things with JDH, it
1379 turns out there are too many corner cases where this can go wrong.
1388 turns out there are too many corner cases where this can go wrong.
1380 It's best not to try to be 'too smart', and simply have ipython
1389 It's best not to try to be 'too smart', and simply have ipython
1381 reproduce as much as possible the default behavior of a normal
1390 reproduce as much as possible the default behavior of a normal
1382 python shell.
1391 python shell.
1383
1392
1384 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1393 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1385 line-splitting regexp and _prefilter() to avoid calling getattr()
1394 line-splitting regexp and _prefilter() to avoid calling getattr()
1386 on assignments. This closes
1395 on assignments. This closes
1387 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1396 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1388 readline uses getattr(), so a simple <TAB> keypress is still
1397 readline uses getattr(), so a simple <TAB> keypress is still
1389 enough to trigger getattr() calls on an object.
1398 enough to trigger getattr() calls on an object.
1390
1399
1391 2005-01-21 Fernando Perez <fperez@colorado.edu>
1400 2005-01-21 Fernando Perez <fperez@colorado.edu>
1392
1401
1393 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1402 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1394 docstring under pylab so it doesn't mask the original.
1403 docstring under pylab so it doesn't mask the original.
1395
1404
1396 2005-01-21 *** Released version 0.6.7
1405 2005-01-21 *** Released version 0.6.7
1397
1406
1398 2005-01-21 Fernando Perez <fperez@colorado.edu>
1407 2005-01-21 Fernando Perez <fperez@colorado.edu>
1399
1408
1400 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1409 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1401 signal handling for win32 users in multithreaded mode.
1410 signal handling for win32 users in multithreaded mode.
1402
1411
1403 2005-01-17 Fernando Perez <fperez@colorado.edu>
1412 2005-01-17 Fernando Perez <fperez@colorado.edu>
1404
1413
1405 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1414 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1406 instances with no __init__. After a crash report by Norbert Nemec
1415 instances with no __init__. After a crash report by Norbert Nemec
1407 <Norbert-AT-nemec-online.de>.
1416 <Norbert-AT-nemec-online.de>.
1408
1417
1409 2005-01-14 Fernando Perez <fperez@colorado.edu>
1418 2005-01-14 Fernando Perez <fperez@colorado.edu>
1410
1419
1411 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1420 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1412 names for verbose exceptions, when multiple dotted names and the
1421 names for verbose exceptions, when multiple dotted names and the
1413 'parent' object were present on the same line.
1422 'parent' object were present on the same line.
1414
1423
1415 2005-01-11 Fernando Perez <fperez@colorado.edu>
1424 2005-01-11 Fernando Perez <fperez@colorado.edu>
1416
1425
1417 * IPython/genutils.py (flag_calls): new utility to trap and flag
1426 * IPython/genutils.py (flag_calls): new utility to trap and flag
1418 calls in functions. I need it to clean up matplotlib support.
1427 calls in functions. I need it to clean up matplotlib support.
1419 Also removed some deprecated code in genutils.
1428 Also removed some deprecated code in genutils.
1420
1429
1421 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1430 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1422 that matplotlib scripts called with %run, which don't call show()
1431 that matplotlib scripts called with %run, which don't call show()
1423 themselves, still have their plotting windows open.
1432 themselves, still have their plotting windows open.
1424
1433
1425 2005-01-05 Fernando Perez <fperez@colorado.edu>
1434 2005-01-05 Fernando Perez <fperez@colorado.edu>
1426
1435
1427 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1436 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1428 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1437 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1429
1438
1430 2004-12-19 Fernando Perez <fperez@colorado.edu>
1439 2004-12-19 Fernando Perez <fperez@colorado.edu>
1431
1440
1432 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1441 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1433 parent_runcode, which was an eyesore. The same result can be
1442 parent_runcode, which was an eyesore. The same result can be
1434 obtained with Python's regular superclass mechanisms.
1443 obtained with Python's regular superclass mechanisms.
1435
1444
1436 2004-12-17 Fernando Perez <fperez@colorado.edu>
1445 2004-12-17 Fernando Perez <fperez@colorado.edu>
1437
1446
1438 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1447 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1439 reported by Prabhu.
1448 reported by Prabhu.
1440 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1449 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1441 sys.stderr) instead of explicitly calling sys.stderr. This helps
1450 sys.stderr) instead of explicitly calling sys.stderr. This helps
1442 maintain our I/O abstractions clean, for future GUI embeddings.
1451 maintain our I/O abstractions clean, for future GUI embeddings.
1443
1452
1444 * IPython/genutils.py (info): added new utility for sys.stderr
1453 * IPython/genutils.py (info): added new utility for sys.stderr
1445 unified info message handling (thin wrapper around warn()).
1454 unified info message handling (thin wrapper around warn()).
1446
1455
1447 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1456 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1448 composite (dotted) names on verbose exceptions.
1457 composite (dotted) names on verbose exceptions.
1449 (VerboseTB.nullrepr): harden against another kind of errors which
1458 (VerboseTB.nullrepr): harden against another kind of errors which
1450 Python's inspect module can trigger, and which were crashing
1459 Python's inspect module can trigger, and which were crashing
1451 IPython. Thanks to a report by Marco Lombardi
1460 IPython. Thanks to a report by Marco Lombardi
1452 <mlombard-AT-ma010192.hq.eso.org>.
1461 <mlombard-AT-ma010192.hq.eso.org>.
1453
1462
1454 2004-12-13 *** Released version 0.6.6
1463 2004-12-13 *** Released version 0.6.6
1455
1464
1456 2004-12-12 Fernando Perez <fperez@colorado.edu>
1465 2004-12-12 Fernando Perez <fperez@colorado.edu>
1457
1466
1458 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1467 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1459 generated by pygtk upon initialization if it was built without
1468 generated by pygtk upon initialization if it was built without
1460 threads (for matplotlib users). After a crash reported by
1469 threads (for matplotlib users). After a crash reported by
1461 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1470 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1462
1471
1463 * IPython/ipmaker.py (make_IPython): fix small bug in the
1472 * IPython/ipmaker.py (make_IPython): fix small bug in the
1464 import_some parameter for multiple imports.
1473 import_some parameter for multiple imports.
1465
1474
1466 * IPython/iplib.py (ipmagic): simplified the interface of
1475 * IPython/iplib.py (ipmagic): simplified the interface of
1467 ipmagic() to take a single string argument, just as it would be
1476 ipmagic() to take a single string argument, just as it would be
1468 typed at the IPython cmd line.
1477 typed at the IPython cmd line.
1469 (ipalias): Added new ipalias() with an interface identical to
1478 (ipalias): Added new ipalias() with an interface identical to
1470 ipmagic(). This completes exposing a pure python interface to the
1479 ipmagic(). This completes exposing a pure python interface to the
1471 alias and magic system, which can be used in loops or more complex
1480 alias and magic system, which can be used in loops or more complex
1472 code where IPython's automatic line mangling is not active.
1481 code where IPython's automatic line mangling is not active.
1473
1482
1474 * IPython/genutils.py (timing): changed interface of timing to
1483 * IPython/genutils.py (timing): changed interface of timing to
1475 simply run code once, which is the most common case. timings()
1484 simply run code once, which is the most common case. timings()
1476 remains unchanged, for the cases where you want multiple runs.
1485 remains unchanged, for the cases where you want multiple runs.
1477
1486
1478 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1487 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1479 bug where Python2.2 crashes with exec'ing code which does not end
1488 bug where Python2.2 crashes with exec'ing code which does not end
1480 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1489 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1481 before.
1490 before.
1482
1491
1483 2004-12-10 Fernando Perez <fperez@colorado.edu>
1492 2004-12-10 Fernando Perez <fperez@colorado.edu>
1484
1493
1485 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1494 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1486 -t to -T, to accomodate the new -t flag in %run (the %run and
1495 -t to -T, to accomodate the new -t flag in %run (the %run and
1487 %prun options are kind of intermixed, and it's not easy to change
1496 %prun options are kind of intermixed, and it's not easy to change
1488 this with the limitations of python's getopt).
1497 this with the limitations of python's getopt).
1489
1498
1490 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1499 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1491 the execution of scripts. It's not as fine-tuned as timeit.py,
1500 the execution of scripts. It's not as fine-tuned as timeit.py,
1492 but it works from inside ipython (and under 2.2, which lacks
1501 but it works from inside ipython (and under 2.2, which lacks
1493 timeit.py). Optionally a number of runs > 1 can be given for
1502 timeit.py). Optionally a number of runs > 1 can be given for
1494 timing very short-running code.
1503 timing very short-running code.
1495
1504
1496 * IPython/genutils.py (uniq_stable): new routine which returns a
1505 * IPython/genutils.py (uniq_stable): new routine which returns a
1497 list of unique elements in any iterable, but in stable order of
1506 list of unique elements in any iterable, but in stable order of
1498 appearance. I needed this for the ultraTB fixes, and it's a handy
1507 appearance. I needed this for the ultraTB fixes, and it's a handy
1499 utility.
1508 utility.
1500
1509
1501 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1510 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1502 dotted names in Verbose exceptions. This had been broken since
1511 dotted names in Verbose exceptions. This had been broken since
1503 the very start, now x.y will properly be printed in a Verbose
1512 the very start, now x.y will properly be printed in a Verbose
1504 traceback, instead of x being shown and y appearing always as an
1513 traceback, instead of x being shown and y appearing always as an
1505 'undefined global'. Getting this to work was a bit tricky,
1514 'undefined global'. Getting this to work was a bit tricky,
1506 because by default python tokenizers are stateless. Saved by
1515 because by default python tokenizers are stateless. Saved by
1507 python's ability to easily add a bit of state to an arbitrary
1516 python's ability to easily add a bit of state to an arbitrary
1508 function (without needing to build a full-blown callable object).
1517 function (without needing to build a full-blown callable object).
1509
1518
1510 Also big cleanup of this code, which had horrendous runtime
1519 Also big cleanup of this code, which had horrendous runtime
1511 lookups of zillions of attributes for colorization. Moved all
1520 lookups of zillions of attributes for colorization. Moved all
1512 this code into a few templates, which make it cleaner and quicker.
1521 this code into a few templates, which make it cleaner and quicker.
1513
1522
1514 Printout quality was also improved for Verbose exceptions: one
1523 Printout quality was also improved for Verbose exceptions: one
1515 variable per line, and memory addresses are printed (this can be
1524 variable per line, and memory addresses are printed (this can be
1516 quite handy in nasty debugging situations, which is what Verbose
1525 quite handy in nasty debugging situations, which is what Verbose
1517 is for).
1526 is for).
1518
1527
1519 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1528 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1520 the command line as scripts to be loaded by embedded instances.
1529 the command line as scripts to be loaded by embedded instances.
1521 Doing so has the potential for an infinite recursion if there are
1530 Doing so has the potential for an infinite recursion if there are
1522 exceptions thrown in the process. This fixes a strange crash
1531 exceptions thrown in the process. This fixes a strange crash
1523 reported by Philippe MULLER <muller-AT-irit.fr>.
1532 reported by Philippe MULLER <muller-AT-irit.fr>.
1524
1533
1525 2004-12-09 Fernando Perez <fperez@colorado.edu>
1534 2004-12-09 Fernando Perez <fperez@colorado.edu>
1526
1535
1527 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1536 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1528 to reflect new names in matplotlib, which now expose the
1537 to reflect new names in matplotlib, which now expose the
1529 matlab-compatible interface via a pylab module instead of the
1538 matlab-compatible interface via a pylab module instead of the
1530 'matlab' name. The new code is backwards compatible, so users of
1539 'matlab' name. The new code is backwards compatible, so users of
1531 all matplotlib versions are OK. Patch by J. Hunter.
1540 all matplotlib versions are OK. Patch by J. Hunter.
1532
1541
1533 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1542 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1534 of __init__ docstrings for instances (class docstrings are already
1543 of __init__ docstrings for instances (class docstrings are already
1535 automatically printed). Instances with customized docstrings
1544 automatically printed). Instances with customized docstrings
1536 (indep. of the class) are also recognized and all 3 separate
1545 (indep. of the class) are also recognized and all 3 separate
1537 docstrings are printed (instance, class, constructor). After some
1546 docstrings are printed (instance, class, constructor). After some
1538 comments/suggestions by J. Hunter.
1547 comments/suggestions by J. Hunter.
1539
1548
1540 2004-12-05 Fernando Perez <fperez@colorado.edu>
1549 2004-12-05 Fernando Perez <fperez@colorado.edu>
1541
1550
1542 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1551 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1543 warnings when tab-completion fails and triggers an exception.
1552 warnings when tab-completion fails and triggers an exception.
1544
1553
1545 2004-12-03 Fernando Perez <fperez@colorado.edu>
1554 2004-12-03 Fernando Perez <fperez@colorado.edu>
1546
1555
1547 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1556 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1548 be triggered when using 'run -p'. An incorrect option flag was
1557 be triggered when using 'run -p'. An incorrect option flag was
1549 being set ('d' instead of 'D').
1558 being set ('d' instead of 'D').
1550 (manpage): fix missing escaped \- sign.
1559 (manpage): fix missing escaped \- sign.
1551
1560
1552 2004-11-30 *** Released version 0.6.5
1561 2004-11-30 *** Released version 0.6.5
1553
1562
1554 2004-11-30 Fernando Perez <fperez@colorado.edu>
1563 2004-11-30 Fernando Perez <fperez@colorado.edu>
1555
1564
1556 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1565 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1557 setting with -d option.
1566 setting with -d option.
1558
1567
1559 * setup.py (docfiles): Fix problem where the doc glob I was using
1568 * setup.py (docfiles): Fix problem where the doc glob I was using
1560 was COMPLETELY BROKEN. It was giving the right files by pure
1569 was COMPLETELY BROKEN. It was giving the right files by pure
1561 accident, but failed once I tried to include ipython.el. Note:
1570 accident, but failed once I tried to include ipython.el. Note:
1562 glob() does NOT allow you to do exclusion on multiple endings!
1571 glob() does NOT allow you to do exclusion on multiple endings!
1563
1572
1564 2004-11-29 Fernando Perez <fperez@colorado.edu>
1573 2004-11-29 Fernando Perez <fperez@colorado.edu>
1565
1574
1566 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1575 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1567 the manpage as the source. Better formatting & consistency.
1576 the manpage as the source. Better formatting & consistency.
1568
1577
1569 * IPython/Magic.py (magic_run): Added new -d option, to run
1578 * IPython/Magic.py (magic_run): Added new -d option, to run
1570 scripts under the control of the python pdb debugger. Note that
1579 scripts under the control of the python pdb debugger. Note that
1571 this required changing the %prun option -d to -D, to avoid a clash
1580 this required changing the %prun option -d to -D, to avoid a clash
1572 (since %run must pass options to %prun, and getopt is too dumb to
1581 (since %run must pass options to %prun, and getopt is too dumb to
1573 handle options with string values with embedded spaces). Thanks
1582 handle options with string values with embedded spaces). Thanks
1574 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1583 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1575 (magic_who_ls): added type matching to %who and %whos, so that one
1584 (magic_who_ls): added type matching to %who and %whos, so that one
1576 can filter their output to only include variables of certain
1585 can filter their output to only include variables of certain
1577 types. Another suggestion by Matthew.
1586 types. Another suggestion by Matthew.
1578 (magic_whos): Added memory summaries in kb and Mb for arrays.
1587 (magic_whos): Added memory summaries in kb and Mb for arrays.
1579 (magic_who): Improve formatting (break lines every 9 vars).
1588 (magic_who): Improve formatting (break lines every 9 vars).
1580
1589
1581 2004-11-28 Fernando Perez <fperez@colorado.edu>
1590 2004-11-28 Fernando Perez <fperez@colorado.edu>
1582
1591
1583 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1592 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1584 cache when empty lines were present.
1593 cache when empty lines were present.
1585
1594
1586 2004-11-24 Fernando Perez <fperez@colorado.edu>
1595 2004-11-24 Fernando Perez <fperez@colorado.edu>
1587
1596
1588 * IPython/usage.py (__doc__): document the re-activated threading
1597 * IPython/usage.py (__doc__): document the re-activated threading
1589 options for WX and GTK.
1598 options for WX and GTK.
1590
1599
1591 2004-11-23 Fernando Perez <fperez@colorado.edu>
1600 2004-11-23 Fernando Perez <fperez@colorado.edu>
1592
1601
1593 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1602 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1594 the -wthread and -gthread options, along with a new -tk one to try
1603 the -wthread and -gthread options, along with a new -tk one to try
1595 and coordinate Tk threading with wx/gtk. The tk support is very
1604 and coordinate Tk threading with wx/gtk. The tk support is very
1596 platform dependent, since it seems to require Tcl and Tk to be
1605 platform dependent, since it seems to require Tcl and Tk to be
1597 built with threads (Fedora1/2 appears NOT to have it, but in
1606 built with threads (Fedora1/2 appears NOT to have it, but in
1598 Prabhu's Debian boxes it works OK). But even with some Tk
1607 Prabhu's Debian boxes it works OK). But even with some Tk
1599 limitations, this is a great improvement.
1608 limitations, this is a great improvement.
1600
1609
1601 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1610 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1602 info in user prompts. Patch by Prabhu.
1611 info in user prompts. Patch by Prabhu.
1603
1612
1604 2004-11-18 Fernando Perez <fperez@colorado.edu>
1613 2004-11-18 Fernando Perez <fperez@colorado.edu>
1605
1614
1606 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1615 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1607 EOFErrors and bail, to avoid infinite loops if a non-terminating
1616 EOFErrors and bail, to avoid infinite loops if a non-terminating
1608 file is fed into ipython. Patch submitted in issue 19 by user,
1617 file is fed into ipython. Patch submitted in issue 19 by user,
1609 many thanks.
1618 many thanks.
1610
1619
1611 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1620 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1612 autoquote/parens in continuation prompts, which can cause lots of
1621 autoquote/parens in continuation prompts, which can cause lots of
1613 problems. Closes roundup issue 20.
1622 problems. Closes roundup issue 20.
1614
1623
1615 2004-11-17 Fernando Perez <fperez@colorado.edu>
1624 2004-11-17 Fernando Perez <fperez@colorado.edu>
1616
1625
1617 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1626 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1618 reported as debian bug #280505. I'm not sure my local changelog
1627 reported as debian bug #280505. I'm not sure my local changelog
1619 entry has the proper debian format (Jack?).
1628 entry has the proper debian format (Jack?).
1620
1629
1621 2004-11-08 *** Released version 0.6.4
1630 2004-11-08 *** Released version 0.6.4
1622
1631
1623 2004-11-08 Fernando Perez <fperez@colorado.edu>
1632 2004-11-08 Fernando Perez <fperez@colorado.edu>
1624
1633
1625 * IPython/iplib.py (init_readline): Fix exit message for Windows
1634 * IPython/iplib.py (init_readline): Fix exit message for Windows
1626 when readline is active. Thanks to a report by Eric Jones
1635 when readline is active. Thanks to a report by Eric Jones
1627 <eric-AT-enthought.com>.
1636 <eric-AT-enthought.com>.
1628
1637
1629 2004-11-07 Fernando Perez <fperez@colorado.edu>
1638 2004-11-07 Fernando Perez <fperez@colorado.edu>
1630
1639
1631 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1640 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1632 sometimes seen by win2k/cygwin users.
1641 sometimes seen by win2k/cygwin users.
1633
1642
1634 2004-11-06 Fernando Perez <fperez@colorado.edu>
1643 2004-11-06 Fernando Perez <fperez@colorado.edu>
1635
1644
1636 * IPython/iplib.py (interact): Change the handling of %Exit from
1645 * IPython/iplib.py (interact): Change the handling of %Exit from
1637 trying to propagate a SystemExit to an internal ipython flag.
1646 trying to propagate a SystemExit to an internal ipython flag.
1638 This is less elegant than using Python's exception mechanism, but
1647 This is less elegant than using Python's exception mechanism, but
1639 I can't get that to work reliably with threads, so under -pylab
1648 I can't get that to work reliably with threads, so under -pylab
1640 %Exit was hanging IPython. Cross-thread exception handling is
1649 %Exit was hanging IPython. Cross-thread exception handling is
1641 really a bitch. Thaks to a bug report by Stephen Walton
1650 really a bitch. Thaks to a bug report by Stephen Walton
1642 <stephen.walton-AT-csun.edu>.
1651 <stephen.walton-AT-csun.edu>.
1643
1652
1644 2004-11-04 Fernando Perez <fperez@colorado.edu>
1653 2004-11-04 Fernando Perez <fperez@colorado.edu>
1645
1654
1646 * IPython/iplib.py (raw_input_original): store a pointer to the
1655 * IPython/iplib.py (raw_input_original): store a pointer to the
1647 true raw_input to harden against code which can modify it
1656 true raw_input to harden against code which can modify it
1648 (wx.py.PyShell does this and would otherwise crash ipython).
1657 (wx.py.PyShell does this and would otherwise crash ipython).
1649 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1658 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1650
1659
1651 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1660 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1652 Ctrl-C problem, which does not mess up the input line.
1661 Ctrl-C problem, which does not mess up the input line.
1653
1662
1654 2004-11-03 Fernando Perez <fperez@colorado.edu>
1663 2004-11-03 Fernando Perez <fperez@colorado.edu>
1655
1664
1656 * IPython/Release.py: Changed licensing to BSD, in all files.
1665 * IPython/Release.py: Changed licensing to BSD, in all files.
1657 (name): lowercase name for tarball/RPM release.
1666 (name): lowercase name for tarball/RPM release.
1658
1667
1659 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1668 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1660 use throughout ipython.
1669 use throughout ipython.
1661
1670
1662 * IPython/Magic.py (Magic._ofind): Switch to using the new
1671 * IPython/Magic.py (Magic._ofind): Switch to using the new
1663 OInspect.getdoc() function.
1672 OInspect.getdoc() function.
1664
1673
1665 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1674 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1666 of the line currently being canceled via Ctrl-C. It's extremely
1675 of the line currently being canceled via Ctrl-C. It's extremely
1667 ugly, but I don't know how to do it better (the problem is one of
1676 ugly, but I don't know how to do it better (the problem is one of
1668 handling cross-thread exceptions).
1677 handling cross-thread exceptions).
1669
1678
1670 2004-10-28 Fernando Perez <fperez@colorado.edu>
1679 2004-10-28 Fernando Perez <fperez@colorado.edu>
1671
1680
1672 * IPython/Shell.py (signal_handler): add signal handlers to trap
1681 * IPython/Shell.py (signal_handler): add signal handlers to trap
1673 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1682 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1674 report by Francesc Alted.
1683 report by Francesc Alted.
1675
1684
1676 2004-10-21 Fernando Perez <fperez@colorado.edu>
1685 2004-10-21 Fernando Perez <fperez@colorado.edu>
1677
1686
1678 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1687 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1679 to % for pysh syntax extensions.
1688 to % for pysh syntax extensions.
1680
1689
1681 2004-10-09 Fernando Perez <fperez@colorado.edu>
1690 2004-10-09 Fernando Perez <fperez@colorado.edu>
1682
1691
1683 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1692 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1684 arrays to print a more useful summary, without calling str(arr).
1693 arrays to print a more useful summary, without calling str(arr).
1685 This avoids the problem of extremely lengthy computations which
1694 This avoids the problem of extremely lengthy computations which
1686 occur if arr is large, and appear to the user as a system lockup
1695 occur if arr is large, and appear to the user as a system lockup
1687 with 100% cpu activity. After a suggestion by Kristian Sandberg
1696 with 100% cpu activity. After a suggestion by Kristian Sandberg
1688 <Kristian.Sandberg@colorado.edu>.
1697 <Kristian.Sandberg@colorado.edu>.
1689 (Magic.__init__): fix bug in global magic escapes not being
1698 (Magic.__init__): fix bug in global magic escapes not being
1690 correctly set.
1699 correctly set.
1691
1700
1692 2004-10-08 Fernando Perez <fperez@colorado.edu>
1701 2004-10-08 Fernando Perez <fperez@colorado.edu>
1693
1702
1694 * IPython/Magic.py (__license__): change to absolute imports of
1703 * IPython/Magic.py (__license__): change to absolute imports of
1695 ipython's own internal packages, to start adapting to the absolute
1704 ipython's own internal packages, to start adapting to the absolute
1696 import requirement of PEP-328.
1705 import requirement of PEP-328.
1697
1706
1698 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1707 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1699 files, and standardize author/license marks through the Release
1708 files, and standardize author/license marks through the Release
1700 module instead of having per/file stuff (except for files with
1709 module instead of having per/file stuff (except for files with
1701 particular licenses, like the MIT/PSF-licensed codes).
1710 particular licenses, like the MIT/PSF-licensed codes).
1702
1711
1703 * IPython/Debugger.py: remove dead code for python 2.1
1712 * IPython/Debugger.py: remove dead code for python 2.1
1704
1713
1705 2004-10-04 Fernando Perez <fperez@colorado.edu>
1714 2004-10-04 Fernando Perez <fperez@colorado.edu>
1706
1715
1707 * IPython/iplib.py (ipmagic): New function for accessing magics
1716 * IPython/iplib.py (ipmagic): New function for accessing magics
1708 via a normal python function call.
1717 via a normal python function call.
1709
1718
1710 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1719 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1711 from '@' to '%', to accomodate the new @decorator syntax of python
1720 from '@' to '%', to accomodate the new @decorator syntax of python
1712 2.4.
1721 2.4.
1713
1722
1714 2004-09-29 Fernando Perez <fperez@colorado.edu>
1723 2004-09-29 Fernando Perez <fperez@colorado.edu>
1715
1724
1716 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1725 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1717 matplotlib.use to prevent running scripts which try to switch
1726 matplotlib.use to prevent running scripts which try to switch
1718 interactive backends from within ipython. This will just crash
1727 interactive backends from within ipython. This will just crash
1719 the python interpreter, so we can't allow it (but a detailed error
1728 the python interpreter, so we can't allow it (but a detailed error
1720 is given to the user).
1729 is given to the user).
1721
1730
1722 2004-09-28 Fernando Perez <fperez@colorado.edu>
1731 2004-09-28 Fernando Perez <fperez@colorado.edu>
1723
1732
1724 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1733 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1725 matplotlib-related fixes so that using @run with non-matplotlib
1734 matplotlib-related fixes so that using @run with non-matplotlib
1726 scripts doesn't pop up spurious plot windows. This requires
1735 scripts doesn't pop up spurious plot windows. This requires
1727 matplotlib >= 0.63, where I had to make some changes as well.
1736 matplotlib >= 0.63, where I had to make some changes as well.
1728
1737
1729 * IPython/ipmaker.py (make_IPython): update version requirement to
1738 * IPython/ipmaker.py (make_IPython): update version requirement to
1730 python 2.2.
1739 python 2.2.
1731
1740
1732 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1741 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1733 banner arg for embedded customization.
1742 banner arg for embedded customization.
1734
1743
1735 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1744 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1736 explicit uses of __IP as the IPython's instance name. Now things
1745 explicit uses of __IP as the IPython's instance name. Now things
1737 are properly handled via the shell.name value. The actual code
1746 are properly handled via the shell.name value. The actual code
1738 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1747 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1739 is much better than before. I'll clean things completely when the
1748 is much better than before. I'll clean things completely when the
1740 magic stuff gets a real overhaul.
1749 magic stuff gets a real overhaul.
1741
1750
1742 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1751 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1743 minor changes to debian dir.
1752 minor changes to debian dir.
1744
1753
1745 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1754 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1746 pointer to the shell itself in the interactive namespace even when
1755 pointer to the shell itself in the interactive namespace even when
1747 a user-supplied dict is provided. This is needed for embedding
1756 a user-supplied dict is provided. This is needed for embedding
1748 purposes (found by tests with Michel Sanner).
1757 purposes (found by tests with Michel Sanner).
1749
1758
1750 2004-09-27 Fernando Perez <fperez@colorado.edu>
1759 2004-09-27 Fernando Perez <fperez@colorado.edu>
1751
1760
1752 * IPython/UserConfig/ipythonrc: remove []{} from
1761 * IPython/UserConfig/ipythonrc: remove []{} from
1753 readline_remove_delims, so that things like [modname.<TAB> do
1762 readline_remove_delims, so that things like [modname.<TAB> do
1754 proper completion. This disables [].TAB, but that's a less common
1763 proper completion. This disables [].TAB, but that's a less common
1755 case than module names in list comprehensions, for example.
1764 case than module names in list comprehensions, for example.
1756 Thanks to a report by Andrea Riciputi.
1765 Thanks to a report by Andrea Riciputi.
1757
1766
1758 2004-09-09 Fernando Perez <fperez@colorado.edu>
1767 2004-09-09 Fernando Perez <fperez@colorado.edu>
1759
1768
1760 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1769 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1761 blocking problems in win32 and osx. Fix by John.
1770 blocking problems in win32 and osx. Fix by John.
1762
1771
1763 2004-09-08 Fernando Perez <fperez@colorado.edu>
1772 2004-09-08 Fernando Perez <fperez@colorado.edu>
1764
1773
1765 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1774 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1766 for Win32 and OSX. Fix by John Hunter.
1775 for Win32 and OSX. Fix by John Hunter.
1767
1776
1768 2004-08-30 *** Released version 0.6.3
1777 2004-08-30 *** Released version 0.6.3
1769
1778
1770 2004-08-30 Fernando Perez <fperez@colorado.edu>
1779 2004-08-30 Fernando Perez <fperez@colorado.edu>
1771
1780
1772 * setup.py (isfile): Add manpages to list of dependent files to be
1781 * setup.py (isfile): Add manpages to list of dependent files to be
1773 updated.
1782 updated.
1774
1783
1775 2004-08-27 Fernando Perez <fperez@colorado.edu>
1784 2004-08-27 Fernando Perez <fperez@colorado.edu>
1776
1785
1777 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1786 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1778 for now. They don't really work with standalone WX/GTK code
1787 for now. They don't really work with standalone WX/GTK code
1779 (though matplotlib IS working fine with both of those backends).
1788 (though matplotlib IS working fine with both of those backends).
1780 This will neeed much more testing. I disabled most things with
1789 This will neeed much more testing. I disabled most things with
1781 comments, so turning it back on later should be pretty easy.
1790 comments, so turning it back on later should be pretty easy.
1782
1791
1783 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1792 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1784 autocalling of expressions like r'foo', by modifying the line
1793 autocalling of expressions like r'foo', by modifying the line
1785 split regexp. Closes
1794 split regexp. Closes
1786 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1795 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1787 Riley <ipythonbugs-AT-sabi.net>.
1796 Riley <ipythonbugs-AT-sabi.net>.
1788 (InteractiveShell.mainloop): honor --nobanner with banner
1797 (InteractiveShell.mainloop): honor --nobanner with banner
1789 extensions.
1798 extensions.
1790
1799
1791 * IPython/Shell.py: Significant refactoring of all classes, so
1800 * IPython/Shell.py: Significant refactoring of all classes, so
1792 that we can really support ALL matplotlib backends and threading
1801 that we can really support ALL matplotlib backends and threading
1793 models (John spotted a bug with Tk which required this). Now we
1802 models (John spotted a bug with Tk which required this). Now we
1794 should support single-threaded, WX-threads and GTK-threads, both
1803 should support single-threaded, WX-threads and GTK-threads, both
1795 for generic code and for matplotlib.
1804 for generic code and for matplotlib.
1796
1805
1797 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1806 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1798 -pylab, to simplify things for users. Will also remove the pylab
1807 -pylab, to simplify things for users. Will also remove the pylab
1799 profile, since now all of matplotlib configuration is directly
1808 profile, since now all of matplotlib configuration is directly
1800 handled here. This also reduces startup time.
1809 handled here. This also reduces startup time.
1801
1810
1802 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1811 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1803 shell wasn't being correctly called. Also in IPShellWX.
1812 shell wasn't being correctly called. Also in IPShellWX.
1804
1813
1805 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1814 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1806 fine-tune banner.
1815 fine-tune banner.
1807
1816
1808 * IPython/numutils.py (spike): Deprecate these spike functions,
1817 * IPython/numutils.py (spike): Deprecate these spike functions,
1809 delete (long deprecated) gnuplot_exec handler.
1818 delete (long deprecated) gnuplot_exec handler.
1810
1819
1811 2004-08-26 Fernando Perez <fperez@colorado.edu>
1820 2004-08-26 Fernando Perez <fperez@colorado.edu>
1812
1821
1813 * ipython.1: Update for threading options, plus some others which
1822 * ipython.1: Update for threading options, plus some others which
1814 were missing.
1823 were missing.
1815
1824
1816 * IPython/ipmaker.py (__call__): Added -wthread option for
1825 * IPython/ipmaker.py (__call__): Added -wthread option for
1817 wxpython thread handling. Make sure threading options are only
1826 wxpython thread handling. Make sure threading options are only
1818 valid at the command line.
1827 valid at the command line.
1819
1828
1820 * scripts/ipython: moved shell selection into a factory function
1829 * scripts/ipython: moved shell selection into a factory function
1821 in Shell.py, to keep the starter script to a minimum.
1830 in Shell.py, to keep the starter script to a minimum.
1822
1831
1823 2004-08-25 Fernando Perez <fperez@colorado.edu>
1832 2004-08-25 Fernando Perez <fperez@colorado.edu>
1824
1833
1825 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1834 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1826 John. Along with some recent changes he made to matplotlib, the
1835 John. Along with some recent changes he made to matplotlib, the
1827 next versions of both systems should work very well together.
1836 next versions of both systems should work very well together.
1828
1837
1829 2004-08-24 Fernando Perez <fperez@colorado.edu>
1838 2004-08-24 Fernando Perez <fperez@colorado.edu>
1830
1839
1831 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1840 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1832 tried to switch the profiling to using hotshot, but I'm getting
1841 tried to switch the profiling to using hotshot, but I'm getting
1833 strange errors from prof.runctx() there. I may be misreading the
1842 strange errors from prof.runctx() there. I may be misreading the
1834 docs, but it looks weird. For now the profiling code will
1843 docs, but it looks weird. For now the profiling code will
1835 continue to use the standard profiler.
1844 continue to use the standard profiler.
1836
1845
1837 2004-08-23 Fernando Perez <fperez@colorado.edu>
1846 2004-08-23 Fernando Perez <fperez@colorado.edu>
1838
1847
1839 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1848 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1840 threaded shell, by John Hunter. It's not quite ready yet, but
1849 threaded shell, by John Hunter. It's not quite ready yet, but
1841 close.
1850 close.
1842
1851
1843 2004-08-22 Fernando Perez <fperez@colorado.edu>
1852 2004-08-22 Fernando Perez <fperez@colorado.edu>
1844
1853
1845 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1854 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1846 in Magic and ultraTB.
1855 in Magic and ultraTB.
1847
1856
1848 * ipython.1: document threading options in manpage.
1857 * ipython.1: document threading options in manpage.
1849
1858
1850 * scripts/ipython: Changed name of -thread option to -gthread,
1859 * scripts/ipython: Changed name of -thread option to -gthread,
1851 since this is GTK specific. I want to leave the door open for a
1860 since this is GTK specific. I want to leave the door open for a
1852 -wthread option for WX, which will most likely be necessary. This
1861 -wthread option for WX, which will most likely be necessary. This
1853 change affects usage and ipmaker as well.
1862 change affects usage and ipmaker as well.
1854
1863
1855 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1864 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1856 handle the matplotlib shell issues. Code by John Hunter
1865 handle the matplotlib shell issues. Code by John Hunter
1857 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1866 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1858 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1867 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1859 broken (and disabled for end users) for now, but it puts the
1868 broken (and disabled for end users) for now, but it puts the
1860 infrastructure in place.
1869 infrastructure in place.
1861
1870
1862 2004-08-21 Fernando Perez <fperez@colorado.edu>
1871 2004-08-21 Fernando Perez <fperez@colorado.edu>
1863
1872
1864 * ipythonrc-pylab: Add matplotlib support.
1873 * ipythonrc-pylab: Add matplotlib support.
1865
1874
1866 * matplotlib_config.py: new files for matplotlib support, part of
1875 * matplotlib_config.py: new files for matplotlib support, part of
1867 the pylab profile.
1876 the pylab profile.
1868
1877
1869 * IPython/usage.py (__doc__): documented the threading options.
1878 * IPython/usage.py (__doc__): documented the threading options.
1870
1879
1871 2004-08-20 Fernando Perez <fperez@colorado.edu>
1880 2004-08-20 Fernando Perez <fperez@colorado.edu>
1872
1881
1873 * ipython: Modified the main calling routine to handle the -thread
1882 * ipython: Modified the main calling routine to handle the -thread
1874 and -mpthread options. This needs to be done as a top-level hack,
1883 and -mpthread options. This needs to be done as a top-level hack,
1875 because it determines which class to instantiate for IPython
1884 because it determines which class to instantiate for IPython
1876 itself.
1885 itself.
1877
1886
1878 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1887 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1879 classes to support multithreaded GTK operation without blocking,
1888 classes to support multithreaded GTK operation without blocking,
1880 and matplotlib with all backends. This is a lot of still very
1889 and matplotlib with all backends. This is a lot of still very
1881 experimental code, and threads are tricky. So it may still have a
1890 experimental code, and threads are tricky. So it may still have a
1882 few rough edges... This code owes a lot to
1891 few rough edges... This code owes a lot to
1883 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1892 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1884 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1893 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1885 to John Hunter for all the matplotlib work.
1894 to John Hunter for all the matplotlib work.
1886
1895
1887 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1896 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1888 options for gtk thread and matplotlib support.
1897 options for gtk thread and matplotlib support.
1889
1898
1890 2004-08-16 Fernando Perez <fperez@colorado.edu>
1899 2004-08-16 Fernando Perez <fperez@colorado.edu>
1891
1900
1892 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1901 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1893 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1902 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1894 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1903 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1895
1904
1896 2004-08-11 Fernando Perez <fperez@colorado.edu>
1905 2004-08-11 Fernando Perez <fperez@colorado.edu>
1897
1906
1898 * setup.py (isfile): Fix build so documentation gets updated for
1907 * setup.py (isfile): Fix build so documentation gets updated for
1899 rpms (it was only done for .tgz builds).
1908 rpms (it was only done for .tgz builds).
1900
1909
1901 2004-08-10 Fernando Perez <fperez@colorado.edu>
1910 2004-08-10 Fernando Perez <fperez@colorado.edu>
1902
1911
1903 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1912 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1904
1913
1905 * iplib.py : Silence syntax error exceptions in tab-completion.
1914 * iplib.py : Silence syntax error exceptions in tab-completion.
1906
1915
1907 2004-08-05 Fernando Perez <fperez@colorado.edu>
1916 2004-08-05 Fernando Perez <fperez@colorado.edu>
1908
1917
1909 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1918 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1910 'color off' mark for continuation prompts. This was causing long
1919 'color off' mark for continuation prompts. This was causing long
1911 continuation lines to mis-wrap.
1920 continuation lines to mis-wrap.
1912
1921
1913 2004-08-01 Fernando Perez <fperez@colorado.edu>
1922 2004-08-01 Fernando Perez <fperez@colorado.edu>
1914
1923
1915 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1924 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1916 for building ipython to be a parameter. All this is necessary
1925 for building ipython to be a parameter. All this is necessary
1917 right now to have a multithreaded version, but this insane
1926 right now to have a multithreaded version, but this insane
1918 non-design will be cleaned up soon. For now, it's a hack that
1927 non-design will be cleaned up soon. For now, it's a hack that
1919 works.
1928 works.
1920
1929
1921 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1930 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1922 args in various places. No bugs so far, but it's a dangerous
1931 args in various places. No bugs so far, but it's a dangerous
1923 practice.
1932 practice.
1924
1933
1925 2004-07-31 Fernando Perez <fperez@colorado.edu>
1934 2004-07-31 Fernando Perez <fperez@colorado.edu>
1926
1935
1927 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1936 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1928 fix completion of files with dots in their names under most
1937 fix completion of files with dots in their names under most
1929 profiles (pysh was OK because the completion order is different).
1938 profiles (pysh was OK because the completion order is different).
1930
1939
1931 2004-07-27 Fernando Perez <fperez@colorado.edu>
1940 2004-07-27 Fernando Perez <fperez@colorado.edu>
1932
1941
1933 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1942 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1934 keywords manually, b/c the one in keyword.py was removed in python
1943 keywords manually, b/c the one in keyword.py was removed in python
1935 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1944 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1936 This is NOT a bug under python 2.3 and earlier.
1945 This is NOT a bug under python 2.3 and earlier.
1937
1946
1938 2004-07-26 Fernando Perez <fperez@colorado.edu>
1947 2004-07-26 Fernando Perez <fperez@colorado.edu>
1939
1948
1940 * IPython/ultraTB.py (VerboseTB.text): Add another
1949 * IPython/ultraTB.py (VerboseTB.text): Add another
1941 linecache.checkcache() call to try to prevent inspect.py from
1950 linecache.checkcache() call to try to prevent inspect.py from
1942 crashing under python 2.3. I think this fixes
1951 crashing under python 2.3. I think this fixes
1943 http://www.scipy.net/roundup/ipython/issue17.
1952 http://www.scipy.net/roundup/ipython/issue17.
1944
1953
1945 2004-07-26 *** Released version 0.6.2
1954 2004-07-26 *** Released version 0.6.2
1946
1955
1947 2004-07-26 Fernando Perez <fperez@colorado.edu>
1956 2004-07-26 Fernando Perez <fperez@colorado.edu>
1948
1957
1949 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1958 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1950 fail for any number.
1959 fail for any number.
1951 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1960 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1952 empty bookmarks.
1961 empty bookmarks.
1953
1962
1954 2004-07-26 *** Released version 0.6.1
1963 2004-07-26 *** Released version 0.6.1
1955
1964
1956 2004-07-26 Fernando Perez <fperez@colorado.edu>
1965 2004-07-26 Fernando Perez <fperez@colorado.edu>
1957
1966
1958 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1967 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1959
1968
1960 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1969 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1961 escaping '()[]{}' in filenames.
1970 escaping '()[]{}' in filenames.
1962
1971
1963 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1972 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1964 Python 2.2 users who lack a proper shlex.split.
1973 Python 2.2 users who lack a proper shlex.split.
1965
1974
1966 2004-07-19 Fernando Perez <fperez@colorado.edu>
1975 2004-07-19 Fernando Perez <fperez@colorado.edu>
1967
1976
1968 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1977 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1969 for reading readline's init file. I follow the normal chain:
1978 for reading readline's init file. I follow the normal chain:
1970 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1979 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1971 report by Mike Heeter. This closes
1980 report by Mike Heeter. This closes
1972 http://www.scipy.net/roundup/ipython/issue16.
1981 http://www.scipy.net/roundup/ipython/issue16.
1973
1982
1974 2004-07-18 Fernando Perez <fperez@colorado.edu>
1983 2004-07-18 Fernando Perez <fperez@colorado.edu>
1975
1984
1976 * IPython/iplib.py (__init__): Add better handling of '\' under
1985 * IPython/iplib.py (__init__): Add better handling of '\' under
1977 Win32 for filenames. After a patch by Ville.
1986 Win32 for filenames. After a patch by Ville.
1978
1987
1979 2004-07-17 Fernando Perez <fperez@colorado.edu>
1988 2004-07-17 Fernando Perez <fperez@colorado.edu>
1980
1989
1981 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1990 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1982 autocalling would be triggered for 'foo is bar' if foo is
1991 autocalling would be triggered for 'foo is bar' if foo is
1983 callable. I also cleaned up the autocall detection code to use a
1992 callable. I also cleaned up the autocall detection code to use a
1984 regexp, which is faster. Bug reported by Alexander Schmolck.
1993 regexp, which is faster. Bug reported by Alexander Schmolck.
1985
1994
1986 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1995 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1987 '?' in them would confuse the help system. Reported by Alex
1996 '?' in them would confuse the help system. Reported by Alex
1988 Schmolck.
1997 Schmolck.
1989
1998
1990 2004-07-16 Fernando Perez <fperez@colorado.edu>
1999 2004-07-16 Fernando Perez <fperez@colorado.edu>
1991
2000
1992 * IPython/GnuplotInteractive.py (__all__): added plot2.
2001 * IPython/GnuplotInteractive.py (__all__): added plot2.
1993
2002
1994 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
2003 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1995 plotting dictionaries, lists or tuples of 1d arrays.
2004 plotting dictionaries, lists or tuples of 1d arrays.
1996
2005
1997 * IPython/Magic.py (Magic.magic_hist): small clenaups and
2006 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1998 optimizations.
2007 optimizations.
1999
2008
2000 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
2009 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
2001 the information which was there from Janko's original IPP code:
2010 the information which was there from Janko's original IPP code:
2002
2011
2003 03.05.99 20:53 porto.ifm.uni-kiel.de
2012 03.05.99 20:53 porto.ifm.uni-kiel.de
2004 --Started changelog.
2013 --Started changelog.
2005 --make clear do what it say it does
2014 --make clear do what it say it does
2006 --added pretty output of lines from inputcache
2015 --added pretty output of lines from inputcache
2007 --Made Logger a mixin class, simplifies handling of switches
2016 --Made Logger a mixin class, simplifies handling of switches
2008 --Added own completer class. .string<TAB> expands to last history
2017 --Added own completer class. .string<TAB> expands to last history
2009 line which starts with string. The new expansion is also present
2018 line which starts with string. The new expansion is also present
2010 with Ctrl-r from the readline library. But this shows, who this
2019 with Ctrl-r from the readline library. But this shows, who this
2011 can be done for other cases.
2020 can be done for other cases.
2012 --Added convention that all shell functions should accept a
2021 --Added convention that all shell functions should accept a
2013 parameter_string This opens the door for different behaviour for
2022 parameter_string This opens the door for different behaviour for
2014 each function. @cd is a good example of this.
2023 each function. @cd is a good example of this.
2015
2024
2016 04.05.99 12:12 porto.ifm.uni-kiel.de
2025 04.05.99 12:12 porto.ifm.uni-kiel.de
2017 --added logfile rotation
2026 --added logfile rotation
2018 --added new mainloop method which freezes first the namespace
2027 --added new mainloop method which freezes first the namespace
2019
2028
2020 07.05.99 21:24 porto.ifm.uni-kiel.de
2029 07.05.99 21:24 porto.ifm.uni-kiel.de
2021 --added the docreader classes. Now there is a help system.
2030 --added the docreader classes. Now there is a help system.
2022 -This is only a first try. Currently it's not easy to put new
2031 -This is only a first try. Currently it's not easy to put new
2023 stuff in the indices. But this is the way to go. Info would be
2032 stuff in the indices. But this is the way to go. Info would be
2024 better, but HTML is every where and not everybody has an info
2033 better, but HTML is every where and not everybody has an info
2025 system installed and it's not so easy to change html-docs to info.
2034 system installed and it's not so easy to change html-docs to info.
2026 --added global logfile option
2035 --added global logfile option
2027 --there is now a hook for object inspection method pinfo needs to
2036 --there is now a hook for object inspection method pinfo needs to
2028 be provided for this. Can be reached by two '??'.
2037 be provided for this. Can be reached by two '??'.
2029
2038
2030 08.05.99 20:51 porto.ifm.uni-kiel.de
2039 08.05.99 20:51 porto.ifm.uni-kiel.de
2031 --added a README
2040 --added a README
2032 --bug in rc file. Something has changed so functions in the rc
2041 --bug in rc file. Something has changed so functions in the rc
2033 file need to reference the shell and not self. Not clear if it's a
2042 file need to reference the shell and not self. Not clear if it's a
2034 bug or feature.
2043 bug or feature.
2035 --changed rc file for new behavior
2044 --changed rc file for new behavior
2036
2045
2037 2004-07-15 Fernando Perez <fperez@colorado.edu>
2046 2004-07-15 Fernando Perez <fperez@colorado.edu>
2038
2047
2039 * IPython/Logger.py (Logger.log): fixed recent bug where the input
2048 * IPython/Logger.py (Logger.log): fixed recent bug where the input
2040 cache was falling out of sync in bizarre manners when multi-line
2049 cache was falling out of sync in bizarre manners when multi-line
2041 input was present. Minor optimizations and cleanup.
2050 input was present. Minor optimizations and cleanup.
2042
2051
2043 (Logger): Remove old Changelog info for cleanup. This is the
2052 (Logger): Remove old Changelog info for cleanup. This is the
2044 information which was there from Janko's original code:
2053 information which was there from Janko's original code:
2045
2054
2046 Changes to Logger: - made the default log filename a parameter
2055 Changes to Logger: - made the default log filename a parameter
2047
2056
2048 - put a check for lines beginning with !@? in log(). Needed
2057 - put a check for lines beginning with !@? in log(). Needed
2049 (even if the handlers properly log their lines) for mid-session
2058 (even if the handlers properly log their lines) for mid-session
2050 logging activation to work properly. Without this, lines logged
2059 logging activation to work properly. Without this, lines logged
2051 in mid session, which get read from the cache, would end up
2060 in mid session, which get read from the cache, would end up
2052 'bare' (with !@? in the open) in the log. Now they are caught
2061 'bare' (with !@? in the open) in the log. Now they are caught
2053 and prepended with a #.
2062 and prepended with a #.
2054
2063
2055 * IPython/iplib.py (InteractiveShell.init_readline): added check
2064 * IPython/iplib.py (InteractiveShell.init_readline): added check
2056 in case MagicCompleter fails to be defined, so we don't crash.
2065 in case MagicCompleter fails to be defined, so we don't crash.
2057
2066
2058 2004-07-13 Fernando Perez <fperez@colorado.edu>
2067 2004-07-13 Fernando Perez <fperez@colorado.edu>
2059
2068
2060 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
2069 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
2061 of EPS if the requested filename ends in '.eps'.
2070 of EPS if the requested filename ends in '.eps'.
2062
2071
2063 2004-07-04 Fernando Perez <fperez@colorado.edu>
2072 2004-07-04 Fernando Perez <fperez@colorado.edu>
2064
2073
2065 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
2074 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
2066 escaping of quotes when calling the shell.
2075 escaping of quotes when calling the shell.
2067
2076
2068 2004-07-02 Fernando Perez <fperez@colorado.edu>
2077 2004-07-02 Fernando Perez <fperez@colorado.edu>
2069
2078
2070 * IPython/Prompts.py (CachedOutput.update): Fix problem with
2079 * IPython/Prompts.py (CachedOutput.update): Fix problem with
2071 gettext not working because we were clobbering '_'. Fixes
2080 gettext not working because we were clobbering '_'. Fixes
2072 http://www.scipy.net/roundup/ipython/issue6.
2081 http://www.scipy.net/roundup/ipython/issue6.
2073
2082
2074 2004-07-01 Fernando Perez <fperez@colorado.edu>
2083 2004-07-01 Fernando Perez <fperez@colorado.edu>
2075
2084
2076 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
2085 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
2077 into @cd. Patch by Ville.
2086 into @cd. Patch by Ville.
2078
2087
2079 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2088 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2080 new function to store things after ipmaker runs. Patch by Ville.
2089 new function to store things after ipmaker runs. Patch by Ville.
2081 Eventually this will go away once ipmaker is removed and the class
2090 Eventually this will go away once ipmaker is removed and the class
2082 gets cleaned up, but for now it's ok. Key functionality here is
2091 gets cleaned up, but for now it's ok. Key functionality here is
2083 the addition of the persistent storage mechanism, a dict for
2092 the addition of the persistent storage mechanism, a dict for
2084 keeping data across sessions (for now just bookmarks, but more can
2093 keeping data across sessions (for now just bookmarks, but more can
2085 be implemented later).
2094 be implemented later).
2086
2095
2087 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2096 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2088 persistent across sections. Patch by Ville, I modified it
2097 persistent across sections. Patch by Ville, I modified it
2089 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2098 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2090 added a '-l' option to list all bookmarks.
2099 added a '-l' option to list all bookmarks.
2091
2100
2092 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2101 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2093 center for cleanup. Registered with atexit.register(). I moved
2102 center for cleanup. Registered with atexit.register(). I moved
2094 here the old exit_cleanup(). After a patch by Ville.
2103 here the old exit_cleanup(). After a patch by Ville.
2095
2104
2096 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2105 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2097 characters in the hacked shlex_split for python 2.2.
2106 characters in the hacked shlex_split for python 2.2.
2098
2107
2099 * IPython/iplib.py (file_matches): more fixes to filenames with
2108 * IPython/iplib.py (file_matches): more fixes to filenames with
2100 whitespace in them. It's not perfect, but limitations in python's
2109 whitespace in them. It's not perfect, but limitations in python's
2101 readline make it impossible to go further.
2110 readline make it impossible to go further.
2102
2111
2103 2004-06-29 Fernando Perez <fperez@colorado.edu>
2112 2004-06-29 Fernando Perez <fperez@colorado.edu>
2104
2113
2105 * IPython/iplib.py (file_matches): escape whitespace correctly in
2114 * IPython/iplib.py (file_matches): escape whitespace correctly in
2106 filename completions. Bug reported by Ville.
2115 filename completions. Bug reported by Ville.
2107
2116
2108 2004-06-28 Fernando Perez <fperez@colorado.edu>
2117 2004-06-28 Fernando Perez <fperez@colorado.edu>
2109
2118
2110 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
2119 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
2111 the history file will be called 'history-PROFNAME' (or just
2120 the history file will be called 'history-PROFNAME' (or just
2112 'history' if no profile is loaded). I was getting annoyed at
2121 'history' if no profile is loaded). I was getting annoyed at
2113 getting my Numerical work history clobbered by pysh sessions.
2122 getting my Numerical work history clobbered by pysh sessions.
2114
2123
2115 * IPython/iplib.py (InteractiveShell.__init__): Internal
2124 * IPython/iplib.py (InteractiveShell.__init__): Internal
2116 getoutputerror() function so that we can honor the system_verbose
2125 getoutputerror() function so that we can honor the system_verbose
2117 flag for _all_ system calls. I also added escaping of #
2126 flag for _all_ system calls. I also added escaping of #
2118 characters here to avoid confusing Itpl.
2127 characters here to avoid confusing Itpl.
2119
2128
2120 * IPython/Magic.py (shlex_split): removed call to shell in
2129 * IPython/Magic.py (shlex_split): removed call to shell in
2121 parse_options and replaced it with shlex.split(). The annoying
2130 parse_options and replaced it with shlex.split(). The annoying
2122 part was that in Python 2.2, shlex.split() doesn't exist, so I had
2131 part was that in Python 2.2, shlex.split() doesn't exist, so I had
2123 to backport it from 2.3, with several frail hacks (the shlex
2132 to backport it from 2.3, with several frail hacks (the shlex
2124 module is rather limited in 2.2). Thanks to a suggestion by Ville
2133 module is rather limited in 2.2). Thanks to a suggestion by Ville
2125 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
2134 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
2126 problem.
2135 problem.
2127
2136
2128 (Magic.magic_system_verbose): new toggle to print the actual
2137 (Magic.magic_system_verbose): new toggle to print the actual
2129 system calls made by ipython. Mainly for debugging purposes.
2138 system calls made by ipython. Mainly for debugging purposes.
2130
2139
2131 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
2140 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
2132 doesn't support persistence. Reported (and fix suggested) by
2141 doesn't support persistence. Reported (and fix suggested) by
2133 Travis Caldwell <travis_caldwell2000@yahoo.com>.
2142 Travis Caldwell <travis_caldwell2000@yahoo.com>.
2134
2143
2135 2004-06-26 Fernando Perez <fperez@colorado.edu>
2144 2004-06-26 Fernando Perez <fperez@colorado.edu>
2136
2145
2137 * IPython/Logger.py (Logger.log): fix to handle correctly empty
2146 * IPython/Logger.py (Logger.log): fix to handle correctly empty
2138 continue prompts.
2147 continue prompts.
2139
2148
2140 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
2149 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
2141 function (basically a big docstring) and a few more things here to
2150 function (basically a big docstring) and a few more things here to
2142 speedup startup. pysh.py is now very lightweight. We want because
2151 speedup startup. pysh.py is now very lightweight. We want because
2143 it gets execfile'd, while InterpreterExec gets imported, so
2152 it gets execfile'd, while InterpreterExec gets imported, so
2144 byte-compilation saves time.
2153 byte-compilation saves time.
2145
2154
2146 2004-06-25 Fernando Perez <fperez@colorado.edu>
2155 2004-06-25 Fernando Perez <fperez@colorado.edu>
2147
2156
2148 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
2157 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
2149 -NUM', which was recently broken.
2158 -NUM', which was recently broken.
2150
2159
2151 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
2160 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
2152 in multi-line input (but not !!, which doesn't make sense there).
2161 in multi-line input (but not !!, which doesn't make sense there).
2153
2162
2154 * IPython/UserConfig/ipythonrc: made autoindent on by default.
2163 * IPython/UserConfig/ipythonrc: made autoindent on by default.
2155 It's just too useful, and people can turn it off in the less
2164 It's just too useful, and people can turn it off in the less
2156 common cases where it's a problem.
2165 common cases where it's a problem.
2157
2166
2158 2004-06-24 Fernando Perez <fperez@colorado.edu>
2167 2004-06-24 Fernando Perez <fperez@colorado.edu>
2159
2168
2160 * IPython/iplib.py (InteractiveShell._prefilter): big change -
2169 * IPython/iplib.py (InteractiveShell._prefilter): big change -
2161 special syntaxes (like alias calling) is now allied in multi-line
2170 special syntaxes (like alias calling) is now allied in multi-line
2162 input. This is still _very_ experimental, but it's necessary for
2171 input. This is still _very_ experimental, but it's necessary for
2163 efficient shell usage combining python looping syntax with system
2172 efficient shell usage combining python looping syntax with system
2164 calls. For now it's restricted to aliases, I don't think it
2173 calls. For now it's restricted to aliases, I don't think it
2165 really even makes sense to have this for magics.
2174 really even makes sense to have this for magics.
2166
2175
2167 2004-06-23 Fernando Perez <fperez@colorado.edu>
2176 2004-06-23 Fernando Perez <fperez@colorado.edu>
2168
2177
2169 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
2178 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
2170 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
2179 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
2171
2180
2172 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
2181 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
2173 extensions under Windows (after code sent by Gary Bishop). The
2182 extensions under Windows (after code sent by Gary Bishop). The
2174 extensions considered 'executable' are stored in IPython's rc
2183 extensions considered 'executable' are stored in IPython's rc
2175 structure as win_exec_ext.
2184 structure as win_exec_ext.
2176
2185
2177 * IPython/genutils.py (shell): new function, like system() but
2186 * IPython/genutils.py (shell): new function, like system() but
2178 without return value. Very useful for interactive shell work.
2187 without return value. Very useful for interactive shell work.
2179
2188
2180 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
2189 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
2181 delete aliases.
2190 delete aliases.
2182
2191
2183 * IPython/iplib.py (InteractiveShell.alias_table_update): make
2192 * IPython/iplib.py (InteractiveShell.alias_table_update): make
2184 sure that the alias table doesn't contain python keywords.
2193 sure that the alias table doesn't contain python keywords.
2185
2194
2186 2004-06-21 Fernando Perez <fperez@colorado.edu>
2195 2004-06-21 Fernando Perez <fperez@colorado.edu>
2187
2196
2188 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
2197 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
2189 non-existent items are found in $PATH. Reported by Thorsten.
2198 non-existent items are found in $PATH. Reported by Thorsten.
2190
2199
2191 2004-06-20 Fernando Perez <fperez@colorado.edu>
2200 2004-06-20 Fernando Perez <fperez@colorado.edu>
2192
2201
2193 * IPython/iplib.py (complete): modified the completer so that the
2202 * IPython/iplib.py (complete): modified the completer so that the
2194 order of priorities can be easily changed at runtime.
2203 order of priorities can be easily changed at runtime.
2195
2204
2196 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
2205 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
2197 Modified to auto-execute all lines beginning with '~', '/' or '.'.
2206 Modified to auto-execute all lines beginning with '~', '/' or '.'.
2198
2207
2199 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
2208 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
2200 expand Python variables prepended with $ in all system calls. The
2209 expand Python variables prepended with $ in all system calls. The
2201 same was done to InteractiveShell.handle_shell_escape. Now all
2210 same was done to InteractiveShell.handle_shell_escape. Now all
2202 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
2211 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
2203 expansion of python variables and expressions according to the
2212 expansion of python variables and expressions according to the
2204 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
2213 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
2205
2214
2206 Though PEP-215 has been rejected, a similar (but simpler) one
2215 Though PEP-215 has been rejected, a similar (but simpler) one
2207 seems like it will go into Python 2.4, PEP-292 -
2216 seems like it will go into Python 2.4, PEP-292 -
2208 http://www.python.org/peps/pep-0292.html.
2217 http://www.python.org/peps/pep-0292.html.
2209
2218
2210 I'll keep the full syntax of PEP-215, since IPython has since the
2219 I'll keep the full syntax of PEP-215, since IPython has since the
2211 start used Ka-Ping Yee's reference implementation discussed there
2220 start used Ka-Ping Yee's reference implementation discussed there
2212 (Itpl), and I actually like the powerful semantics it offers.
2221 (Itpl), and I actually like the powerful semantics it offers.
2213
2222
2214 In order to access normal shell variables, the $ has to be escaped
2223 In order to access normal shell variables, the $ has to be escaped
2215 via an extra $. For example:
2224 via an extra $. For example:
2216
2225
2217 In [7]: PATH='a python variable'
2226 In [7]: PATH='a python variable'
2218
2227
2219 In [8]: !echo $PATH
2228 In [8]: !echo $PATH
2220 a python variable
2229 a python variable
2221
2230
2222 In [9]: !echo $$PATH
2231 In [9]: !echo $$PATH
2223 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2232 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2224
2233
2225 (Magic.parse_options): escape $ so the shell doesn't evaluate
2234 (Magic.parse_options): escape $ so the shell doesn't evaluate
2226 things prematurely.
2235 things prematurely.
2227
2236
2228 * IPython/iplib.py (InteractiveShell.call_alias): added the
2237 * IPython/iplib.py (InteractiveShell.call_alias): added the
2229 ability for aliases to expand python variables via $.
2238 ability for aliases to expand python variables via $.
2230
2239
2231 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
2240 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
2232 system, now there's a @rehash/@rehashx pair of magics. These work
2241 system, now there's a @rehash/@rehashx pair of magics. These work
2233 like the csh rehash command, and can be invoked at any time. They
2242 like the csh rehash command, and can be invoked at any time. They
2234 build a table of aliases to everything in the user's $PATH
2243 build a table of aliases to everything in the user's $PATH
2235 (@rehash uses everything, @rehashx is slower but only adds
2244 (@rehash uses everything, @rehashx is slower but only adds
2236 executable files). With this, the pysh.py-based shell profile can
2245 executable files). With this, the pysh.py-based shell profile can
2237 now simply call rehash upon startup, and full access to all
2246 now simply call rehash upon startup, and full access to all
2238 programs in the user's path is obtained.
2247 programs in the user's path is obtained.
2239
2248
2240 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
2249 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
2241 functionality is now fully in place. I removed the old dynamic
2250 functionality is now fully in place. I removed the old dynamic
2242 code generation based approach, in favor of a much lighter one
2251 code generation based approach, in favor of a much lighter one
2243 based on a simple dict. The advantage is that this allows me to
2252 based on a simple dict. The advantage is that this allows me to
2244 now have thousands of aliases with negligible cost (unthinkable
2253 now have thousands of aliases with negligible cost (unthinkable
2245 with the old system).
2254 with the old system).
2246
2255
2247 2004-06-19 Fernando Perez <fperez@colorado.edu>
2256 2004-06-19 Fernando Perez <fperez@colorado.edu>
2248
2257
2249 * IPython/iplib.py (__init__): extended MagicCompleter class to
2258 * IPython/iplib.py (__init__): extended MagicCompleter class to
2250 also complete (last in priority) on user aliases.
2259 also complete (last in priority) on user aliases.
2251
2260
2252 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
2261 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
2253 call to eval.
2262 call to eval.
2254 (ItplNS.__init__): Added a new class which functions like Itpl,
2263 (ItplNS.__init__): Added a new class which functions like Itpl,
2255 but allows configuring the namespace for the evaluation to occur
2264 but allows configuring the namespace for the evaluation to occur
2256 in.
2265 in.
2257
2266
2258 2004-06-18 Fernando Perez <fperez@colorado.edu>
2267 2004-06-18 Fernando Perez <fperez@colorado.edu>
2259
2268
2260 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
2269 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
2261 better message when 'exit' or 'quit' are typed (a common newbie
2270 better message when 'exit' or 'quit' are typed (a common newbie
2262 confusion).
2271 confusion).
2263
2272
2264 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
2273 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
2265 check for Windows users.
2274 check for Windows users.
2266
2275
2267 * IPython/iplib.py (InteractiveShell.user_setup): removed
2276 * IPython/iplib.py (InteractiveShell.user_setup): removed
2268 disabling of colors for Windows. I'll test at runtime and issue a
2277 disabling of colors for Windows. I'll test at runtime and issue a
2269 warning if Gary's readline isn't found, as to nudge users to
2278 warning if Gary's readline isn't found, as to nudge users to
2270 download it.
2279 download it.
2271
2280
2272 2004-06-16 Fernando Perez <fperez@colorado.edu>
2281 2004-06-16 Fernando Perez <fperez@colorado.edu>
2273
2282
2274 * IPython/genutils.py (Stream.__init__): changed to print errors
2283 * IPython/genutils.py (Stream.__init__): changed to print errors
2275 to sys.stderr. I had a circular dependency here. Now it's
2284 to sys.stderr. I had a circular dependency here. Now it's
2276 possible to run ipython as IDLE's shell (consider this pre-alpha,
2285 possible to run ipython as IDLE's shell (consider this pre-alpha,
2277 since true stdout things end up in the starting terminal instead
2286 since true stdout things end up in the starting terminal instead
2278 of IDLE's out).
2287 of IDLE's out).
2279
2288
2280 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2289 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2281 users who haven't # updated their prompt_in2 definitions. Remove
2290 users who haven't # updated their prompt_in2 definitions. Remove
2282 eventually.
2291 eventually.
2283 (multiple_replace): added credit to original ASPN recipe.
2292 (multiple_replace): added credit to original ASPN recipe.
2284
2293
2285 2004-06-15 Fernando Perez <fperez@colorado.edu>
2294 2004-06-15 Fernando Perez <fperez@colorado.edu>
2286
2295
2287 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2296 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2288 list of auto-defined aliases.
2297 list of auto-defined aliases.
2289
2298
2290 2004-06-13 Fernando Perez <fperez@colorado.edu>
2299 2004-06-13 Fernando Perez <fperez@colorado.edu>
2291
2300
2292 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2301 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2293 install was really requested (so setup.py can be used for other
2302 install was really requested (so setup.py can be used for other
2294 things under Windows).
2303 things under Windows).
2295
2304
2296 2004-06-10 Fernando Perez <fperez@colorado.edu>
2305 2004-06-10 Fernando Perez <fperez@colorado.edu>
2297
2306
2298 * IPython/Logger.py (Logger.create_log): Manually remove any old
2307 * IPython/Logger.py (Logger.create_log): Manually remove any old
2299 backup, since os.remove may fail under Windows. Fixes bug
2308 backup, since os.remove may fail under Windows. Fixes bug
2300 reported by Thorsten.
2309 reported by Thorsten.
2301
2310
2302 2004-06-09 Fernando Perez <fperez@colorado.edu>
2311 2004-06-09 Fernando Perez <fperez@colorado.edu>
2303
2312
2304 * examples/example-embed.py: fixed all references to %n (replaced
2313 * examples/example-embed.py: fixed all references to %n (replaced
2305 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2314 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2306 for all examples and the manual as well.
2315 for all examples and the manual as well.
2307
2316
2308 2004-06-08 Fernando Perez <fperez@colorado.edu>
2317 2004-06-08 Fernando Perez <fperez@colorado.edu>
2309
2318
2310 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2319 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2311 alignment and color management. All 3 prompt subsystems now
2320 alignment and color management. All 3 prompt subsystems now
2312 inherit from BasePrompt.
2321 inherit from BasePrompt.
2313
2322
2314 * tools/release: updates for windows installer build and tag rpms
2323 * tools/release: updates for windows installer build and tag rpms
2315 with python version (since paths are fixed).
2324 with python version (since paths are fixed).
2316
2325
2317 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2326 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2318 which will become eventually obsolete. Also fixed the default
2327 which will become eventually obsolete. Also fixed the default
2319 prompt_in2 to use \D, so at least new users start with the correct
2328 prompt_in2 to use \D, so at least new users start with the correct
2320 defaults.
2329 defaults.
2321 WARNING: Users with existing ipythonrc files will need to apply
2330 WARNING: Users with existing ipythonrc files will need to apply
2322 this fix manually!
2331 this fix manually!
2323
2332
2324 * setup.py: make windows installer (.exe). This is finally the
2333 * setup.py: make windows installer (.exe). This is finally the
2325 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2334 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2326 which I hadn't included because it required Python 2.3 (or recent
2335 which I hadn't included because it required Python 2.3 (or recent
2327 distutils).
2336 distutils).
2328
2337
2329 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2338 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2330 usage of new '\D' escape.
2339 usage of new '\D' escape.
2331
2340
2332 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2341 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2333 lacks os.getuid())
2342 lacks os.getuid())
2334 (CachedOutput.set_colors): Added the ability to turn coloring
2343 (CachedOutput.set_colors): Added the ability to turn coloring
2335 on/off with @colors even for manually defined prompt colors. It
2344 on/off with @colors even for manually defined prompt colors. It
2336 uses a nasty global, but it works safely and via the generic color
2345 uses a nasty global, but it works safely and via the generic color
2337 handling mechanism.
2346 handling mechanism.
2338 (Prompt2.__init__): Introduced new escape '\D' for continuation
2347 (Prompt2.__init__): Introduced new escape '\D' for continuation
2339 prompts. It represents the counter ('\#') as dots.
2348 prompts. It represents the counter ('\#') as dots.
2340 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2349 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2341 need to update their ipythonrc files and replace '%n' with '\D' in
2350 need to update their ipythonrc files and replace '%n' with '\D' in
2342 their prompt_in2 settings everywhere. Sorry, but there's
2351 their prompt_in2 settings everywhere. Sorry, but there's
2343 otherwise no clean way to get all prompts to properly align. The
2352 otherwise no clean way to get all prompts to properly align. The
2344 ipythonrc shipped with IPython has been updated.
2353 ipythonrc shipped with IPython has been updated.
2345
2354
2346 2004-06-07 Fernando Perez <fperez@colorado.edu>
2355 2004-06-07 Fernando Perez <fperez@colorado.edu>
2347
2356
2348 * setup.py (isfile): Pass local_icons option to latex2html, so the
2357 * setup.py (isfile): Pass local_icons option to latex2html, so the
2349 resulting HTML file is self-contained. Thanks to
2358 resulting HTML file is self-contained. Thanks to
2350 dryice-AT-liu.com.cn for the tip.
2359 dryice-AT-liu.com.cn for the tip.
2351
2360
2352 * pysh.py: I created a new profile 'shell', which implements a
2361 * pysh.py: I created a new profile 'shell', which implements a
2353 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2362 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2354 system shell, nor will it become one anytime soon. It's mainly
2363 system shell, nor will it become one anytime soon. It's mainly
2355 meant to illustrate the use of the new flexible bash-like prompts.
2364 meant to illustrate the use of the new flexible bash-like prompts.
2356 I guess it could be used by hardy souls for true shell management,
2365 I guess it could be used by hardy souls for true shell management,
2357 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2366 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2358 profile. This uses the InterpreterExec extension provided by
2367 profile. This uses the InterpreterExec extension provided by
2359 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2368 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2360
2369
2361 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2370 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2362 auto-align itself with the length of the previous input prompt
2371 auto-align itself with the length of the previous input prompt
2363 (taking into account the invisible color escapes).
2372 (taking into account the invisible color escapes).
2364 (CachedOutput.__init__): Large restructuring of this class. Now
2373 (CachedOutput.__init__): Large restructuring of this class. Now
2365 all three prompts (primary1, primary2, output) are proper objects,
2374 all three prompts (primary1, primary2, output) are proper objects,
2366 managed by the 'parent' CachedOutput class. The code is still a
2375 managed by the 'parent' CachedOutput class. The code is still a
2367 bit hackish (all prompts share state via a pointer to the cache),
2376 bit hackish (all prompts share state via a pointer to the cache),
2368 but it's overall far cleaner than before.
2377 but it's overall far cleaner than before.
2369
2378
2370 * IPython/genutils.py (getoutputerror): modified to add verbose,
2379 * IPython/genutils.py (getoutputerror): modified to add verbose,
2371 debug and header options. This makes the interface of all getout*
2380 debug and header options. This makes the interface of all getout*
2372 functions uniform.
2381 functions uniform.
2373 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2382 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2374
2383
2375 * IPython/Magic.py (Magic.default_option): added a function to
2384 * IPython/Magic.py (Magic.default_option): added a function to
2376 allow registering default options for any magic command. This
2385 allow registering default options for any magic command. This
2377 makes it easy to have profiles which customize the magics globally
2386 makes it easy to have profiles which customize the magics globally
2378 for a certain use. The values set through this function are
2387 for a certain use. The values set through this function are
2379 picked up by the parse_options() method, which all magics should
2388 picked up by the parse_options() method, which all magics should
2380 use to parse their options.
2389 use to parse their options.
2381
2390
2382 * IPython/genutils.py (warn): modified the warnings framework to
2391 * IPython/genutils.py (warn): modified the warnings framework to
2383 use the Term I/O class. I'm trying to slowly unify all of
2392 use the Term I/O class. I'm trying to slowly unify all of
2384 IPython's I/O operations to pass through Term.
2393 IPython's I/O operations to pass through Term.
2385
2394
2386 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2395 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2387 the secondary prompt to correctly match the length of the primary
2396 the secondary prompt to correctly match the length of the primary
2388 one for any prompt. Now multi-line code will properly line up
2397 one for any prompt. Now multi-line code will properly line up
2389 even for path dependent prompts, such as the new ones available
2398 even for path dependent prompts, such as the new ones available
2390 via the prompt_specials.
2399 via the prompt_specials.
2391
2400
2392 2004-06-06 Fernando Perez <fperez@colorado.edu>
2401 2004-06-06 Fernando Perez <fperez@colorado.edu>
2393
2402
2394 * IPython/Prompts.py (prompt_specials): Added the ability to have
2403 * IPython/Prompts.py (prompt_specials): Added the ability to have
2395 bash-like special sequences in the prompts, which get
2404 bash-like special sequences in the prompts, which get
2396 automatically expanded. Things like hostname, current working
2405 automatically expanded. Things like hostname, current working
2397 directory and username are implemented already, but it's easy to
2406 directory and username are implemented already, but it's easy to
2398 add more in the future. Thanks to a patch by W.J. van der Laan
2407 add more in the future. Thanks to a patch by W.J. van der Laan
2399 <gnufnork-AT-hetdigitalegat.nl>
2408 <gnufnork-AT-hetdigitalegat.nl>
2400 (prompt_specials): Added color support for prompt strings, so
2409 (prompt_specials): Added color support for prompt strings, so
2401 users can define arbitrary color setups for their prompts.
2410 users can define arbitrary color setups for their prompts.
2402
2411
2403 2004-06-05 Fernando Perez <fperez@colorado.edu>
2412 2004-06-05 Fernando Perez <fperez@colorado.edu>
2404
2413
2405 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2414 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2406 code to load Gary Bishop's readline and configure it
2415 code to load Gary Bishop's readline and configure it
2407 automatically. Thanks to Gary for help on this.
2416 automatically. Thanks to Gary for help on this.
2408
2417
2409 2004-06-01 Fernando Perez <fperez@colorado.edu>
2418 2004-06-01 Fernando Perez <fperez@colorado.edu>
2410
2419
2411 * IPython/Logger.py (Logger.create_log): fix bug for logging
2420 * IPython/Logger.py (Logger.create_log): fix bug for logging
2412 with no filename (previous fix was incomplete).
2421 with no filename (previous fix was incomplete).
2413
2422
2414 2004-05-25 Fernando Perez <fperez@colorado.edu>
2423 2004-05-25 Fernando Perez <fperez@colorado.edu>
2415
2424
2416 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2425 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2417 parens would get passed to the shell.
2426 parens would get passed to the shell.
2418
2427
2419 2004-05-20 Fernando Perez <fperez@colorado.edu>
2428 2004-05-20 Fernando Perez <fperez@colorado.edu>
2420
2429
2421 * IPython/Magic.py (Magic.magic_prun): changed default profile
2430 * IPython/Magic.py (Magic.magic_prun): changed default profile
2422 sort order to 'time' (the more common profiling need).
2431 sort order to 'time' (the more common profiling need).
2423
2432
2424 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2433 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2425 so that source code shown is guaranteed in sync with the file on
2434 so that source code shown is guaranteed in sync with the file on
2426 disk (also changed in psource). Similar fix to the one for
2435 disk (also changed in psource). Similar fix to the one for
2427 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2436 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2428 <yann.ledu-AT-noos.fr>.
2437 <yann.ledu-AT-noos.fr>.
2429
2438
2430 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2439 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2431 with a single option would not be correctly parsed. Closes
2440 with a single option would not be correctly parsed. Closes
2432 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2441 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2433 introduced in 0.6.0 (on 2004-05-06).
2442 introduced in 0.6.0 (on 2004-05-06).
2434
2443
2435 2004-05-13 *** Released version 0.6.0
2444 2004-05-13 *** Released version 0.6.0
2436
2445
2437 2004-05-13 Fernando Perez <fperez@colorado.edu>
2446 2004-05-13 Fernando Perez <fperez@colorado.edu>
2438
2447
2439 * debian/: Added debian/ directory to CVS, so that debian support
2448 * debian/: Added debian/ directory to CVS, so that debian support
2440 is publicly accessible. The debian package is maintained by Jack
2449 is publicly accessible. The debian package is maintained by Jack
2441 Moffit <jack-AT-xiph.org>.
2450 Moffit <jack-AT-xiph.org>.
2442
2451
2443 * Documentation: included the notes about an ipython-based system
2452 * Documentation: included the notes about an ipython-based system
2444 shell (the hypothetical 'pysh') into the new_design.pdf document,
2453 shell (the hypothetical 'pysh') into the new_design.pdf document,
2445 so that these ideas get distributed to users along with the
2454 so that these ideas get distributed to users along with the
2446 official documentation.
2455 official documentation.
2447
2456
2448 2004-05-10 Fernando Perez <fperez@colorado.edu>
2457 2004-05-10 Fernando Perez <fperez@colorado.edu>
2449
2458
2450 * IPython/Logger.py (Logger.create_log): fix recently introduced
2459 * IPython/Logger.py (Logger.create_log): fix recently introduced
2451 bug (misindented line) where logstart would fail when not given an
2460 bug (misindented line) where logstart would fail when not given an
2452 explicit filename.
2461 explicit filename.
2453
2462
2454 2004-05-09 Fernando Perez <fperez@colorado.edu>
2463 2004-05-09 Fernando Perez <fperez@colorado.edu>
2455
2464
2456 * IPython/Magic.py (Magic.parse_options): skip system call when
2465 * IPython/Magic.py (Magic.parse_options): skip system call when
2457 there are no options to look for. Faster, cleaner for the common
2466 there are no options to look for. Faster, cleaner for the common
2458 case.
2467 case.
2459
2468
2460 * Documentation: many updates to the manual: describing Windows
2469 * Documentation: many updates to the manual: describing Windows
2461 support better, Gnuplot updates, credits, misc small stuff. Also
2470 support better, Gnuplot updates, credits, misc small stuff. Also
2462 updated the new_design doc a bit.
2471 updated the new_design doc a bit.
2463
2472
2464 2004-05-06 *** Released version 0.6.0.rc1
2473 2004-05-06 *** Released version 0.6.0.rc1
2465
2474
2466 2004-05-06 Fernando Perez <fperez@colorado.edu>
2475 2004-05-06 Fernando Perez <fperez@colorado.edu>
2467
2476
2468 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2477 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2469 operations to use the vastly more efficient list/''.join() method.
2478 operations to use the vastly more efficient list/''.join() method.
2470 (FormattedTB.text): Fix
2479 (FormattedTB.text): Fix
2471 http://www.scipy.net/roundup/ipython/issue12 - exception source
2480 http://www.scipy.net/roundup/ipython/issue12 - exception source
2472 extract not updated after reload. Thanks to Mike Salib
2481 extract not updated after reload. Thanks to Mike Salib
2473 <msalib-AT-mit.edu> for pinning the source of the problem.
2482 <msalib-AT-mit.edu> for pinning the source of the problem.
2474 Fortunately, the solution works inside ipython and doesn't require
2483 Fortunately, the solution works inside ipython and doesn't require
2475 any changes to python proper.
2484 any changes to python proper.
2476
2485
2477 * IPython/Magic.py (Magic.parse_options): Improved to process the
2486 * IPython/Magic.py (Magic.parse_options): Improved to process the
2478 argument list as a true shell would (by actually using the
2487 argument list as a true shell would (by actually using the
2479 underlying system shell). This way, all @magics automatically get
2488 underlying system shell). This way, all @magics automatically get
2480 shell expansion for variables. Thanks to a comment by Alex
2489 shell expansion for variables. Thanks to a comment by Alex
2481 Schmolck.
2490 Schmolck.
2482
2491
2483 2004-04-04 Fernando Perez <fperez@colorado.edu>
2492 2004-04-04 Fernando Perez <fperez@colorado.edu>
2484
2493
2485 * IPython/iplib.py (InteractiveShell.interact): Added a special
2494 * IPython/iplib.py (InteractiveShell.interact): Added a special
2486 trap for a debugger quit exception, which is basically impossible
2495 trap for a debugger quit exception, which is basically impossible
2487 to handle by normal mechanisms, given what pdb does to the stack.
2496 to handle by normal mechanisms, given what pdb does to the stack.
2488 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2497 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2489
2498
2490 2004-04-03 Fernando Perez <fperez@colorado.edu>
2499 2004-04-03 Fernando Perez <fperez@colorado.edu>
2491
2500
2492 * IPython/genutils.py (Term): Standardized the names of the Term
2501 * IPython/genutils.py (Term): Standardized the names of the Term
2493 class streams to cin/cout/cerr, following C++ naming conventions
2502 class streams to cin/cout/cerr, following C++ naming conventions
2494 (I can't use in/out/err because 'in' is not a valid attribute
2503 (I can't use in/out/err because 'in' is not a valid attribute
2495 name).
2504 name).
2496
2505
2497 * IPython/iplib.py (InteractiveShell.interact): don't increment
2506 * IPython/iplib.py (InteractiveShell.interact): don't increment
2498 the prompt if there's no user input. By Daniel 'Dang' Griffith
2507 the prompt if there's no user input. By Daniel 'Dang' Griffith
2499 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2508 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2500 Francois Pinard.
2509 Francois Pinard.
2501
2510
2502 2004-04-02 Fernando Perez <fperez@colorado.edu>
2511 2004-04-02 Fernando Perez <fperez@colorado.edu>
2503
2512
2504 * IPython/genutils.py (Stream.__init__): Modified to survive at
2513 * IPython/genutils.py (Stream.__init__): Modified to survive at
2505 least importing in contexts where stdin/out/err aren't true file
2514 least importing in contexts where stdin/out/err aren't true file
2506 objects, such as PyCrust (they lack fileno() and mode). However,
2515 objects, such as PyCrust (they lack fileno() and mode). However,
2507 the recovery facilities which rely on these things existing will
2516 the recovery facilities which rely on these things existing will
2508 not work.
2517 not work.
2509
2518
2510 2004-04-01 Fernando Perez <fperez@colorado.edu>
2519 2004-04-01 Fernando Perez <fperez@colorado.edu>
2511
2520
2512 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2521 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2513 use the new getoutputerror() function, so it properly
2522 use the new getoutputerror() function, so it properly
2514 distinguishes stdout/err.
2523 distinguishes stdout/err.
2515
2524
2516 * IPython/genutils.py (getoutputerror): added a function to
2525 * IPython/genutils.py (getoutputerror): added a function to
2517 capture separately the standard output and error of a command.
2526 capture separately the standard output and error of a command.
2518 After a comment from dang on the mailing lists. This code is
2527 After a comment from dang on the mailing lists. This code is
2519 basically a modified version of commands.getstatusoutput(), from
2528 basically a modified version of commands.getstatusoutput(), from
2520 the standard library.
2529 the standard library.
2521
2530
2522 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2531 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2523 '!!' as a special syntax (shorthand) to access @sx.
2532 '!!' as a special syntax (shorthand) to access @sx.
2524
2533
2525 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2534 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2526 command and return its output as a list split on '\n'.
2535 command and return its output as a list split on '\n'.
2527
2536
2528 2004-03-31 Fernando Perez <fperez@colorado.edu>
2537 2004-03-31 Fernando Perez <fperez@colorado.edu>
2529
2538
2530 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2539 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2531 method to dictionaries used as FakeModule instances if they lack
2540 method to dictionaries used as FakeModule instances if they lack
2532 it. At least pydoc in python2.3 breaks for runtime-defined
2541 it. At least pydoc in python2.3 breaks for runtime-defined
2533 functions without this hack. At some point I need to _really_
2542 functions without this hack. At some point I need to _really_
2534 understand what FakeModule is doing, because it's a gross hack.
2543 understand what FakeModule is doing, because it's a gross hack.
2535 But it solves Arnd's problem for now...
2544 But it solves Arnd's problem for now...
2536
2545
2537 2004-02-27 Fernando Perez <fperez@colorado.edu>
2546 2004-02-27 Fernando Perez <fperez@colorado.edu>
2538
2547
2539 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2548 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2540 mode would behave erratically. Also increased the number of
2549 mode would behave erratically. Also increased the number of
2541 possible logs in rotate mod to 999. Thanks to Rod Holland
2550 possible logs in rotate mod to 999. Thanks to Rod Holland
2542 <rhh@StructureLABS.com> for the report and fixes.
2551 <rhh@StructureLABS.com> for the report and fixes.
2543
2552
2544 2004-02-26 Fernando Perez <fperez@colorado.edu>
2553 2004-02-26 Fernando Perez <fperez@colorado.edu>
2545
2554
2546 * IPython/genutils.py (page): Check that the curses module really
2555 * IPython/genutils.py (page): Check that the curses module really
2547 has the initscr attribute before trying to use it. For some
2556 has the initscr attribute before trying to use it. For some
2548 reason, the Solaris curses module is missing this. I think this
2557 reason, the Solaris curses module is missing this. I think this
2549 should be considered a Solaris python bug, but I'm not sure.
2558 should be considered a Solaris python bug, but I'm not sure.
2550
2559
2551 2004-01-17 Fernando Perez <fperez@colorado.edu>
2560 2004-01-17 Fernando Perez <fperez@colorado.edu>
2552
2561
2553 * IPython/genutils.py (Stream.__init__): Changes to try to make
2562 * IPython/genutils.py (Stream.__init__): Changes to try to make
2554 ipython robust against stdin/out/err being closed by the user.
2563 ipython robust against stdin/out/err being closed by the user.
2555 This is 'user error' (and blocks a normal python session, at least
2564 This is 'user error' (and blocks a normal python session, at least
2556 the stdout case). However, Ipython should be able to survive such
2565 the stdout case). However, Ipython should be able to survive such
2557 instances of abuse as gracefully as possible. To simplify the
2566 instances of abuse as gracefully as possible. To simplify the
2558 coding and maintain compatibility with Gary Bishop's Term
2567 coding and maintain compatibility with Gary Bishop's Term
2559 contributions, I've made use of classmethods for this. I think
2568 contributions, I've made use of classmethods for this. I think
2560 this introduces a dependency on python 2.2.
2569 this introduces a dependency on python 2.2.
2561
2570
2562 2004-01-13 Fernando Perez <fperez@colorado.edu>
2571 2004-01-13 Fernando Perez <fperez@colorado.edu>
2563
2572
2564 * IPython/numutils.py (exp_safe): simplified the code a bit and
2573 * IPython/numutils.py (exp_safe): simplified the code a bit and
2565 removed the need for importing the kinds module altogether.
2574 removed the need for importing the kinds module altogether.
2566
2575
2567 2004-01-06 Fernando Perez <fperez@colorado.edu>
2576 2004-01-06 Fernando Perez <fperez@colorado.edu>
2568
2577
2569 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2578 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2570 a magic function instead, after some community feedback. No
2579 a magic function instead, after some community feedback. No
2571 special syntax will exist for it, but its name is deliberately
2580 special syntax will exist for it, but its name is deliberately
2572 very short.
2581 very short.
2573
2582
2574 2003-12-20 Fernando Perez <fperez@colorado.edu>
2583 2003-12-20 Fernando Perez <fperez@colorado.edu>
2575
2584
2576 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2585 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2577 new functionality, to automagically assign the result of a shell
2586 new functionality, to automagically assign the result of a shell
2578 command to a variable. I'll solicit some community feedback on
2587 command to a variable. I'll solicit some community feedback on
2579 this before making it permanent.
2588 this before making it permanent.
2580
2589
2581 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2590 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2582 requested about callables for which inspect couldn't obtain a
2591 requested about callables for which inspect couldn't obtain a
2583 proper argspec. Thanks to a crash report sent by Etienne
2592 proper argspec. Thanks to a crash report sent by Etienne
2584 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2593 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2585
2594
2586 2003-12-09 Fernando Perez <fperez@colorado.edu>
2595 2003-12-09 Fernando Perez <fperez@colorado.edu>
2587
2596
2588 * IPython/genutils.py (page): patch for the pager to work across
2597 * IPython/genutils.py (page): patch for the pager to work across
2589 various versions of Windows. By Gary Bishop.
2598 various versions of Windows. By Gary Bishop.
2590
2599
2591 2003-12-04 Fernando Perez <fperez@colorado.edu>
2600 2003-12-04 Fernando Perez <fperez@colorado.edu>
2592
2601
2593 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2602 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2594 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2603 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2595 While I tested this and it looks ok, there may still be corner
2604 While I tested this and it looks ok, there may still be corner
2596 cases I've missed.
2605 cases I've missed.
2597
2606
2598 2003-12-01 Fernando Perez <fperez@colorado.edu>
2607 2003-12-01 Fernando Perez <fperez@colorado.edu>
2599
2608
2600 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2609 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2601 where a line like 'p,q=1,2' would fail because the automagic
2610 where a line like 'p,q=1,2' would fail because the automagic
2602 system would be triggered for @p.
2611 system would be triggered for @p.
2603
2612
2604 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2613 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2605 cleanups, code unmodified.
2614 cleanups, code unmodified.
2606
2615
2607 * IPython/genutils.py (Term): added a class for IPython to handle
2616 * IPython/genutils.py (Term): added a class for IPython to handle
2608 output. In most cases it will just be a proxy for stdout/err, but
2617 output. In most cases it will just be a proxy for stdout/err, but
2609 having this allows modifications to be made for some platforms,
2618 having this allows modifications to be made for some platforms,
2610 such as handling color escapes under Windows. All of this code
2619 such as handling color escapes under Windows. All of this code
2611 was contributed by Gary Bishop, with minor modifications by me.
2620 was contributed by Gary Bishop, with minor modifications by me.
2612 The actual changes affect many files.
2621 The actual changes affect many files.
2613
2622
2614 2003-11-30 Fernando Perez <fperez@colorado.edu>
2623 2003-11-30 Fernando Perez <fperez@colorado.edu>
2615
2624
2616 * IPython/iplib.py (file_matches): new completion code, courtesy
2625 * IPython/iplib.py (file_matches): new completion code, courtesy
2617 of Jeff Collins. This enables filename completion again under
2626 of Jeff Collins. This enables filename completion again under
2618 python 2.3, which disabled it at the C level.
2627 python 2.3, which disabled it at the C level.
2619
2628
2620 2003-11-11 Fernando Perez <fperez@colorado.edu>
2629 2003-11-11 Fernando Perez <fperez@colorado.edu>
2621
2630
2622 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2631 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2623 for Numeric.array(map(...)), but often convenient.
2632 for Numeric.array(map(...)), but often convenient.
2624
2633
2625 2003-11-05 Fernando Perez <fperez@colorado.edu>
2634 2003-11-05 Fernando Perez <fperez@colorado.edu>
2626
2635
2627 * IPython/numutils.py (frange): Changed a call from int() to
2636 * IPython/numutils.py (frange): Changed a call from int() to
2628 int(round()) to prevent a problem reported with arange() in the
2637 int(round()) to prevent a problem reported with arange() in the
2629 numpy list.
2638 numpy list.
2630
2639
2631 2003-10-06 Fernando Perez <fperez@colorado.edu>
2640 2003-10-06 Fernando Perez <fperez@colorado.edu>
2632
2641
2633 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2642 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2634 prevent crashes if sys lacks an argv attribute (it happens with
2643 prevent crashes if sys lacks an argv attribute (it happens with
2635 embedded interpreters which build a bare-bones sys module).
2644 embedded interpreters which build a bare-bones sys module).
2636 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2645 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2637
2646
2638 2003-09-24 Fernando Perez <fperez@colorado.edu>
2647 2003-09-24 Fernando Perez <fperez@colorado.edu>
2639
2648
2640 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2649 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2641 to protect against poorly written user objects where __getattr__
2650 to protect against poorly written user objects where __getattr__
2642 raises exceptions other than AttributeError. Thanks to a bug
2651 raises exceptions other than AttributeError. Thanks to a bug
2643 report by Oliver Sander <osander-AT-gmx.de>.
2652 report by Oliver Sander <osander-AT-gmx.de>.
2644
2653
2645 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2654 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2646 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2655 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2647
2656
2648 2003-09-09 Fernando Perez <fperez@colorado.edu>
2657 2003-09-09 Fernando Perez <fperez@colorado.edu>
2649
2658
2650 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2659 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2651 unpacking a list whith a callable as first element would
2660 unpacking a list whith a callable as first element would
2652 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2661 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2653 Collins.
2662 Collins.
2654
2663
2655 2003-08-25 *** Released version 0.5.0
2664 2003-08-25 *** Released version 0.5.0
2656
2665
2657 2003-08-22 Fernando Perez <fperez@colorado.edu>
2666 2003-08-22 Fernando Perez <fperez@colorado.edu>
2658
2667
2659 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2668 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2660 improperly defined user exceptions. Thanks to feedback from Mark
2669 improperly defined user exceptions. Thanks to feedback from Mark
2661 Russell <mrussell-AT-verio.net>.
2670 Russell <mrussell-AT-verio.net>.
2662
2671
2663 2003-08-20 Fernando Perez <fperez@colorado.edu>
2672 2003-08-20 Fernando Perez <fperez@colorado.edu>
2664
2673
2665 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2674 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2666 printing so that it would print multi-line string forms starting
2675 printing so that it would print multi-line string forms starting
2667 with a new line. This way the formatting is better respected for
2676 with a new line. This way the formatting is better respected for
2668 objects which work hard to make nice string forms.
2677 objects which work hard to make nice string forms.
2669
2678
2670 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2679 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2671 autocall would overtake data access for objects with both
2680 autocall would overtake data access for objects with both
2672 __getitem__ and __call__.
2681 __getitem__ and __call__.
2673
2682
2674 2003-08-19 *** Released version 0.5.0-rc1
2683 2003-08-19 *** Released version 0.5.0-rc1
2675
2684
2676 2003-08-19 Fernando Perez <fperez@colorado.edu>
2685 2003-08-19 Fernando Perez <fperez@colorado.edu>
2677
2686
2678 * IPython/deep_reload.py (load_tail): single tiny change here
2687 * IPython/deep_reload.py (load_tail): single tiny change here
2679 seems to fix the long-standing bug of dreload() failing to work
2688 seems to fix the long-standing bug of dreload() failing to work
2680 for dotted names. But this module is pretty tricky, so I may have
2689 for dotted names. But this module is pretty tricky, so I may have
2681 missed some subtlety. Needs more testing!.
2690 missed some subtlety. Needs more testing!.
2682
2691
2683 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2692 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2684 exceptions which have badly implemented __str__ methods.
2693 exceptions which have badly implemented __str__ methods.
2685 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2694 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2686 which I've been getting reports about from Python 2.3 users. I
2695 which I've been getting reports about from Python 2.3 users. I
2687 wish I had a simple test case to reproduce the problem, so I could
2696 wish I had a simple test case to reproduce the problem, so I could
2688 either write a cleaner workaround or file a bug report if
2697 either write a cleaner workaround or file a bug report if
2689 necessary.
2698 necessary.
2690
2699
2691 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2700 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2692 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2701 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2693 a bug report by Tjabo Kloppenburg.
2702 a bug report by Tjabo Kloppenburg.
2694
2703
2695 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2704 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2696 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2705 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2697 seems rather unstable. Thanks to a bug report by Tjabo
2706 seems rather unstable. Thanks to a bug report by Tjabo
2698 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2707 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2699
2708
2700 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2709 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2701 this out soon because of the critical fixes in the inner loop for
2710 this out soon because of the critical fixes in the inner loop for
2702 generators.
2711 generators.
2703
2712
2704 * IPython/Magic.py (Magic.getargspec): removed. This (and
2713 * IPython/Magic.py (Magic.getargspec): removed. This (and
2705 _get_def) have been obsoleted by OInspect for a long time, I
2714 _get_def) have been obsoleted by OInspect for a long time, I
2706 hadn't noticed that they were dead code.
2715 hadn't noticed that they were dead code.
2707 (Magic._ofind): restored _ofind functionality for a few literals
2716 (Magic._ofind): restored _ofind functionality for a few literals
2708 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2717 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2709 for things like "hello".capitalize?, since that would require a
2718 for things like "hello".capitalize?, since that would require a
2710 potentially dangerous eval() again.
2719 potentially dangerous eval() again.
2711
2720
2712 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2721 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2713 logic a bit more to clean up the escapes handling and minimize the
2722 logic a bit more to clean up the escapes handling and minimize the
2714 use of _ofind to only necessary cases. The interactive 'feel' of
2723 use of _ofind to only necessary cases. The interactive 'feel' of
2715 IPython should have improved quite a bit with the changes in
2724 IPython should have improved quite a bit with the changes in
2716 _prefilter and _ofind (besides being far safer than before).
2725 _prefilter and _ofind (besides being far safer than before).
2717
2726
2718 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2727 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2719 obscure, never reported). Edit would fail to find the object to
2728 obscure, never reported). Edit would fail to find the object to
2720 edit under some circumstances.
2729 edit under some circumstances.
2721 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2730 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2722 which were causing double-calling of generators. Those eval calls
2731 which were causing double-calling of generators. Those eval calls
2723 were _very_ dangerous, since code with side effects could be
2732 were _very_ dangerous, since code with side effects could be
2724 triggered. As they say, 'eval is evil'... These were the
2733 triggered. As they say, 'eval is evil'... These were the
2725 nastiest evals in IPython. Besides, _ofind is now far simpler,
2734 nastiest evals in IPython. Besides, _ofind is now far simpler,
2726 and it should also be quite a bit faster. Its use of inspect is
2735 and it should also be quite a bit faster. Its use of inspect is
2727 also safer, so perhaps some of the inspect-related crashes I've
2736 also safer, so perhaps some of the inspect-related crashes I've
2728 seen lately with Python 2.3 might be taken care of. That will
2737 seen lately with Python 2.3 might be taken care of. That will
2729 need more testing.
2738 need more testing.
2730
2739
2731 2003-08-17 Fernando Perez <fperez@colorado.edu>
2740 2003-08-17 Fernando Perez <fperez@colorado.edu>
2732
2741
2733 * IPython/iplib.py (InteractiveShell._prefilter): significant
2742 * IPython/iplib.py (InteractiveShell._prefilter): significant
2734 simplifications to the logic for handling user escapes. Faster
2743 simplifications to the logic for handling user escapes. Faster
2735 and simpler code.
2744 and simpler code.
2736
2745
2737 2003-08-14 Fernando Perez <fperez@colorado.edu>
2746 2003-08-14 Fernando Perez <fperez@colorado.edu>
2738
2747
2739 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2748 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2740 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2749 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2741 but it should be quite a bit faster. And the recursive version
2750 but it should be quite a bit faster. And the recursive version
2742 generated O(log N) intermediate storage for all rank>1 arrays,
2751 generated O(log N) intermediate storage for all rank>1 arrays,
2743 even if they were contiguous.
2752 even if they were contiguous.
2744 (l1norm): Added this function.
2753 (l1norm): Added this function.
2745 (norm): Added this function for arbitrary norms (including
2754 (norm): Added this function for arbitrary norms (including
2746 l-infinity). l1 and l2 are still special cases for convenience
2755 l-infinity). l1 and l2 are still special cases for convenience
2747 and speed.
2756 and speed.
2748
2757
2749 2003-08-03 Fernando Perez <fperez@colorado.edu>
2758 2003-08-03 Fernando Perez <fperez@colorado.edu>
2750
2759
2751 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2760 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2752 exceptions, which now raise PendingDeprecationWarnings in Python
2761 exceptions, which now raise PendingDeprecationWarnings in Python
2753 2.3. There were some in Magic and some in Gnuplot2.
2762 2.3. There were some in Magic and some in Gnuplot2.
2754
2763
2755 2003-06-30 Fernando Perez <fperez@colorado.edu>
2764 2003-06-30 Fernando Perez <fperez@colorado.edu>
2756
2765
2757 * IPython/genutils.py (page): modified to call curses only for
2766 * IPython/genutils.py (page): modified to call curses only for
2758 terminals where TERM=='xterm'. After problems under many other
2767 terminals where TERM=='xterm'. After problems under many other
2759 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2768 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2760
2769
2761 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2770 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2762 would be triggered when readline was absent. This was just an old
2771 would be triggered when readline was absent. This was just an old
2763 debugging statement I'd forgotten to take out.
2772 debugging statement I'd forgotten to take out.
2764
2773
2765 2003-06-20 Fernando Perez <fperez@colorado.edu>
2774 2003-06-20 Fernando Perez <fperez@colorado.edu>
2766
2775
2767 * IPython/genutils.py (clock): modified to return only user time
2776 * IPython/genutils.py (clock): modified to return only user time
2768 (not counting system time), after a discussion on scipy. While
2777 (not counting system time), after a discussion on scipy. While
2769 system time may be a useful quantity occasionally, it may much
2778 system time may be a useful quantity occasionally, it may much
2770 more easily be skewed by occasional swapping or other similar
2779 more easily be skewed by occasional swapping or other similar
2771 activity.
2780 activity.
2772
2781
2773 2003-06-05 Fernando Perez <fperez@colorado.edu>
2782 2003-06-05 Fernando Perez <fperez@colorado.edu>
2774
2783
2775 * IPython/numutils.py (identity): new function, for building
2784 * IPython/numutils.py (identity): new function, for building
2776 arbitrary rank Kronecker deltas (mostly backwards compatible with
2785 arbitrary rank Kronecker deltas (mostly backwards compatible with
2777 Numeric.identity)
2786 Numeric.identity)
2778
2787
2779 2003-06-03 Fernando Perez <fperez@colorado.edu>
2788 2003-06-03 Fernando Perez <fperez@colorado.edu>
2780
2789
2781 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2790 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2782 arguments passed to magics with spaces, to allow trailing '\' to
2791 arguments passed to magics with spaces, to allow trailing '\' to
2783 work normally (mainly for Windows users).
2792 work normally (mainly for Windows users).
2784
2793
2785 2003-05-29 Fernando Perez <fperez@colorado.edu>
2794 2003-05-29 Fernando Perez <fperez@colorado.edu>
2786
2795
2787 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2796 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2788 instead of pydoc.help. This fixes a bizarre behavior where
2797 instead of pydoc.help. This fixes a bizarre behavior where
2789 printing '%s' % locals() would trigger the help system. Now
2798 printing '%s' % locals() would trigger the help system. Now
2790 ipython behaves like normal python does.
2799 ipython behaves like normal python does.
2791
2800
2792 Note that if one does 'from pydoc import help', the bizarre
2801 Note that if one does 'from pydoc import help', the bizarre
2793 behavior returns, but this will also happen in normal python, so
2802 behavior returns, but this will also happen in normal python, so
2794 it's not an ipython bug anymore (it has to do with how pydoc.help
2803 it's not an ipython bug anymore (it has to do with how pydoc.help
2795 is implemented).
2804 is implemented).
2796
2805
2797 2003-05-22 Fernando Perez <fperez@colorado.edu>
2806 2003-05-22 Fernando Perez <fperez@colorado.edu>
2798
2807
2799 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2808 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2800 return [] instead of None when nothing matches, also match to end
2809 return [] instead of None when nothing matches, also match to end
2801 of line. Patch by Gary Bishop.
2810 of line. Patch by Gary Bishop.
2802
2811
2803 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2812 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2804 protection as before, for files passed on the command line. This
2813 protection as before, for files passed on the command line. This
2805 prevents the CrashHandler from kicking in if user files call into
2814 prevents the CrashHandler from kicking in if user files call into
2806 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2815 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2807 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2816 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2808
2817
2809 2003-05-20 *** Released version 0.4.0
2818 2003-05-20 *** Released version 0.4.0
2810
2819
2811 2003-05-20 Fernando Perez <fperez@colorado.edu>
2820 2003-05-20 Fernando Perez <fperez@colorado.edu>
2812
2821
2813 * setup.py: added support for manpages. It's a bit hackish b/c of
2822 * setup.py: added support for manpages. It's a bit hackish b/c of
2814 a bug in the way the bdist_rpm distutils target handles gzipped
2823 a bug in the way the bdist_rpm distutils target handles gzipped
2815 manpages, but it works. After a patch by Jack.
2824 manpages, but it works. After a patch by Jack.
2816
2825
2817 2003-05-19 Fernando Perez <fperez@colorado.edu>
2826 2003-05-19 Fernando Perez <fperez@colorado.edu>
2818
2827
2819 * IPython/numutils.py: added a mockup of the kinds module, since
2828 * IPython/numutils.py: added a mockup of the kinds module, since
2820 it was recently removed from Numeric. This way, numutils will
2829 it was recently removed from Numeric. This way, numutils will
2821 work for all users even if they are missing kinds.
2830 work for all users even if they are missing kinds.
2822
2831
2823 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2832 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2824 failure, which can occur with SWIG-wrapped extensions. After a
2833 failure, which can occur with SWIG-wrapped extensions. After a
2825 crash report from Prabhu.
2834 crash report from Prabhu.
2826
2835
2827 2003-05-16 Fernando Perez <fperez@colorado.edu>
2836 2003-05-16 Fernando Perez <fperez@colorado.edu>
2828
2837
2829 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2838 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2830 protect ipython from user code which may call directly
2839 protect ipython from user code which may call directly
2831 sys.excepthook (this looks like an ipython crash to the user, even
2840 sys.excepthook (this looks like an ipython crash to the user, even
2832 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2841 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2833 This is especially important to help users of WxWindows, but may
2842 This is especially important to help users of WxWindows, but may
2834 also be useful in other cases.
2843 also be useful in other cases.
2835
2844
2836 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2845 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2837 an optional tb_offset to be specified, and to preserve exception
2846 an optional tb_offset to be specified, and to preserve exception
2838 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2847 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2839
2848
2840 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2849 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2841
2850
2842 2003-05-15 Fernando Perez <fperez@colorado.edu>
2851 2003-05-15 Fernando Perez <fperez@colorado.edu>
2843
2852
2844 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2853 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2845 installing for a new user under Windows.
2854 installing for a new user under Windows.
2846
2855
2847 2003-05-12 Fernando Perez <fperez@colorado.edu>
2856 2003-05-12 Fernando Perez <fperez@colorado.edu>
2848
2857
2849 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2858 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2850 handler for Emacs comint-based lines. Currently it doesn't do
2859 handler for Emacs comint-based lines. Currently it doesn't do
2851 much (but importantly, it doesn't update the history cache). In
2860 much (but importantly, it doesn't update the history cache). In
2852 the future it may be expanded if Alex needs more functionality
2861 the future it may be expanded if Alex needs more functionality
2853 there.
2862 there.
2854
2863
2855 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2864 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2856 info to crash reports.
2865 info to crash reports.
2857
2866
2858 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2867 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2859 just like Python's -c. Also fixed crash with invalid -color
2868 just like Python's -c. Also fixed crash with invalid -color
2860 option value at startup. Thanks to Will French
2869 option value at startup. Thanks to Will French
2861 <wfrench-AT-bestweb.net> for the bug report.
2870 <wfrench-AT-bestweb.net> for the bug report.
2862
2871
2863 2003-05-09 Fernando Perez <fperez@colorado.edu>
2872 2003-05-09 Fernando Perez <fperez@colorado.edu>
2864
2873
2865 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2874 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2866 to EvalDict (it's a mapping, after all) and simplified its code
2875 to EvalDict (it's a mapping, after all) and simplified its code
2867 quite a bit, after a nice discussion on c.l.py where Gustavo
2876 quite a bit, after a nice discussion on c.l.py where Gustavo
2868 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2877 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2869
2878
2870 2003-04-30 Fernando Perez <fperez@colorado.edu>
2879 2003-04-30 Fernando Perez <fperez@colorado.edu>
2871
2880
2872 * IPython/genutils.py (timings_out): modified it to reduce its
2881 * IPython/genutils.py (timings_out): modified it to reduce its
2873 overhead in the common reps==1 case.
2882 overhead in the common reps==1 case.
2874
2883
2875 2003-04-29 Fernando Perez <fperez@colorado.edu>
2884 2003-04-29 Fernando Perez <fperez@colorado.edu>
2876
2885
2877 * IPython/genutils.py (timings_out): Modified to use the resource
2886 * IPython/genutils.py (timings_out): Modified to use the resource
2878 module, which avoids the wraparound problems of time.clock().
2887 module, which avoids the wraparound problems of time.clock().
2879
2888
2880 2003-04-17 *** Released version 0.2.15pre4
2889 2003-04-17 *** Released version 0.2.15pre4
2881
2890
2882 2003-04-17 Fernando Perez <fperez@colorado.edu>
2891 2003-04-17 Fernando Perez <fperez@colorado.edu>
2883
2892
2884 * setup.py (scriptfiles): Split windows-specific stuff over to a
2893 * setup.py (scriptfiles): Split windows-specific stuff over to a
2885 separate file, in an attempt to have a Windows GUI installer.
2894 separate file, in an attempt to have a Windows GUI installer.
2886 That didn't work, but part of the groundwork is done.
2895 That didn't work, but part of the groundwork is done.
2887
2896
2888 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2897 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2889 indent/unindent with 4 spaces. Particularly useful in combination
2898 indent/unindent with 4 spaces. Particularly useful in combination
2890 with the new auto-indent option.
2899 with the new auto-indent option.
2891
2900
2892 2003-04-16 Fernando Perez <fperez@colorado.edu>
2901 2003-04-16 Fernando Perez <fperez@colorado.edu>
2893
2902
2894 * IPython/Magic.py: various replacements of self.rc for
2903 * IPython/Magic.py: various replacements of self.rc for
2895 self.shell.rc. A lot more remains to be done to fully disentangle
2904 self.shell.rc. A lot more remains to be done to fully disentangle
2896 this class from the main Shell class.
2905 this class from the main Shell class.
2897
2906
2898 * IPython/GnuplotRuntime.py: added checks for mouse support so
2907 * IPython/GnuplotRuntime.py: added checks for mouse support so
2899 that we don't try to enable it if the current gnuplot doesn't
2908 that we don't try to enable it if the current gnuplot doesn't
2900 really support it. Also added checks so that we don't try to
2909 really support it. Also added checks so that we don't try to
2901 enable persist under Windows (where Gnuplot doesn't recognize the
2910 enable persist under Windows (where Gnuplot doesn't recognize the
2902 option).
2911 option).
2903
2912
2904 * IPython/iplib.py (InteractiveShell.interact): Added optional
2913 * IPython/iplib.py (InteractiveShell.interact): Added optional
2905 auto-indenting code, after a patch by King C. Shu
2914 auto-indenting code, after a patch by King C. Shu
2906 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2915 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2907 get along well with pasting indented code. If I ever figure out
2916 get along well with pasting indented code. If I ever figure out
2908 how to make that part go well, it will become on by default.
2917 how to make that part go well, it will become on by default.
2909
2918
2910 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2919 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2911 crash ipython if there was an unmatched '%' in the user's prompt
2920 crash ipython if there was an unmatched '%' in the user's prompt
2912 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2921 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2913
2922
2914 * IPython/iplib.py (InteractiveShell.interact): removed the
2923 * IPython/iplib.py (InteractiveShell.interact): removed the
2915 ability to ask the user whether he wants to crash or not at the
2924 ability to ask the user whether he wants to crash or not at the
2916 'last line' exception handler. Calling functions at that point
2925 'last line' exception handler. Calling functions at that point
2917 changes the stack, and the error reports would have incorrect
2926 changes the stack, and the error reports would have incorrect
2918 tracebacks.
2927 tracebacks.
2919
2928
2920 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2929 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2921 pass through a peger a pretty-printed form of any object. After a
2930 pass through a peger a pretty-printed form of any object. After a
2922 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2931 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2923
2932
2924 2003-04-14 Fernando Perez <fperez@colorado.edu>
2933 2003-04-14 Fernando Perez <fperez@colorado.edu>
2925
2934
2926 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2935 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2927 all files in ~ would be modified at first install (instead of
2936 all files in ~ would be modified at first install (instead of
2928 ~/.ipython). This could be potentially disastrous, as the
2937 ~/.ipython). This could be potentially disastrous, as the
2929 modification (make line-endings native) could damage binary files.
2938 modification (make line-endings native) could damage binary files.
2930
2939
2931 2003-04-10 Fernando Perez <fperez@colorado.edu>
2940 2003-04-10 Fernando Perez <fperez@colorado.edu>
2932
2941
2933 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2942 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2934 handle only lines which are invalid python. This now means that
2943 handle only lines which are invalid python. This now means that
2935 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2944 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2936 for the bug report.
2945 for the bug report.
2937
2946
2938 2003-04-01 Fernando Perez <fperez@colorado.edu>
2947 2003-04-01 Fernando Perez <fperez@colorado.edu>
2939
2948
2940 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2949 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2941 where failing to set sys.last_traceback would crash pdb.pm().
2950 where failing to set sys.last_traceback would crash pdb.pm().
2942 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2951 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2943 report.
2952 report.
2944
2953
2945 2003-03-25 Fernando Perez <fperez@colorado.edu>
2954 2003-03-25 Fernando Perez <fperez@colorado.edu>
2946
2955
2947 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2956 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2948 before printing it (it had a lot of spurious blank lines at the
2957 before printing it (it had a lot of spurious blank lines at the
2949 end).
2958 end).
2950
2959
2951 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2960 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2952 output would be sent 21 times! Obviously people don't use this
2961 output would be sent 21 times! Obviously people don't use this
2953 too often, or I would have heard about it.
2962 too often, or I would have heard about it.
2954
2963
2955 2003-03-24 Fernando Perez <fperez@colorado.edu>
2964 2003-03-24 Fernando Perez <fperez@colorado.edu>
2956
2965
2957 * setup.py (scriptfiles): renamed the data_files parameter from
2966 * setup.py (scriptfiles): renamed the data_files parameter from
2958 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2967 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2959 for the patch.
2968 for the patch.
2960
2969
2961 2003-03-20 Fernando Perez <fperez@colorado.edu>
2970 2003-03-20 Fernando Perez <fperez@colorado.edu>
2962
2971
2963 * IPython/genutils.py (error): added error() and fatal()
2972 * IPython/genutils.py (error): added error() and fatal()
2964 functions.
2973 functions.
2965
2974
2966 2003-03-18 *** Released version 0.2.15pre3
2975 2003-03-18 *** Released version 0.2.15pre3
2967
2976
2968 2003-03-18 Fernando Perez <fperez@colorado.edu>
2977 2003-03-18 Fernando Perez <fperez@colorado.edu>
2969
2978
2970 * setupext/install_data_ext.py
2979 * setupext/install_data_ext.py
2971 (install_data_ext.initialize_options): Class contributed by Jack
2980 (install_data_ext.initialize_options): Class contributed by Jack
2972 Moffit for fixing the old distutils hack. He is sending this to
2981 Moffit for fixing the old distutils hack. He is sending this to
2973 the distutils folks so in the future we may not need it as a
2982 the distutils folks so in the future we may not need it as a
2974 private fix.
2983 private fix.
2975
2984
2976 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2985 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2977 changes for Debian packaging. See his patch for full details.
2986 changes for Debian packaging. See his patch for full details.
2978 The old distutils hack of making the ipythonrc* files carry a
2987 The old distutils hack of making the ipythonrc* files carry a
2979 bogus .py extension is gone, at last. Examples were moved to a
2988 bogus .py extension is gone, at last. Examples were moved to a
2980 separate subdir under doc/, and the separate executable scripts
2989 separate subdir under doc/, and the separate executable scripts
2981 now live in their own directory. Overall a great cleanup. The
2990 now live in their own directory. Overall a great cleanup. The
2982 manual was updated to use the new files, and setup.py has been
2991 manual was updated to use the new files, and setup.py has been
2983 fixed for this setup.
2992 fixed for this setup.
2984
2993
2985 * IPython/PyColorize.py (Parser.usage): made non-executable and
2994 * IPython/PyColorize.py (Parser.usage): made non-executable and
2986 created a pycolor wrapper around it to be included as a script.
2995 created a pycolor wrapper around it to be included as a script.
2987
2996
2988 2003-03-12 *** Released version 0.2.15pre2
2997 2003-03-12 *** Released version 0.2.15pre2
2989
2998
2990 2003-03-12 Fernando Perez <fperez@colorado.edu>
2999 2003-03-12 Fernando Perez <fperez@colorado.edu>
2991
3000
2992 * IPython/ColorANSI.py (make_color_table): Finally fixed the
3001 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2993 long-standing problem with garbage characters in some terminals.
3002 long-standing problem with garbage characters in some terminals.
2994 The issue was really that the \001 and \002 escapes must _only_ be
3003 The issue was really that the \001 and \002 escapes must _only_ be
2995 passed to input prompts (which call readline), but _never_ to
3004 passed to input prompts (which call readline), but _never_ to
2996 normal text to be printed on screen. I changed ColorANSI to have
3005 normal text to be printed on screen. I changed ColorANSI to have
2997 two classes: TermColors and InputTermColors, each with the
3006 two classes: TermColors and InputTermColors, each with the
2998 appropriate escapes for input prompts or normal text. The code in
3007 appropriate escapes for input prompts or normal text. The code in
2999 Prompts.py got slightly more complicated, but this very old and
3008 Prompts.py got slightly more complicated, but this very old and
3000 annoying bug is finally fixed.
3009 annoying bug is finally fixed.
3001
3010
3002 All the credit for nailing down the real origin of this problem
3011 All the credit for nailing down the real origin of this problem
3003 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
3012 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
3004 *Many* thanks to him for spending quite a bit of effort on this.
3013 *Many* thanks to him for spending quite a bit of effort on this.
3005
3014
3006 2003-03-05 *** Released version 0.2.15pre1
3015 2003-03-05 *** Released version 0.2.15pre1
3007
3016
3008 2003-03-03 Fernando Perez <fperez@colorado.edu>
3017 2003-03-03 Fernando Perez <fperez@colorado.edu>
3009
3018
3010 * IPython/FakeModule.py: Moved the former _FakeModule to a
3019 * IPython/FakeModule.py: Moved the former _FakeModule to a
3011 separate file, because it's also needed by Magic (to fix a similar
3020 separate file, because it's also needed by Magic (to fix a similar
3012 pickle-related issue in @run).
3021 pickle-related issue in @run).
3013
3022
3014 2003-03-02 Fernando Perez <fperez@colorado.edu>
3023 2003-03-02 Fernando Perez <fperez@colorado.edu>
3015
3024
3016 * IPython/Magic.py (Magic.magic_autocall): new magic to control
3025 * IPython/Magic.py (Magic.magic_autocall): new magic to control
3017 the autocall option at runtime.
3026 the autocall option at runtime.
3018 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
3027 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
3019 across Magic.py to start separating Magic from InteractiveShell.
3028 across Magic.py to start separating Magic from InteractiveShell.
3020 (Magic._ofind): Fixed to return proper namespace for dotted
3029 (Magic._ofind): Fixed to return proper namespace for dotted
3021 names. Before, a dotted name would always return 'not currently
3030 names. Before, a dotted name would always return 'not currently
3022 defined', because it would find the 'parent'. s.x would be found,
3031 defined', because it would find the 'parent'. s.x would be found,
3023 but since 'x' isn't defined by itself, it would get confused.
3032 but since 'x' isn't defined by itself, it would get confused.
3024 (Magic.magic_run): Fixed pickling problems reported by Ralf
3033 (Magic.magic_run): Fixed pickling problems reported by Ralf
3025 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
3034 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
3026 that I'd used when Mike Heeter reported similar issues at the
3035 that I'd used when Mike Heeter reported similar issues at the
3027 top-level, but now for @run. It boils down to injecting the
3036 top-level, but now for @run. It boils down to injecting the
3028 namespace where code is being executed with something that looks
3037 namespace where code is being executed with something that looks
3029 enough like a module to fool pickle.dump(). Since a pickle stores
3038 enough like a module to fool pickle.dump(). Since a pickle stores
3030 a named reference to the importing module, we need this for
3039 a named reference to the importing module, we need this for
3031 pickles to save something sensible.
3040 pickles to save something sensible.
3032
3041
3033 * IPython/ipmaker.py (make_IPython): added an autocall option.
3042 * IPython/ipmaker.py (make_IPython): added an autocall option.
3034
3043
3035 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
3044 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
3036 the auto-eval code. Now autocalling is an option, and the code is
3045 the auto-eval code. Now autocalling is an option, and the code is
3037 also vastly safer. There is no more eval() involved at all.
3046 also vastly safer. There is no more eval() involved at all.
3038
3047
3039 2003-03-01 Fernando Perez <fperez@colorado.edu>
3048 2003-03-01 Fernando Perez <fperez@colorado.edu>
3040
3049
3041 * IPython/Magic.py (Magic._ofind): Changed interface to return a
3050 * IPython/Magic.py (Magic._ofind): Changed interface to return a
3042 dict with named keys instead of a tuple.
3051 dict with named keys instead of a tuple.
3043
3052
3044 * IPython: Started using CVS for IPython as of 0.2.15pre1.
3053 * IPython: Started using CVS for IPython as of 0.2.15pre1.
3045
3054
3046 * setup.py (make_shortcut): Fixed message about directories
3055 * setup.py (make_shortcut): Fixed message about directories
3047 created during Windows installation (the directories were ok, just
3056 created during Windows installation (the directories were ok, just
3048 the printed message was misleading). Thanks to Chris Liechti
3057 the printed message was misleading). Thanks to Chris Liechti
3049 <cliechti-AT-gmx.net> for the heads up.
3058 <cliechti-AT-gmx.net> for the heads up.
3050
3059
3051 2003-02-21 Fernando Perez <fperez@colorado.edu>
3060 2003-02-21 Fernando Perez <fperez@colorado.edu>
3052
3061
3053 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
3062 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
3054 of ValueError exception when checking for auto-execution. This
3063 of ValueError exception when checking for auto-execution. This
3055 one is raised by things like Numeric arrays arr.flat when the
3064 one is raised by things like Numeric arrays arr.flat when the
3056 array is non-contiguous.
3065 array is non-contiguous.
3057
3066
3058 2003-01-31 Fernando Perez <fperez@colorado.edu>
3067 2003-01-31 Fernando Perez <fperez@colorado.edu>
3059
3068
3060 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
3069 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
3061 not return any value at all (even though the command would get
3070 not return any value at all (even though the command would get
3062 executed).
3071 executed).
3063 (xsys): Flush stdout right after printing the command to ensure
3072 (xsys): Flush stdout right after printing the command to ensure
3064 proper ordering of commands and command output in the total
3073 proper ordering of commands and command output in the total
3065 output.
3074 output.
3066 (SystemExec/xsys/bq): Switched the names of xsys/bq and
3075 (SystemExec/xsys/bq): Switched the names of xsys/bq and
3067 system/getoutput as defaults. The old ones are kept for
3076 system/getoutput as defaults. The old ones are kept for
3068 compatibility reasons, so no code which uses this library needs
3077 compatibility reasons, so no code which uses this library needs
3069 changing.
3078 changing.
3070
3079
3071 2003-01-27 *** Released version 0.2.14
3080 2003-01-27 *** Released version 0.2.14
3072
3081
3073 2003-01-25 Fernando Perez <fperez@colorado.edu>
3082 2003-01-25 Fernando Perez <fperez@colorado.edu>
3074
3083
3075 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
3084 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
3076 functions defined in previous edit sessions could not be re-edited
3085 functions defined in previous edit sessions could not be re-edited
3077 (because the temp files were immediately removed). Now temp files
3086 (because the temp files were immediately removed). Now temp files
3078 are removed only at IPython's exit.
3087 are removed only at IPython's exit.
3079 (Magic.magic_run): Improved @run to perform shell-like expansions
3088 (Magic.magic_run): Improved @run to perform shell-like expansions
3080 on its arguments (~users and $VARS). With this, @run becomes more
3089 on its arguments (~users and $VARS). With this, @run becomes more
3081 like a normal command-line.
3090 like a normal command-line.
3082
3091
3083 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
3092 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
3084 bugs related to embedding and cleaned up that code. A fairly
3093 bugs related to embedding and cleaned up that code. A fairly
3085 important one was the impossibility to access the global namespace
3094 important one was the impossibility to access the global namespace
3086 through the embedded IPython (only local variables were visible).
3095 through the embedded IPython (only local variables were visible).
3087
3096
3088 2003-01-14 Fernando Perez <fperez@colorado.edu>
3097 2003-01-14 Fernando Perez <fperez@colorado.edu>
3089
3098
3090 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3099 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3091 auto-calling to be a bit more conservative. Now it doesn't get
3100 auto-calling to be a bit more conservative. Now it doesn't get
3092 triggered if any of '!=()<>' are in the rest of the input line, to
3101 triggered if any of '!=()<>' are in the rest of the input line, to
3093 allow comparing callables. Thanks to Alex for the heads up.
3102 allow comparing callables. Thanks to Alex for the heads up.
3094
3103
3095 2003-01-07 Fernando Perez <fperez@colorado.edu>
3104 2003-01-07 Fernando Perez <fperez@colorado.edu>
3096
3105
3097 * IPython/genutils.py (page): fixed estimation of the number of
3106 * IPython/genutils.py (page): fixed estimation of the number of
3098 lines in a string to be paged to simply count newlines. This
3107 lines in a string to be paged to simply count newlines. This
3099 prevents over-guessing due to embedded escape sequences. A better
3108 prevents over-guessing due to embedded escape sequences. A better
3100 long-term solution would involve stripping out the control chars
3109 long-term solution would involve stripping out the control chars
3101 for the count, but it's potentially so expensive I just don't
3110 for the count, but it's potentially so expensive I just don't
3102 think it's worth doing.
3111 think it's worth doing.
3103
3112
3104 2002-12-19 *** Released version 0.2.14pre50
3113 2002-12-19 *** Released version 0.2.14pre50
3105
3114
3106 2002-12-19 Fernando Perez <fperez@colorado.edu>
3115 2002-12-19 Fernando Perez <fperez@colorado.edu>
3107
3116
3108 * tools/release (version): Changed release scripts to inform
3117 * tools/release (version): Changed release scripts to inform
3109 Andrea and build a NEWS file with a list of recent changes.
3118 Andrea and build a NEWS file with a list of recent changes.
3110
3119
3111 * IPython/ColorANSI.py (__all__): changed terminal detection
3120 * IPython/ColorANSI.py (__all__): changed terminal detection
3112 code. Seems to work better for xterms without breaking
3121 code. Seems to work better for xterms without breaking
3113 konsole. Will need more testing to determine if WinXP and Mac OSX
3122 konsole. Will need more testing to determine if WinXP and Mac OSX
3114 also work ok.
3123 also work ok.
3115
3124
3116 2002-12-18 *** Released version 0.2.14pre49
3125 2002-12-18 *** Released version 0.2.14pre49
3117
3126
3118 2002-12-18 Fernando Perez <fperez@colorado.edu>
3127 2002-12-18 Fernando Perez <fperez@colorado.edu>
3119
3128
3120 * Docs: added new info about Mac OSX, from Andrea.
3129 * Docs: added new info about Mac OSX, from Andrea.
3121
3130
3122 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
3131 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
3123 allow direct plotting of python strings whose format is the same
3132 allow direct plotting of python strings whose format is the same
3124 of gnuplot data files.
3133 of gnuplot data files.
3125
3134
3126 2002-12-16 Fernando Perez <fperez@colorado.edu>
3135 2002-12-16 Fernando Perez <fperez@colorado.edu>
3127
3136
3128 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
3137 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
3129 value of exit question to be acknowledged.
3138 value of exit question to be acknowledged.
3130
3139
3131 2002-12-03 Fernando Perez <fperez@colorado.edu>
3140 2002-12-03 Fernando Perez <fperez@colorado.edu>
3132
3141
3133 * IPython/ipmaker.py: removed generators, which had been added
3142 * IPython/ipmaker.py: removed generators, which had been added
3134 by mistake in an earlier debugging run. This was causing trouble
3143 by mistake in an earlier debugging run. This was causing trouble
3135 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
3144 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
3136 for pointing this out.
3145 for pointing this out.
3137
3146
3138 2002-11-17 Fernando Perez <fperez@colorado.edu>
3147 2002-11-17 Fernando Perez <fperez@colorado.edu>
3139
3148
3140 * Manual: updated the Gnuplot section.
3149 * Manual: updated the Gnuplot section.
3141
3150
3142 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
3151 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
3143 a much better split of what goes in Runtime and what goes in
3152 a much better split of what goes in Runtime and what goes in
3144 Interactive.
3153 Interactive.
3145
3154
3146 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
3155 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
3147 being imported from iplib.
3156 being imported from iplib.
3148
3157
3149 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
3158 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
3150 for command-passing. Now the global Gnuplot instance is called
3159 for command-passing. Now the global Gnuplot instance is called
3151 'gp' instead of 'g', which was really a far too fragile and
3160 'gp' instead of 'g', which was really a far too fragile and
3152 common name.
3161 common name.
3153
3162
3154 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
3163 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
3155 bounding boxes generated by Gnuplot for square plots.
3164 bounding boxes generated by Gnuplot for square plots.
3156
3165
3157 * IPython/genutils.py (popkey): new function added. I should
3166 * IPython/genutils.py (popkey): new function added. I should
3158 suggest this on c.l.py as a dict method, it seems useful.
3167 suggest this on c.l.py as a dict method, it seems useful.
3159
3168
3160 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
3169 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
3161 to transparently handle PostScript generation. MUCH better than
3170 to transparently handle PostScript generation. MUCH better than
3162 the previous plot_eps/replot_eps (which I removed now). The code
3171 the previous plot_eps/replot_eps (which I removed now). The code
3163 is also fairly clean and well documented now (including
3172 is also fairly clean and well documented now (including
3164 docstrings).
3173 docstrings).
3165
3174
3166 2002-11-13 Fernando Perez <fperez@colorado.edu>
3175 2002-11-13 Fernando Perez <fperez@colorado.edu>
3167
3176
3168 * IPython/Magic.py (Magic.magic_edit): fixed docstring
3177 * IPython/Magic.py (Magic.magic_edit): fixed docstring
3169 (inconsistent with options).
3178 (inconsistent with options).
3170
3179
3171 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
3180 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
3172 manually disabled, I don't know why. Fixed it.
3181 manually disabled, I don't know why. Fixed it.
3173 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
3182 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
3174 eps output.
3183 eps output.
3175
3184
3176 2002-11-12 Fernando Perez <fperez@colorado.edu>
3185 2002-11-12 Fernando Perez <fperez@colorado.edu>
3177
3186
3178 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
3187 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
3179 don't propagate up to caller. Fixes crash reported by François
3188 don't propagate up to caller. Fixes crash reported by François
3180 Pinard.
3189 Pinard.
3181
3190
3182 2002-11-09 Fernando Perez <fperez@colorado.edu>
3191 2002-11-09 Fernando Perez <fperez@colorado.edu>
3183
3192
3184 * IPython/ipmaker.py (make_IPython): fixed problem with writing
3193 * IPython/ipmaker.py (make_IPython): fixed problem with writing
3185 history file for new users.
3194 history file for new users.
3186 (make_IPython): fixed bug where initial install would leave the
3195 (make_IPython): fixed bug where initial install would leave the
3187 user running in the .ipython dir.
3196 user running in the .ipython dir.
3188 (make_IPython): fixed bug where config dir .ipython would be
3197 (make_IPython): fixed bug where config dir .ipython would be
3189 created regardless of the given -ipythondir option. Thanks to Cory
3198 created regardless of the given -ipythondir option. Thanks to Cory
3190 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
3199 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
3191
3200
3192 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
3201 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
3193 type confirmations. Will need to use it in all of IPython's code
3202 type confirmations. Will need to use it in all of IPython's code
3194 consistently.
3203 consistently.
3195
3204
3196 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
3205 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
3197 context to print 31 lines instead of the default 5. This will make
3206 context to print 31 lines instead of the default 5. This will make
3198 the crash reports extremely detailed in case the problem is in
3207 the crash reports extremely detailed in case the problem is in
3199 libraries I don't have access to.
3208 libraries I don't have access to.
3200
3209
3201 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
3210 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
3202 line of defense' code to still crash, but giving users fair
3211 line of defense' code to still crash, but giving users fair
3203 warning. I don't want internal errors to go unreported: if there's
3212 warning. I don't want internal errors to go unreported: if there's
3204 an internal problem, IPython should crash and generate a full
3213 an internal problem, IPython should crash and generate a full
3205 report.
3214 report.
3206
3215
3207 2002-11-08 Fernando Perez <fperez@colorado.edu>
3216 2002-11-08 Fernando Perez <fperez@colorado.edu>
3208
3217
3209 * IPython/iplib.py (InteractiveShell.interact): added code to trap
3218 * IPython/iplib.py (InteractiveShell.interact): added code to trap
3210 otherwise uncaught exceptions which can appear if people set
3219 otherwise uncaught exceptions which can appear if people set
3211 sys.stdout to something badly broken. Thanks to a crash report
3220 sys.stdout to something badly broken. Thanks to a crash report
3212 from henni-AT-mail.brainbot.com.
3221 from henni-AT-mail.brainbot.com.
3213
3222
3214 2002-11-04 Fernando Perez <fperez@colorado.edu>
3223 2002-11-04 Fernando Perez <fperez@colorado.edu>
3215
3224
3216 * IPython/iplib.py (InteractiveShell.interact): added
3225 * IPython/iplib.py (InteractiveShell.interact): added
3217 __IPYTHON__active to the builtins. It's a flag which goes on when
3226 __IPYTHON__active to the builtins. It's a flag which goes on when
3218 the interaction starts and goes off again when it stops. This
3227 the interaction starts and goes off again when it stops. This
3219 allows embedding code to detect being inside IPython. Before this
3228 allows embedding code to detect being inside IPython. Before this
3220 was done via __IPYTHON__, but that only shows that an IPython
3229 was done via __IPYTHON__, but that only shows that an IPython
3221 instance has been created.
3230 instance has been created.
3222
3231
3223 * IPython/Magic.py (Magic.magic_env): I realized that in a
3232 * IPython/Magic.py (Magic.magic_env): I realized that in a
3224 UserDict, instance.data holds the data as a normal dict. So I
3233 UserDict, instance.data holds the data as a normal dict. So I
3225 modified @env to return os.environ.data instead of rebuilding a
3234 modified @env to return os.environ.data instead of rebuilding a
3226 dict by hand.
3235 dict by hand.
3227
3236
3228 2002-11-02 Fernando Perez <fperez@colorado.edu>
3237 2002-11-02 Fernando Perez <fperez@colorado.edu>
3229
3238
3230 * IPython/genutils.py (warn): changed so that level 1 prints no
3239 * IPython/genutils.py (warn): changed so that level 1 prints no
3231 header. Level 2 is now the default (with 'WARNING' header, as
3240 header. Level 2 is now the default (with 'WARNING' header, as
3232 before). I think I tracked all places where changes were needed in
3241 before). I think I tracked all places where changes were needed in
3233 IPython, but outside code using the old level numbering may have
3242 IPython, but outside code using the old level numbering may have
3234 broken.
3243 broken.
3235
3244
3236 * IPython/iplib.py (InteractiveShell.runcode): added this to
3245 * IPython/iplib.py (InteractiveShell.runcode): added this to
3237 handle the tracebacks in SystemExit traps correctly. The previous
3246 handle the tracebacks in SystemExit traps correctly. The previous
3238 code (through interact) was printing more of the stack than
3247 code (through interact) was printing more of the stack than
3239 necessary, showing IPython internal code to the user.
3248 necessary, showing IPython internal code to the user.
3240
3249
3241 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
3250 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
3242 default. Now that the default at the confirmation prompt is yes,
3251 default. Now that the default at the confirmation prompt is yes,
3243 it's not so intrusive. François' argument that ipython sessions
3252 it's not so intrusive. François' argument that ipython sessions
3244 tend to be complex enough not to lose them from an accidental C-d,
3253 tend to be complex enough not to lose them from an accidental C-d,
3245 is a valid one.
3254 is a valid one.
3246
3255
3247 * IPython/iplib.py (InteractiveShell.interact): added a
3256 * IPython/iplib.py (InteractiveShell.interact): added a
3248 showtraceback() call to the SystemExit trap, and modified the exit
3257 showtraceback() call to the SystemExit trap, and modified the exit
3249 confirmation to have yes as the default.
3258 confirmation to have yes as the default.
3250
3259
3251 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
3260 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
3252 this file. It's been gone from the code for a long time, this was
3261 this file. It's been gone from the code for a long time, this was
3253 simply leftover junk.
3262 simply leftover junk.
3254
3263
3255 2002-11-01 Fernando Perez <fperez@colorado.edu>
3264 2002-11-01 Fernando Perez <fperez@colorado.edu>
3256
3265
3257 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
3266 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
3258 added. If set, IPython now traps EOF and asks for
3267 added. If set, IPython now traps EOF and asks for
3259 confirmation. After a request by François Pinard.
3268 confirmation. After a request by François Pinard.
3260
3269
3261 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
3270 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
3262 of @abort, and with a new (better) mechanism for handling the
3271 of @abort, and with a new (better) mechanism for handling the
3263 exceptions.
3272 exceptions.
3264
3273
3265 2002-10-27 Fernando Perez <fperez@colorado.edu>
3274 2002-10-27 Fernando Perez <fperez@colorado.edu>
3266
3275
3267 * IPython/usage.py (__doc__): updated the --help information and
3276 * IPython/usage.py (__doc__): updated the --help information and
3268 the ipythonrc file to indicate that -log generates
3277 the ipythonrc file to indicate that -log generates
3269 ./ipython.log. Also fixed the corresponding info in @logstart.
3278 ./ipython.log. Also fixed the corresponding info in @logstart.
3270 This and several other fixes in the manuals thanks to reports by
3279 This and several other fixes in the manuals thanks to reports by
3271 François Pinard <pinard-AT-iro.umontreal.ca>.
3280 François Pinard <pinard-AT-iro.umontreal.ca>.
3272
3281
3273 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3282 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3274 refer to @logstart (instead of @log, which doesn't exist).
3283 refer to @logstart (instead of @log, which doesn't exist).
3275
3284
3276 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3285 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3277 AttributeError crash. Thanks to Christopher Armstrong
3286 AttributeError crash. Thanks to Christopher Armstrong
3278 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3287 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3279 introduced recently (in 0.2.14pre37) with the fix to the eval
3288 introduced recently (in 0.2.14pre37) with the fix to the eval
3280 problem mentioned below.
3289 problem mentioned below.
3281
3290
3282 2002-10-17 Fernando Perez <fperez@colorado.edu>
3291 2002-10-17 Fernando Perez <fperez@colorado.edu>
3283
3292
3284 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3293 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3285 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3294 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3286
3295
3287 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3296 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3288 this function to fix a problem reported by Alex Schmolck. He saw
3297 this function to fix a problem reported by Alex Schmolck. He saw
3289 it with list comprehensions and generators, which were getting
3298 it with list comprehensions and generators, which were getting
3290 called twice. The real problem was an 'eval' call in testing for
3299 called twice. The real problem was an 'eval' call in testing for
3291 automagic which was evaluating the input line silently.
3300 automagic which was evaluating the input line silently.
3292
3301
3293 This is a potentially very nasty bug, if the input has side
3302 This is a potentially very nasty bug, if the input has side
3294 effects which must not be repeated. The code is much cleaner now,
3303 effects which must not be repeated. The code is much cleaner now,
3295 without any blanket 'except' left and with a regexp test for
3304 without any blanket 'except' left and with a regexp test for
3296 actual function names.
3305 actual function names.
3297
3306
3298 But an eval remains, which I'm not fully comfortable with. I just
3307 But an eval remains, which I'm not fully comfortable with. I just
3299 don't know how to find out if an expression could be a callable in
3308 don't know how to find out if an expression could be a callable in
3300 the user's namespace without doing an eval on the string. However
3309 the user's namespace without doing an eval on the string. However
3301 that string is now much more strictly checked so that no code
3310 that string is now much more strictly checked so that no code
3302 slips by, so the eval should only happen for things that can
3311 slips by, so the eval should only happen for things that can
3303 really be only function/method names.
3312 really be only function/method names.
3304
3313
3305 2002-10-15 Fernando Perez <fperez@colorado.edu>
3314 2002-10-15 Fernando Perez <fperez@colorado.edu>
3306
3315
3307 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3316 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3308 OSX information to main manual, removed README_Mac_OSX file from
3317 OSX information to main manual, removed README_Mac_OSX file from
3309 distribution. Also updated credits for recent additions.
3318 distribution. Also updated credits for recent additions.
3310
3319
3311 2002-10-10 Fernando Perez <fperez@colorado.edu>
3320 2002-10-10 Fernando Perez <fperez@colorado.edu>
3312
3321
3313 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3322 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3314 terminal-related issues. Many thanks to Andrea Riciputi
3323 terminal-related issues. Many thanks to Andrea Riciputi
3315 <andrea.riciputi-AT-libero.it> for writing it.
3324 <andrea.riciputi-AT-libero.it> for writing it.
3316
3325
3317 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3326 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3318 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3327 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3319
3328
3320 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3329 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3321 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3330 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3322 <syver-en-AT-online.no> who both submitted patches for this problem.
3331 <syver-en-AT-online.no> who both submitted patches for this problem.
3323
3332
3324 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3333 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3325 global embedding to make sure that things don't overwrite user
3334 global embedding to make sure that things don't overwrite user
3326 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3335 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3327
3336
3328 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3337 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3329 compatibility. Thanks to Hayden Callow
3338 compatibility. Thanks to Hayden Callow
3330 <h.callow-AT-elec.canterbury.ac.nz>
3339 <h.callow-AT-elec.canterbury.ac.nz>
3331
3340
3332 2002-10-04 Fernando Perez <fperez@colorado.edu>
3341 2002-10-04 Fernando Perez <fperez@colorado.edu>
3333
3342
3334 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3343 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3335 Gnuplot.File objects.
3344 Gnuplot.File objects.
3336
3345
3337 2002-07-23 Fernando Perez <fperez@colorado.edu>
3346 2002-07-23 Fernando Perez <fperez@colorado.edu>
3338
3347
3339 * IPython/genutils.py (timing): Added timings() and timing() for
3348 * IPython/genutils.py (timing): Added timings() and timing() for
3340 quick access to the most commonly needed data, the execution
3349 quick access to the most commonly needed data, the execution
3341 times. Old timing() renamed to timings_out().
3350 times. Old timing() renamed to timings_out().
3342
3351
3343 2002-07-18 Fernando Perez <fperez@colorado.edu>
3352 2002-07-18 Fernando Perez <fperez@colorado.edu>
3344
3353
3345 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3354 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3346 bug with nested instances disrupting the parent's tab completion.
3355 bug with nested instances disrupting the parent's tab completion.
3347
3356
3348 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3357 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3349 all_completions code to begin the emacs integration.
3358 all_completions code to begin the emacs integration.
3350
3359
3351 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3360 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3352 argument to allow titling individual arrays when plotting.
3361 argument to allow titling individual arrays when plotting.
3353
3362
3354 2002-07-15 Fernando Perez <fperez@colorado.edu>
3363 2002-07-15 Fernando Perez <fperez@colorado.edu>
3355
3364
3356 * setup.py (make_shortcut): changed to retrieve the value of
3365 * setup.py (make_shortcut): changed to retrieve the value of
3357 'Program Files' directory from the registry (this value changes in
3366 'Program Files' directory from the registry (this value changes in
3358 non-english versions of Windows). Thanks to Thomas Fanslau
3367 non-english versions of Windows). Thanks to Thomas Fanslau
3359 <tfanslau-AT-gmx.de> for the report.
3368 <tfanslau-AT-gmx.de> for the report.
3360
3369
3361 2002-07-10 Fernando Perez <fperez@colorado.edu>
3370 2002-07-10 Fernando Perez <fperez@colorado.edu>
3362
3371
3363 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3372 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3364 a bug in pdb, which crashes if a line with only whitespace is
3373 a bug in pdb, which crashes if a line with only whitespace is
3365 entered. Bug report submitted to sourceforge.
3374 entered. Bug report submitted to sourceforge.
3366
3375
3367 2002-07-09 Fernando Perez <fperez@colorado.edu>
3376 2002-07-09 Fernando Perez <fperez@colorado.edu>
3368
3377
3369 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3378 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3370 reporting exceptions (it's a bug in inspect.py, I just set a
3379 reporting exceptions (it's a bug in inspect.py, I just set a
3371 workaround).
3380 workaround).
3372
3381
3373 2002-07-08 Fernando Perez <fperez@colorado.edu>
3382 2002-07-08 Fernando Perez <fperez@colorado.edu>
3374
3383
3375 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3384 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3376 __IPYTHON__ in __builtins__ to show up in user_ns.
3385 __IPYTHON__ in __builtins__ to show up in user_ns.
3377
3386
3378 2002-07-03 Fernando Perez <fperez@colorado.edu>
3387 2002-07-03 Fernando Perez <fperez@colorado.edu>
3379
3388
3380 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3389 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3381 name from @gp_set_instance to @gp_set_default.
3390 name from @gp_set_instance to @gp_set_default.
3382
3391
3383 * IPython/ipmaker.py (make_IPython): default editor value set to
3392 * IPython/ipmaker.py (make_IPython): default editor value set to
3384 '0' (a string), to match the rc file. Otherwise will crash when
3393 '0' (a string), to match the rc file. Otherwise will crash when
3385 .strip() is called on it.
3394 .strip() is called on it.
3386
3395
3387
3396
3388 2002-06-28 Fernando Perez <fperez@colorado.edu>
3397 2002-06-28 Fernando Perez <fperez@colorado.edu>
3389
3398
3390 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3399 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3391 of files in current directory when a file is executed via
3400 of files in current directory when a file is executed via
3392 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3401 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3393
3402
3394 * setup.py (manfiles): fix for rpm builds, submitted by RA
3403 * setup.py (manfiles): fix for rpm builds, submitted by RA
3395 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3404 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3396
3405
3397 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3406 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3398 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3407 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3399 string!). A. Schmolck caught this one.
3408 string!). A. Schmolck caught this one.
3400
3409
3401 2002-06-27 Fernando Perez <fperez@colorado.edu>
3410 2002-06-27 Fernando Perez <fperez@colorado.edu>
3402
3411
3403 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3412 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3404 defined files at the cmd line. __name__ wasn't being set to
3413 defined files at the cmd line. __name__ wasn't being set to
3405 __main__.
3414 __main__.
3406
3415
3407 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3416 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3408 regular lists and tuples besides Numeric arrays.
3417 regular lists and tuples besides Numeric arrays.
3409
3418
3410 * IPython/Prompts.py (CachedOutput.__call__): Added output
3419 * IPython/Prompts.py (CachedOutput.__call__): Added output
3411 supression for input ending with ';'. Similar to Mathematica and
3420 supression for input ending with ';'. Similar to Mathematica and
3412 Matlab. The _* vars and Out[] list are still updated, just like
3421 Matlab. The _* vars and Out[] list are still updated, just like
3413 Mathematica behaves.
3422 Mathematica behaves.
3414
3423
3415 2002-06-25 Fernando Perez <fperez@colorado.edu>
3424 2002-06-25 Fernando Perez <fperez@colorado.edu>
3416
3425
3417 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3426 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3418 .ini extensions for profiels under Windows.
3427 .ini extensions for profiels under Windows.
3419
3428
3420 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3429 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3421 string form. Fix contributed by Alexander Schmolck
3430 string form. Fix contributed by Alexander Schmolck
3422 <a.schmolck-AT-gmx.net>
3431 <a.schmolck-AT-gmx.net>
3423
3432
3424 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3433 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3425 pre-configured Gnuplot instance.
3434 pre-configured Gnuplot instance.
3426
3435
3427 2002-06-21 Fernando Perez <fperez@colorado.edu>
3436 2002-06-21 Fernando Perez <fperez@colorado.edu>
3428
3437
3429 * IPython/numutils.py (exp_safe): new function, works around the
3438 * IPython/numutils.py (exp_safe): new function, works around the
3430 underflow problems in Numeric.
3439 underflow problems in Numeric.
3431 (log2): New fn. Safe log in base 2: returns exact integer answer
3440 (log2): New fn. Safe log in base 2: returns exact integer answer
3432 for exact integer powers of 2.
3441 for exact integer powers of 2.
3433
3442
3434 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3443 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3435 properly.
3444 properly.
3436
3445
3437 2002-06-20 Fernando Perez <fperez@colorado.edu>
3446 2002-06-20 Fernando Perez <fperez@colorado.edu>
3438
3447
3439 * IPython/genutils.py (timing): new function like
3448 * IPython/genutils.py (timing): new function like
3440 Mathematica's. Similar to time_test, but returns more info.
3449 Mathematica's. Similar to time_test, but returns more info.
3441
3450
3442 2002-06-18 Fernando Perez <fperez@colorado.edu>
3451 2002-06-18 Fernando Perez <fperez@colorado.edu>
3443
3452
3444 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3453 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3445 according to Mike Heeter's suggestions.
3454 according to Mike Heeter's suggestions.
3446
3455
3447 2002-06-16 Fernando Perez <fperez@colorado.edu>
3456 2002-06-16 Fernando Perez <fperez@colorado.edu>
3448
3457
3449 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3458 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3450 system. GnuplotMagic is gone as a user-directory option. New files
3459 system. GnuplotMagic is gone as a user-directory option. New files
3451 make it easier to use all the gnuplot stuff both from external
3460 make it easier to use all the gnuplot stuff both from external
3452 programs as well as from IPython. Had to rewrite part of
3461 programs as well as from IPython. Had to rewrite part of
3453 hardcopy() b/c of a strange bug: often the ps files simply don't
3462 hardcopy() b/c of a strange bug: often the ps files simply don't
3454 get created, and require a repeat of the command (often several
3463 get created, and require a repeat of the command (often several
3455 times).
3464 times).
3456
3465
3457 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3466 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3458 resolve output channel at call time, so that if sys.stderr has
3467 resolve output channel at call time, so that if sys.stderr has
3459 been redirected by user this gets honored.
3468 been redirected by user this gets honored.
3460
3469
3461 2002-06-13 Fernando Perez <fperez@colorado.edu>
3470 2002-06-13 Fernando Perez <fperez@colorado.edu>
3462
3471
3463 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3472 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3464 IPShell. Kept a copy with the old names to avoid breaking people's
3473 IPShell. Kept a copy with the old names to avoid breaking people's
3465 embedded code.
3474 embedded code.
3466
3475
3467 * IPython/ipython: simplified it to the bare minimum after
3476 * IPython/ipython: simplified it to the bare minimum after
3468 Holger's suggestions. Added info about how to use it in
3477 Holger's suggestions. Added info about how to use it in
3469 PYTHONSTARTUP.
3478 PYTHONSTARTUP.
3470
3479
3471 * IPython/Shell.py (IPythonShell): changed the options passing
3480 * IPython/Shell.py (IPythonShell): changed the options passing
3472 from a string with funky %s replacements to a straight list. Maybe
3481 from a string with funky %s replacements to a straight list. Maybe
3473 a bit more typing, but it follows sys.argv conventions, so there's
3482 a bit more typing, but it follows sys.argv conventions, so there's
3474 less special-casing to remember.
3483 less special-casing to remember.
3475
3484
3476 2002-06-12 Fernando Perez <fperez@colorado.edu>
3485 2002-06-12 Fernando Perez <fperez@colorado.edu>
3477
3486
3478 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3487 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3479 command. Thanks to a suggestion by Mike Heeter.
3488 command. Thanks to a suggestion by Mike Heeter.
3480 (Magic.magic_pfile): added behavior to look at filenames if given
3489 (Magic.magic_pfile): added behavior to look at filenames if given
3481 arg is not a defined object.
3490 arg is not a defined object.
3482 (Magic.magic_save): New @save function to save code snippets. Also
3491 (Magic.magic_save): New @save function to save code snippets. Also
3483 a Mike Heeter idea.
3492 a Mike Heeter idea.
3484
3493
3485 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3494 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3486 plot() and replot(). Much more convenient now, especially for
3495 plot() and replot(). Much more convenient now, especially for
3487 interactive use.
3496 interactive use.
3488
3497
3489 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3498 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3490 filenames.
3499 filenames.
3491
3500
3492 2002-06-02 Fernando Perez <fperez@colorado.edu>
3501 2002-06-02 Fernando Perez <fperez@colorado.edu>
3493
3502
3494 * IPython/Struct.py (Struct.__init__): modified to admit
3503 * IPython/Struct.py (Struct.__init__): modified to admit
3495 initialization via another struct.
3504 initialization via another struct.
3496
3505
3497 * IPython/genutils.py (SystemExec.__init__): New stateful
3506 * IPython/genutils.py (SystemExec.__init__): New stateful
3498 interface to xsys and bq. Useful for writing system scripts.
3507 interface to xsys and bq. Useful for writing system scripts.
3499
3508
3500 2002-05-30 Fernando Perez <fperez@colorado.edu>
3509 2002-05-30 Fernando Perez <fperez@colorado.edu>
3501
3510
3502 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3511 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3503 documents. This will make the user download smaller (it's getting
3512 documents. This will make the user download smaller (it's getting
3504 too big).
3513 too big).
3505
3514
3506 2002-05-29 Fernando Perez <fperez@colorado.edu>
3515 2002-05-29 Fernando Perez <fperez@colorado.edu>
3507
3516
3508 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3517 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3509 fix problems with shelve and pickle. Seems to work, but I don't
3518 fix problems with shelve and pickle. Seems to work, but I don't
3510 know if corner cases break it. Thanks to Mike Heeter
3519 know if corner cases break it. Thanks to Mike Heeter
3511 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3520 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3512
3521
3513 2002-05-24 Fernando Perez <fperez@colorado.edu>
3522 2002-05-24 Fernando Perez <fperez@colorado.edu>
3514
3523
3515 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3524 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3516 macros having broken.
3525 macros having broken.
3517
3526
3518 2002-05-21 Fernando Perez <fperez@colorado.edu>
3527 2002-05-21 Fernando Perez <fperez@colorado.edu>
3519
3528
3520 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3529 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3521 introduced logging bug: all history before logging started was
3530 introduced logging bug: all history before logging started was
3522 being written one character per line! This came from the redesign
3531 being written one character per line! This came from the redesign
3523 of the input history as a special list which slices to strings,
3532 of the input history as a special list which slices to strings,
3524 not to lists.
3533 not to lists.
3525
3534
3526 2002-05-20 Fernando Perez <fperez@colorado.edu>
3535 2002-05-20 Fernando Perez <fperez@colorado.edu>
3527
3536
3528 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3537 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3529 be an attribute of all classes in this module. The design of these
3538 be an attribute of all classes in this module. The design of these
3530 classes needs some serious overhauling.
3539 classes needs some serious overhauling.
3531
3540
3532 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3541 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3533 which was ignoring '_' in option names.
3542 which was ignoring '_' in option names.
3534
3543
3535 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3544 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3536 'Verbose_novars' to 'Context' and made it the new default. It's a
3545 'Verbose_novars' to 'Context' and made it the new default. It's a
3537 bit more readable and also safer than verbose.
3546 bit more readable and also safer than verbose.
3538
3547
3539 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3548 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3540 triple-quoted strings.
3549 triple-quoted strings.
3541
3550
3542 * IPython/OInspect.py (__all__): new module exposing the object
3551 * IPython/OInspect.py (__all__): new module exposing the object
3543 introspection facilities. Now the corresponding magics are dummy
3552 introspection facilities. Now the corresponding magics are dummy
3544 wrappers around this. Having this module will make it much easier
3553 wrappers around this. Having this module will make it much easier
3545 to put these functions into our modified pdb.
3554 to put these functions into our modified pdb.
3546 This new object inspector system uses the new colorizing module,
3555 This new object inspector system uses the new colorizing module,
3547 so source code and other things are nicely syntax highlighted.
3556 so source code and other things are nicely syntax highlighted.
3548
3557
3549 2002-05-18 Fernando Perez <fperez@colorado.edu>
3558 2002-05-18 Fernando Perez <fperez@colorado.edu>
3550
3559
3551 * IPython/ColorANSI.py: Split the coloring tools into a separate
3560 * IPython/ColorANSI.py: Split the coloring tools into a separate
3552 module so I can use them in other code easier (they were part of
3561 module so I can use them in other code easier (they were part of
3553 ultraTB).
3562 ultraTB).
3554
3563
3555 2002-05-17 Fernando Perez <fperez@colorado.edu>
3564 2002-05-17 Fernando Perez <fperez@colorado.edu>
3556
3565
3557 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3566 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3558 fixed it to set the global 'g' also to the called instance, as
3567 fixed it to set the global 'g' also to the called instance, as
3559 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3568 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3560 user's 'g' variables).
3569 user's 'g' variables).
3561
3570
3562 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3571 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3563 global variables (aliases to _ih,_oh) so that users which expect
3572 global variables (aliases to _ih,_oh) so that users which expect
3564 In[5] or Out[7] to work aren't unpleasantly surprised.
3573 In[5] or Out[7] to work aren't unpleasantly surprised.
3565 (InputList.__getslice__): new class to allow executing slices of
3574 (InputList.__getslice__): new class to allow executing slices of
3566 input history directly. Very simple class, complements the use of
3575 input history directly. Very simple class, complements the use of
3567 macros.
3576 macros.
3568
3577
3569 2002-05-16 Fernando Perez <fperez@colorado.edu>
3578 2002-05-16 Fernando Perez <fperez@colorado.edu>
3570
3579
3571 * setup.py (docdirbase): make doc directory be just doc/IPython
3580 * setup.py (docdirbase): make doc directory be just doc/IPython
3572 without version numbers, it will reduce clutter for users.
3581 without version numbers, it will reduce clutter for users.
3573
3582
3574 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3583 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3575 execfile call to prevent possible memory leak. See for details:
3584 execfile call to prevent possible memory leak. See for details:
3576 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3585 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3577
3586
3578 2002-05-15 Fernando Perez <fperez@colorado.edu>
3587 2002-05-15 Fernando Perez <fperez@colorado.edu>
3579
3588
3580 * IPython/Magic.py (Magic.magic_psource): made the object
3589 * IPython/Magic.py (Magic.magic_psource): made the object
3581 introspection names be more standard: pdoc, pdef, pfile and
3590 introspection names be more standard: pdoc, pdef, pfile and
3582 psource. They all print/page their output, and it makes
3591 psource. They all print/page their output, and it makes
3583 remembering them easier. Kept old names for compatibility as
3592 remembering them easier. Kept old names for compatibility as
3584 aliases.
3593 aliases.
3585
3594
3586 2002-05-14 Fernando Perez <fperez@colorado.edu>
3595 2002-05-14 Fernando Perez <fperez@colorado.edu>
3587
3596
3588 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3597 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3589 what the mouse problem was. The trick is to use gnuplot with temp
3598 what the mouse problem was. The trick is to use gnuplot with temp
3590 files and NOT with pipes (for data communication), because having
3599 files and NOT with pipes (for data communication), because having
3591 both pipes and the mouse on is bad news.
3600 both pipes and the mouse on is bad news.
3592
3601
3593 2002-05-13 Fernando Perez <fperez@colorado.edu>
3602 2002-05-13 Fernando Perez <fperez@colorado.edu>
3594
3603
3595 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3604 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3596 bug. Information would be reported about builtins even when
3605 bug. Information would be reported about builtins even when
3597 user-defined functions overrode them.
3606 user-defined functions overrode them.
3598
3607
3599 2002-05-11 Fernando Perez <fperez@colorado.edu>
3608 2002-05-11 Fernando Perez <fperez@colorado.edu>
3600
3609
3601 * IPython/__init__.py (__all__): removed FlexCompleter from
3610 * IPython/__init__.py (__all__): removed FlexCompleter from
3602 __all__ so that things don't fail in platforms without readline.
3611 __all__ so that things don't fail in platforms without readline.
3603
3612
3604 2002-05-10 Fernando Perez <fperez@colorado.edu>
3613 2002-05-10 Fernando Perez <fperez@colorado.edu>
3605
3614
3606 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3615 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3607 it requires Numeric, effectively making Numeric a dependency for
3616 it requires Numeric, effectively making Numeric a dependency for
3608 IPython.
3617 IPython.
3609
3618
3610 * Released 0.2.13
3619 * Released 0.2.13
3611
3620
3612 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3621 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3613 profiler interface. Now all the major options from the profiler
3622 profiler interface. Now all the major options from the profiler
3614 module are directly supported in IPython, both for single
3623 module are directly supported in IPython, both for single
3615 expressions (@prun) and for full programs (@run -p).
3624 expressions (@prun) and for full programs (@run -p).
3616
3625
3617 2002-05-09 Fernando Perez <fperez@colorado.edu>
3626 2002-05-09 Fernando Perez <fperez@colorado.edu>
3618
3627
3619 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3628 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3620 magic properly formatted for screen.
3629 magic properly formatted for screen.
3621
3630
3622 * setup.py (make_shortcut): Changed things to put pdf version in
3631 * setup.py (make_shortcut): Changed things to put pdf version in
3623 doc/ instead of doc/manual (had to change lyxport a bit).
3632 doc/ instead of doc/manual (had to change lyxport a bit).
3624
3633
3625 * IPython/Magic.py (Profile.string_stats): made profile runs go
3634 * IPython/Magic.py (Profile.string_stats): made profile runs go
3626 through pager (they are long and a pager allows searching, saving,
3635 through pager (they are long and a pager allows searching, saving,
3627 etc.)
3636 etc.)
3628
3637
3629 2002-05-08 Fernando Perez <fperez@colorado.edu>
3638 2002-05-08 Fernando Perez <fperez@colorado.edu>
3630
3639
3631 * Released 0.2.12
3640 * Released 0.2.12
3632
3641
3633 2002-05-06 Fernando Perez <fperez@colorado.edu>
3642 2002-05-06 Fernando Perez <fperez@colorado.edu>
3634
3643
3635 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3644 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3636 introduced); 'hist n1 n2' was broken.
3645 introduced); 'hist n1 n2' was broken.
3637 (Magic.magic_pdb): added optional on/off arguments to @pdb
3646 (Magic.magic_pdb): added optional on/off arguments to @pdb
3638 (Magic.magic_run): added option -i to @run, which executes code in
3647 (Magic.magic_run): added option -i to @run, which executes code in
3639 the IPython namespace instead of a clean one. Also added @irun as
3648 the IPython namespace instead of a clean one. Also added @irun as
3640 an alias to @run -i.
3649 an alias to @run -i.
3641
3650
3642 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3651 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3643 fixed (it didn't really do anything, the namespaces were wrong).
3652 fixed (it didn't really do anything, the namespaces were wrong).
3644
3653
3645 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3654 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3646
3655
3647 * IPython/__init__.py (__all__): Fixed package namespace, now
3656 * IPython/__init__.py (__all__): Fixed package namespace, now
3648 'import IPython' does give access to IPython.<all> as
3657 'import IPython' does give access to IPython.<all> as
3649 expected. Also renamed __release__ to Release.
3658 expected. Also renamed __release__ to Release.
3650
3659
3651 * IPython/Debugger.py (__license__): created new Pdb class which
3660 * IPython/Debugger.py (__license__): created new Pdb class which
3652 functions like a drop-in for the normal pdb.Pdb but does NOT
3661 functions like a drop-in for the normal pdb.Pdb but does NOT
3653 import readline by default. This way it doesn't muck up IPython's
3662 import readline by default. This way it doesn't muck up IPython's
3654 readline handling, and now tab-completion finally works in the
3663 readline handling, and now tab-completion finally works in the
3655 debugger -- sort of. It completes things globally visible, but the
3664 debugger -- sort of. It completes things globally visible, but the
3656 completer doesn't track the stack as pdb walks it. That's a bit
3665 completer doesn't track the stack as pdb walks it. That's a bit
3657 tricky, and I'll have to implement it later.
3666 tricky, and I'll have to implement it later.
3658
3667
3659 2002-05-05 Fernando Perez <fperez@colorado.edu>
3668 2002-05-05 Fernando Perez <fperez@colorado.edu>
3660
3669
3661 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3670 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3662 magic docstrings when printed via ? (explicit \'s were being
3671 magic docstrings when printed via ? (explicit \'s were being
3663 printed).
3672 printed).
3664
3673
3665 * IPython/ipmaker.py (make_IPython): fixed namespace
3674 * IPython/ipmaker.py (make_IPython): fixed namespace
3666 identification bug. Now variables loaded via logs or command-line
3675 identification bug. Now variables loaded via logs or command-line
3667 files are recognized in the interactive namespace by @who.
3676 files are recognized in the interactive namespace by @who.
3668
3677
3669 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3678 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3670 log replay system stemming from the string form of Structs.
3679 log replay system stemming from the string form of Structs.
3671
3680
3672 * IPython/Magic.py (Macro.__init__): improved macros to properly
3681 * IPython/Magic.py (Macro.__init__): improved macros to properly
3673 handle magic commands in them.
3682 handle magic commands in them.
3674 (Magic.magic_logstart): usernames are now expanded so 'logstart
3683 (Magic.magic_logstart): usernames are now expanded so 'logstart
3675 ~/mylog' now works.
3684 ~/mylog' now works.
3676
3685
3677 * IPython/iplib.py (complete): fixed bug where paths starting with
3686 * IPython/iplib.py (complete): fixed bug where paths starting with
3678 '/' would be completed as magic names.
3687 '/' would be completed as magic names.
3679
3688
3680 2002-05-04 Fernando Perez <fperez@colorado.edu>
3689 2002-05-04 Fernando Perez <fperez@colorado.edu>
3681
3690
3682 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3691 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3683 allow running full programs under the profiler's control.
3692 allow running full programs under the profiler's control.
3684
3693
3685 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3694 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3686 mode to report exceptions verbosely but without formatting
3695 mode to report exceptions verbosely but without formatting
3687 variables. This addresses the issue of ipython 'freezing' (it's
3696 variables. This addresses the issue of ipython 'freezing' (it's
3688 not frozen, but caught in an expensive formatting loop) when huge
3697 not frozen, but caught in an expensive formatting loop) when huge
3689 variables are in the context of an exception.
3698 variables are in the context of an exception.
3690 (VerboseTB.text): Added '--->' markers at line where exception was
3699 (VerboseTB.text): Added '--->' markers at line where exception was
3691 triggered. Much clearer to read, especially in NoColor modes.
3700 triggered. Much clearer to read, especially in NoColor modes.
3692
3701
3693 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3702 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3694 implemented in reverse when changing to the new parse_options().
3703 implemented in reverse when changing to the new parse_options().
3695
3704
3696 2002-05-03 Fernando Perez <fperez@colorado.edu>
3705 2002-05-03 Fernando Perez <fperez@colorado.edu>
3697
3706
3698 * IPython/Magic.py (Magic.parse_options): new function so that
3707 * IPython/Magic.py (Magic.parse_options): new function so that
3699 magics can parse options easier.
3708 magics can parse options easier.
3700 (Magic.magic_prun): new function similar to profile.run(),
3709 (Magic.magic_prun): new function similar to profile.run(),
3701 suggested by Chris Hart.
3710 suggested by Chris Hart.
3702 (Magic.magic_cd): fixed behavior so that it only changes if
3711 (Magic.magic_cd): fixed behavior so that it only changes if
3703 directory actually is in history.
3712 directory actually is in history.
3704
3713
3705 * IPython/usage.py (__doc__): added information about potential
3714 * IPython/usage.py (__doc__): added information about potential
3706 slowness of Verbose exception mode when there are huge data
3715 slowness of Verbose exception mode when there are huge data
3707 structures to be formatted (thanks to Archie Paulson).
3716 structures to be formatted (thanks to Archie Paulson).
3708
3717
3709 * IPython/ipmaker.py (make_IPython): Changed default logging
3718 * IPython/ipmaker.py (make_IPython): Changed default logging
3710 (when simply called with -log) to use curr_dir/ipython.log in
3719 (when simply called with -log) to use curr_dir/ipython.log in
3711 rotate mode. Fixed crash which was occuring with -log before
3720 rotate mode. Fixed crash which was occuring with -log before
3712 (thanks to Jim Boyle).
3721 (thanks to Jim Boyle).
3713
3722
3714 2002-05-01 Fernando Perez <fperez@colorado.edu>
3723 2002-05-01 Fernando Perez <fperez@colorado.edu>
3715
3724
3716 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3725 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3717 was nasty -- though somewhat of a corner case).
3726 was nasty -- though somewhat of a corner case).
3718
3727
3719 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3728 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3720 text (was a bug).
3729 text (was a bug).
3721
3730
3722 2002-04-30 Fernando Perez <fperez@colorado.edu>
3731 2002-04-30 Fernando Perez <fperez@colorado.edu>
3723
3732
3724 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3733 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3725 a print after ^D or ^C from the user so that the In[] prompt
3734 a print after ^D or ^C from the user so that the In[] prompt
3726 doesn't over-run the gnuplot one.
3735 doesn't over-run the gnuplot one.
3727
3736
3728 2002-04-29 Fernando Perez <fperez@colorado.edu>
3737 2002-04-29 Fernando Perez <fperez@colorado.edu>
3729
3738
3730 * Released 0.2.10
3739 * Released 0.2.10
3731
3740
3732 * IPython/__release__.py (version): get date dynamically.
3741 * IPython/__release__.py (version): get date dynamically.
3733
3742
3734 * Misc. documentation updates thanks to Arnd's comments. Also ran
3743 * Misc. documentation updates thanks to Arnd's comments. Also ran
3735 a full spellcheck on the manual (hadn't been done in a while).
3744 a full spellcheck on the manual (hadn't been done in a while).
3736
3745
3737 2002-04-27 Fernando Perez <fperez@colorado.edu>
3746 2002-04-27 Fernando Perez <fperez@colorado.edu>
3738
3747
3739 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3748 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3740 starting a log in mid-session would reset the input history list.
3749 starting a log in mid-session would reset the input history list.
3741
3750
3742 2002-04-26 Fernando Perez <fperez@colorado.edu>
3751 2002-04-26 Fernando Perez <fperez@colorado.edu>
3743
3752
3744 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3753 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3745 all files were being included in an update. Now anything in
3754 all files were being included in an update. Now anything in
3746 UserConfig that matches [A-Za-z]*.py will go (this excludes
3755 UserConfig that matches [A-Za-z]*.py will go (this excludes
3747 __init__.py)
3756 __init__.py)
3748
3757
3749 2002-04-25 Fernando Perez <fperez@colorado.edu>
3758 2002-04-25 Fernando Perez <fperez@colorado.edu>
3750
3759
3751 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3760 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3752 to __builtins__ so that any form of embedded or imported code can
3761 to __builtins__ so that any form of embedded or imported code can
3753 test for being inside IPython.
3762 test for being inside IPython.
3754
3763
3755 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3764 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3756 changed to GnuplotMagic because it's now an importable module,
3765 changed to GnuplotMagic because it's now an importable module,
3757 this makes the name follow that of the standard Gnuplot module.
3766 this makes the name follow that of the standard Gnuplot module.
3758 GnuplotMagic can now be loaded at any time in mid-session.
3767 GnuplotMagic can now be loaded at any time in mid-session.
3759
3768
3760 2002-04-24 Fernando Perez <fperez@colorado.edu>
3769 2002-04-24 Fernando Perez <fperez@colorado.edu>
3761
3770
3762 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3771 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3763 the globals (IPython has its own namespace) and the
3772 the globals (IPython has its own namespace) and the
3764 PhysicalQuantity stuff is much better anyway.
3773 PhysicalQuantity stuff is much better anyway.
3765
3774
3766 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3775 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3767 embedding example to standard user directory for
3776 embedding example to standard user directory for
3768 distribution. Also put it in the manual.
3777 distribution. Also put it in the manual.
3769
3778
3770 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3779 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3771 instance as first argument (so it doesn't rely on some obscure
3780 instance as first argument (so it doesn't rely on some obscure
3772 hidden global).
3781 hidden global).
3773
3782
3774 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3783 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3775 delimiters. While it prevents ().TAB from working, it allows
3784 delimiters. While it prevents ().TAB from working, it allows
3776 completions in open (... expressions. This is by far a more common
3785 completions in open (... expressions. This is by far a more common
3777 case.
3786 case.
3778
3787
3779 2002-04-23 Fernando Perez <fperez@colorado.edu>
3788 2002-04-23 Fernando Perez <fperez@colorado.edu>
3780
3789
3781 * IPython/Extensions/InterpreterPasteInput.py: new
3790 * IPython/Extensions/InterpreterPasteInput.py: new
3782 syntax-processing module for pasting lines with >>> or ... at the
3791 syntax-processing module for pasting lines with >>> or ... at the
3783 start.
3792 start.
3784
3793
3785 * IPython/Extensions/PhysicalQ_Interactive.py
3794 * IPython/Extensions/PhysicalQ_Interactive.py
3786 (PhysicalQuantityInteractive.__int__): fixed to work with either
3795 (PhysicalQuantityInteractive.__int__): fixed to work with either
3787 Numeric or math.
3796 Numeric or math.
3788
3797
3789 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3798 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3790 provided profiles. Now we have:
3799 provided profiles. Now we have:
3791 -math -> math module as * and cmath with its own namespace.
3800 -math -> math module as * and cmath with its own namespace.
3792 -numeric -> Numeric as *, plus gnuplot & grace
3801 -numeric -> Numeric as *, plus gnuplot & grace
3793 -physics -> same as before
3802 -physics -> same as before
3794
3803
3795 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3804 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3796 user-defined magics wouldn't be found by @magic if they were
3805 user-defined magics wouldn't be found by @magic if they were
3797 defined as class methods. Also cleaned up the namespace search
3806 defined as class methods. Also cleaned up the namespace search
3798 logic and the string building (to use %s instead of many repeated
3807 logic and the string building (to use %s instead of many repeated
3799 string adds).
3808 string adds).
3800
3809
3801 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3810 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3802 of user-defined magics to operate with class methods (cleaner, in
3811 of user-defined magics to operate with class methods (cleaner, in
3803 line with the gnuplot code).
3812 line with the gnuplot code).
3804
3813
3805 2002-04-22 Fernando Perez <fperez@colorado.edu>
3814 2002-04-22 Fernando Perez <fperez@colorado.edu>
3806
3815
3807 * setup.py: updated dependency list so that manual is updated when
3816 * setup.py: updated dependency list so that manual is updated when
3808 all included files change.
3817 all included files change.
3809
3818
3810 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3819 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3811 the delimiter removal option (the fix is ugly right now).
3820 the delimiter removal option (the fix is ugly right now).
3812
3821
3813 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3822 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3814 all of the math profile (quicker loading, no conflict between
3823 all of the math profile (quicker loading, no conflict between
3815 g-9.8 and g-gnuplot).
3824 g-9.8 and g-gnuplot).
3816
3825
3817 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3826 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3818 name of post-mortem files to IPython_crash_report.txt.
3827 name of post-mortem files to IPython_crash_report.txt.
3819
3828
3820 * Cleanup/update of the docs. Added all the new readline info and
3829 * Cleanup/update of the docs. Added all the new readline info and
3821 formatted all lists as 'real lists'.
3830 formatted all lists as 'real lists'.
3822
3831
3823 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3832 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3824 tab-completion options, since the full readline parse_and_bind is
3833 tab-completion options, since the full readline parse_and_bind is
3825 now accessible.
3834 now accessible.
3826
3835
3827 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3836 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3828 handling of readline options. Now users can specify any string to
3837 handling of readline options. Now users can specify any string to
3829 be passed to parse_and_bind(), as well as the delimiters to be
3838 be passed to parse_and_bind(), as well as the delimiters to be
3830 removed.
3839 removed.
3831 (InteractiveShell.__init__): Added __name__ to the global
3840 (InteractiveShell.__init__): Added __name__ to the global
3832 namespace so that things like Itpl which rely on its existence
3841 namespace so that things like Itpl which rely on its existence
3833 don't crash.
3842 don't crash.
3834 (InteractiveShell._prefilter): Defined the default with a _ so
3843 (InteractiveShell._prefilter): Defined the default with a _ so
3835 that prefilter() is easier to override, while the default one
3844 that prefilter() is easier to override, while the default one
3836 remains available.
3845 remains available.
3837
3846
3838 2002-04-18 Fernando Perez <fperez@colorado.edu>
3847 2002-04-18 Fernando Perez <fperez@colorado.edu>
3839
3848
3840 * Added information about pdb in the docs.
3849 * Added information about pdb in the docs.
3841
3850
3842 2002-04-17 Fernando Perez <fperez@colorado.edu>
3851 2002-04-17 Fernando Perez <fperez@colorado.edu>
3843
3852
3844 * IPython/ipmaker.py (make_IPython): added rc_override option to
3853 * IPython/ipmaker.py (make_IPython): added rc_override option to
3845 allow passing config options at creation time which may override
3854 allow passing config options at creation time which may override
3846 anything set in the config files or command line. This is
3855 anything set in the config files or command line. This is
3847 particularly useful for configuring embedded instances.
3856 particularly useful for configuring embedded instances.
3848
3857
3849 2002-04-15 Fernando Perez <fperez@colorado.edu>
3858 2002-04-15 Fernando Perez <fperez@colorado.edu>
3850
3859
3851 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3860 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3852 crash embedded instances because of the input cache falling out of
3861 crash embedded instances because of the input cache falling out of
3853 sync with the output counter.
3862 sync with the output counter.
3854
3863
3855 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3864 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3856 mode which calls pdb after an uncaught exception in IPython itself.
3865 mode which calls pdb after an uncaught exception in IPython itself.
3857
3866
3858 2002-04-14 Fernando Perez <fperez@colorado.edu>
3867 2002-04-14 Fernando Perez <fperez@colorado.edu>
3859
3868
3860 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3869 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3861 readline, fix it back after each call.
3870 readline, fix it back after each call.
3862
3871
3863 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3872 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3864 method to force all access via __call__(), which guarantees that
3873 method to force all access via __call__(), which guarantees that
3865 traceback references are properly deleted.
3874 traceback references are properly deleted.
3866
3875
3867 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3876 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3868 improve printing when pprint is in use.
3877 improve printing when pprint is in use.
3869
3878
3870 2002-04-13 Fernando Perez <fperez@colorado.edu>
3879 2002-04-13 Fernando Perez <fperez@colorado.edu>
3871
3880
3872 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3881 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3873 exceptions aren't caught anymore. If the user triggers one, he
3882 exceptions aren't caught anymore. If the user triggers one, he
3874 should know why he's doing it and it should go all the way up,
3883 should know why he's doing it and it should go all the way up,
3875 just like any other exception. So now @abort will fully kill the
3884 just like any other exception. So now @abort will fully kill the
3876 embedded interpreter and the embedding code (unless that happens
3885 embedded interpreter and the embedding code (unless that happens
3877 to catch SystemExit).
3886 to catch SystemExit).
3878
3887
3879 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3888 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3880 and a debugger() method to invoke the interactive pdb debugger
3889 and a debugger() method to invoke the interactive pdb debugger
3881 after printing exception information. Also added the corresponding
3890 after printing exception information. Also added the corresponding
3882 -pdb option and @pdb magic to control this feature, and updated
3891 -pdb option and @pdb magic to control this feature, and updated
3883 the docs. After a suggestion from Christopher Hart
3892 the docs. After a suggestion from Christopher Hart
3884 (hart-AT-caltech.edu).
3893 (hart-AT-caltech.edu).
3885
3894
3886 2002-04-12 Fernando Perez <fperez@colorado.edu>
3895 2002-04-12 Fernando Perez <fperez@colorado.edu>
3887
3896
3888 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3897 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3889 the exception handlers defined by the user (not the CrashHandler)
3898 the exception handlers defined by the user (not the CrashHandler)
3890 so that user exceptions don't trigger an ipython bug report.
3899 so that user exceptions don't trigger an ipython bug report.
3891
3900
3892 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3901 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3893 configurable (it should have always been so).
3902 configurable (it should have always been so).
3894
3903
3895 2002-03-26 Fernando Perez <fperez@colorado.edu>
3904 2002-03-26 Fernando Perez <fperez@colorado.edu>
3896
3905
3897 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3906 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3898 and there to fix embedding namespace issues. This should all be
3907 and there to fix embedding namespace issues. This should all be
3899 done in a more elegant way.
3908 done in a more elegant way.
3900
3909
3901 2002-03-25 Fernando Perez <fperez@colorado.edu>
3910 2002-03-25 Fernando Perez <fperez@colorado.edu>
3902
3911
3903 * IPython/genutils.py (get_home_dir): Try to make it work under
3912 * IPython/genutils.py (get_home_dir): Try to make it work under
3904 win9x also.
3913 win9x also.
3905
3914
3906 2002-03-20 Fernando Perez <fperez@colorado.edu>
3915 2002-03-20 Fernando Perez <fperez@colorado.edu>
3907
3916
3908 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3917 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3909 sys.displayhook untouched upon __init__.
3918 sys.displayhook untouched upon __init__.
3910
3919
3911 2002-03-19 Fernando Perez <fperez@colorado.edu>
3920 2002-03-19 Fernando Perez <fperez@colorado.edu>
3912
3921
3913 * Released 0.2.9 (for embedding bug, basically).
3922 * Released 0.2.9 (for embedding bug, basically).
3914
3923
3915 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3924 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3916 exceptions so that enclosing shell's state can be restored.
3925 exceptions so that enclosing shell's state can be restored.
3917
3926
3918 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3927 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3919 naming conventions in the .ipython/ dir.
3928 naming conventions in the .ipython/ dir.
3920
3929
3921 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3930 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3922 from delimiters list so filenames with - in them get expanded.
3931 from delimiters list so filenames with - in them get expanded.
3923
3932
3924 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3933 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3925 sys.displayhook not being properly restored after an embedded call.
3934 sys.displayhook not being properly restored after an embedded call.
3926
3935
3927 2002-03-18 Fernando Perez <fperez@colorado.edu>
3936 2002-03-18 Fernando Perez <fperez@colorado.edu>
3928
3937
3929 * Released 0.2.8
3938 * Released 0.2.8
3930
3939
3931 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3940 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3932 some files weren't being included in a -upgrade.
3941 some files weren't being included in a -upgrade.
3933 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3942 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3934 on' so that the first tab completes.
3943 on' so that the first tab completes.
3935 (InteractiveShell.handle_magic): fixed bug with spaces around
3944 (InteractiveShell.handle_magic): fixed bug with spaces around
3936 quotes breaking many magic commands.
3945 quotes breaking many magic commands.
3937
3946
3938 * setup.py: added note about ignoring the syntax error messages at
3947 * setup.py: added note about ignoring the syntax error messages at
3939 installation.
3948 installation.
3940
3949
3941 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3950 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3942 streamlining the gnuplot interface, now there's only one magic @gp.
3951 streamlining the gnuplot interface, now there's only one magic @gp.
3943
3952
3944 2002-03-17 Fernando Perez <fperez@colorado.edu>
3953 2002-03-17 Fernando Perez <fperez@colorado.edu>
3945
3954
3946 * IPython/UserConfig/magic_gnuplot.py: new name for the
3955 * IPython/UserConfig/magic_gnuplot.py: new name for the
3947 example-magic_pm.py file. Much enhanced system, now with a shell
3956 example-magic_pm.py file. Much enhanced system, now with a shell
3948 for communicating directly with gnuplot, one command at a time.
3957 for communicating directly with gnuplot, one command at a time.
3949
3958
3950 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3959 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3951 setting __name__=='__main__'.
3960 setting __name__=='__main__'.
3952
3961
3953 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3962 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3954 mini-shell for accessing gnuplot from inside ipython. Should
3963 mini-shell for accessing gnuplot from inside ipython. Should
3955 extend it later for grace access too. Inspired by Arnd's
3964 extend it later for grace access too. Inspired by Arnd's
3956 suggestion.
3965 suggestion.
3957
3966
3958 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3967 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3959 calling magic functions with () in their arguments. Thanks to Arnd
3968 calling magic functions with () in their arguments. Thanks to Arnd
3960 Baecker for pointing this to me.
3969 Baecker for pointing this to me.
3961
3970
3962 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3971 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3963 infinitely for integer or complex arrays (only worked with floats).
3972 infinitely for integer or complex arrays (only worked with floats).
3964
3973
3965 2002-03-16 Fernando Perez <fperez@colorado.edu>
3974 2002-03-16 Fernando Perez <fperez@colorado.edu>
3966
3975
3967 * setup.py: Merged setup and setup_windows into a single script
3976 * setup.py: Merged setup and setup_windows into a single script
3968 which properly handles things for windows users.
3977 which properly handles things for windows users.
3969
3978
3970 2002-03-15 Fernando Perez <fperez@colorado.edu>
3979 2002-03-15 Fernando Perez <fperez@colorado.edu>
3971
3980
3972 * Big change to the manual: now the magics are all automatically
3981 * Big change to the manual: now the magics are all automatically
3973 documented. This information is generated from their docstrings
3982 documented. This information is generated from their docstrings
3974 and put in a latex file included by the manual lyx file. This way
3983 and put in a latex file included by the manual lyx file. This way
3975 we get always up to date information for the magics. The manual
3984 we get always up to date information for the magics. The manual
3976 now also has proper version information, also auto-synced.
3985 now also has proper version information, also auto-synced.
3977
3986
3978 For this to work, an undocumented --magic_docstrings option was added.
3987 For this to work, an undocumented --magic_docstrings option was added.
3979
3988
3980 2002-03-13 Fernando Perez <fperez@colorado.edu>
3989 2002-03-13 Fernando Perez <fperez@colorado.edu>
3981
3990
3982 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3991 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3983 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3992 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3984
3993
3985 2002-03-12 Fernando Perez <fperez@colorado.edu>
3994 2002-03-12 Fernando Perez <fperez@colorado.edu>
3986
3995
3987 * IPython/ultraTB.py (TermColors): changed color escapes again to
3996 * IPython/ultraTB.py (TermColors): changed color escapes again to
3988 fix the (old, reintroduced) line-wrapping bug. Basically, if
3997 fix the (old, reintroduced) line-wrapping bug. Basically, if
3989 \001..\002 aren't given in the color escapes, lines get wrapped
3998 \001..\002 aren't given in the color escapes, lines get wrapped
3990 weirdly. But giving those screws up old xterms and emacs terms. So
3999 weirdly. But giving those screws up old xterms and emacs terms. So
3991 I added some logic for emacs terms to be ok, but I can't identify old
4000 I added some logic for emacs terms to be ok, but I can't identify old
3992 xterms separately ($TERM=='xterm' for many terminals, like konsole).
4001 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3993
4002
3994 2002-03-10 Fernando Perez <fperez@colorado.edu>
4003 2002-03-10 Fernando Perez <fperez@colorado.edu>
3995
4004
3996 * IPython/usage.py (__doc__): Various documentation cleanups and
4005 * IPython/usage.py (__doc__): Various documentation cleanups and
3997 updates, both in usage docstrings and in the manual.
4006 updates, both in usage docstrings and in the manual.
3998
4007
3999 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
4008 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
4000 handling of caching. Set minimum acceptabe value for having a
4009 handling of caching. Set minimum acceptabe value for having a
4001 cache at 20 values.
4010 cache at 20 values.
4002
4011
4003 * IPython/iplib.py (InteractiveShell.user_setup): moved the
4012 * IPython/iplib.py (InteractiveShell.user_setup): moved the
4004 install_first_time function to a method, renamed it and added an
4013 install_first_time function to a method, renamed it and added an
4005 'upgrade' mode. Now people can update their config directory with
4014 'upgrade' mode. Now people can update their config directory with
4006 a simple command line switch (-upgrade, also new).
4015 a simple command line switch (-upgrade, also new).
4007
4016
4008 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
4017 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
4009 @file (convenient for automagic users under Python >= 2.2).
4018 @file (convenient for automagic users under Python >= 2.2).
4010 Removed @files (it seemed more like a plural than an abbrev. of
4019 Removed @files (it seemed more like a plural than an abbrev. of
4011 'file show').
4020 'file show').
4012
4021
4013 * IPython/iplib.py (install_first_time): Fixed crash if there were
4022 * IPython/iplib.py (install_first_time): Fixed crash if there were
4014 backup files ('~') in .ipython/ install directory.
4023 backup files ('~') in .ipython/ install directory.
4015
4024
4016 * IPython/ipmaker.py (make_IPython): fixes for new prompt
4025 * IPython/ipmaker.py (make_IPython): fixes for new prompt
4017 system. Things look fine, but these changes are fairly
4026 system. Things look fine, but these changes are fairly
4018 intrusive. Test them for a few days.
4027 intrusive. Test them for a few days.
4019
4028
4020 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
4029 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
4021 the prompts system. Now all in/out prompt strings are user
4030 the prompts system. Now all in/out prompt strings are user
4022 controllable. This is particularly useful for embedding, as one
4031 controllable. This is particularly useful for embedding, as one
4023 can tag embedded instances with particular prompts.
4032 can tag embedded instances with particular prompts.
4024
4033
4025 Also removed global use of sys.ps1/2, which now allows nested
4034 Also removed global use of sys.ps1/2, which now allows nested
4026 embeddings without any problems. Added command-line options for
4035 embeddings without any problems. Added command-line options for
4027 the prompt strings.
4036 the prompt strings.
4028
4037
4029 2002-03-08 Fernando Perez <fperez@colorado.edu>
4038 2002-03-08 Fernando Perez <fperez@colorado.edu>
4030
4039
4031 * IPython/UserConfig/example-embed-short.py (ipshell): added
4040 * IPython/UserConfig/example-embed-short.py (ipshell): added
4032 example file with the bare minimum code for embedding.
4041 example file with the bare minimum code for embedding.
4033
4042
4034 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
4043 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
4035 functionality for the embeddable shell to be activated/deactivated
4044 functionality for the embeddable shell to be activated/deactivated
4036 either globally or at each call.
4045 either globally or at each call.
4037
4046
4038 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
4047 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
4039 rewriting the prompt with '--->' for auto-inputs with proper
4048 rewriting the prompt with '--->' for auto-inputs with proper
4040 coloring. Now the previous UGLY hack in handle_auto() is gone, and
4049 coloring. Now the previous UGLY hack in handle_auto() is gone, and
4041 this is handled by the prompts class itself, as it should.
4050 this is handled by the prompts class itself, as it should.
4042
4051
4043 2002-03-05 Fernando Perez <fperez@colorado.edu>
4052 2002-03-05 Fernando Perez <fperez@colorado.edu>
4044
4053
4045 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
4054 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
4046 @logstart to avoid name clashes with the math log function.
4055 @logstart to avoid name clashes with the math log function.
4047
4056
4048 * Big updates to X/Emacs section of the manual.
4057 * Big updates to X/Emacs section of the manual.
4049
4058
4050 * Removed ipython_emacs. Milan explained to me how to pass
4059 * Removed ipython_emacs. Milan explained to me how to pass
4051 arguments to ipython through Emacs. Some day I'm going to end up
4060 arguments to ipython through Emacs. Some day I'm going to end up
4052 learning some lisp...
4061 learning some lisp...
4053
4062
4054 2002-03-04 Fernando Perez <fperez@colorado.edu>
4063 2002-03-04 Fernando Perez <fperez@colorado.edu>
4055
4064
4056 * IPython/ipython_emacs: Created script to be used as the
4065 * IPython/ipython_emacs: Created script to be used as the
4057 py-python-command Emacs variable so we can pass IPython
4066 py-python-command Emacs variable so we can pass IPython
4058 parameters. I can't figure out how to tell Emacs directly to pass
4067 parameters. I can't figure out how to tell Emacs directly to pass
4059 parameters to IPython, so a dummy shell script will do it.
4068 parameters to IPython, so a dummy shell script will do it.
4060
4069
4061 Other enhancements made for things to work better under Emacs'
4070 Other enhancements made for things to work better under Emacs'
4062 various types of terminals. Many thanks to Milan Zamazal
4071 various types of terminals. Many thanks to Milan Zamazal
4063 <pdm-AT-zamazal.org> for all the suggestions and pointers.
4072 <pdm-AT-zamazal.org> for all the suggestions and pointers.
4064
4073
4065 2002-03-01 Fernando Perez <fperez@colorado.edu>
4074 2002-03-01 Fernando Perez <fperez@colorado.edu>
4066
4075
4067 * IPython/ipmaker.py (make_IPython): added a --readline! option so
4076 * IPython/ipmaker.py (make_IPython): added a --readline! option so
4068 that loading of readline is now optional. This gives better
4077 that loading of readline is now optional. This gives better
4069 control to emacs users.
4078 control to emacs users.
4070
4079
4071 * IPython/ultraTB.py (__date__): Modified color escape sequences
4080 * IPython/ultraTB.py (__date__): Modified color escape sequences
4072 and now things work fine under xterm and in Emacs' term buffers
4081 and now things work fine under xterm and in Emacs' term buffers
4073 (though not shell ones). Well, in emacs you get colors, but all
4082 (though not shell ones). Well, in emacs you get colors, but all
4074 seem to be 'light' colors (no difference between dark and light
4083 seem to be 'light' colors (no difference between dark and light
4075 ones). But the garbage chars are gone, and also in xterms. It
4084 ones). But the garbage chars are gone, and also in xterms. It
4076 seems that now I'm using 'cleaner' ansi sequences.
4085 seems that now I'm using 'cleaner' ansi sequences.
4077
4086
4078 2002-02-21 Fernando Perez <fperez@colorado.edu>
4087 2002-02-21 Fernando Perez <fperez@colorado.edu>
4079
4088
4080 * Released 0.2.7 (mainly to publish the scoping fix).
4089 * Released 0.2.7 (mainly to publish the scoping fix).
4081
4090
4082 * IPython/Logger.py (Logger.logstate): added. A corresponding
4091 * IPython/Logger.py (Logger.logstate): added. A corresponding
4083 @logstate magic was created.
4092 @logstate magic was created.
4084
4093
4085 * IPython/Magic.py: fixed nested scoping problem under Python
4094 * IPython/Magic.py: fixed nested scoping problem under Python
4086 2.1.x (automagic wasn't working).
4095 2.1.x (automagic wasn't working).
4087
4096
4088 2002-02-20 Fernando Perez <fperez@colorado.edu>
4097 2002-02-20 Fernando Perez <fperez@colorado.edu>
4089
4098
4090 * Released 0.2.6.
4099 * Released 0.2.6.
4091
4100
4092 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4101 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4093 option so that logs can come out without any headers at all.
4102 option so that logs can come out without any headers at all.
4094
4103
4095 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4104 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4096 SciPy.
4105 SciPy.
4097
4106
4098 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4107 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4099 that embedded IPython calls don't require vars() to be explicitly
4108 that embedded IPython calls don't require vars() to be explicitly
4100 passed. Now they are extracted from the caller's frame (code
4109 passed. Now they are extracted from the caller's frame (code
4101 snatched from Eric Jones' weave). Added better documentation to
4110 snatched from Eric Jones' weave). Added better documentation to
4102 the section on embedding and the example file.
4111 the section on embedding and the example file.
4103
4112
4104 * IPython/genutils.py (page): Changed so that under emacs, it just
4113 * IPython/genutils.py (page): Changed so that under emacs, it just
4105 prints the string. You can then page up and down in the emacs
4114 prints the string. You can then page up and down in the emacs
4106 buffer itself. This is how the builtin help() works.
4115 buffer itself. This is how the builtin help() works.
4107
4116
4108 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
4117 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
4109 macro scoping: macros need to be executed in the user's namespace
4118 macro scoping: macros need to be executed in the user's namespace
4110 to work as if they had been typed by the user.
4119 to work as if they had been typed by the user.
4111
4120
4112 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
4121 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
4113 execute automatically (no need to type 'exec...'). They then
4122 execute automatically (no need to type 'exec...'). They then
4114 behave like 'true macros'. The printing system was also modified
4123 behave like 'true macros'. The printing system was also modified
4115 for this to work.
4124 for this to work.
4116
4125
4117 2002-02-19 Fernando Perez <fperez@colorado.edu>
4126 2002-02-19 Fernando Perez <fperez@colorado.edu>
4118
4127
4119 * IPython/genutils.py (page_file): new function for paging files
4128 * IPython/genutils.py (page_file): new function for paging files
4120 in an OS-independent way. Also necessary for file viewing to work
4129 in an OS-independent way. Also necessary for file viewing to work
4121 well inside Emacs buffers.
4130 well inside Emacs buffers.
4122 (page): Added checks for being in an emacs buffer.
4131 (page): Added checks for being in an emacs buffer.
4123 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
4132 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
4124 same bug in iplib.
4133 same bug in iplib.
4125
4134
4126 2002-02-18 Fernando Perez <fperez@colorado.edu>
4135 2002-02-18 Fernando Perez <fperez@colorado.edu>
4127
4136
4128 * IPython/iplib.py (InteractiveShell.init_readline): modified use
4137 * IPython/iplib.py (InteractiveShell.init_readline): modified use
4129 of readline so that IPython can work inside an Emacs buffer.
4138 of readline so that IPython can work inside an Emacs buffer.
4130
4139
4131 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
4140 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
4132 method signatures (they weren't really bugs, but it looks cleaner
4141 method signatures (they weren't really bugs, but it looks cleaner
4133 and keeps PyChecker happy).
4142 and keeps PyChecker happy).
4134
4143
4135 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
4144 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
4136 for implementing various user-defined hooks. Currently only
4145 for implementing various user-defined hooks. Currently only
4137 display is done.
4146 display is done.
4138
4147
4139 * IPython/Prompts.py (CachedOutput._display): changed display
4148 * IPython/Prompts.py (CachedOutput._display): changed display
4140 functions so that they can be dynamically changed by users easily.
4149 functions so that they can be dynamically changed by users easily.
4141
4150
4142 * IPython/Extensions/numeric_formats.py (num_display): added an
4151 * IPython/Extensions/numeric_formats.py (num_display): added an
4143 extension for printing NumPy arrays in flexible manners. It
4152 extension for printing NumPy arrays in flexible manners. It
4144 doesn't do anything yet, but all the structure is in
4153 doesn't do anything yet, but all the structure is in
4145 place. Ultimately the plan is to implement output format control
4154 place. Ultimately the plan is to implement output format control
4146 like in Octave.
4155 like in Octave.
4147
4156
4148 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
4157 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
4149 methods are found at run-time by all the automatic machinery.
4158 methods are found at run-time by all the automatic machinery.
4150
4159
4151 2002-02-17 Fernando Perez <fperez@colorado.edu>
4160 2002-02-17 Fernando Perez <fperez@colorado.edu>
4152
4161
4153 * setup_Windows.py (make_shortcut): documented. Cleaned up the
4162 * setup_Windows.py (make_shortcut): documented. Cleaned up the
4154 whole file a little.
4163 whole file a little.
4155
4164
4156 * ToDo: closed this document. Now there's a new_design.lyx
4165 * ToDo: closed this document. Now there's a new_design.lyx
4157 document for all new ideas. Added making a pdf of it for the
4166 document for all new ideas. Added making a pdf of it for the
4158 end-user distro.
4167 end-user distro.
4159
4168
4160 * IPython/Logger.py (Logger.switch_log): Created this to replace
4169 * IPython/Logger.py (Logger.switch_log): Created this to replace
4161 logon() and logoff(). It also fixes a nasty crash reported by
4170 logon() and logoff(). It also fixes a nasty crash reported by
4162 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
4171 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
4163
4172
4164 * IPython/iplib.py (complete): got auto-completion to work with
4173 * IPython/iplib.py (complete): got auto-completion to work with
4165 automagic (I had wanted this for a long time).
4174 automagic (I had wanted this for a long time).
4166
4175
4167 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
4176 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
4168 to @file, since file() is now a builtin and clashes with automagic
4177 to @file, since file() is now a builtin and clashes with automagic
4169 for @file.
4178 for @file.
4170
4179
4171 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
4180 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
4172 of this was previously in iplib, which had grown to more than 2000
4181 of this was previously in iplib, which had grown to more than 2000
4173 lines, way too long. No new functionality, but it makes managing
4182 lines, way too long. No new functionality, but it makes managing
4174 the code a bit easier.
4183 the code a bit easier.
4175
4184
4176 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
4185 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
4177 information to crash reports.
4186 information to crash reports.
4178
4187
4179 2002-02-12 Fernando Perez <fperez@colorado.edu>
4188 2002-02-12 Fernando Perez <fperez@colorado.edu>
4180
4189
4181 * Released 0.2.5.
4190 * Released 0.2.5.
4182
4191
4183 2002-02-11 Fernando Perez <fperez@colorado.edu>
4192 2002-02-11 Fernando Perez <fperez@colorado.edu>
4184
4193
4185 * Wrote a relatively complete Windows installer. It puts
4194 * Wrote a relatively complete Windows installer. It puts
4186 everything in place, creates Start Menu entries and fixes the
4195 everything in place, creates Start Menu entries and fixes the
4187 color issues. Nothing fancy, but it works.
4196 color issues. Nothing fancy, but it works.
4188
4197
4189 2002-02-10 Fernando Perez <fperez@colorado.edu>
4198 2002-02-10 Fernando Perez <fperez@colorado.edu>
4190
4199
4191 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
4200 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
4192 os.path.expanduser() call so that we can type @run ~/myfile.py and
4201 os.path.expanduser() call so that we can type @run ~/myfile.py and
4193 have thigs work as expected.
4202 have thigs work as expected.
4194
4203
4195 * IPython/genutils.py (page): fixed exception handling so things
4204 * IPython/genutils.py (page): fixed exception handling so things
4196 work both in Unix and Windows correctly. Quitting a pager triggers
4205 work both in Unix and Windows correctly. Quitting a pager triggers
4197 an IOError/broken pipe in Unix, and in windows not finding a pager
4206 an IOError/broken pipe in Unix, and in windows not finding a pager
4198 is also an IOError, so I had to actually look at the return value
4207 is also an IOError, so I had to actually look at the return value
4199 of the exception, not just the exception itself. Should be ok now.
4208 of the exception, not just the exception itself. Should be ok now.
4200
4209
4201 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
4210 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
4202 modified to allow case-insensitive color scheme changes.
4211 modified to allow case-insensitive color scheme changes.
4203
4212
4204 2002-02-09 Fernando Perez <fperez@colorado.edu>
4213 2002-02-09 Fernando Perez <fperez@colorado.edu>
4205
4214
4206 * IPython/genutils.py (native_line_ends): new function to leave
4215 * IPython/genutils.py (native_line_ends): new function to leave
4207 user config files with os-native line-endings.
4216 user config files with os-native line-endings.
4208
4217
4209 * README and manual updates.
4218 * README and manual updates.
4210
4219
4211 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
4220 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
4212 instead of StringType to catch Unicode strings.
4221 instead of StringType to catch Unicode strings.
4213
4222
4214 * IPython/genutils.py (filefind): fixed bug for paths with
4223 * IPython/genutils.py (filefind): fixed bug for paths with
4215 embedded spaces (very common in Windows).
4224 embedded spaces (very common in Windows).
4216
4225
4217 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
4226 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
4218 files under Windows, so that they get automatically associated
4227 files under Windows, so that they get automatically associated
4219 with a text editor. Windows makes it a pain to handle
4228 with a text editor. Windows makes it a pain to handle
4220 extension-less files.
4229 extension-less files.
4221
4230
4222 * IPython/iplib.py (InteractiveShell.init_readline): Made the
4231 * IPython/iplib.py (InteractiveShell.init_readline): Made the
4223 warning about readline only occur for Posix. In Windows there's no
4232 warning about readline only occur for Posix. In Windows there's no
4224 way to get readline, so why bother with the warning.
4233 way to get readline, so why bother with the warning.
4225
4234
4226 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
4235 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
4227 for __str__ instead of dir(self), since dir() changed in 2.2.
4236 for __str__ instead of dir(self), since dir() changed in 2.2.
4228
4237
4229 * Ported to Windows! Tested on XP, I suspect it should work fine
4238 * Ported to Windows! Tested on XP, I suspect it should work fine
4230 on NT/2000, but I don't think it will work on 98 et al. That
4239 on NT/2000, but I don't think it will work on 98 et al. That
4231 series of Windows is such a piece of junk anyway that I won't try
4240 series of Windows is such a piece of junk anyway that I won't try
4232 porting it there. The XP port was straightforward, showed a few
4241 porting it there. The XP port was straightforward, showed a few
4233 bugs here and there (fixed all), in particular some string
4242 bugs here and there (fixed all), in particular some string
4234 handling stuff which required considering Unicode strings (which
4243 handling stuff which required considering Unicode strings (which
4235 Windows uses). This is good, but hasn't been too tested :) No
4244 Windows uses). This is good, but hasn't been too tested :) No
4236 fancy installer yet, I'll put a note in the manual so people at
4245 fancy installer yet, I'll put a note in the manual so people at
4237 least make manually a shortcut.
4246 least make manually a shortcut.
4238
4247
4239 * IPython/iplib.py (Magic.magic_colors): Unified the color options
4248 * IPython/iplib.py (Magic.magic_colors): Unified the color options
4240 into a single one, "colors". This now controls both prompt and
4249 into a single one, "colors". This now controls both prompt and
4241 exception color schemes, and can be changed both at startup
4250 exception color schemes, and can be changed both at startup
4242 (either via command-line switches or via ipythonrc files) and at
4251 (either via command-line switches or via ipythonrc files) and at
4243 runtime, with @colors.
4252 runtime, with @colors.
4244 (Magic.magic_run): renamed @prun to @run and removed the old
4253 (Magic.magic_run): renamed @prun to @run and removed the old
4245 @run. The two were too similar to warrant keeping both.
4254 @run. The two were too similar to warrant keeping both.
4246
4255
4247 2002-02-03 Fernando Perez <fperez@colorado.edu>
4256 2002-02-03 Fernando Perez <fperez@colorado.edu>
4248
4257
4249 * IPython/iplib.py (install_first_time): Added comment on how to
4258 * IPython/iplib.py (install_first_time): Added comment on how to
4250 configure the color options for first-time users. Put a <return>
4259 configure the color options for first-time users. Put a <return>
4251 request at the end so that small-terminal users get a chance to
4260 request at the end so that small-terminal users get a chance to
4252 read the startup info.
4261 read the startup info.
4253
4262
4254 2002-01-23 Fernando Perez <fperez@colorado.edu>
4263 2002-01-23 Fernando Perez <fperez@colorado.edu>
4255
4264
4256 * IPython/iplib.py (CachedOutput.update): Changed output memory
4265 * IPython/iplib.py (CachedOutput.update): Changed output memory
4257 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
4266 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
4258 input history we still use _i. Did this b/c these variable are
4267 input history we still use _i. Did this b/c these variable are
4259 very commonly used in interactive work, so the less we need to
4268 very commonly used in interactive work, so the less we need to
4260 type the better off we are.
4269 type the better off we are.
4261 (Magic.magic_prun): updated @prun to better handle the namespaces
4270 (Magic.magic_prun): updated @prun to better handle the namespaces
4262 the file will run in, including a fix for __name__ not being set
4271 the file will run in, including a fix for __name__ not being set
4263 before.
4272 before.
4264
4273
4265 2002-01-20 Fernando Perez <fperez@colorado.edu>
4274 2002-01-20 Fernando Perez <fperez@colorado.edu>
4266
4275
4267 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
4276 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
4268 extra garbage for Python 2.2. Need to look more carefully into
4277 extra garbage for Python 2.2. Need to look more carefully into
4269 this later.
4278 this later.
4270
4279
4271 2002-01-19 Fernando Perez <fperez@colorado.edu>
4280 2002-01-19 Fernando Perez <fperez@colorado.edu>
4272
4281
4273 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4282 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4274 display SyntaxError exceptions properly formatted when they occur
4283 display SyntaxError exceptions properly formatted when they occur
4275 (they can be triggered by imported code).
4284 (they can be triggered by imported code).
4276
4285
4277 2002-01-18 Fernando Perez <fperez@colorado.edu>
4286 2002-01-18 Fernando Perez <fperez@colorado.edu>
4278
4287
4279 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4288 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4280 SyntaxError exceptions are reported nicely formatted, instead of
4289 SyntaxError exceptions are reported nicely formatted, instead of
4281 spitting out only offset information as before.
4290 spitting out only offset information as before.
4282 (Magic.magic_prun): Added the @prun function for executing
4291 (Magic.magic_prun): Added the @prun function for executing
4283 programs with command line args inside IPython.
4292 programs with command line args inside IPython.
4284
4293
4285 2002-01-16 Fernando Perez <fperez@colorado.edu>
4294 2002-01-16 Fernando Perez <fperez@colorado.edu>
4286
4295
4287 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4296 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4288 to *not* include the last item given in a range. This brings their
4297 to *not* include the last item given in a range. This brings their
4289 behavior in line with Python's slicing:
4298 behavior in line with Python's slicing:
4290 a[n1:n2] -> a[n1]...a[n2-1]
4299 a[n1:n2] -> a[n1]...a[n2-1]
4291 It may be a bit less convenient, but I prefer to stick to Python's
4300 It may be a bit less convenient, but I prefer to stick to Python's
4292 conventions *everywhere*, so users never have to wonder.
4301 conventions *everywhere*, so users never have to wonder.
4293 (Magic.magic_macro): Added @macro function to ease the creation of
4302 (Magic.magic_macro): Added @macro function to ease the creation of
4294 macros.
4303 macros.
4295
4304
4296 2002-01-05 Fernando Perez <fperez@colorado.edu>
4305 2002-01-05 Fernando Perez <fperez@colorado.edu>
4297
4306
4298 * Released 0.2.4.
4307 * Released 0.2.4.
4299
4308
4300 * IPython/iplib.py (Magic.magic_pdef):
4309 * IPython/iplib.py (Magic.magic_pdef):
4301 (InteractiveShell.safe_execfile): report magic lines and error
4310 (InteractiveShell.safe_execfile): report magic lines and error
4302 lines without line numbers so one can easily copy/paste them for
4311 lines without line numbers so one can easily copy/paste them for
4303 re-execution.
4312 re-execution.
4304
4313
4305 * Updated manual with recent changes.
4314 * Updated manual with recent changes.
4306
4315
4307 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4316 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4308 docstring printing when class? is called. Very handy for knowing
4317 docstring printing when class? is called. Very handy for knowing
4309 how to create class instances (as long as __init__ is well
4318 how to create class instances (as long as __init__ is well
4310 documented, of course :)
4319 documented, of course :)
4311 (Magic.magic_doc): print both class and constructor docstrings.
4320 (Magic.magic_doc): print both class and constructor docstrings.
4312 (Magic.magic_pdef): give constructor info if passed a class and
4321 (Magic.magic_pdef): give constructor info if passed a class and
4313 __call__ info for callable object instances.
4322 __call__ info for callable object instances.
4314
4323
4315 2002-01-04 Fernando Perez <fperez@colorado.edu>
4324 2002-01-04 Fernando Perez <fperez@colorado.edu>
4316
4325
4317 * Made deep_reload() off by default. It doesn't always work
4326 * Made deep_reload() off by default. It doesn't always work
4318 exactly as intended, so it's probably safer to have it off. It's
4327 exactly as intended, so it's probably safer to have it off. It's
4319 still available as dreload() anyway, so nothing is lost.
4328 still available as dreload() anyway, so nothing is lost.
4320
4329
4321 2002-01-02 Fernando Perez <fperez@colorado.edu>
4330 2002-01-02 Fernando Perez <fperez@colorado.edu>
4322
4331
4323 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4332 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4324 so I wanted an updated release).
4333 so I wanted an updated release).
4325
4334
4326 2001-12-27 Fernando Perez <fperez@colorado.edu>
4335 2001-12-27 Fernando Perez <fperez@colorado.edu>
4327
4336
4328 * IPython/iplib.py (InteractiveShell.interact): Added the original
4337 * IPython/iplib.py (InteractiveShell.interact): Added the original
4329 code from 'code.py' for this module in order to change the
4338 code from 'code.py' for this module in order to change the
4330 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4339 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4331 the history cache would break when the user hit Ctrl-C, and
4340 the history cache would break when the user hit Ctrl-C, and
4332 interact() offers no way to add any hooks to it.
4341 interact() offers no way to add any hooks to it.
4333
4342
4334 2001-12-23 Fernando Perez <fperez@colorado.edu>
4343 2001-12-23 Fernando Perez <fperez@colorado.edu>
4335
4344
4336 * setup.py: added check for 'MANIFEST' before trying to remove
4345 * setup.py: added check for 'MANIFEST' before trying to remove
4337 it. Thanks to Sean Reifschneider.
4346 it. Thanks to Sean Reifschneider.
4338
4347
4339 2001-12-22 Fernando Perez <fperez@colorado.edu>
4348 2001-12-22 Fernando Perez <fperez@colorado.edu>
4340
4349
4341 * Released 0.2.2.
4350 * Released 0.2.2.
4342
4351
4343 * Finished (reasonably) writing the manual. Later will add the
4352 * Finished (reasonably) writing the manual. Later will add the
4344 python-standard navigation stylesheets, but for the time being
4353 python-standard navigation stylesheets, but for the time being
4345 it's fairly complete. Distribution will include html and pdf
4354 it's fairly complete. Distribution will include html and pdf
4346 versions.
4355 versions.
4347
4356
4348 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4357 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4349 (MayaVi author).
4358 (MayaVi author).
4350
4359
4351 2001-12-21 Fernando Perez <fperez@colorado.edu>
4360 2001-12-21 Fernando Perez <fperez@colorado.edu>
4352
4361
4353 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4362 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4354 good public release, I think (with the manual and the distutils
4363 good public release, I think (with the manual and the distutils
4355 installer). The manual can use some work, but that can go
4364 installer). The manual can use some work, but that can go
4356 slowly. Otherwise I think it's quite nice for end users. Next
4365 slowly. Otherwise I think it's quite nice for end users. Next
4357 summer, rewrite the guts of it...
4366 summer, rewrite the guts of it...
4358
4367
4359 * Changed format of ipythonrc files to use whitespace as the
4368 * Changed format of ipythonrc files to use whitespace as the
4360 separator instead of an explicit '='. Cleaner.
4369 separator instead of an explicit '='. Cleaner.
4361
4370
4362 2001-12-20 Fernando Perez <fperez@colorado.edu>
4371 2001-12-20 Fernando Perez <fperez@colorado.edu>
4363
4372
4364 * Started a manual in LyX. For now it's just a quick merge of the
4373 * Started a manual in LyX. For now it's just a quick merge of the
4365 various internal docstrings and READMEs. Later it may grow into a
4374 various internal docstrings and READMEs. Later it may grow into a
4366 nice, full-blown manual.
4375 nice, full-blown manual.
4367
4376
4368 * Set up a distutils based installer. Installation should now be
4377 * Set up a distutils based installer. Installation should now be
4369 trivially simple for end-users.
4378 trivially simple for end-users.
4370
4379
4371 2001-12-11 Fernando Perez <fperez@colorado.edu>
4380 2001-12-11 Fernando Perez <fperez@colorado.edu>
4372
4381
4373 * Released 0.2.0. First public release, announced it at
4382 * Released 0.2.0. First public release, announced it at
4374 comp.lang.python. From now on, just bugfixes...
4383 comp.lang.python. From now on, just bugfixes...
4375
4384
4376 * Went through all the files, set copyright/license notices and
4385 * Went through all the files, set copyright/license notices and
4377 cleaned up things. Ready for release.
4386 cleaned up things. Ready for release.
4378
4387
4379 2001-12-10 Fernando Perez <fperez@colorado.edu>
4388 2001-12-10 Fernando Perez <fperez@colorado.edu>
4380
4389
4381 * Changed the first-time installer not to use tarfiles. It's more
4390 * Changed the first-time installer not to use tarfiles. It's more
4382 robust now and less unix-dependent. Also makes it easier for
4391 robust now and less unix-dependent. Also makes it easier for
4383 people to later upgrade versions.
4392 people to later upgrade versions.
4384
4393
4385 * Changed @exit to @abort to reflect the fact that it's pretty
4394 * Changed @exit to @abort to reflect the fact that it's pretty
4386 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4395 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4387 becomes significant only when IPyhton is embedded: in that case,
4396 becomes significant only when IPyhton is embedded: in that case,
4388 C-D closes IPython only, but @abort kills the enclosing program
4397 C-D closes IPython only, but @abort kills the enclosing program
4389 too (unless it had called IPython inside a try catching
4398 too (unless it had called IPython inside a try catching
4390 SystemExit).
4399 SystemExit).
4391
4400
4392 * Created Shell module which exposes the actuall IPython Shell
4401 * Created Shell module which exposes the actuall IPython Shell
4393 classes, currently the normal and the embeddable one. This at
4402 classes, currently the normal and the embeddable one. This at
4394 least offers a stable interface we won't need to change when
4403 least offers a stable interface we won't need to change when
4395 (later) the internals are rewritten. That rewrite will be confined
4404 (later) the internals are rewritten. That rewrite will be confined
4396 to iplib and ipmaker, but the Shell interface should remain as is.
4405 to iplib and ipmaker, but the Shell interface should remain as is.
4397
4406
4398 * Added embed module which offers an embeddable IPShell object,
4407 * Added embed module which offers an embeddable IPShell object,
4399 useful to fire up IPython *inside* a running program. Great for
4408 useful to fire up IPython *inside* a running program. Great for
4400 debugging or dynamical data analysis.
4409 debugging or dynamical data analysis.
4401
4410
4402 2001-12-08 Fernando Perez <fperez@colorado.edu>
4411 2001-12-08 Fernando Perez <fperez@colorado.edu>
4403
4412
4404 * Fixed small bug preventing seeing info from methods of defined
4413 * Fixed small bug preventing seeing info from methods of defined
4405 objects (incorrect namespace in _ofind()).
4414 objects (incorrect namespace in _ofind()).
4406
4415
4407 * Documentation cleanup. Moved the main usage docstrings to a
4416 * Documentation cleanup. Moved the main usage docstrings to a
4408 separate file, usage.py (cleaner to maintain, and hopefully in the
4417 separate file, usage.py (cleaner to maintain, and hopefully in the
4409 future some perlpod-like way of producing interactive, man and
4418 future some perlpod-like way of producing interactive, man and
4410 html docs out of it will be found).
4419 html docs out of it will be found).
4411
4420
4412 * Added @profile to see your profile at any time.
4421 * Added @profile to see your profile at any time.
4413
4422
4414 * Added @p as an alias for 'print'. It's especially convenient if
4423 * Added @p as an alias for 'print'. It's especially convenient if
4415 using automagic ('p x' prints x).
4424 using automagic ('p x' prints x).
4416
4425
4417 * Small cleanups and fixes after a pychecker run.
4426 * Small cleanups and fixes after a pychecker run.
4418
4427
4419 * Changed the @cd command to handle @cd - and @cd -<n> for
4428 * Changed the @cd command to handle @cd - and @cd -<n> for
4420 visiting any directory in _dh.
4429 visiting any directory in _dh.
4421
4430
4422 * Introduced _dh, a history of visited directories. @dhist prints
4431 * Introduced _dh, a history of visited directories. @dhist prints
4423 it out with numbers.
4432 it out with numbers.
4424
4433
4425 2001-12-07 Fernando Perez <fperez@colorado.edu>
4434 2001-12-07 Fernando Perez <fperez@colorado.edu>
4426
4435
4427 * Released 0.1.22
4436 * Released 0.1.22
4428
4437
4429 * Made initialization a bit more robust against invalid color
4438 * Made initialization a bit more robust against invalid color
4430 options in user input (exit, not traceback-crash).
4439 options in user input (exit, not traceback-crash).
4431
4440
4432 * Changed the bug crash reporter to write the report only in the
4441 * Changed the bug crash reporter to write the report only in the
4433 user's .ipython directory. That way IPython won't litter people's
4442 user's .ipython directory. That way IPython won't litter people's
4434 hard disks with crash files all over the place. Also print on
4443 hard disks with crash files all over the place. Also print on
4435 screen the necessary mail command.
4444 screen the necessary mail command.
4436
4445
4437 * With the new ultraTB, implemented LightBG color scheme for light
4446 * With the new ultraTB, implemented LightBG color scheme for light
4438 background terminals. A lot of people like white backgrounds, so I
4447 background terminals. A lot of people like white backgrounds, so I
4439 guess we should at least give them something readable.
4448 guess we should at least give them something readable.
4440
4449
4441 2001-12-06 Fernando Perez <fperez@colorado.edu>
4450 2001-12-06 Fernando Perez <fperez@colorado.edu>
4442
4451
4443 * Modified the structure of ultraTB. Now there's a proper class
4452 * Modified the structure of ultraTB. Now there's a proper class
4444 for tables of color schemes which allow adding schemes easily and
4453 for tables of color schemes which allow adding schemes easily and
4445 switching the active scheme without creating a new instance every
4454 switching the active scheme without creating a new instance every
4446 time (which was ridiculous). The syntax for creating new schemes
4455 time (which was ridiculous). The syntax for creating new schemes
4447 is also cleaner. I think ultraTB is finally done, with a clean
4456 is also cleaner. I think ultraTB is finally done, with a clean
4448 class structure. Names are also much cleaner (now there's proper
4457 class structure. Names are also much cleaner (now there's proper
4449 color tables, no need for every variable to also have 'color' in
4458 color tables, no need for every variable to also have 'color' in
4450 its name).
4459 its name).
4451
4460
4452 * Broke down genutils into separate files. Now genutils only
4461 * Broke down genutils into separate files. Now genutils only
4453 contains utility functions, and classes have been moved to their
4462 contains utility functions, and classes have been moved to their
4454 own files (they had enough independent functionality to warrant
4463 own files (they had enough independent functionality to warrant
4455 it): ConfigLoader, OutputTrap, Struct.
4464 it): ConfigLoader, OutputTrap, Struct.
4456
4465
4457 2001-12-05 Fernando Perez <fperez@colorado.edu>
4466 2001-12-05 Fernando Perez <fperez@colorado.edu>
4458
4467
4459 * IPython turns 21! Released version 0.1.21, as a candidate for
4468 * IPython turns 21! Released version 0.1.21, as a candidate for
4460 public consumption. If all goes well, release in a few days.
4469 public consumption. If all goes well, release in a few days.
4461
4470
4462 * Fixed path bug (files in Extensions/ directory wouldn't be found
4471 * Fixed path bug (files in Extensions/ directory wouldn't be found
4463 unless IPython/ was explicitly in sys.path).
4472 unless IPython/ was explicitly in sys.path).
4464
4473
4465 * Extended the FlexCompleter class as MagicCompleter to allow
4474 * Extended the FlexCompleter class as MagicCompleter to allow
4466 completion of @-starting lines.
4475 completion of @-starting lines.
4467
4476
4468 * Created __release__.py file as a central repository for release
4477 * Created __release__.py file as a central repository for release
4469 info that other files can read from.
4478 info that other files can read from.
4470
4479
4471 * Fixed small bug in logging: when logging was turned on in
4480 * Fixed small bug in logging: when logging was turned on in
4472 mid-session, old lines with special meanings (!@?) were being
4481 mid-session, old lines with special meanings (!@?) were being
4473 logged without the prepended comment, which is necessary since
4482 logged without the prepended comment, which is necessary since
4474 they are not truly valid python syntax. This should make session
4483 they are not truly valid python syntax. This should make session
4475 restores produce less errors.
4484 restores produce less errors.
4476
4485
4477 * The namespace cleanup forced me to make a FlexCompleter class
4486 * The namespace cleanup forced me to make a FlexCompleter class
4478 which is nothing but a ripoff of rlcompleter, but with selectable
4487 which is nothing but a ripoff of rlcompleter, but with selectable
4479 namespace (rlcompleter only works in __main__.__dict__). I'll try
4488 namespace (rlcompleter only works in __main__.__dict__). I'll try
4480 to submit a note to the authors to see if this change can be
4489 to submit a note to the authors to see if this change can be
4481 incorporated in future rlcompleter releases (Dec.6: done)
4490 incorporated in future rlcompleter releases (Dec.6: done)
4482
4491
4483 * More fixes to namespace handling. It was a mess! Now all
4492 * More fixes to namespace handling. It was a mess! Now all
4484 explicit references to __main__.__dict__ are gone (except when
4493 explicit references to __main__.__dict__ are gone (except when
4485 really needed) and everything is handled through the namespace
4494 really needed) and everything is handled through the namespace
4486 dicts in the IPython instance. We seem to be getting somewhere
4495 dicts in the IPython instance. We seem to be getting somewhere
4487 with this, finally...
4496 with this, finally...
4488
4497
4489 * Small documentation updates.
4498 * Small documentation updates.
4490
4499
4491 * Created the Extensions directory under IPython (with an
4500 * Created the Extensions directory under IPython (with an
4492 __init__.py). Put the PhysicalQ stuff there. This directory should
4501 __init__.py). Put the PhysicalQ stuff there. This directory should
4493 be used for all special-purpose extensions.
4502 be used for all special-purpose extensions.
4494
4503
4495 * File renaming:
4504 * File renaming:
4496 ipythonlib --> ipmaker
4505 ipythonlib --> ipmaker
4497 ipplib --> iplib
4506 ipplib --> iplib
4498 This makes a bit more sense in terms of what these files actually do.
4507 This makes a bit more sense in terms of what these files actually do.
4499
4508
4500 * Moved all the classes and functions in ipythonlib to ipplib, so
4509 * Moved all the classes and functions in ipythonlib to ipplib, so
4501 now ipythonlib only has make_IPython(). This will ease up its
4510 now ipythonlib only has make_IPython(). This will ease up its
4502 splitting in smaller functional chunks later.
4511 splitting in smaller functional chunks later.
4503
4512
4504 * Cleaned up (done, I think) output of @whos. Better column
4513 * Cleaned up (done, I think) output of @whos. Better column
4505 formatting, and now shows str(var) for as much as it can, which is
4514 formatting, and now shows str(var) for as much as it can, which is
4506 typically what one gets with a 'print var'.
4515 typically what one gets with a 'print var'.
4507
4516
4508 2001-12-04 Fernando Perez <fperez@colorado.edu>
4517 2001-12-04 Fernando Perez <fperez@colorado.edu>
4509
4518
4510 * Fixed namespace problems. Now builtin/IPyhton/user names get
4519 * Fixed namespace problems. Now builtin/IPyhton/user names get
4511 properly reported in their namespace. Internal namespace handling
4520 properly reported in their namespace. Internal namespace handling
4512 is finally getting decent (not perfect yet, but much better than
4521 is finally getting decent (not perfect yet, but much better than
4513 the ad-hoc mess we had).
4522 the ad-hoc mess we had).
4514
4523
4515 * Removed -exit option. If people just want to run a python
4524 * Removed -exit option. If people just want to run a python
4516 script, that's what the normal interpreter is for. Less
4525 script, that's what the normal interpreter is for. Less
4517 unnecessary options, less chances for bugs.
4526 unnecessary options, less chances for bugs.
4518
4527
4519 * Added a crash handler which generates a complete post-mortem if
4528 * Added a crash handler which generates a complete post-mortem if
4520 IPython crashes. This will help a lot in tracking bugs down the
4529 IPython crashes. This will help a lot in tracking bugs down the
4521 road.
4530 road.
4522
4531
4523 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4532 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4524 which were boud to functions being reassigned would bypass the
4533 which were boud to functions being reassigned would bypass the
4525 logger, breaking the sync of _il with the prompt counter. This
4534 logger, breaking the sync of _il with the prompt counter. This
4526 would then crash IPython later when a new line was logged.
4535 would then crash IPython later when a new line was logged.
4527
4536
4528 2001-12-02 Fernando Perez <fperez@colorado.edu>
4537 2001-12-02 Fernando Perez <fperez@colorado.edu>
4529
4538
4530 * Made IPython a package. This means people don't have to clutter
4539 * Made IPython a package. This means people don't have to clutter
4531 their sys.path with yet another directory. Changed the INSTALL
4540 their sys.path with yet another directory. Changed the INSTALL
4532 file accordingly.
4541 file accordingly.
4533
4542
4534 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4543 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4535 sorts its output (so @who shows it sorted) and @whos formats the
4544 sorts its output (so @who shows it sorted) and @whos formats the
4536 table according to the width of the first column. Nicer, easier to
4545 table according to the width of the first column. Nicer, easier to
4537 read. Todo: write a generic table_format() which takes a list of
4546 read. Todo: write a generic table_format() which takes a list of
4538 lists and prints it nicely formatted, with optional row/column
4547 lists and prints it nicely formatted, with optional row/column
4539 separators and proper padding and justification.
4548 separators and proper padding and justification.
4540
4549
4541 * Released 0.1.20
4550 * Released 0.1.20
4542
4551
4543 * Fixed bug in @log which would reverse the inputcache list (a
4552 * Fixed bug in @log which would reverse the inputcache list (a
4544 copy operation was missing).
4553 copy operation was missing).
4545
4554
4546 * Code cleanup. @config was changed to use page(). Better, since
4555 * Code cleanup. @config was changed to use page(). Better, since
4547 its output is always quite long.
4556 its output is always quite long.
4548
4557
4549 * Itpl is back as a dependency. I was having too many problems
4558 * Itpl is back as a dependency. I was having too many problems
4550 getting the parametric aliases to work reliably, and it's just
4559 getting the parametric aliases to work reliably, and it's just
4551 easier to code weird string operations with it than playing %()s
4560 easier to code weird string operations with it than playing %()s
4552 games. It's only ~6k, so I don't think it's too big a deal.
4561 games. It's only ~6k, so I don't think it's too big a deal.
4553
4562
4554 * Found (and fixed) a very nasty bug with history. !lines weren't
4563 * Found (and fixed) a very nasty bug with history. !lines weren't
4555 getting cached, and the out of sync caches would crash
4564 getting cached, and the out of sync caches would crash
4556 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4565 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4557 division of labor a bit better. Bug fixed, cleaner structure.
4566 division of labor a bit better. Bug fixed, cleaner structure.
4558
4567
4559 2001-12-01 Fernando Perez <fperez@colorado.edu>
4568 2001-12-01 Fernando Perez <fperez@colorado.edu>
4560
4569
4561 * Released 0.1.19
4570 * Released 0.1.19
4562
4571
4563 * Added option -n to @hist to prevent line number printing. Much
4572 * Added option -n to @hist to prevent line number printing. Much
4564 easier to copy/paste code this way.
4573 easier to copy/paste code this way.
4565
4574
4566 * Created global _il to hold the input list. Allows easy
4575 * Created global _il to hold the input list. Allows easy
4567 re-execution of blocks of code by slicing it (inspired by Janko's
4576 re-execution of blocks of code by slicing it (inspired by Janko's
4568 comment on 'macros').
4577 comment on 'macros').
4569
4578
4570 * Small fixes and doc updates.
4579 * Small fixes and doc updates.
4571
4580
4572 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4581 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4573 much too fragile with automagic. Handles properly multi-line
4582 much too fragile with automagic. Handles properly multi-line
4574 statements and takes parameters.
4583 statements and takes parameters.
4575
4584
4576 2001-11-30 Fernando Perez <fperez@colorado.edu>
4585 2001-11-30 Fernando Perez <fperez@colorado.edu>
4577
4586
4578 * Version 0.1.18 released.
4587 * Version 0.1.18 released.
4579
4588
4580 * Fixed nasty namespace bug in initial module imports.
4589 * Fixed nasty namespace bug in initial module imports.
4581
4590
4582 * Added copyright/license notes to all code files (except
4591 * Added copyright/license notes to all code files (except
4583 DPyGetOpt). For the time being, LGPL. That could change.
4592 DPyGetOpt). For the time being, LGPL. That could change.
4584
4593
4585 * Rewrote a much nicer README, updated INSTALL, cleaned up
4594 * Rewrote a much nicer README, updated INSTALL, cleaned up
4586 ipythonrc-* samples.
4595 ipythonrc-* samples.
4587
4596
4588 * Overall code/documentation cleanup. Basically ready for
4597 * Overall code/documentation cleanup. Basically ready for
4589 release. Only remaining thing: licence decision (LGPL?).
4598 release. Only remaining thing: licence decision (LGPL?).
4590
4599
4591 * Converted load_config to a class, ConfigLoader. Now recursion
4600 * Converted load_config to a class, ConfigLoader. Now recursion
4592 control is better organized. Doesn't include the same file twice.
4601 control is better organized. Doesn't include the same file twice.
4593
4602
4594 2001-11-29 Fernando Perez <fperez@colorado.edu>
4603 2001-11-29 Fernando Perez <fperez@colorado.edu>
4595
4604
4596 * Got input history working. Changed output history variables from
4605 * Got input history working. Changed output history variables from
4597 _p to _o so that _i is for input and _o for output. Just cleaner
4606 _p to _o so that _i is for input and _o for output. Just cleaner
4598 convention.
4607 convention.
4599
4608
4600 * Implemented parametric aliases. This pretty much allows the
4609 * Implemented parametric aliases. This pretty much allows the
4601 alias system to offer full-blown shell convenience, I think.
4610 alias system to offer full-blown shell convenience, I think.
4602
4611
4603 * Version 0.1.17 released, 0.1.18 opened.
4612 * Version 0.1.17 released, 0.1.18 opened.
4604
4613
4605 * dot_ipython/ipythonrc (alias): added documentation.
4614 * dot_ipython/ipythonrc (alias): added documentation.
4606 (xcolor): Fixed small bug (xcolors -> xcolor)
4615 (xcolor): Fixed small bug (xcolors -> xcolor)
4607
4616
4608 * Changed the alias system. Now alias is a magic command to define
4617 * Changed the alias system. Now alias is a magic command to define
4609 aliases just like the shell. Rationale: the builtin magics should
4618 aliases just like the shell. Rationale: the builtin magics should
4610 be there for things deeply connected to IPython's
4619 be there for things deeply connected to IPython's
4611 architecture. And this is a much lighter system for what I think
4620 architecture. And this is a much lighter system for what I think
4612 is the really important feature: allowing users to define quickly
4621 is the really important feature: allowing users to define quickly
4613 magics that will do shell things for them, so they can customize
4622 magics that will do shell things for them, so they can customize
4614 IPython easily to match their work habits. If someone is really
4623 IPython easily to match their work habits. If someone is really
4615 desperate to have another name for a builtin alias, they can
4624 desperate to have another name for a builtin alias, they can
4616 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4625 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4617 works.
4626 works.
4618
4627
4619 2001-11-28 Fernando Perez <fperez@colorado.edu>
4628 2001-11-28 Fernando Perez <fperez@colorado.edu>
4620
4629
4621 * Changed @file so that it opens the source file at the proper
4630 * Changed @file so that it opens the source file at the proper
4622 line. Since it uses less, if your EDITOR environment is
4631 line. Since it uses less, if your EDITOR environment is
4623 configured, typing v will immediately open your editor of choice
4632 configured, typing v will immediately open your editor of choice
4624 right at the line where the object is defined. Not as quick as
4633 right at the line where the object is defined. Not as quick as
4625 having a direct @edit command, but for all intents and purposes it
4634 having a direct @edit command, but for all intents and purposes it
4626 works. And I don't have to worry about writing @edit to deal with
4635 works. And I don't have to worry about writing @edit to deal with
4627 all the editors, less does that.
4636 all the editors, less does that.
4628
4637
4629 * Version 0.1.16 released, 0.1.17 opened.
4638 * Version 0.1.16 released, 0.1.17 opened.
4630
4639
4631 * Fixed some nasty bugs in the page/page_dumb combo that could
4640 * Fixed some nasty bugs in the page/page_dumb combo that could
4632 crash IPython.
4641 crash IPython.
4633
4642
4634 2001-11-27 Fernando Perez <fperez@colorado.edu>
4643 2001-11-27 Fernando Perez <fperez@colorado.edu>
4635
4644
4636 * Version 0.1.15 released, 0.1.16 opened.
4645 * Version 0.1.15 released, 0.1.16 opened.
4637
4646
4638 * Finally got ? and ?? to work for undefined things: now it's
4647 * Finally got ? and ?? to work for undefined things: now it's
4639 possible to type {}.get? and get information about the get method
4648 possible to type {}.get? and get information about the get method
4640 of dicts, or os.path? even if only os is defined (so technically
4649 of dicts, or os.path? even if only os is defined (so technically
4641 os.path isn't). Works at any level. For example, after import os,
4650 os.path isn't). Works at any level. For example, after import os,
4642 os?, os.path?, os.path.abspath? all work. This is great, took some
4651 os?, os.path?, os.path.abspath? all work. This is great, took some
4643 work in _ofind.
4652 work in _ofind.
4644
4653
4645 * Fixed more bugs with logging. The sanest way to do it was to add
4654 * Fixed more bugs with logging. The sanest way to do it was to add
4646 to @log a 'mode' parameter. Killed two in one shot (this mode
4655 to @log a 'mode' parameter. Killed two in one shot (this mode
4647 option was a request of Janko's). I think it's finally clean
4656 option was a request of Janko's). I think it's finally clean
4648 (famous last words).
4657 (famous last words).
4649
4658
4650 * Added a page_dumb() pager which does a decent job of paging on
4659 * Added a page_dumb() pager which does a decent job of paging on
4651 screen, if better things (like less) aren't available. One less
4660 screen, if better things (like less) aren't available. One less
4652 unix dependency (someday maybe somebody will port this to
4661 unix dependency (someday maybe somebody will port this to
4653 windows).
4662 windows).
4654
4663
4655 * Fixed problem in magic_log: would lock of logging out if log
4664 * Fixed problem in magic_log: would lock of logging out if log
4656 creation failed (because it would still think it had succeeded).
4665 creation failed (because it would still think it had succeeded).
4657
4666
4658 * Improved the page() function using curses to auto-detect screen
4667 * Improved the page() function using curses to auto-detect screen
4659 size. Now it can make a much better decision on whether to print
4668 size. Now it can make a much better decision on whether to print
4660 or page a string. Option screen_length was modified: a value 0
4669 or page a string. Option screen_length was modified: a value 0
4661 means auto-detect, and that's the default now.
4670 means auto-detect, and that's the default now.
4662
4671
4663 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4672 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4664 go out. I'll test it for a few days, then talk to Janko about
4673 go out. I'll test it for a few days, then talk to Janko about
4665 licences and announce it.
4674 licences and announce it.
4666
4675
4667 * Fixed the length of the auto-generated ---> prompt which appears
4676 * Fixed the length of the auto-generated ---> prompt which appears
4668 for auto-parens and auto-quotes. Getting this right isn't trivial,
4677 for auto-parens and auto-quotes. Getting this right isn't trivial,
4669 with all the color escapes, different prompt types and optional
4678 with all the color escapes, different prompt types and optional
4670 separators. But it seems to be working in all the combinations.
4679 separators. But it seems to be working in all the combinations.
4671
4680
4672 2001-11-26 Fernando Perez <fperez@colorado.edu>
4681 2001-11-26 Fernando Perez <fperez@colorado.edu>
4673
4682
4674 * Wrote a regexp filter to get option types from the option names
4683 * Wrote a regexp filter to get option types from the option names
4675 string. This eliminates the need to manually keep two duplicate
4684 string. This eliminates the need to manually keep two duplicate
4676 lists.
4685 lists.
4677
4686
4678 * Removed the unneeded check_option_names. Now options are handled
4687 * Removed the unneeded check_option_names. Now options are handled
4679 in a much saner manner and it's easy to visually check that things
4688 in a much saner manner and it's easy to visually check that things
4680 are ok.
4689 are ok.
4681
4690
4682 * Updated version numbers on all files I modified to carry a
4691 * Updated version numbers on all files I modified to carry a
4683 notice so Janko and Nathan have clear version markers.
4692 notice so Janko and Nathan have clear version markers.
4684
4693
4685 * Updated docstring for ultraTB with my changes. I should send
4694 * Updated docstring for ultraTB with my changes. I should send
4686 this to Nathan.
4695 this to Nathan.
4687
4696
4688 * Lots of small fixes. Ran everything through pychecker again.
4697 * Lots of small fixes. Ran everything through pychecker again.
4689
4698
4690 * Made loading of deep_reload an cmd line option. If it's not too
4699 * Made loading of deep_reload an cmd line option. If it's not too
4691 kosher, now people can just disable it. With -nodeep_reload it's
4700 kosher, now people can just disable it. With -nodeep_reload it's
4692 still available as dreload(), it just won't overwrite reload().
4701 still available as dreload(), it just won't overwrite reload().
4693
4702
4694 * Moved many options to the no| form (-opt and -noopt
4703 * Moved many options to the no| form (-opt and -noopt
4695 accepted). Cleaner.
4704 accepted). Cleaner.
4696
4705
4697 * Changed magic_log so that if called with no parameters, it uses
4706 * Changed magic_log so that if called with no parameters, it uses
4698 'rotate' mode. That way auto-generated logs aren't automatically
4707 'rotate' mode. That way auto-generated logs aren't automatically
4699 over-written. For normal logs, now a backup is made if it exists
4708 over-written. For normal logs, now a backup is made if it exists
4700 (only 1 level of backups). A new 'backup' mode was added to the
4709 (only 1 level of backups). A new 'backup' mode was added to the
4701 Logger class to support this. This was a request by Janko.
4710 Logger class to support this. This was a request by Janko.
4702
4711
4703 * Added @logoff/@logon to stop/restart an active log.
4712 * Added @logoff/@logon to stop/restart an active log.
4704
4713
4705 * Fixed a lot of bugs in log saving/replay. It was pretty
4714 * Fixed a lot of bugs in log saving/replay. It was pretty
4706 broken. Now special lines (!@,/) appear properly in the command
4715 broken. Now special lines (!@,/) appear properly in the command
4707 history after a log replay.
4716 history after a log replay.
4708
4717
4709 * Tried and failed to implement full session saving via pickle. My
4718 * Tried and failed to implement full session saving via pickle. My
4710 idea was to pickle __main__.__dict__, but modules can't be
4719 idea was to pickle __main__.__dict__, but modules can't be
4711 pickled. This would be a better alternative to replaying logs, but
4720 pickled. This would be a better alternative to replaying logs, but
4712 seems quite tricky to get to work. Changed -session to be called
4721 seems quite tricky to get to work. Changed -session to be called
4713 -logplay, which more accurately reflects what it does. And if we
4722 -logplay, which more accurately reflects what it does. And if we
4714 ever get real session saving working, -session is now available.
4723 ever get real session saving working, -session is now available.
4715
4724
4716 * Implemented color schemes for prompts also. As for tracebacks,
4725 * Implemented color schemes for prompts also. As for tracebacks,
4717 currently only NoColor and Linux are supported. But now the
4726 currently only NoColor and Linux are supported. But now the
4718 infrastructure is in place, based on a generic ColorScheme
4727 infrastructure is in place, based on a generic ColorScheme
4719 class. So writing and activating new schemes both for the prompts
4728 class. So writing and activating new schemes both for the prompts
4720 and the tracebacks should be straightforward.
4729 and the tracebacks should be straightforward.
4721
4730
4722 * Version 0.1.13 released, 0.1.14 opened.
4731 * Version 0.1.13 released, 0.1.14 opened.
4723
4732
4724 * Changed handling of options for output cache. Now counter is
4733 * Changed handling of options for output cache. Now counter is
4725 hardwired starting at 1 and one specifies the maximum number of
4734 hardwired starting at 1 and one specifies the maximum number of
4726 entries *in the outcache* (not the max prompt counter). This is
4735 entries *in the outcache* (not the max prompt counter). This is
4727 much better, since many statements won't increase the cache
4736 much better, since many statements won't increase the cache
4728 count. It also eliminated some confusing options, now there's only
4737 count. It also eliminated some confusing options, now there's only
4729 one: cache_size.
4738 one: cache_size.
4730
4739
4731 * Added 'alias' magic function and magic_alias option in the
4740 * Added 'alias' magic function and magic_alias option in the
4732 ipythonrc file. Now the user can easily define whatever names he
4741 ipythonrc file. Now the user can easily define whatever names he
4733 wants for the magic functions without having to play weird
4742 wants for the magic functions without having to play weird
4734 namespace games. This gives IPython a real shell-like feel.
4743 namespace games. This gives IPython a real shell-like feel.
4735
4744
4736 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4745 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4737 @ or not).
4746 @ or not).
4738
4747
4739 This was one of the last remaining 'visible' bugs (that I know
4748 This was one of the last remaining 'visible' bugs (that I know
4740 of). I think if I can clean up the session loading so it works
4749 of). I think if I can clean up the session loading so it works
4741 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4750 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4742 about licensing).
4751 about licensing).
4743
4752
4744 2001-11-25 Fernando Perez <fperez@colorado.edu>
4753 2001-11-25 Fernando Perez <fperez@colorado.edu>
4745
4754
4746 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4755 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4747 there's a cleaner distinction between what ? and ?? show.
4756 there's a cleaner distinction between what ? and ?? show.
4748
4757
4749 * Added screen_length option. Now the user can define his own
4758 * Added screen_length option. Now the user can define his own
4750 screen size for page() operations.
4759 screen size for page() operations.
4751
4760
4752 * Implemented magic shell-like functions with automatic code
4761 * Implemented magic shell-like functions with automatic code
4753 generation. Now adding another function is just a matter of adding
4762 generation. Now adding another function is just a matter of adding
4754 an entry to a dict, and the function is dynamically generated at
4763 an entry to a dict, and the function is dynamically generated at
4755 run-time. Python has some really cool features!
4764 run-time. Python has some really cool features!
4756
4765
4757 * Renamed many options to cleanup conventions a little. Now all
4766 * Renamed many options to cleanup conventions a little. Now all
4758 are lowercase, and only underscores where needed. Also in the code
4767 are lowercase, and only underscores where needed. Also in the code
4759 option name tables are clearer.
4768 option name tables are clearer.
4760
4769
4761 * Changed prompts a little. Now input is 'In [n]:' instead of
4770 * Changed prompts a little. Now input is 'In [n]:' instead of
4762 'In[n]:='. This allows it the numbers to be aligned with the
4771 'In[n]:='. This allows it the numbers to be aligned with the
4763 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4772 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4764 Python (it was a Mathematica thing). The '...' continuation prompt
4773 Python (it was a Mathematica thing). The '...' continuation prompt
4765 was also changed a little to align better.
4774 was also changed a little to align better.
4766
4775
4767 * Fixed bug when flushing output cache. Not all _p<n> variables
4776 * Fixed bug when flushing output cache. Not all _p<n> variables
4768 exist, so their deletion needs to be wrapped in a try:
4777 exist, so their deletion needs to be wrapped in a try:
4769
4778
4770 * Figured out how to properly use inspect.formatargspec() (it
4779 * Figured out how to properly use inspect.formatargspec() (it
4771 requires the args preceded by *). So I removed all the code from
4780 requires the args preceded by *). So I removed all the code from
4772 _get_pdef in Magic, which was just replicating that.
4781 _get_pdef in Magic, which was just replicating that.
4773
4782
4774 * Added test to prefilter to allow redefining magic function names
4783 * Added test to prefilter to allow redefining magic function names
4775 as variables. This is ok, since the @ form is always available,
4784 as variables. This is ok, since the @ form is always available,
4776 but whe should allow the user to define a variable called 'ls' if
4785 but whe should allow the user to define a variable called 'ls' if
4777 he needs it.
4786 he needs it.
4778
4787
4779 * Moved the ToDo information from README into a separate ToDo.
4788 * Moved the ToDo information from README into a separate ToDo.
4780
4789
4781 * General code cleanup and small bugfixes. I think it's close to a
4790 * General code cleanup and small bugfixes. I think it's close to a
4782 state where it can be released, obviously with a big 'beta'
4791 state where it can be released, obviously with a big 'beta'
4783 warning on it.
4792 warning on it.
4784
4793
4785 * Got the magic function split to work. Now all magics are defined
4794 * Got the magic function split to work. Now all magics are defined
4786 in a separate class. It just organizes things a bit, and now
4795 in a separate class. It just organizes things a bit, and now
4787 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4796 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4788 was too long).
4797 was too long).
4789
4798
4790 * Changed @clear to @reset to avoid potential confusions with
4799 * Changed @clear to @reset to avoid potential confusions with
4791 the shell command clear. Also renamed @cl to @clear, which does
4800 the shell command clear. Also renamed @cl to @clear, which does
4792 exactly what people expect it to from their shell experience.
4801 exactly what people expect it to from their shell experience.
4793
4802
4794 Added a check to the @reset command (since it's so
4803 Added a check to the @reset command (since it's so
4795 destructive, it's probably a good idea to ask for confirmation).
4804 destructive, it's probably a good idea to ask for confirmation).
4796 But now reset only works for full namespace resetting. Since the
4805 But now reset only works for full namespace resetting. Since the
4797 del keyword is already there for deleting a few specific
4806 del keyword is already there for deleting a few specific
4798 variables, I don't see the point of having a redundant magic
4807 variables, I don't see the point of having a redundant magic
4799 function for the same task.
4808 function for the same task.
4800
4809
4801 2001-11-24 Fernando Perez <fperez@colorado.edu>
4810 2001-11-24 Fernando Perez <fperez@colorado.edu>
4802
4811
4803 * Updated the builtin docs (esp. the ? ones).
4812 * Updated the builtin docs (esp. the ? ones).
4804
4813
4805 * Ran all the code through pychecker. Not terribly impressed with
4814 * Ran all the code through pychecker. Not terribly impressed with
4806 it: lots of spurious warnings and didn't really find anything of
4815 it: lots of spurious warnings and didn't really find anything of
4807 substance (just a few modules being imported and not used).
4816 substance (just a few modules being imported and not used).
4808
4817
4809 * Implemented the new ultraTB functionality into IPython. New
4818 * Implemented the new ultraTB functionality into IPython. New
4810 option: xcolors. This chooses color scheme. xmode now only selects
4819 option: xcolors. This chooses color scheme. xmode now only selects
4811 between Plain and Verbose. Better orthogonality.
4820 between Plain and Verbose. Better orthogonality.
4812
4821
4813 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4822 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4814 mode and color scheme for the exception handlers. Now it's
4823 mode and color scheme for the exception handlers. Now it's
4815 possible to have the verbose traceback with no coloring.
4824 possible to have the verbose traceback with no coloring.
4816
4825
4817 2001-11-23 Fernando Perez <fperez@colorado.edu>
4826 2001-11-23 Fernando Perez <fperez@colorado.edu>
4818
4827
4819 * Version 0.1.12 released, 0.1.13 opened.
4828 * Version 0.1.12 released, 0.1.13 opened.
4820
4829
4821 * Removed option to set auto-quote and auto-paren escapes by
4830 * Removed option to set auto-quote and auto-paren escapes by
4822 user. The chances of breaking valid syntax are just too high. If
4831 user. The chances of breaking valid syntax are just too high. If
4823 someone *really* wants, they can always dig into the code.
4832 someone *really* wants, they can always dig into the code.
4824
4833
4825 * Made prompt separators configurable.
4834 * Made prompt separators configurable.
4826
4835
4827 2001-11-22 Fernando Perez <fperez@colorado.edu>
4836 2001-11-22 Fernando Perez <fperez@colorado.edu>
4828
4837
4829 * Small bugfixes in many places.
4838 * Small bugfixes in many places.
4830
4839
4831 * Removed the MyCompleter class from ipplib. It seemed redundant
4840 * Removed the MyCompleter class from ipplib. It seemed redundant
4832 with the C-p,C-n history search functionality. Less code to
4841 with the C-p,C-n history search functionality. Less code to
4833 maintain.
4842 maintain.
4834
4843
4835 * Moved all the original ipython.py code into ipythonlib.py. Right
4844 * Moved all the original ipython.py code into ipythonlib.py. Right
4836 now it's just one big dump into a function called make_IPython, so
4845 now it's just one big dump into a function called make_IPython, so
4837 no real modularity has been gained. But at least it makes the
4846 no real modularity has been gained. But at least it makes the
4838 wrapper script tiny, and since ipythonlib is a module, it gets
4847 wrapper script tiny, and since ipythonlib is a module, it gets
4839 compiled and startup is much faster.
4848 compiled and startup is much faster.
4840
4849
4841 This is a reasobably 'deep' change, so we should test it for a
4850 This is a reasobably 'deep' change, so we should test it for a
4842 while without messing too much more with the code.
4851 while without messing too much more with the code.
4843
4852
4844 2001-11-21 Fernando Perez <fperez@colorado.edu>
4853 2001-11-21 Fernando Perez <fperez@colorado.edu>
4845
4854
4846 * Version 0.1.11 released, 0.1.12 opened for further work.
4855 * Version 0.1.11 released, 0.1.12 opened for further work.
4847
4856
4848 * Removed dependency on Itpl. It was only needed in one place. It
4857 * Removed dependency on Itpl. It was only needed in one place. It
4849 would be nice if this became part of python, though. It makes life
4858 would be nice if this became part of python, though. It makes life
4850 *a lot* easier in some cases.
4859 *a lot* easier in some cases.
4851
4860
4852 * Simplified the prefilter code a bit. Now all handlers are
4861 * Simplified the prefilter code a bit. Now all handlers are
4853 expected to explicitly return a value (at least a blank string).
4862 expected to explicitly return a value (at least a blank string).
4854
4863
4855 * Heavy edits in ipplib. Removed the help system altogether. Now
4864 * Heavy edits in ipplib. Removed the help system altogether. Now
4856 obj?/?? is used for inspecting objects, a magic @doc prints
4865 obj?/?? is used for inspecting objects, a magic @doc prints
4857 docstrings, and full-blown Python help is accessed via the 'help'
4866 docstrings, and full-blown Python help is accessed via the 'help'
4858 keyword. This cleans up a lot of code (less to maintain) and does
4867 keyword. This cleans up a lot of code (less to maintain) and does
4859 the job. Since 'help' is now a standard Python component, might as
4868 the job. Since 'help' is now a standard Python component, might as
4860 well use it and remove duplicate functionality.
4869 well use it and remove duplicate functionality.
4861
4870
4862 Also removed the option to use ipplib as a standalone program. By
4871 Also removed the option to use ipplib as a standalone program. By
4863 now it's too dependent on other parts of IPython to function alone.
4872 now it's too dependent on other parts of IPython to function alone.
4864
4873
4865 * Fixed bug in genutils.pager. It would crash if the pager was
4874 * Fixed bug in genutils.pager. It would crash if the pager was
4866 exited immediately after opening (broken pipe).
4875 exited immediately after opening (broken pipe).
4867
4876
4868 * Trimmed down the VerboseTB reporting a little. The header is
4877 * Trimmed down the VerboseTB reporting a little. The header is
4869 much shorter now and the repeated exception arguments at the end
4878 much shorter now and the repeated exception arguments at the end
4870 have been removed. For interactive use the old header seemed a bit
4879 have been removed. For interactive use the old header seemed a bit
4871 excessive.
4880 excessive.
4872
4881
4873 * Fixed small bug in output of @whos for variables with multi-word
4882 * Fixed small bug in output of @whos for variables with multi-word
4874 types (only first word was displayed).
4883 types (only first word was displayed).
4875
4884
4876 2001-11-17 Fernando Perez <fperez@colorado.edu>
4885 2001-11-17 Fernando Perez <fperez@colorado.edu>
4877
4886
4878 * Version 0.1.10 released, 0.1.11 opened for further work.
4887 * Version 0.1.10 released, 0.1.11 opened for further work.
4879
4888
4880 * Modified dirs and friends. dirs now *returns* the stack (not
4889 * Modified dirs and friends. dirs now *returns* the stack (not
4881 prints), so one can manipulate it as a variable. Convenient to
4890 prints), so one can manipulate it as a variable. Convenient to
4882 travel along many directories.
4891 travel along many directories.
4883
4892
4884 * Fixed bug in magic_pdef: would only work with functions with
4893 * Fixed bug in magic_pdef: would only work with functions with
4885 arguments with default values.
4894 arguments with default values.
4886
4895
4887 2001-11-14 Fernando Perez <fperez@colorado.edu>
4896 2001-11-14 Fernando Perez <fperez@colorado.edu>
4888
4897
4889 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4898 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4890 example with IPython. Various other minor fixes and cleanups.
4899 example with IPython. Various other minor fixes and cleanups.
4891
4900
4892 * Version 0.1.9 released, 0.1.10 opened for further work.
4901 * Version 0.1.9 released, 0.1.10 opened for further work.
4893
4902
4894 * Added sys.path to the list of directories searched in the
4903 * Added sys.path to the list of directories searched in the
4895 execfile= option. It used to be the current directory and the
4904 execfile= option. It used to be the current directory and the
4896 user's IPYTHONDIR only.
4905 user's IPYTHONDIR only.
4897
4906
4898 2001-11-13 Fernando Perez <fperez@colorado.edu>
4907 2001-11-13 Fernando Perez <fperez@colorado.edu>
4899
4908
4900 * Reinstated the raw_input/prefilter separation that Janko had
4909 * Reinstated the raw_input/prefilter separation that Janko had
4901 initially. This gives a more convenient setup for extending the
4910 initially. This gives a more convenient setup for extending the
4902 pre-processor from the outside: raw_input always gets a string,
4911 pre-processor from the outside: raw_input always gets a string,
4903 and prefilter has to process it. We can then redefine prefilter
4912 and prefilter has to process it. We can then redefine prefilter
4904 from the outside and implement extensions for special
4913 from the outside and implement extensions for special
4905 purposes.
4914 purposes.
4906
4915
4907 Today I got one for inputting PhysicalQuantity objects
4916 Today I got one for inputting PhysicalQuantity objects
4908 (from Scientific) without needing any function calls at
4917 (from Scientific) without needing any function calls at
4909 all. Extremely convenient, and it's all done as a user-level
4918 all. Extremely convenient, and it's all done as a user-level
4910 extension (no IPython code was touched). Now instead of:
4919 extension (no IPython code was touched). Now instead of:
4911 a = PhysicalQuantity(4.2,'m/s**2')
4920 a = PhysicalQuantity(4.2,'m/s**2')
4912 one can simply say
4921 one can simply say
4913 a = 4.2 m/s**2
4922 a = 4.2 m/s**2
4914 or even
4923 or even
4915 a = 4.2 m/s^2
4924 a = 4.2 m/s^2
4916
4925
4917 I use this, but it's also a proof of concept: IPython really is
4926 I use this, but it's also a proof of concept: IPython really is
4918 fully user-extensible, even at the level of the parsing of the
4927 fully user-extensible, even at the level of the parsing of the
4919 command line. It's not trivial, but it's perfectly doable.
4928 command line. It's not trivial, but it's perfectly doable.
4920
4929
4921 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4930 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4922 the problem of modules being loaded in the inverse order in which
4931 the problem of modules being loaded in the inverse order in which
4923 they were defined in
4932 they were defined in
4924
4933
4925 * Version 0.1.8 released, 0.1.9 opened for further work.
4934 * Version 0.1.8 released, 0.1.9 opened for further work.
4926
4935
4927 * Added magics pdef, source and file. They respectively show the
4936 * Added magics pdef, source and file. They respectively show the
4928 definition line ('prototype' in C), source code and full python
4937 definition line ('prototype' in C), source code and full python
4929 file for any callable object. The object inspector oinfo uses
4938 file for any callable object. The object inspector oinfo uses
4930 these to show the same information.
4939 these to show the same information.
4931
4940
4932 * Version 0.1.7 released, 0.1.8 opened for further work.
4941 * Version 0.1.7 released, 0.1.8 opened for further work.
4933
4942
4934 * Separated all the magic functions into a class called Magic. The
4943 * Separated all the magic functions into a class called Magic. The
4935 InteractiveShell class was becoming too big for Xemacs to handle
4944 InteractiveShell class was becoming too big for Xemacs to handle
4936 (de-indenting a line would lock it up for 10 seconds while it
4945 (de-indenting a line would lock it up for 10 seconds while it
4937 backtracked on the whole class!)
4946 backtracked on the whole class!)
4938
4947
4939 FIXME: didn't work. It can be done, but right now namespaces are
4948 FIXME: didn't work. It can be done, but right now namespaces are
4940 all messed up. Do it later (reverted it for now, so at least
4949 all messed up. Do it later (reverted it for now, so at least
4941 everything works as before).
4950 everything works as before).
4942
4951
4943 * Got the object introspection system (magic_oinfo) working! I
4952 * Got the object introspection system (magic_oinfo) working! I
4944 think this is pretty much ready for release to Janko, so he can
4953 think this is pretty much ready for release to Janko, so he can
4945 test it for a while and then announce it. Pretty much 100% of what
4954 test it for a while and then announce it. Pretty much 100% of what
4946 I wanted for the 'phase 1' release is ready. Happy, tired.
4955 I wanted for the 'phase 1' release is ready. Happy, tired.
4947
4956
4948 2001-11-12 Fernando Perez <fperez@colorado.edu>
4957 2001-11-12 Fernando Perez <fperez@colorado.edu>
4949
4958
4950 * Version 0.1.6 released, 0.1.7 opened for further work.
4959 * Version 0.1.6 released, 0.1.7 opened for further work.
4951
4960
4952 * Fixed bug in printing: it used to test for truth before
4961 * Fixed bug in printing: it used to test for truth before
4953 printing, so 0 wouldn't print. Now checks for None.
4962 printing, so 0 wouldn't print. Now checks for None.
4954
4963
4955 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4964 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4956 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4965 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4957 reaches by hand into the outputcache. Think of a better way to do
4966 reaches by hand into the outputcache. Think of a better way to do
4958 this later.
4967 this later.
4959
4968
4960 * Various small fixes thanks to Nathan's comments.
4969 * Various small fixes thanks to Nathan's comments.
4961
4970
4962 * Changed magic_pprint to magic_Pprint. This way it doesn't
4971 * Changed magic_pprint to magic_Pprint. This way it doesn't
4963 collide with pprint() and the name is consistent with the command
4972 collide with pprint() and the name is consistent with the command
4964 line option.
4973 line option.
4965
4974
4966 * Changed prompt counter behavior to be fully like
4975 * Changed prompt counter behavior to be fully like
4967 Mathematica's. That is, even input that doesn't return a result
4976 Mathematica's. That is, even input that doesn't return a result
4968 raises the prompt counter. The old behavior was kind of confusing
4977 raises the prompt counter. The old behavior was kind of confusing
4969 (getting the same prompt number several times if the operation
4978 (getting the same prompt number several times if the operation
4970 didn't return a result).
4979 didn't return a result).
4971
4980
4972 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4981 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4973
4982
4974 * Fixed -Classic mode (wasn't working anymore).
4983 * Fixed -Classic mode (wasn't working anymore).
4975
4984
4976 * Added colored prompts using Nathan's new code. Colors are
4985 * Added colored prompts using Nathan's new code. Colors are
4977 currently hardwired, they can be user-configurable. For
4986 currently hardwired, they can be user-configurable. For
4978 developers, they can be chosen in file ipythonlib.py, at the
4987 developers, they can be chosen in file ipythonlib.py, at the
4979 beginning of the CachedOutput class def.
4988 beginning of the CachedOutput class def.
4980
4989
4981 2001-11-11 Fernando Perez <fperez@colorado.edu>
4990 2001-11-11 Fernando Perez <fperez@colorado.edu>
4982
4991
4983 * Version 0.1.5 released, 0.1.6 opened for further work.
4992 * Version 0.1.5 released, 0.1.6 opened for further work.
4984
4993
4985 * Changed magic_env to *return* the environment as a dict (not to
4994 * Changed magic_env to *return* the environment as a dict (not to
4986 print it). This way it prints, but it can also be processed.
4995 print it). This way it prints, but it can also be processed.
4987
4996
4988 * Added Verbose exception reporting to interactive
4997 * Added Verbose exception reporting to interactive
4989 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4998 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4990 traceback. Had to make some changes to the ultraTB file. This is
4999 traceback. Had to make some changes to the ultraTB file. This is
4991 probably the last 'big' thing in my mental todo list. This ties
5000 probably the last 'big' thing in my mental todo list. This ties
4992 in with the next entry:
5001 in with the next entry:
4993
5002
4994 * Changed -Xi and -Xf to a single -xmode option. Now all the user
5003 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4995 has to specify is Plain, Color or Verbose for all exception
5004 has to specify is Plain, Color or Verbose for all exception
4996 handling.
5005 handling.
4997
5006
4998 * Removed ShellServices option. All this can really be done via
5007 * Removed ShellServices option. All this can really be done via
4999 the magic system. It's easier to extend, cleaner and has automatic
5008 the magic system. It's easier to extend, cleaner and has automatic
5000 namespace protection and documentation.
5009 namespace protection and documentation.
5001
5010
5002 2001-11-09 Fernando Perez <fperez@colorado.edu>
5011 2001-11-09 Fernando Perez <fperez@colorado.edu>
5003
5012
5004 * Fixed bug in output cache flushing (missing parameter to
5013 * Fixed bug in output cache flushing (missing parameter to
5005 __init__). Other small bugs fixed (found using pychecker).
5014 __init__). Other small bugs fixed (found using pychecker).
5006
5015
5007 * Version 0.1.4 opened for bugfixing.
5016 * Version 0.1.4 opened for bugfixing.
5008
5017
5009 2001-11-07 Fernando Perez <fperez@colorado.edu>
5018 2001-11-07 Fernando Perez <fperez@colorado.edu>
5010
5019
5011 * Version 0.1.3 released, mainly because of the raw_input bug.
5020 * Version 0.1.3 released, mainly because of the raw_input bug.
5012
5021
5013 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
5022 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
5014 and when testing for whether things were callable, a call could
5023 and when testing for whether things were callable, a call could
5015 actually be made to certain functions. They would get called again
5024 actually be made to certain functions. They would get called again
5016 once 'really' executed, with a resulting double call. A disaster
5025 once 'really' executed, with a resulting double call. A disaster
5017 in many cases (list.reverse() would never work!).
5026 in many cases (list.reverse() would never work!).
5018
5027
5019 * Removed prefilter() function, moved its code to raw_input (which
5028 * Removed prefilter() function, moved its code to raw_input (which
5020 after all was just a near-empty caller for prefilter). This saves
5029 after all was just a near-empty caller for prefilter). This saves
5021 a function call on every prompt, and simplifies the class a tiny bit.
5030 a function call on every prompt, and simplifies the class a tiny bit.
5022
5031
5023 * Fix _ip to __ip name in magic example file.
5032 * Fix _ip to __ip name in magic example file.
5024
5033
5025 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
5034 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
5026 work with non-gnu versions of tar.
5035 work with non-gnu versions of tar.
5027
5036
5028 2001-11-06 Fernando Perez <fperez@colorado.edu>
5037 2001-11-06 Fernando Perez <fperez@colorado.edu>
5029
5038
5030 * Version 0.1.2. Just to keep track of the recent changes.
5039 * Version 0.1.2. Just to keep track of the recent changes.
5031
5040
5032 * Fixed nasty bug in output prompt routine. It used to check 'if
5041 * Fixed nasty bug in output prompt routine. It used to check 'if
5033 arg != None...'. Problem is, this fails if arg implements a
5042 arg != None...'. Problem is, this fails if arg implements a
5034 special comparison (__cmp__) which disallows comparing to
5043 special comparison (__cmp__) which disallows comparing to
5035 None. Found it when trying to use the PhysicalQuantity module from
5044 None. Found it when trying to use the PhysicalQuantity module from
5036 ScientificPython.
5045 ScientificPython.
5037
5046
5038 2001-11-05 Fernando Perez <fperez@colorado.edu>
5047 2001-11-05 Fernando Perez <fperez@colorado.edu>
5039
5048
5040 * Also added dirs. Now the pushd/popd/dirs family functions
5049 * Also added dirs. Now the pushd/popd/dirs family functions
5041 basically like the shell, with the added convenience of going home
5050 basically like the shell, with the added convenience of going home
5042 when called with no args.
5051 when called with no args.
5043
5052
5044 * pushd/popd slightly modified to mimic shell behavior more
5053 * pushd/popd slightly modified to mimic shell behavior more
5045 closely.
5054 closely.
5046
5055
5047 * Added env,pushd,popd from ShellServices as magic functions. I
5056 * Added env,pushd,popd from ShellServices as magic functions. I
5048 think the cleanest will be to port all desired functions from
5057 think the cleanest will be to port all desired functions from
5049 ShellServices as magics and remove ShellServices altogether. This
5058 ShellServices as magics and remove ShellServices altogether. This
5050 will provide a single, clean way of adding functionality
5059 will provide a single, clean way of adding functionality
5051 (shell-type or otherwise) to IP.
5060 (shell-type or otherwise) to IP.
5052
5061
5053 2001-11-04 Fernando Perez <fperez@colorado.edu>
5062 2001-11-04 Fernando Perez <fperez@colorado.edu>
5054
5063
5055 * Added .ipython/ directory to sys.path. This way users can keep
5064 * Added .ipython/ directory to sys.path. This way users can keep
5056 customizations there and access them via import.
5065 customizations there and access them via import.
5057
5066
5058 2001-11-03 Fernando Perez <fperez@colorado.edu>
5067 2001-11-03 Fernando Perez <fperez@colorado.edu>
5059
5068
5060 * Opened version 0.1.1 for new changes.
5069 * Opened version 0.1.1 for new changes.
5061
5070
5062 * Changed version number to 0.1.0: first 'public' release, sent to
5071 * Changed version number to 0.1.0: first 'public' release, sent to
5063 Nathan and Janko.
5072 Nathan and Janko.
5064
5073
5065 * Lots of small fixes and tweaks.
5074 * Lots of small fixes and tweaks.
5066
5075
5067 * Minor changes to whos format. Now strings are shown, snipped if
5076 * Minor changes to whos format. Now strings are shown, snipped if
5068 too long.
5077 too long.
5069
5078
5070 * Changed ShellServices to work on __main__ so they show up in @who
5079 * Changed ShellServices to work on __main__ so they show up in @who
5071
5080
5072 * Help also works with ? at the end of a line:
5081 * Help also works with ? at the end of a line:
5073 ?sin and sin?
5082 ?sin and sin?
5074 both produce the same effect. This is nice, as often I use the
5083 both produce the same effect. This is nice, as often I use the
5075 tab-complete to find the name of a method, but I used to then have
5084 tab-complete to find the name of a method, but I used to then have
5076 to go to the beginning of the line to put a ? if I wanted more
5085 to go to the beginning of the line to put a ? if I wanted more
5077 info. Now I can just add the ? and hit return. Convenient.
5086 info. Now I can just add the ? and hit return. Convenient.
5078
5087
5079 2001-11-02 Fernando Perez <fperez@colorado.edu>
5088 2001-11-02 Fernando Perez <fperez@colorado.edu>
5080
5089
5081 * Python version check (>=2.1) added.
5090 * Python version check (>=2.1) added.
5082
5091
5083 * Added LazyPython documentation. At this point the docs are quite
5092 * Added LazyPython documentation. At this point the docs are quite
5084 a mess. A cleanup is in order.
5093 a mess. A cleanup is in order.
5085
5094
5086 * Auto-installer created. For some bizarre reason, the zipfiles
5095 * Auto-installer created. For some bizarre reason, the zipfiles
5087 module isn't working on my system. So I made a tar version
5096 module isn't working on my system. So I made a tar version
5088 (hopefully the command line options in various systems won't kill
5097 (hopefully the command line options in various systems won't kill
5089 me).
5098 me).
5090
5099
5091 * Fixes to Struct in genutils. Now all dictionary-like methods are
5100 * Fixes to Struct in genutils. Now all dictionary-like methods are
5092 protected (reasonably).
5101 protected (reasonably).
5093
5102
5094 * Added pager function to genutils and changed ? to print usage
5103 * Added pager function to genutils and changed ? to print usage
5095 note through it (it was too long).
5104 note through it (it was too long).
5096
5105
5097 * Added the LazyPython functionality. Works great! I changed the
5106 * Added the LazyPython functionality. Works great! I changed the
5098 auto-quote escape to ';', it's on home row and next to '. But
5107 auto-quote escape to ';', it's on home row and next to '. But
5099 both auto-quote and auto-paren (still /) escapes are command-line
5108 both auto-quote and auto-paren (still /) escapes are command-line
5100 parameters.
5109 parameters.
5101
5110
5102
5111
5103 2001-11-01 Fernando Perez <fperez@colorado.edu>
5112 2001-11-01 Fernando Perez <fperez@colorado.edu>
5104
5113
5105 * Version changed to 0.0.7. Fairly large change: configuration now
5114 * Version changed to 0.0.7. Fairly large change: configuration now
5106 is all stored in a directory, by default .ipython. There, all
5115 is all stored in a directory, by default .ipython. There, all
5107 config files have normal looking names (not .names)
5116 config files have normal looking names (not .names)
5108
5117
5109 * Version 0.0.6 Released first to Lucas and Archie as a test
5118 * Version 0.0.6 Released first to Lucas and Archie as a test
5110 run. Since it's the first 'semi-public' release, change version to
5119 run. Since it's the first 'semi-public' release, change version to
5111 > 0.0.6 for any changes now.
5120 > 0.0.6 for any changes now.
5112
5121
5113 * Stuff I had put in the ipplib.py changelog:
5122 * Stuff I had put in the ipplib.py changelog:
5114
5123
5115 Changes to InteractiveShell:
5124 Changes to InteractiveShell:
5116
5125
5117 - Made the usage message a parameter.
5126 - Made the usage message a parameter.
5118
5127
5119 - Require the name of the shell variable to be given. It's a bit
5128 - Require the name of the shell variable to be given. It's a bit
5120 of a hack, but allows the name 'shell' not to be hardwire in the
5129 of a hack, but allows the name 'shell' not to be hardwire in the
5121 magic (@) handler, which is problematic b/c it requires
5130 magic (@) handler, which is problematic b/c it requires
5122 polluting the global namespace with 'shell'. This in turn is
5131 polluting the global namespace with 'shell'. This in turn is
5123 fragile: if a user redefines a variable called shell, things
5132 fragile: if a user redefines a variable called shell, things
5124 break.
5133 break.
5125
5134
5126 - magic @: all functions available through @ need to be defined
5135 - magic @: all functions available through @ need to be defined
5127 as magic_<name>, even though they can be called simply as
5136 as magic_<name>, even though they can be called simply as
5128 @<name>. This allows the special command @magic to gather
5137 @<name>. This allows the special command @magic to gather
5129 information automatically about all existing magic functions,
5138 information automatically about all existing magic functions,
5130 even if they are run-time user extensions, by parsing the shell
5139 even if they are run-time user extensions, by parsing the shell
5131 instance __dict__ looking for special magic_ names.
5140 instance __dict__ looking for special magic_ names.
5132
5141
5133 - mainloop: added *two* local namespace parameters. This allows
5142 - mainloop: added *two* local namespace parameters. This allows
5134 the class to differentiate between parameters which were there
5143 the class to differentiate between parameters which were there
5135 before and after command line initialization was processed. This
5144 before and after command line initialization was processed. This
5136 way, later @who can show things loaded at startup by the
5145 way, later @who can show things loaded at startup by the
5137 user. This trick was necessary to make session saving/reloading
5146 user. This trick was necessary to make session saving/reloading
5138 really work: ideally after saving/exiting/reloading a session,
5147 really work: ideally after saving/exiting/reloading a session,
5139 *everythin* should look the same, including the output of @who. I
5148 *everythin* should look the same, including the output of @who. I
5140 was only able to make this work with this double namespace
5149 was only able to make this work with this double namespace
5141 trick.
5150 trick.
5142
5151
5143 - added a header to the logfile which allows (almost) full
5152 - added a header to the logfile which allows (almost) full
5144 session restoring.
5153 session restoring.
5145
5154
5146 - prepend lines beginning with @ or !, with a and log
5155 - prepend lines beginning with @ or !, with a and log
5147 them. Why? !lines: may be useful to know what you did @lines:
5156 them. Why? !lines: may be useful to know what you did @lines:
5148 they may affect session state. So when restoring a session, at
5157 they may affect session state. So when restoring a session, at
5149 least inform the user of their presence. I couldn't quite get
5158 least inform the user of their presence. I couldn't quite get
5150 them to properly re-execute, but at least the user is warned.
5159 them to properly re-execute, but at least the user is warned.
5151
5160
5152 * Started ChangeLog.
5161 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now