##// END OF EJS Templates
Fix GTK timer/idle problems, finally.
fperez -
Show More
@@ -1,76 +1,76 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Release data for the IPython project.
2 """Release data for the IPython project.
3
3
4 $Id: Release.py 1000 2006-01-10 08:06:04Z fperez $"""
4 $Id: Release.py 1002 2006-01-11 22:18:29Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 #
8 #
9 # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray
9 # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray
10 # <n8gray@caltech.edu>
10 # <n8gray@caltech.edu>
11 #
11 #
12 # Distributed under the terms of the BSD License. The full license is in
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
13 # the file COPYING, distributed as part of this software.
14 #*****************************************************************************
14 #*****************************************************************************
15
15
16 # Name of the package for release purposes. This is the name which labels
16 # Name of the package for release purposes. This is the name which labels
17 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
17 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
18 name = 'ipython'
18 name = 'ipython'
19
19
20 # For versions with substrings (like 0.6.16.svn), use an extra . to separate
20 # For versions with substrings (like 0.6.16.svn), use an extra . to separate
21 # the new substring. We have to avoid using either dashes or underscores,
21 # the new substring. We have to avoid using either dashes or underscores,
22 # because bdist_rpm does not accept dashes (an RPM) convention, and
22 # because bdist_rpm does not accept dashes (an RPM) convention, and
23 # bdist_deb does not accept underscores (a Debian convention).
23 # bdist_deb does not accept underscores (a Debian convention).
24
24
25 version = '0.7.0'
25 version = '0.7.1.svn'
26
26
27 revision = '$Revision: 1000 $'
27 revision = '$Revision: 1002 $'
28
28
29 description = "An enhanced interactive Python shell."
29 description = "An enhanced interactive Python shell."
30
30
31 long_description = \
31 long_description = \
32 """
32 """
33 IPython provides a replacement for the interactive Python interpreter with
33 IPython provides a replacement for the interactive Python interpreter with
34 extra functionality.
34 extra functionality.
35
35
36 Main features:
36 Main features:
37
37
38 * Comprehensive object introspection.
38 * Comprehensive object introspection.
39
39
40 * Input history, persistent across sessions.
40 * Input history, persistent across sessions.
41
41
42 * Caching of output results during a session with automatically generated
42 * Caching of output results during a session with automatically generated
43 references.
43 references.
44
44
45 * Readline based name completion.
45 * Readline based name completion.
46
46
47 * Extensible system of 'magic' commands for controlling the environment and
47 * Extensible system of 'magic' commands for controlling the environment and
48 performing many tasks related either to IPython or the operating system.
48 performing many tasks related either to IPython or the operating system.
49
49
50 * Configuration system with easy switching between different setups (simpler
50 * Configuration system with easy switching between different setups (simpler
51 than changing $PYTHONSTARTUP environment variables every time).
51 than changing $PYTHONSTARTUP environment variables every time).
52
52
53 * Session logging and reloading.
53 * Session logging and reloading.
54
54
55 * Extensible syntax processing for special purpose situations.
55 * Extensible syntax processing for special purpose situations.
56
56
57 * Access to the system shell with user-extensible alias system.
57 * Access to the system shell with user-extensible alias system.
58
58
59 * Easily embeddable in other Python programs.
59 * Easily embeddable in other Python programs.
60
60
61 * Integrated access to the pdb debugger and the Python profiler. """
61 * Integrated access to the pdb debugger and the Python profiler. """
62
62
63 license = 'BSD'
63 license = 'BSD'
64
64
65 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
65 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
66 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
66 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
67 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu')
67 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu')
68 }
68 }
69
69
70 url = 'http://ipython.scipy.org'
70 url = 'http://ipython.scipy.org'
71
71
72 download_url = 'http://ipython.scipy.org/dist'
72 download_url = 'http://ipython.scipy.org/dist'
73
73
74 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
74 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
75
75
76 keywords = ['Interactive','Interpreter','Shell']
76 keywords = ['Interactive','Interpreter','Shell']
@@ -1,933 +1,939 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """IPython Shell classes.
2 """IPython Shell classes.
3
3
4 All the matplotlib support code was co-developed with John Hunter,
4 All the matplotlib support code was co-developed with John Hunter,
5 matplotlib's author.
5 matplotlib's author.
6
6
7 $Id: Shell.py 998 2006-01-09 06:57:40Z fperez $"""
7 $Id: Shell.py 1002 2006-01-11 22:18:29Z fperez $"""
8
8
9 #*****************************************************************************
9 #*****************************************************************************
10 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
10 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
11 #
11 #
12 # Distributed under the terms of the BSD License. The full license is in
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
13 # the file COPYING, distributed as part of this software.
14 #*****************************************************************************
14 #*****************************************************************************
15
15
16 from IPython import Release
16 from IPython import Release
17 __author__ = '%s <%s>' % Release.authors['Fernando']
17 __author__ = '%s <%s>' % Release.authors['Fernando']
18 __license__ = Release.license
18 __license__ = Release.license
19
19
20 # Code begins
20 # Code begins
21 import __main__
21 import __main__
22 import __builtin__
22 import __builtin__
23 import os
23 import os
24 import sys
24 import sys
25 import signal
25 import signal
26 import time
26 import threading
27 import threading
27
28
28 import IPython
29 import IPython
29 from IPython import ultraTB
30 from IPython import ultraTB
30 from IPython.genutils import Term,warn,error,flag_calls
31 from IPython.genutils import Term,warn,error,flag_calls
31 from IPython.iplib import InteractiveShell
32 from IPython.iplib import InteractiveShell
32 from IPython.ipmaker import make_IPython
33 from IPython.ipmaker import make_IPython
33 from IPython.Magic import Magic
34 from IPython.Magic import Magic
34 from IPython.Struct import Struct
35 from IPython.Struct import Struct
35
36
36 # global flag to pass around information about Ctrl-C without exceptions
37 # global flag to pass around information about Ctrl-C without exceptions
37 KBINT = False
38 KBINT = False
38
39
39 # global flag to turn on/off Tk support.
40 # global flag to turn on/off Tk support.
40 USE_TK = False
41 USE_TK = False
41
42
42 #-----------------------------------------------------------------------------
43 #-----------------------------------------------------------------------------
43 # This class is trivial now, but I want to have it in to publish a clean
44 # This class is trivial now, but I want to have it in to publish a clean
44 # interface. Later when the internals are reorganized, code that uses this
45 # interface. Later when the internals are reorganized, code that uses this
45 # shouldn't have to change.
46 # shouldn't have to change.
46
47
47 class IPShell:
48 class IPShell:
48 """Create an IPython instance."""
49 """Create an IPython instance."""
49
50
50 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
51 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
51 debug=1,shell_class=InteractiveShell):
52 debug=1,shell_class=InteractiveShell):
52 self.IP = make_IPython(argv,user_ns=user_ns,user_global_ns=user_global_ns,
53 self.IP = make_IPython(argv,user_ns=user_ns,user_global_ns=user_global_ns,
53 debug=debug,shell_class=shell_class)
54 debug=debug,shell_class=shell_class)
54
55
55 def mainloop(self,sys_exit=0,banner=None):
56 def mainloop(self,sys_exit=0,banner=None):
56 self.IP.mainloop(banner)
57 self.IP.mainloop(banner)
57 if sys_exit:
58 if sys_exit:
58 sys.exit()
59 sys.exit()
59
60
60 #-----------------------------------------------------------------------------
61 #-----------------------------------------------------------------------------
61 class IPShellEmbed:
62 class IPShellEmbed:
62 """Allow embedding an IPython shell into a running program.
63 """Allow embedding an IPython shell into a running program.
63
64
64 Instances of this class are callable, with the __call__ method being an
65 Instances of this class are callable, with the __call__ method being an
65 alias to the embed() method of an InteractiveShell instance.
66 alias to the embed() method of an InteractiveShell instance.
66
67
67 Usage (see also the example-embed.py file for a running example):
68 Usage (see also the example-embed.py file for a running example):
68
69
69 ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override])
70 ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override])
70
71
71 - argv: list containing valid command-line options for IPython, as they
72 - argv: list containing valid command-line options for IPython, as they
72 would appear in sys.argv[1:].
73 would appear in sys.argv[1:].
73
74
74 For example, the following command-line options:
75 For example, the following command-line options:
75
76
76 $ ipython -prompt_in1 'Input <\\#>' -colors LightBG
77 $ ipython -prompt_in1 'Input <\\#>' -colors LightBG
77
78
78 would be passed in the argv list as:
79 would be passed in the argv list as:
79
80
80 ['-prompt_in1','Input <\\#>','-colors','LightBG']
81 ['-prompt_in1','Input <\\#>','-colors','LightBG']
81
82
82 - banner: string which gets printed every time the interpreter starts.
83 - banner: string which gets printed every time the interpreter starts.
83
84
84 - exit_msg: string which gets printed every time the interpreter exits.
85 - exit_msg: string which gets printed every time the interpreter exits.
85
86
86 - rc_override: a dict or Struct of configuration options such as those
87 - rc_override: a dict or Struct of configuration options such as those
87 used by IPython. These options are read from your ~/.ipython/ipythonrc
88 used by IPython. These options are read from your ~/.ipython/ipythonrc
88 file when the Shell object is created. Passing an explicit rc_override
89 file when the Shell object is created. Passing an explicit rc_override
89 dict with any options you want allows you to override those values at
90 dict with any options you want allows you to override those values at
90 creation time without having to modify the file. This way you can create
91 creation time without having to modify the file. This way you can create
91 embeddable instances configured in any way you want without editing any
92 embeddable instances configured in any way you want without editing any
92 global files (thus keeping your interactive IPython configuration
93 global files (thus keeping your interactive IPython configuration
93 unchanged).
94 unchanged).
94
95
95 Then the ipshell instance can be called anywhere inside your code:
96 Then the ipshell instance can be called anywhere inside your code:
96
97
97 ipshell(header='') -> Opens up an IPython shell.
98 ipshell(header='') -> Opens up an IPython shell.
98
99
99 - header: string printed by the IPython shell upon startup. This can let
100 - header: string printed by the IPython shell upon startup. This can let
100 you know where in your code you are when dropping into the shell. Note
101 you know where in your code you are when dropping into the shell. Note
101 that 'banner' gets prepended to all calls, so header is used for
102 that 'banner' gets prepended to all calls, so header is used for
102 location-specific information.
103 location-specific information.
103
104
104 For more details, see the __call__ method below.
105 For more details, see the __call__ method below.
105
106
106 When the IPython shell is exited with Ctrl-D, normal program execution
107 When the IPython shell is exited with Ctrl-D, normal program execution
107 resumes.
108 resumes.
108
109
109 This functionality was inspired by a posting on comp.lang.python by cmkl
110 This functionality was inspired by a posting on comp.lang.python by cmkl
110 <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and
111 <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and
111 by the IDL stop/continue commands."""
112 by the IDL stop/continue commands."""
112
113
113 def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None):
114 def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None):
114 """Note that argv here is a string, NOT a list."""
115 """Note that argv here is a string, NOT a list."""
115 self.set_banner(banner)
116 self.set_banner(banner)
116 self.set_exit_msg(exit_msg)
117 self.set_exit_msg(exit_msg)
117 self.set_dummy_mode(0)
118 self.set_dummy_mode(0)
118
119
119 # sys.displayhook is a global, we need to save the user's original
120 # sys.displayhook is a global, we need to save the user's original
120 # Don't rely on __displayhook__, as the user may have changed that.
121 # Don't rely on __displayhook__, as the user may have changed that.
121 self.sys_displayhook_ori = sys.displayhook
122 self.sys_displayhook_ori = sys.displayhook
122
123
123 # save readline completer status
124 # save readline completer status
124 try:
125 try:
125 #print 'Save completer',sys.ipcompleter # dbg
126 #print 'Save completer',sys.ipcompleter # dbg
126 self.sys_ipcompleter_ori = sys.ipcompleter
127 self.sys_ipcompleter_ori = sys.ipcompleter
127 except:
128 except:
128 pass # not nested with IPython
129 pass # not nested with IPython
129
130
130 # FIXME. Passing user_ns breaks namespace handling.
131 # FIXME. Passing user_ns breaks namespace handling.
131 #self.IP = make_IPython(argv,user_ns=__main__.__dict__)
132 #self.IP = make_IPython(argv,user_ns=__main__.__dict__)
132 self.IP = make_IPython(argv,rc_override=rc_override,embedded=True)
133 self.IP = make_IPython(argv,rc_override=rc_override,embedded=True)
133
134
134 # copy our own displayhook also
135 # copy our own displayhook also
135 self.sys_displayhook_embed = sys.displayhook
136 self.sys_displayhook_embed = sys.displayhook
136 # and leave the system's display hook clean
137 # and leave the system's display hook clean
137 sys.displayhook = self.sys_displayhook_ori
138 sys.displayhook = self.sys_displayhook_ori
138 # don't use the ipython crash handler so that user exceptions aren't
139 # don't use the ipython crash handler so that user exceptions aren't
139 # trapped
140 # trapped
140 sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors,
141 sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors,
141 mode = self.IP.rc.xmode,
142 mode = self.IP.rc.xmode,
142 call_pdb = self.IP.rc.pdb)
143 call_pdb = self.IP.rc.pdb)
143 self.restore_system_completer()
144 self.restore_system_completer()
144
145
145 def restore_system_completer(self):
146 def restore_system_completer(self):
146 """Restores the readline completer which was in place.
147 """Restores the readline completer which was in place.
147
148
148 This allows embedded IPython within IPython not to disrupt the
149 This allows embedded IPython within IPython not to disrupt the
149 parent's completion.
150 parent's completion.
150 """
151 """
151
152
152 try:
153 try:
153 self.IP.readline.set_completer(self.sys_ipcompleter_ori)
154 self.IP.readline.set_completer(self.sys_ipcompleter_ori)
154 sys.ipcompleter = self.sys_ipcompleter_ori
155 sys.ipcompleter = self.sys_ipcompleter_ori
155 except:
156 except:
156 pass
157 pass
157
158
158 def __call__(self,header='',local_ns=None,global_ns=None,dummy=None):
159 def __call__(self,header='',local_ns=None,global_ns=None,dummy=None):
159 """Activate the interactive interpreter.
160 """Activate the interactive interpreter.
160
161
161 __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start
162 __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start
162 the interpreter shell with the given local and global namespaces, and
163 the interpreter shell with the given local and global namespaces, and
163 optionally print a header string at startup.
164 optionally print a header string at startup.
164
165
165 The shell can be globally activated/deactivated using the
166 The shell can be globally activated/deactivated using the
166 set/get_dummy_mode methods. This allows you to turn off a shell used
167 set/get_dummy_mode methods. This allows you to turn off a shell used
167 for debugging globally.
168 for debugging globally.
168
169
169 However, *each* time you call the shell you can override the current
170 However, *each* time you call the shell you can override the current
170 state of dummy_mode with the optional keyword parameter 'dummy'. For
171 state of dummy_mode with the optional keyword parameter 'dummy'. For
171 example, if you set dummy mode on with IPShell.set_dummy_mode(1), you
172 example, if you set dummy mode on with IPShell.set_dummy_mode(1), you
172 can still have a specific call work by making it as IPShell(dummy=0).
173 can still have a specific call work by making it as IPShell(dummy=0).
173
174
174 The optional keyword parameter dummy controls whether the call
175 The optional keyword parameter dummy controls whether the call
175 actually does anything. """
176 actually does anything. """
176
177
177 # Allow the dummy parameter to override the global __dummy_mode
178 # Allow the dummy parameter to override the global __dummy_mode
178 if dummy or (dummy != 0 and self.__dummy_mode):
179 if dummy or (dummy != 0 and self.__dummy_mode):
179 return
180 return
180
181
181 # Set global subsystems (display,completions) to our values
182 # Set global subsystems (display,completions) to our values
182 sys.displayhook = self.sys_displayhook_embed
183 sys.displayhook = self.sys_displayhook_embed
183 if self.IP.has_readline:
184 if self.IP.has_readline:
184 self.IP.readline.set_completer(self.IP.Completer.complete)
185 self.IP.readline.set_completer(self.IP.Completer.complete)
185
186
186 if self.banner and header:
187 if self.banner and header:
187 format = '%s\n%s\n'
188 format = '%s\n%s\n'
188 else:
189 else:
189 format = '%s%s\n'
190 format = '%s%s\n'
190 banner = format % (self.banner,header)
191 banner = format % (self.banner,header)
191
192
192 # Call the embedding code with a stack depth of 1 so it can skip over
193 # Call the embedding code with a stack depth of 1 so it can skip over
193 # our call and get the original caller's namespaces.
194 # our call and get the original caller's namespaces.
194 self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1)
195 self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1)
195
196
196 if self.exit_msg:
197 if self.exit_msg:
197 print self.exit_msg
198 print self.exit_msg
198
199
199 # Restore global systems (display, completion)
200 # Restore global systems (display, completion)
200 sys.displayhook = self.sys_displayhook_ori
201 sys.displayhook = self.sys_displayhook_ori
201 self.restore_system_completer()
202 self.restore_system_completer()
202
203
203 def set_dummy_mode(self,dummy):
204 def set_dummy_mode(self,dummy):
204 """Sets the embeddable shell's dummy mode parameter.
205 """Sets the embeddable shell's dummy mode parameter.
205
206
206 set_dummy_mode(dummy): dummy = 0 or 1.
207 set_dummy_mode(dummy): dummy = 0 or 1.
207
208
208 This parameter is persistent and makes calls to the embeddable shell
209 This parameter is persistent and makes calls to the embeddable shell
209 silently return without performing any action. This allows you to
210 silently return without performing any action. This allows you to
210 globally activate or deactivate a shell you're using with a single call.
211 globally activate or deactivate a shell you're using with a single call.
211
212
212 If you need to manually"""
213 If you need to manually"""
213
214
214 if dummy not in [0,1,False,True]:
215 if dummy not in [0,1,False,True]:
215 raise ValueError,'dummy parameter must be boolean'
216 raise ValueError,'dummy parameter must be boolean'
216 self.__dummy_mode = dummy
217 self.__dummy_mode = dummy
217
218
218 def get_dummy_mode(self):
219 def get_dummy_mode(self):
219 """Return the current value of the dummy mode parameter.
220 """Return the current value of the dummy mode parameter.
220 """
221 """
221 return self.__dummy_mode
222 return self.__dummy_mode
222
223
223 def set_banner(self,banner):
224 def set_banner(self,banner):
224 """Sets the global banner.
225 """Sets the global banner.
225
226
226 This banner gets prepended to every header printed when the shell
227 This banner gets prepended to every header printed when the shell
227 instance is called."""
228 instance is called."""
228
229
229 self.banner = banner
230 self.banner = banner
230
231
231 def set_exit_msg(self,exit_msg):
232 def set_exit_msg(self,exit_msg):
232 """Sets the global exit_msg.
233 """Sets the global exit_msg.
233
234
234 This exit message gets printed upon exiting every time the embedded
235 This exit message gets printed upon exiting every time the embedded
235 shell is called. It is None by default. """
236 shell is called. It is None by default. """
236
237
237 self.exit_msg = exit_msg
238 self.exit_msg = exit_msg
238
239
239 #-----------------------------------------------------------------------------
240 #-----------------------------------------------------------------------------
240 def sigint_handler (signum,stack_frame):
241 def sigint_handler (signum,stack_frame):
241 """Sigint handler for threaded apps.
242 """Sigint handler for threaded apps.
242
243
243 This is a horrible hack to pass information about SIGINT _without_ using
244 This is a horrible hack to pass information about SIGINT _without_ using
244 exceptions, since I haven't been able to properly manage cross-thread
245 exceptions, since I haven't been able to properly manage cross-thread
245 exceptions in GTK/WX. In fact, I don't think it can be done (or at least
246 exceptions in GTK/WX. In fact, I don't think it can be done (or at least
246 that's my understanding from a c.l.py thread where this was discussed)."""
247 that's my understanding from a c.l.py thread where this was discussed)."""
247
248
248 global KBINT
249 global KBINT
249
250
250 print '\nKeyboardInterrupt - Press <Enter> to continue.',
251 print '\nKeyboardInterrupt - Press <Enter> to continue.',
251 Term.cout.flush()
252 Term.cout.flush()
252 # Set global flag so that runsource can know that Ctrl-C was hit
253 # Set global flag so that runsource can know that Ctrl-C was hit
253 KBINT = True
254 KBINT = True
254
255
255 class MTInteractiveShell(InteractiveShell):
256 class MTInteractiveShell(InteractiveShell):
256 """Simple multi-threaded shell."""
257 """Simple multi-threaded shell."""
257
258
258 # Threading strategy taken from:
259 # Threading strategy taken from:
259 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
260 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
260 # McErlean and John Finlay. Modified with corrections by Antoon Pardon,
261 # McErlean and John Finlay. Modified with corrections by Antoon Pardon,
261 # from the pygtk mailing list, to avoid lockups with system calls.
262 # from the pygtk mailing list, to avoid lockups with system calls.
262
263
263 # class attribute to indicate whether the class supports threads or not.
264 # class attribute to indicate whether the class supports threads or not.
264 # Subclasses with thread support should override this as needed.
265 # Subclasses with thread support should override this as needed.
265 isthreaded = True
266 isthreaded = True
266
267
267 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
268 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
268 user_ns=None,user_global_ns=None,banner2='',**kw):
269 user_ns=None,user_global_ns=None,banner2='',**kw):
269 """Similar to the normal InteractiveShell, but with threading control"""
270 """Similar to the normal InteractiveShell, but with threading control"""
270
271
271 InteractiveShell.__init__(self,name,usage,rc,user_ns,
272 InteractiveShell.__init__(self,name,usage,rc,user_ns,
272 user_global_ns,banner2)
273 user_global_ns,banner2)
273
274
274 # Locking control variable
275 # Locking control variable
275 self.thread_ready = threading.Condition()
276 self.thread_ready = threading.Condition()
276
277
277 # Stuff to do at closing time
278 # Stuff to do at closing time
278 self._kill = False
279 self._kill = False
279 on_kill = kw.get('on_kill')
280 on_kill = kw.get('on_kill')
280 if on_kill is None:
281 if on_kill is None:
281 on_kill = []
282 on_kill = []
282 # Check that all things to kill are callable:
283 # Check that all things to kill are callable:
283 for t in on_kill:
284 for t in on_kill:
284 if not callable(t):
285 if not callable(t):
285 raise TypeError,'on_kill must be a list of callables'
286 raise TypeError,'on_kill must be a list of callables'
286 self.on_kill = on_kill
287 self.on_kill = on_kill
287
288
288 def runsource(self, source, filename="<input>", symbol="single"):
289 def runsource(self, source, filename="<input>", symbol="single"):
289 """Compile and run some source in the interpreter.
290 """Compile and run some source in the interpreter.
290
291
291 Modified version of code.py's runsource(), to handle threading issues.
292 Modified version of code.py's runsource(), to handle threading issues.
292 See the original for full docstring details."""
293 See the original for full docstring details."""
293
294
294 global KBINT
295 global KBINT
295
296
296 # If Ctrl-C was typed, we reset the flag and return right away
297 # If Ctrl-C was typed, we reset the flag and return right away
297 if KBINT:
298 if KBINT:
298 KBINT = False
299 KBINT = False
299 return False
300 return False
300
301
301 try:
302 try:
302 code = self.compile(source, filename, symbol)
303 code = self.compile(source, filename, symbol)
303 except (OverflowError, SyntaxError, ValueError):
304 except (OverflowError, SyntaxError, ValueError):
304 # Case 1
305 # Case 1
305 self.showsyntaxerror(filename)
306 self.showsyntaxerror(filename)
306 return False
307 return False
307
308
308 if code is None:
309 if code is None:
309 # Case 2
310 # Case 2
310 return True
311 return True
311
312
312 # Case 3
313 # Case 3
313 # Store code in self, so the execution thread can handle it
314 # Store code in self, so the execution thread can handle it
314 self.thread_ready.acquire()
315 self.thread_ready.acquire()
315 self.code_to_run = code
316 self.code_to_run = code
316 self.thread_ready.wait() # Wait until processed in timeout interval
317 self.thread_ready.wait() # Wait until processed in timeout interval
317 self.thread_ready.release()
318 self.thread_ready.release()
318
319
319 return False
320 return False
320
321
321 def runcode(self):
322 def runcode(self):
322 """Execute a code object.
323 """Execute a code object.
323
324
324 Multithreaded wrapper around IPython's runcode()."""
325 Multithreaded wrapper around IPython's runcode()."""
325
326
326 # lock thread-protected stuff
327 # lock thread-protected stuff
327 self.thread_ready.acquire()
328 self.thread_ready.acquire()
328
329
329 # Install sigint handler
330 # Install sigint handler
330 try:
331 try:
331 signal.signal(signal.SIGINT, sigint_handler)
332 signal.signal(signal.SIGINT, sigint_handler)
332 except SystemError:
333 except SystemError:
333 # This happens under Windows, which seems to have all sorts
334 # This happens under Windows, which seems to have all sorts
334 # of problems with signal handling. Oh well...
335 # of problems with signal handling. Oh well...
335 pass
336 pass
336
337
337 if self._kill:
338 if self._kill:
338 print >>Term.cout, 'Closing threads...',
339 print >>Term.cout, 'Closing threads...',
339 Term.cout.flush()
340 Term.cout.flush()
340 for tokill in self.on_kill:
341 for tokill in self.on_kill:
341 tokill()
342 tokill()
342 print >>Term.cout, 'Done.'
343 print >>Term.cout, 'Done.'
343
344
344 # Run pending code by calling parent class
345 # Run pending code by calling parent class
345 if self.code_to_run is not None:
346 if self.code_to_run is not None:
346 self.thread_ready.notify()
347 self.thread_ready.notify()
347 InteractiveShell.runcode(self,self.code_to_run)
348 InteractiveShell.runcode(self,self.code_to_run)
348
349
349 # We're done with thread-protected variables
350 # We're done with thread-protected variables
350 self.thread_ready.release()
351 self.thread_ready.release()
351 # This MUST return true for gtk threading to work
352 # This MUST return true for gtk threading to work
352 return True
353 return True
353
354
354 def kill (self):
355 def kill (self):
355 """Kill the thread, returning when it has been shut down."""
356 """Kill the thread, returning when it has been shut down."""
356 self.thread_ready.acquire()
357 self.thread_ready.acquire()
357 self._kill = True
358 self._kill = True
358 self.thread_ready.release()
359 self.thread_ready.release()
359
360
360 class MatplotlibShellBase:
361 class MatplotlibShellBase:
361 """Mixin class to provide the necessary modifications to regular IPython
362 """Mixin class to provide the necessary modifications to regular IPython
362 shell classes for matplotlib support.
363 shell classes for matplotlib support.
363
364
364 Given Python's MRO, this should be used as the FIRST class in the
365 Given Python's MRO, this should be used as the FIRST class in the
365 inheritance hierarchy, so that it overrides the relevant methods."""
366 inheritance hierarchy, so that it overrides the relevant methods."""
366
367
367 def _matplotlib_config(self,name):
368 def _matplotlib_config(self,name):
368 """Return various items needed to setup the user's shell with matplotlib"""
369 """Return various items needed to setup the user's shell with matplotlib"""
369
370
370 # Initialize matplotlib to interactive mode always
371 # Initialize matplotlib to interactive mode always
371 import matplotlib
372 import matplotlib
372 from matplotlib import backends
373 from matplotlib import backends
373 matplotlib.interactive(True)
374 matplotlib.interactive(True)
374
375
375 def use(arg):
376 def use(arg):
376 """IPython wrapper for matplotlib's backend switcher.
377 """IPython wrapper for matplotlib's backend switcher.
377
378
378 In interactive use, we can not allow switching to a different
379 In interactive use, we can not allow switching to a different
379 interactive backend, since thread conflicts will most likely crash
380 interactive backend, since thread conflicts will most likely crash
380 the python interpreter. This routine does a safety check first,
381 the python interpreter. This routine does a safety check first,
381 and refuses to perform a dangerous switch. It still allows
382 and refuses to perform a dangerous switch. It still allows
382 switching to non-interactive backends."""
383 switching to non-interactive backends."""
383
384
384 if arg in backends.interactive_bk and arg != self.mpl_backend:
385 if arg in backends.interactive_bk and arg != self.mpl_backend:
385 m=('invalid matplotlib backend switch.\n'
386 m=('invalid matplotlib backend switch.\n'
386 'This script attempted to switch to the interactive '
387 'This script attempted to switch to the interactive '
387 'backend: `%s`\n'
388 'backend: `%s`\n'
388 'Your current choice of interactive backend is: `%s`\n\n'
389 'Your current choice of interactive backend is: `%s`\n\n'
389 'Switching interactive matplotlib backends at runtime\n'
390 'Switching interactive matplotlib backends at runtime\n'
390 'would crash the python interpreter, '
391 'would crash the python interpreter, '
391 'and IPython has blocked it.\n\n'
392 'and IPython has blocked it.\n\n'
392 'You need to either change your choice of matplotlib backend\n'
393 'You need to either change your choice of matplotlib backend\n'
393 'by editing your .matplotlibrc file, or run this script as a \n'
394 'by editing your .matplotlibrc file, or run this script as a \n'
394 'standalone file from the command line, not using IPython.\n' %
395 'standalone file from the command line, not using IPython.\n' %
395 (arg,self.mpl_backend) )
396 (arg,self.mpl_backend) )
396 raise RuntimeError, m
397 raise RuntimeError, m
397 else:
398 else:
398 self.mpl_use(arg)
399 self.mpl_use(arg)
399 self.mpl_use._called = True
400 self.mpl_use._called = True
400
401
401 self.matplotlib = matplotlib
402 self.matplotlib = matplotlib
402 self.mpl_backend = matplotlib.rcParams['backend']
403 self.mpl_backend = matplotlib.rcParams['backend']
403
404
404 # we also need to block switching of interactive backends by use()
405 # we also need to block switching of interactive backends by use()
405 self.mpl_use = matplotlib.use
406 self.mpl_use = matplotlib.use
406 self.mpl_use._called = False
407 self.mpl_use._called = False
407 # overwrite the original matplotlib.use with our wrapper
408 # overwrite the original matplotlib.use with our wrapper
408 matplotlib.use = use
409 matplotlib.use = use
409
410
410
411
411 # This must be imported last in the matplotlib series, after
412 # This must be imported last in the matplotlib series, after
412 # backend/interactivity choices have been made
413 # backend/interactivity choices have been made
413 try:
414 try:
414 import matplotlib.pylab as pylab
415 import matplotlib.pylab as pylab
415 self.pylab = pylab
416 self.pylab = pylab
416 self.pylab_name = 'pylab'
417 self.pylab_name = 'pylab'
417 except ImportError:
418 except ImportError:
418 import matplotlib.matlab as matlab
419 import matplotlib.matlab as matlab
419 self.pylab = matlab
420 self.pylab = matlab
420 self.pylab_name = 'matlab'
421 self.pylab_name = 'matlab'
421
422
422 self.pylab.show._needmain = False
423 self.pylab.show._needmain = False
423 # We need to detect at runtime whether show() is called by the user.
424 # We need to detect at runtime whether show() is called by the user.
424 # For this, we wrap it into a decorator which adds a 'called' flag.
425 # For this, we wrap it into a decorator which adds a 'called' flag.
425 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
426 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
426
427
427 # Build a user namespace initialized with matplotlib/matlab features.
428 # Build a user namespace initialized with matplotlib/matlab features.
428 user_ns = {'__name__':'__main__',
429 user_ns = {'__name__':'__main__',
429 '__builtins__' : __builtin__ }
430 '__builtins__' : __builtin__ }
430
431
431 # Be careful not to remove the final \n in the code string below, or
432 # Be careful not to remove the final \n in the code string below, or
432 # things will break badly with py22 (I think it's a python bug, 2.3 is
433 # things will break badly with py22 (I think it's a python bug, 2.3 is
433 # OK).
434 # OK).
434 pname = self.pylab_name # Python can't interpolate dotted var names
435 pname = self.pylab_name # Python can't interpolate dotted var names
435 exec ("import matplotlib\n"
436 exec ("import matplotlib\n"
436 "import matplotlib.%(pname)s as %(pname)s\n"
437 "import matplotlib.%(pname)s as %(pname)s\n"
437 "from matplotlib.%(pname)s import *\n" % locals()) in user_ns
438 "from matplotlib.%(pname)s import *\n" % locals()) in user_ns
438
439
439 # Build matplotlib info banner
440 # Build matplotlib info banner
440 b="""
441 b="""
441 Welcome to pylab, a matplotlib-based Python environment.
442 Welcome to pylab, a matplotlib-based Python environment.
442 For more information, type 'help(pylab)'.
443 For more information, type 'help(pylab)'.
443 """
444 """
444 return user_ns,b
445 return user_ns,b
445
446
446 def mplot_exec(self,fname,*where,**kw):
447 def mplot_exec(self,fname,*where,**kw):
447 """Execute a matplotlib script.
448 """Execute a matplotlib script.
448
449
449 This is a call to execfile(), but wrapped in safeties to properly
450 This is a call to execfile(), but wrapped in safeties to properly
450 handle interactive rendering and backend switching."""
451 handle interactive rendering and backend switching."""
451
452
452 #print '*** Matplotlib runner ***' # dbg
453 #print '*** Matplotlib runner ***' # dbg
453 # turn off rendering until end of script
454 # turn off rendering until end of script
454 isInteractive = self.matplotlib.rcParams['interactive']
455 isInteractive = self.matplotlib.rcParams['interactive']
455 self.matplotlib.interactive(False)
456 self.matplotlib.interactive(False)
456 self.safe_execfile(fname,*where,**kw)
457 self.safe_execfile(fname,*where,**kw)
457 self.matplotlib.interactive(isInteractive)
458 self.matplotlib.interactive(isInteractive)
458 # make rendering call now, if the user tried to do it
459 # make rendering call now, if the user tried to do it
459 if self.pylab.draw_if_interactive.called:
460 if self.pylab.draw_if_interactive.called:
460 self.pylab.draw()
461 self.pylab.draw()
461 self.pylab.draw_if_interactive.called = False
462 self.pylab.draw_if_interactive.called = False
462
463
463 # if a backend switch was performed, reverse it now
464 # if a backend switch was performed, reverse it now
464 if self.mpl_use._called:
465 if self.mpl_use._called:
465 self.matplotlib.rcParams['backend'] = self.mpl_backend
466 self.matplotlib.rcParams['backend'] = self.mpl_backend
466
467
467 def magic_run(self,parameter_s=''):
468 def magic_run(self,parameter_s=''):
468 Magic.magic_run(self,parameter_s,runner=self.mplot_exec)
469 Magic.magic_run(self,parameter_s,runner=self.mplot_exec)
469
470
470 # Fix the docstring so users see the original as well
471 # Fix the docstring so users see the original as well
471 magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__,
472 magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__,
472 "\n *** Modified %run for Matplotlib,"
473 "\n *** Modified %run for Matplotlib,"
473 " with proper interactive handling ***")
474 " with proper interactive handling ***")
474
475
475 # Now we provide 2 versions of a matplotlib-aware IPython base shells, single
476 # Now we provide 2 versions of a matplotlib-aware IPython base shells, single
476 # and multithreaded. Note that these are meant for internal use, the IPShell*
477 # and multithreaded. Note that these are meant for internal use, the IPShell*
477 # classes below are the ones meant for public consumption.
478 # classes below are the ones meant for public consumption.
478
479
479 class MatplotlibShell(MatplotlibShellBase,InteractiveShell):
480 class MatplotlibShell(MatplotlibShellBase,InteractiveShell):
480 """Single-threaded shell with matplotlib support."""
481 """Single-threaded shell with matplotlib support."""
481
482
482 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
483 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
483 user_ns=None,user_global_ns=None,**kw):
484 user_ns=None,user_global_ns=None,**kw):
484 user_ns,b2 = self._matplotlib_config(name)
485 user_ns,b2 = self._matplotlib_config(name)
485 InteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
486 InteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
486 banner2=b2,**kw)
487 banner2=b2,**kw)
487
488
488 class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell):
489 class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell):
489 """Multi-threaded shell with matplotlib support."""
490 """Multi-threaded shell with matplotlib support."""
490
491
491 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
492 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
492 user_ns=None,user_global_ns=None, **kw):
493 user_ns=None,user_global_ns=None, **kw):
493 user_ns,b2 = self._matplotlib_config(name)
494 user_ns,b2 = self._matplotlib_config(name)
494 MTInteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
495 MTInteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
495 banner2=b2,**kw)
496 banner2=b2,**kw)
496
497
497 #-----------------------------------------------------------------------------
498 #-----------------------------------------------------------------------------
498 # Utility functions for the different GUI enabled IPShell* classes.
499 # Utility functions for the different GUI enabled IPShell* classes.
499
500
500 def get_tk():
501 def get_tk():
501 """Tries to import Tkinter and returns a withdrawn Tkinter root
502 """Tries to import Tkinter and returns a withdrawn Tkinter root
502 window. If Tkinter is already imported or not available, this
503 window. If Tkinter is already imported or not available, this
503 returns None. This function calls `hijack_tk` underneath.
504 returns None. This function calls `hijack_tk` underneath.
504 """
505 """
505 if not USE_TK or sys.modules.has_key('Tkinter'):
506 if not USE_TK or sys.modules.has_key('Tkinter'):
506 return None
507 return None
507 else:
508 else:
508 try:
509 try:
509 import Tkinter
510 import Tkinter
510 except ImportError:
511 except ImportError:
511 return None
512 return None
512 else:
513 else:
513 hijack_tk()
514 hijack_tk()
514 r = Tkinter.Tk()
515 r = Tkinter.Tk()
515 r.withdraw()
516 r.withdraw()
516 return r
517 return r
517
518
518 def hijack_tk():
519 def hijack_tk():
519 """Modifies Tkinter's mainloop with a dummy so when a module calls
520 """Modifies Tkinter's mainloop with a dummy so when a module calls
520 mainloop, it does not block.
521 mainloop, it does not block.
521
522
522 """
523 """
523 def misc_mainloop(self, n=0):
524 def misc_mainloop(self, n=0):
524 pass
525 pass
525 def tkinter_mainloop(n=0):
526 def tkinter_mainloop(n=0):
526 pass
527 pass
527
528
528 import Tkinter
529 import Tkinter
529 Tkinter.Misc.mainloop = misc_mainloop
530 Tkinter.Misc.mainloop = misc_mainloop
530 Tkinter.mainloop = tkinter_mainloop
531 Tkinter.mainloop = tkinter_mainloop
531
532
532 def update_tk(tk):
533 def update_tk(tk):
533 """Updates the Tkinter event loop. This is typically called from
534 """Updates the Tkinter event loop. This is typically called from
534 the respective WX or GTK mainloops.
535 the respective WX or GTK mainloops.
535 """
536 """
536 if tk:
537 if tk:
537 tk.update()
538 tk.update()
538
539
539 def hijack_wx():
540 def hijack_wx():
540 """Modifies wxPython's MainLoop with a dummy so user code does not
541 """Modifies wxPython's MainLoop with a dummy so user code does not
541 block IPython. The hijacked mainloop function is returned.
542 block IPython. The hijacked mainloop function is returned.
542 """
543 """
543 def dummy_mainloop(*args, **kw):
544 def dummy_mainloop(*args, **kw):
544 pass
545 pass
545 import wxPython
546 import wxPython
546 ver = wxPython.__version__
547 ver = wxPython.__version__
547 orig_mainloop = None
548 orig_mainloop = None
548 if ver[:3] >= '2.5':
549 if ver[:3] >= '2.5':
549 import wx
550 import wx
550 if hasattr(wx, '_core_'): core = getattr(wx, '_core_')
551 if hasattr(wx, '_core_'): core = getattr(wx, '_core_')
551 elif hasattr(wx, '_core'): core = getattr(wx, '_core')
552 elif hasattr(wx, '_core'): core = getattr(wx, '_core')
552 else: raise AttributeError('Could not find wx core module')
553 else: raise AttributeError('Could not find wx core module')
553 orig_mainloop = core.PyApp_MainLoop
554 orig_mainloop = core.PyApp_MainLoop
554 core.PyApp_MainLoop = dummy_mainloop
555 core.PyApp_MainLoop = dummy_mainloop
555 elif ver[:3] == '2.4':
556 elif ver[:3] == '2.4':
556 orig_mainloop = wxPython.wxc.wxPyApp_MainLoop
557 orig_mainloop = wxPython.wxc.wxPyApp_MainLoop
557 wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop
558 wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop
558 else:
559 else:
559 warn("Unable to find either wxPython version 2.4 or >= 2.5.")
560 warn("Unable to find either wxPython version 2.4 or >= 2.5.")
560 return orig_mainloop
561 return orig_mainloop
561
562
562 def hijack_gtk():
563 def hijack_gtk():
563 """Modifies pyGTK's mainloop with a dummy so user code does not
564 """Modifies pyGTK's mainloop with a dummy so user code does not
564 block IPython. This function returns the original `gtk.mainloop`
565 block IPython. This function returns the original `gtk.mainloop`
565 function that has been hijacked.
566 function that has been hijacked.
566 """
567 """
567 def dummy_mainloop(*args, **kw):
568 def dummy_mainloop(*args, **kw):
568 pass
569 pass
569 import gtk
570 import gtk
570 if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main
571 if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main
571 else: orig_mainloop = gtk.mainloop
572 else: orig_mainloop = gtk.mainloop
572 gtk.mainloop = dummy_mainloop
573 gtk.mainloop = dummy_mainloop
573 gtk.main = dummy_mainloop
574 gtk.main = dummy_mainloop
574 return orig_mainloop
575 return orig_mainloop
575
576
576 #-----------------------------------------------------------------------------
577 #-----------------------------------------------------------------------------
577 # The IPShell* classes below are the ones meant to be run by external code as
578 # The IPShell* classes below are the ones meant to be run by external code as
578 # IPython instances. Note that unless a specific threading strategy is
579 # IPython instances. Note that unless a specific threading strategy is
579 # desired, the factory function start() below should be used instead (it
580 # desired, the factory function start() below should be used instead (it
580 # selects the proper threaded class).
581 # selects the proper threaded class).
581
582
582 class IPShellGTK(threading.Thread):
583 class IPShellGTK(threading.Thread):
583 """Run a gtk mainloop() in a separate thread.
584 """Run a gtk mainloop() in a separate thread.
584
585
585 Python commands can be passed to the thread where they will be executed.
586 Python commands can be passed to the thread where they will be executed.
586 This is implemented by periodically checking for passed code using a
587 This is implemented by periodically checking for passed code using a
587 GTK timeout callback."""
588 GTK timeout callback."""
588
589
589 TIMEOUT = 100 # Millisecond interval between timeouts.
590 TIMEOUT = 100 # Millisecond interval between timeouts.
590
591
591 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
592 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
592 debug=1,shell_class=MTInteractiveShell):
593 debug=1,shell_class=MTInteractiveShell):
593
594
594 import gtk
595 import gtk
595
596
596 self.gtk = gtk
597 self.gtk = gtk
597 self.gtk_mainloop = hijack_gtk()
598 self.gtk_mainloop = hijack_gtk()
598
599
599 # Allows us to use both Tk and GTK.
600 # Allows us to use both Tk and GTK.
600 self.tk = get_tk()
601 self.tk = get_tk()
601
602
602 if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit
603 if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit
603 else: mainquit = self.gtk.mainquit
604 else: mainquit = self.gtk.mainquit
604
605
605 self.IP = make_IPython(argv,user_ns=user_ns,
606 self.IP = make_IPython(argv,user_ns=user_ns,
606 user_global_ns=user_global_ns,
607 user_global_ns=user_global_ns,
607 debug=debug,
608 debug=debug,
608 shell_class=shell_class,
609 shell_class=shell_class,
609 on_kill=[mainquit])
610 on_kill=[mainquit])
610
611
611 # HACK: slot for banner in self; it will be passed to the mainloop
612 # HACK: slot for banner in self; it will be passed to the mainloop
612 # method only and .run() needs it. The actual value will be set by
613 # method only and .run() needs it. The actual value will be set by
613 # .mainloop().
614 # .mainloop().
614 self._banner = None
615 self._banner = None
615
616
616 threading.Thread.__init__(self)
617 threading.Thread.__init__(self)
617
618
618 def run(self):
619 def run(self):
619 self.IP.mainloop(self._banner)
620 self.IP.mainloop(self._banner)
620 self.IP.kill()
621 self.IP.kill()
621
622
622 def mainloop(self,sys_exit=0,banner=None):
623 def mainloop(self,sys_exit=0,banner=None):
623
624
624 self._banner = banner
625 self._banner = banner
625
626
626 if self.gtk.pygtk_version >= (2,4,0):
627 if self.gtk.pygtk_version >= (2,4,0):
627 import gobject
628 import gobject
628 gobject.timeout_add(self.TIMEOUT, self.on_timer)
629 gobject.idle_add(self.on_timer)
629 else:
630 else:
630 self.gtk.timeout_add(self.TIMEOUT, self.on_timer)
631 self.gtk.idle_add(self.on_timer)
631
632
632 if sys.platform != 'win32':
633 if sys.platform != 'win32':
633 try:
634 try:
634 if self.gtk.gtk_version[0] >= 2:
635 if self.gtk.gtk_version[0] >= 2:
635 self.gtk.threads_init()
636 self.gtk.threads_init()
636 except AttributeError:
637 except AttributeError:
637 pass
638 pass
638 except RuntimeError:
639 except RuntimeError:
639 error('Your pyGTK likely has not been compiled with '
640 error('Your pyGTK likely has not been compiled with '
640 'threading support.\n'
641 'threading support.\n'
641 'The exception printout is below.\n'
642 'The exception printout is below.\n'
642 'You can either rebuild pyGTK with threads, or '
643 'You can either rebuild pyGTK with threads, or '
643 'try using \n'
644 'try using \n'
644 'matplotlib with a different backend (like Tk or WX).\n'
645 'matplotlib with a different backend (like Tk or WX).\n'
645 'Note that matplotlib will most likely not work in its '
646 'Note that matplotlib will most likely not work in its '
646 'current state!')
647 'current state!')
647 self.IP.InteractiveTB()
648 self.IP.InteractiveTB()
648 self.start()
649 self.start()
649 self.gtk.threads_enter()
650 self.gtk.threads_enter()
650 self.gtk_mainloop()
651 self.gtk_mainloop()
651 self.gtk.threads_leave()
652 self.gtk.threads_leave()
652 self.join()
653 self.join()
653
654
654 def on_timer(self):
655 def on_timer(self):
655 update_tk(self.tk)
656 """Called when GTK is idle.
656 return self.IP.runcode()
657
658 Must return True always, otherwise GTK stops calling it"""
657
659
660 update_tk(self.tk)
661 self.IP.runcode()
662 time.sleep(0.01)
663 return True
658
664
659 class IPShellWX(threading.Thread):
665 class IPShellWX(threading.Thread):
660 """Run a wx mainloop() in a separate thread.
666 """Run a wx mainloop() in a separate thread.
661
667
662 Python commands can be passed to the thread where they will be executed.
668 Python commands can be passed to the thread where they will be executed.
663 This is implemented by periodically checking for passed code using a
669 This is implemented by periodically checking for passed code using a
664 GTK timeout callback."""
670 GTK timeout callback."""
665
671
666 TIMEOUT = 100 # Millisecond interval between timeouts.
672 TIMEOUT = 100 # Millisecond interval between timeouts.
667
673
668 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
674 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
669 debug=1,shell_class=MTInteractiveShell):
675 debug=1,shell_class=MTInteractiveShell):
670
676
671 self.IP = make_IPython(argv,user_ns=user_ns,
677 self.IP = make_IPython(argv,user_ns=user_ns,
672 user_global_ns=user_global_ns,
678 user_global_ns=user_global_ns,
673 debug=debug,
679 debug=debug,
674 shell_class=shell_class,
680 shell_class=shell_class,
675 on_kill=[self.wxexit])
681 on_kill=[self.wxexit])
676
682
677 wantedwxversion=self.IP.rc.wxversion
683 wantedwxversion=self.IP.rc.wxversion
678 if wantedwxversion!="0":
684 if wantedwxversion!="0":
679 try:
685 try:
680 import wxversion
686 import wxversion
681 except ImportError:
687 except ImportError:
682 error('The wxversion module is needed for WX version selection')
688 error('The wxversion module is needed for WX version selection')
683 else:
689 else:
684 try:
690 try:
685 wxversion.select(wantedwxversion)
691 wxversion.select(wantedwxversion)
686 except:
692 except:
687 self.IP.InteractiveTB()
693 self.IP.InteractiveTB()
688 error('Requested wxPython version %s could not be loaded' %
694 error('Requested wxPython version %s could not be loaded' %
689 wantedwxversion)
695 wantedwxversion)
690
696
691 import wxPython.wx as wx
697 import wxPython.wx as wx
692
698
693 threading.Thread.__init__(self)
699 threading.Thread.__init__(self)
694 self.wx = wx
700 self.wx = wx
695 self.wx_mainloop = hijack_wx()
701 self.wx_mainloop = hijack_wx()
696
702
697 # Allows us to use both Tk and GTK.
703 # Allows us to use both Tk and GTK.
698 self.tk = get_tk()
704 self.tk = get_tk()
699
705
700
706
701 # HACK: slot for banner in self; it will be passed to the mainloop
707 # HACK: slot for banner in self; it will be passed to the mainloop
702 # method only and .run() needs it. The actual value will be set by
708 # method only and .run() needs it. The actual value will be set by
703 # .mainloop().
709 # .mainloop().
704 self._banner = None
710 self._banner = None
705
711
706 self.app = None
712 self.app = None
707
713
708 def wxexit(self, *args):
714 def wxexit(self, *args):
709 if self.app is not None:
715 if self.app is not None:
710 self.app.agent.timer.Stop()
716 self.app.agent.timer.Stop()
711 self.app.ExitMainLoop()
717 self.app.ExitMainLoop()
712
718
713 def run(self):
719 def run(self):
714 self.IP.mainloop(self._banner)
720 self.IP.mainloop(self._banner)
715 self.IP.kill()
721 self.IP.kill()
716
722
717 def mainloop(self,sys_exit=0,banner=None):
723 def mainloop(self,sys_exit=0,banner=None):
718
724
719 self._banner = banner
725 self._banner = banner
720
726
721 self.start()
727 self.start()
722
728
723 class TimerAgent(self.wx.wxMiniFrame):
729 class TimerAgent(self.wx.wxMiniFrame):
724 wx = self.wx
730 wx = self.wx
725 IP = self.IP
731 IP = self.IP
726 tk = self.tk
732 tk = self.tk
727 def __init__(self, parent, interval):
733 def __init__(self, parent, interval):
728 style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ
734 style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ
729 self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200),
735 self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200),
730 size=(100, 100),style=style)
736 size=(100, 100),style=style)
731 self.Show(False)
737 self.Show(False)
732 self.interval = interval
738 self.interval = interval
733 self.timerId = self.wx.wxNewId()
739 self.timerId = self.wx.wxNewId()
734
740
735 def StartWork(self):
741 def StartWork(self):
736 self.timer = self.wx.wxTimer(self, self.timerId)
742 self.timer = self.wx.wxTimer(self, self.timerId)
737 self.wx.EVT_TIMER(self, self.timerId, self.OnTimer)
743 self.wx.EVT_TIMER(self, self.timerId, self.OnTimer)
738 self.timer.Start(self.interval)
744 self.timer.Start(self.interval)
739
745
740 def OnTimer(self, event):
746 def OnTimer(self, event):
741 update_tk(self.tk)
747 update_tk(self.tk)
742 self.IP.runcode()
748 self.IP.runcode()
743
749
744 class App(self.wx.wxApp):
750 class App(self.wx.wxApp):
745 wx = self.wx
751 wx = self.wx
746 TIMEOUT = self.TIMEOUT
752 TIMEOUT = self.TIMEOUT
747 def OnInit(self):
753 def OnInit(self):
748 'Create the main window and insert the custom frame'
754 'Create the main window and insert the custom frame'
749 self.agent = TimerAgent(None, self.TIMEOUT)
755 self.agent = TimerAgent(None, self.TIMEOUT)
750 self.agent.Show(self.wx.false)
756 self.agent.Show(self.wx.false)
751 self.agent.StartWork()
757 self.agent.StartWork()
752 return self.wx.true
758 return self.wx.true
753
759
754 self.app = App(redirect=False)
760 self.app = App(redirect=False)
755 self.wx_mainloop(self.app)
761 self.wx_mainloop(self.app)
756 self.join()
762 self.join()
757
763
758
764
759 class IPShellQt(threading.Thread):
765 class IPShellQt(threading.Thread):
760 """Run a Qt event loop in a separate thread.
766 """Run a Qt event loop in a separate thread.
761
767
762 Python commands can be passed to the thread where they will be executed.
768 Python commands can be passed to the thread where they will be executed.
763 This is implemented by periodically checking for passed code using a
769 This is implemented by periodically checking for passed code using a
764 Qt timer / slot."""
770 Qt timer / slot."""
765
771
766 TIMEOUT = 100 # Millisecond interval between timeouts.
772 TIMEOUT = 100 # Millisecond interval between timeouts.
767
773
768 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
774 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
769 debug=0,shell_class=MTInteractiveShell):
775 debug=0,shell_class=MTInteractiveShell):
770
776
771 import qt
777 import qt
772
778
773 class newQApplication:
779 class newQApplication:
774 def __init__( self ):
780 def __init__( self ):
775 self.QApplication = qt.QApplication
781 self.QApplication = qt.QApplication
776
782
777 def __call__( *args, **kwargs ):
783 def __call__( *args, **kwargs ):
778 return qt.qApp
784 return qt.qApp
779
785
780 def exec_loop( *args, **kwargs ):
786 def exec_loop( *args, **kwargs ):
781 pass
787 pass
782
788
783 def __getattr__( self, name ):
789 def __getattr__( self, name ):
784 return getattr( self.QApplication, name )
790 return getattr( self.QApplication, name )
785
791
786 qt.QApplication = newQApplication()
792 qt.QApplication = newQApplication()
787
793
788 # Allows us to use both Tk and QT.
794 # Allows us to use both Tk and QT.
789 self.tk = get_tk()
795 self.tk = get_tk()
790
796
791 self.IP = make_IPython(argv,user_ns=user_ns,
797 self.IP = make_IPython(argv,user_ns=user_ns,
792 user_global_ns=user_global_ns,
798 user_global_ns=user_global_ns,
793 debug=debug,
799 debug=debug,
794 shell_class=shell_class,
800 shell_class=shell_class,
795 on_kill=[qt.qApp.exit])
801 on_kill=[qt.qApp.exit])
796
802
797 # HACK: slot for banner in self; it will be passed to the mainloop
803 # HACK: slot for banner in self; it will be passed to the mainloop
798 # method only and .run() needs it. The actual value will be set by
804 # method only and .run() needs it. The actual value will be set by
799 # .mainloop().
805 # .mainloop().
800 self._banner = None
806 self._banner = None
801
807
802 threading.Thread.__init__(self)
808 threading.Thread.__init__(self)
803
809
804 def run(self):
810 def run(self):
805 self.IP.mainloop(self._banner)
811 self.IP.mainloop(self._banner)
806 self.IP.kill()
812 self.IP.kill()
807
813
808 def mainloop(self,sys_exit=0,banner=None):
814 def mainloop(self,sys_exit=0,banner=None):
809
815
810 import qt
816 import qt
811
817
812 self._banner = banner
818 self._banner = banner
813
819
814 if qt.QApplication.startingUp():
820 if qt.QApplication.startingUp():
815 a = qt.QApplication.QApplication(sys.argv)
821 a = qt.QApplication.QApplication(sys.argv)
816 self.timer = qt.QTimer()
822 self.timer = qt.QTimer()
817 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
823 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
818
824
819 self.start()
825 self.start()
820 self.timer.start( self.TIMEOUT, True )
826 self.timer.start( self.TIMEOUT, True )
821 while True:
827 while True:
822 if self.IP._kill: break
828 if self.IP._kill: break
823 qt.qApp.exec_loop()
829 qt.qApp.exec_loop()
824 self.join()
830 self.join()
825
831
826 def on_timer(self):
832 def on_timer(self):
827 update_tk(self.tk)
833 update_tk(self.tk)
828 result = self.IP.runcode()
834 result = self.IP.runcode()
829 self.timer.start( self.TIMEOUT, True )
835 self.timer.start( self.TIMEOUT, True )
830 return result
836 return result
831
837
832 # A set of matplotlib public IPython shell classes, for single-threaded
838 # A set of matplotlib public IPython shell classes, for single-threaded
833 # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use.
839 # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use.
834 class IPShellMatplotlib(IPShell):
840 class IPShellMatplotlib(IPShell):
835 """Subclass IPShell with MatplotlibShell as the internal shell.
841 """Subclass IPShell with MatplotlibShell as the internal shell.
836
842
837 Single-threaded class, meant for the Tk* and FLTK* backends.
843 Single-threaded class, meant for the Tk* and FLTK* backends.
838
844
839 Having this on a separate class simplifies the external driver code."""
845 Having this on a separate class simplifies the external driver code."""
840
846
841 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
847 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
842 IPShell.__init__(self,argv,user_ns,user_global_ns,debug,
848 IPShell.__init__(self,argv,user_ns,user_global_ns,debug,
843 shell_class=MatplotlibShell)
849 shell_class=MatplotlibShell)
844
850
845 class IPShellMatplotlibGTK(IPShellGTK):
851 class IPShellMatplotlibGTK(IPShellGTK):
846 """Subclass IPShellGTK with MatplotlibMTShell as the internal shell.
852 """Subclass IPShellGTK with MatplotlibMTShell as the internal shell.
847
853
848 Multi-threaded class, meant for the GTK* backends."""
854 Multi-threaded class, meant for the GTK* backends."""
849
855
850 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
856 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
851 IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug,
857 IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug,
852 shell_class=MatplotlibMTShell)
858 shell_class=MatplotlibMTShell)
853
859
854 class IPShellMatplotlibWX(IPShellWX):
860 class IPShellMatplotlibWX(IPShellWX):
855 """Subclass IPShellWX with MatplotlibMTShell as the internal shell.
861 """Subclass IPShellWX with MatplotlibMTShell as the internal shell.
856
862
857 Multi-threaded class, meant for the WX* backends."""
863 Multi-threaded class, meant for the WX* backends."""
858
864
859 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
865 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
860 IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug,
866 IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug,
861 shell_class=MatplotlibMTShell)
867 shell_class=MatplotlibMTShell)
862
868
863 class IPShellMatplotlibQt(IPShellQt):
869 class IPShellMatplotlibQt(IPShellQt):
864 """Subclass IPShellQt with MatplotlibMTShell as the internal shell.
870 """Subclass IPShellQt with MatplotlibMTShell as the internal shell.
865
871
866 Multi-threaded class, meant for the Qt* backends."""
872 Multi-threaded class, meant for the Qt* backends."""
867
873
868 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
874 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
869 IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug,
875 IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug,
870 shell_class=MatplotlibMTShell)
876 shell_class=MatplotlibMTShell)
871
877
872 #-----------------------------------------------------------------------------
878 #-----------------------------------------------------------------------------
873 # Factory functions to actually start the proper thread-aware shell
879 # Factory functions to actually start the proper thread-aware shell
874
880
875 def _matplotlib_shell_class():
881 def _matplotlib_shell_class():
876 """Factory function to handle shell class selection for matplotlib.
882 """Factory function to handle shell class selection for matplotlib.
877
883
878 The proper shell class to use depends on the matplotlib backend, since
884 The proper shell class to use depends on the matplotlib backend, since
879 each backend requires a different threading strategy."""
885 each backend requires a different threading strategy."""
880
886
881 try:
887 try:
882 import matplotlib
888 import matplotlib
883 except ImportError:
889 except ImportError:
884 error('matplotlib could NOT be imported! Starting normal IPython.')
890 error('matplotlib could NOT be imported! Starting normal IPython.')
885 sh_class = IPShell
891 sh_class = IPShell
886 else:
892 else:
887 backend = matplotlib.rcParams['backend']
893 backend = matplotlib.rcParams['backend']
888 if backend.startswith('GTK'):
894 if backend.startswith('GTK'):
889 sh_class = IPShellMatplotlibGTK
895 sh_class = IPShellMatplotlibGTK
890 elif backend.startswith('WX'):
896 elif backend.startswith('WX'):
891 sh_class = IPShellMatplotlibWX
897 sh_class = IPShellMatplotlibWX
892 elif backend.startswith('Qt'):
898 elif backend.startswith('Qt'):
893 sh_class = IPShellMatplotlibQt
899 sh_class = IPShellMatplotlibQt
894 else:
900 else:
895 sh_class = IPShellMatplotlib
901 sh_class = IPShellMatplotlib
896 #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg
902 #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg
897 return sh_class
903 return sh_class
898
904
899 # This is the one which should be called by external code.
905 # This is the one which should be called by external code.
900 def start():
906 def start():
901 """Return a running shell instance, dealing with threading options.
907 """Return a running shell instance, dealing with threading options.
902
908
903 This is a factory function which will instantiate the proper IPython shell
909 This is a factory function which will instantiate the proper IPython shell
904 based on the user's threading choice. Such a selector is needed because
910 based on the user's threading choice. Such a selector is needed because
905 different GUI toolkits require different thread handling details."""
911 different GUI toolkits require different thread handling details."""
906
912
907 global USE_TK
913 global USE_TK
908 # Crude sys.argv hack to extract the threading options.
914 # Crude sys.argv hack to extract the threading options.
909 argv = sys.argv
915 argv = sys.argv
910 if len(argv) > 1:
916 if len(argv) > 1:
911 if len(argv) > 2:
917 if len(argv) > 2:
912 arg2 = argv[2]
918 arg2 = argv[2]
913 if arg2.endswith('-tk'):
919 if arg2.endswith('-tk'):
914 USE_TK = True
920 USE_TK = True
915 arg1 = argv[1]
921 arg1 = argv[1]
916 if arg1.endswith('-gthread'):
922 if arg1.endswith('-gthread'):
917 shell = IPShellGTK
923 shell = IPShellGTK
918 elif arg1.endswith( '-qthread' ):
924 elif arg1.endswith( '-qthread' ):
919 shell = IPShellQt
925 shell = IPShellQt
920 elif arg1.endswith('-wthread'):
926 elif arg1.endswith('-wthread'):
921 shell = IPShellWX
927 shell = IPShellWX
922 elif arg1.endswith('-pylab'):
928 elif arg1.endswith('-pylab'):
923 shell = _matplotlib_shell_class()
929 shell = _matplotlib_shell_class()
924 else:
930 else:
925 shell = IPShell
931 shell = IPShell
926 else:
932 else:
927 shell = IPShell
933 shell = IPShell
928 return shell()
934 return shell()
929
935
930 # Some aliases for backwards compatibility
936 # Some aliases for backwards compatibility
931 IPythonShell = IPShell
937 IPythonShell = IPShell
932 IPythonShellEmbed = IPShellEmbed
938 IPythonShellEmbed = IPShellEmbed
933 #************************ End of file <Shell.py> ***************************
939 #************************ End of file <Shell.py> ***************************
@@ -1,2165 +1,2165 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.1 or newer.
5 Requires Python 2.1 or newer.
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 1000 2006-01-10 08:06:04Z fperez $
9 $Id: iplib.py 1002 2006-01-11 22:18:29Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 # Copyright (C) 2001-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
61
62 from pprint import pprint, pformat
62 from pprint import pprint, pformat
63
63
64 # IPython's own modules
64 # IPython's own modules
65 import IPython
65 import IPython
66 from IPython import OInspect,PyColorize,ultraTB
66 from IPython import OInspect,PyColorize,ultraTB
67 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
67 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
68 from IPython.FakeModule import FakeModule
68 from IPython.FakeModule import FakeModule
69 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
69 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
70 from IPython.Logger import Logger
70 from IPython.Logger import Logger
71 from IPython.Magic import Magic
71 from IPython.Magic import Magic
72 from IPython.Prompts import CachedOutput
72 from IPython.Prompts import CachedOutput
73 from IPython.Struct import Struct
73 from IPython.Struct import Struct
74 from IPython.background_jobs import BackgroundJobManager
74 from IPython.background_jobs import BackgroundJobManager
75 from IPython.usage import cmd_line_usage,interactive_usage
75 from IPython.usage import cmd_line_usage,interactive_usage
76 from IPython.genutils import *
76 from IPython.genutils import *
77
77
78 # Globals
78 # Globals
79
79
80 # store the builtin raw_input globally, and use this always, in case user code
80 # store the builtin raw_input globally, and use this always, in case user code
81 # overwrites it (like wx.py.PyShell does)
81 # overwrites it (like wx.py.PyShell does)
82 raw_input_original = raw_input
82 raw_input_original = raw_input
83
83
84 # compiled regexps for autoindent management
84 # compiled regexps for autoindent management
85 ini_spaces_re = re.compile(r'^(\s+)')
85 ini_spaces_re = re.compile(r'^(\s+)')
86 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
86 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
87
87
88
88
89 #****************************************************************************
89 #****************************************************************************
90 # Some utility function definitions
90 # Some utility function definitions
91
91
92 def softspace(file, newvalue):
92 def softspace(file, newvalue):
93 """Copied from code.py, to remove the dependency"""
93 """Copied from code.py, to remove the dependency"""
94 oldvalue = 0
94 oldvalue = 0
95 try:
95 try:
96 oldvalue = file.softspace
96 oldvalue = file.softspace
97 except AttributeError:
97 except AttributeError:
98 pass
98 pass
99 try:
99 try:
100 file.softspace = newvalue
100 file.softspace = newvalue
101 except (AttributeError, TypeError):
101 except (AttributeError, TypeError):
102 # "attribute-less object" or "read-only attributes"
102 # "attribute-less object" or "read-only attributes"
103 pass
103 pass
104 return oldvalue
104 return oldvalue
105
105
106
106
107 #****************************************************************************
107 #****************************************************************************
108 # Local use exceptions
108 # Local use exceptions
109 class SpaceInInput(exceptions.Exception): pass
109 class SpaceInInput(exceptions.Exception): pass
110
110
111
111
112 #****************************************************************************
112 #****************************************************************************
113 # Local use classes
113 # Local use classes
114 class Bunch: pass
114 class Bunch: pass
115
115
116 class Undefined: pass
116 class Undefined: pass
117
117
118 class InputList(list):
118 class InputList(list):
119 """Class to store user input.
119 """Class to store user input.
120
120
121 It's basically a list, but slices return a string instead of a list, thus
121 It's basically a list, but slices return a string instead of a list, thus
122 allowing things like (assuming 'In' is an instance):
122 allowing things like (assuming 'In' is an instance):
123
123
124 exec In[4:7]
124 exec In[4:7]
125
125
126 or
126 or
127
127
128 exec In[5:9] + In[14] + In[21:25]"""
128 exec In[5:9] + In[14] + In[21:25]"""
129
129
130 def __getslice__(self,i,j):
130 def __getslice__(self,i,j):
131 return ''.join(list.__getslice__(self,i,j))
131 return ''.join(list.__getslice__(self,i,j))
132
132
133 class SyntaxTB(ultraTB.ListTB):
133 class SyntaxTB(ultraTB.ListTB):
134 """Extension which holds some state: the last exception value"""
134 """Extension which holds some state: the last exception value"""
135
135
136 def __init__(self,color_scheme = 'NoColor'):
136 def __init__(self,color_scheme = 'NoColor'):
137 ultraTB.ListTB.__init__(self,color_scheme)
137 ultraTB.ListTB.__init__(self,color_scheme)
138 self.last_syntax_error = None
138 self.last_syntax_error = None
139
139
140 def __call__(self, etype, value, elist):
140 def __call__(self, etype, value, elist):
141 self.last_syntax_error = value
141 self.last_syntax_error = value
142 ultraTB.ListTB.__call__(self,etype,value,elist)
142 ultraTB.ListTB.__call__(self,etype,value,elist)
143
143
144 def clear_err_state(self):
144 def clear_err_state(self):
145 """Return the current error state and clear it"""
145 """Return the current error state and clear it"""
146 e = self.last_syntax_error
146 e = self.last_syntax_error
147 self.last_syntax_error = None
147 self.last_syntax_error = None
148 return e
148 return e
149
149
150 #****************************************************************************
150 #****************************************************************************
151 # Main IPython class
151 # Main IPython class
152
152
153 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
153 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
154 # until a full rewrite is made. I've cleaned all cross-class uses of
154 # until a full rewrite is made. I've cleaned all cross-class uses of
155 # attributes and methods, but too much user code out there relies on the
155 # attributes and methods, but too much user code out there relies on the
156 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
156 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
157 #
157 #
158 # But at least now, all the pieces have been separated and we could, in
158 # But at least now, all the pieces have been separated and we could, in
159 # principle, stop using the mixin. This will ease the transition to the
159 # principle, stop using the mixin. This will ease the transition to the
160 # chainsaw branch.
160 # chainsaw branch.
161
161
162 # For reference, the following is the list of 'self.foo' uses in the Magic
162 # For reference, the following is the list of 'self.foo' uses in the Magic
163 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
163 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
164 # class, to prevent clashes.
164 # class, to prevent clashes.
165
165
166 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
166 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
167 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
167 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
168 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
168 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
169 # 'self.value']
169 # 'self.value']
170
170
171 class InteractiveShell(object,Magic):
171 class InteractiveShell(object,Magic):
172 """An enhanced console for Python."""
172 """An enhanced console for Python."""
173
173
174 # class attribute to indicate whether the class supports threads or not.
174 # class attribute to indicate whether the class supports threads or not.
175 # Subclasses with thread support should override this as needed.
175 # Subclasses with thread support should override this as needed.
176 isthreaded = False
176 isthreaded = False
177
177
178 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
178 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
179 user_ns = None,user_global_ns=None,banner2='',
179 user_ns = None,user_global_ns=None,banner2='',
180 custom_exceptions=((),None),embedded=False):
180 custom_exceptions=((),None),embedded=False):
181
181
182 # some minimal strict typechecks. For some core data structures, I
182 # some minimal strict typechecks. For some core data structures, I
183 # want actual basic python types, not just anything that looks like
183 # want actual basic python types, not just anything that looks like
184 # one. This is especially true for namespaces.
184 # one. This is especially true for namespaces.
185 for ns in (user_ns,user_global_ns):
185 for ns in (user_ns,user_global_ns):
186 if ns is not None and type(ns) != types.DictType:
186 if ns is not None and type(ns) != types.DictType:
187 raise TypeError,'namespace must be a dictionary'
187 raise TypeError,'namespace must be a dictionary'
188
188
189 # Job manager (for jobs run as background threads)
189 # Job manager (for jobs run as background threads)
190 self.jobs = BackgroundJobManager()
190 self.jobs = BackgroundJobManager()
191
191
192 # track which builtins we add, so we can clean up later
192 # track which builtins we add, so we can clean up later
193 self.builtins_added = {}
193 self.builtins_added = {}
194 # This method will add the necessary builtins for operation, but
194 # This method will add the necessary builtins for operation, but
195 # tracking what it did via the builtins_added dict.
195 # tracking what it did via the builtins_added dict.
196 self.add_builtins()
196 self.add_builtins()
197
197
198 # Do the intuitively correct thing for quit/exit: we remove the
198 # Do the intuitively correct thing for quit/exit: we remove the
199 # builtins if they exist, and our own magics will deal with this
199 # builtins if they exist, and our own magics will deal with this
200 try:
200 try:
201 del __builtin__.exit, __builtin__.quit
201 del __builtin__.exit, __builtin__.quit
202 except AttributeError:
202 except AttributeError:
203 pass
203 pass
204
204
205 # Store the actual shell's name
205 # Store the actual shell's name
206 self.name = name
206 self.name = name
207
207
208 # We need to know whether the instance is meant for embedding, since
208 # We need to know whether the instance is meant for embedding, since
209 # global/local namespaces need to be handled differently in that case
209 # global/local namespaces need to be handled differently in that case
210 self.embedded = embedded
210 self.embedded = embedded
211
211
212 # command compiler
212 # command compiler
213 self.compile = codeop.CommandCompiler()
213 self.compile = codeop.CommandCompiler()
214
214
215 # User input buffer
215 # User input buffer
216 self.buffer = []
216 self.buffer = []
217
217
218 # Default name given in compilation of code
218 # Default name given in compilation of code
219 self.filename = '<ipython console>'
219 self.filename = '<ipython console>'
220
220
221 # Make an empty namespace, which extension writers can rely on both
221 # Make an empty namespace, which extension writers can rely on both
222 # existing and NEVER being used by ipython itself. This gives them a
222 # existing and NEVER being used by ipython itself. This gives them a
223 # convenient location for storing additional information and state
223 # convenient location for storing additional information and state
224 # their extensions may require, without fear of collisions with other
224 # their extensions may require, without fear of collisions with other
225 # ipython names that may develop later.
225 # ipython names that may develop later.
226 self.meta = Bunch()
226 self.meta = Bunch()
227
227
228 # Create the namespace where the user will operate. user_ns is
228 # Create the namespace where the user will operate. user_ns is
229 # normally the only one used, and it is passed to the exec calls as
229 # normally the only one used, and it is passed to the exec calls as
230 # the locals argument. But we do carry a user_global_ns namespace
230 # the locals argument. But we do carry a user_global_ns namespace
231 # given as the exec 'globals' argument, This is useful in embedding
231 # given as the exec 'globals' argument, This is useful in embedding
232 # situations where the ipython shell opens in a context where the
232 # situations where the ipython shell opens in a context where the
233 # distinction between locals and globals is meaningful.
233 # distinction between locals and globals is meaningful.
234
234
235 # FIXME. For some strange reason, __builtins__ is showing up at user
235 # FIXME. For some strange reason, __builtins__ is showing up at user
236 # level as a dict instead of a module. This is a manual fix, but I
236 # level as a dict instead of a module. This is a manual fix, but I
237 # should really track down where the problem is coming from. Alex
237 # should really track down where the problem is coming from. Alex
238 # Schmolck reported this problem first.
238 # Schmolck reported this problem first.
239
239
240 # A useful post by Alex Martelli on this topic:
240 # A useful post by Alex Martelli on this topic:
241 # Re: inconsistent value from __builtins__
241 # Re: inconsistent value from __builtins__
242 # Von: Alex Martelli <aleaxit@yahoo.com>
242 # Von: Alex Martelli <aleaxit@yahoo.com>
243 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
243 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
244 # Gruppen: comp.lang.python
244 # Gruppen: comp.lang.python
245
245
246 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
246 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
247 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
247 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
248 # > <type 'dict'>
248 # > <type 'dict'>
249 # > >>> print type(__builtins__)
249 # > >>> print type(__builtins__)
250 # > <type 'module'>
250 # > <type 'module'>
251 # > Is this difference in return value intentional?
251 # > Is this difference in return value intentional?
252
252
253 # Well, it's documented that '__builtins__' can be either a dictionary
253 # Well, it's documented that '__builtins__' can be either a dictionary
254 # or a module, and it's been that way for a long time. Whether it's
254 # or a module, and it's been that way for a long time. Whether it's
255 # intentional (or sensible), I don't know. In any case, the idea is
255 # intentional (or sensible), I don't know. In any case, the idea is
256 # that if you need to access the built-in namespace directly, you
256 # that if you need to access the built-in namespace directly, you
257 # should start with "import __builtin__" (note, no 's') which will
257 # should start with "import __builtin__" (note, no 's') which will
258 # definitely give you a module. Yeah, it's somewhatΒ confusing:-(.
258 # definitely give you a module. Yeah, it's somewhatΒ confusing:-(.
259
259
260 if user_ns is None:
260 if user_ns is None:
261 # Set __name__ to __main__ to better match the behavior of the
261 # Set __name__ to __main__ to better match the behavior of the
262 # normal interpreter.
262 # normal interpreter.
263 user_ns = {'__name__' :'__main__',
263 user_ns = {'__name__' :'__main__',
264 '__builtins__' : __builtin__,
264 '__builtins__' : __builtin__,
265 }
265 }
266
266
267 if user_global_ns is None:
267 if user_global_ns is None:
268 user_global_ns = {}
268 user_global_ns = {}
269
269
270 # Assign namespaces
270 # Assign namespaces
271 # This is the namespace where all normal user variables live
271 # This is the namespace where all normal user variables live
272 self.user_ns = user_ns
272 self.user_ns = user_ns
273 # Embedded instances require a separate namespace for globals.
273 # Embedded instances require a separate namespace for globals.
274 # Normally this one is unused by non-embedded instances.
274 # Normally this one is unused by non-embedded instances.
275 self.user_global_ns = user_global_ns
275 self.user_global_ns = user_global_ns
276 # A namespace to keep track of internal data structures to prevent
276 # A namespace to keep track of internal data structures to prevent
277 # them from cluttering user-visible stuff. Will be updated later
277 # them from cluttering user-visible stuff. Will be updated later
278 self.internal_ns = {}
278 self.internal_ns = {}
279
279
280 # Namespace of system aliases. Each entry in the alias
280 # Namespace of system aliases. Each entry in the alias
281 # table must be a 2-tuple of the form (N,name), where N is the number
281 # table must be a 2-tuple of the form (N,name), where N is the number
282 # of positional arguments of the alias.
282 # of positional arguments of the alias.
283 self.alias_table = {}
283 self.alias_table = {}
284
284
285 # A table holding all the namespaces IPython deals with, so that
285 # A table holding all the namespaces IPython deals with, so that
286 # introspection facilities can search easily.
286 # introspection facilities can search easily.
287 self.ns_table = {'user':user_ns,
287 self.ns_table = {'user':user_ns,
288 'user_global':user_global_ns,
288 'user_global':user_global_ns,
289 'alias':self.alias_table,
289 'alias':self.alias_table,
290 'internal':self.internal_ns,
290 'internal':self.internal_ns,
291 'builtin':__builtin__.__dict__
291 'builtin':__builtin__.__dict__
292 }
292 }
293
293
294 # The user namespace MUST have a pointer to the shell itself.
294 # The user namespace MUST have a pointer to the shell itself.
295 self.user_ns[name] = self
295 self.user_ns[name] = self
296
296
297 # We need to insert into sys.modules something that looks like a
297 # We need to insert into sys.modules something that looks like a
298 # module but which accesses the IPython namespace, for shelve and
298 # module but which accesses the IPython namespace, for shelve and
299 # pickle to work interactively. Normally they rely on getting
299 # pickle to work interactively. Normally they rely on getting
300 # everything out of __main__, but for embedding purposes each IPython
300 # everything out of __main__, but for embedding purposes each IPython
301 # instance has its own private namespace, so we can't go shoving
301 # instance has its own private namespace, so we can't go shoving
302 # everything into __main__.
302 # everything into __main__.
303
303
304 # note, however, that we should only do this for non-embedded
304 # note, however, that we should only do this for non-embedded
305 # ipythons, which really mimic the __main__.__dict__ with their own
305 # ipythons, which really mimic the __main__.__dict__ with their own
306 # namespace. Embedded instances, on the other hand, should not do
306 # namespace. Embedded instances, on the other hand, should not do
307 # this because they need to manage the user local/global namespaces
307 # this because they need to manage the user local/global namespaces
308 # only, but they live within a 'normal' __main__ (meaning, they
308 # only, but they live within a 'normal' __main__ (meaning, they
309 # shouldn't overtake the execution environment of the script they're
309 # shouldn't overtake the execution environment of the script they're
310 # embedded in).
310 # embedded in).
311
311
312 if not embedded:
312 if not embedded:
313 try:
313 try:
314 main_name = self.user_ns['__name__']
314 main_name = self.user_ns['__name__']
315 except KeyError:
315 except KeyError:
316 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
316 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
317 else:
317 else:
318 #print "pickle hack in place" # dbg
318 #print "pickle hack in place" # dbg
319 #print 'main_name:',main_name # dbg
319 #print 'main_name:',main_name # dbg
320 sys.modules[main_name] = FakeModule(self.user_ns)
320 sys.modules[main_name] = FakeModule(self.user_ns)
321
321
322 # List of input with multi-line handling.
322 # List of input with multi-line handling.
323 # Fill its zero entry, user counter starts at 1
323 # Fill its zero entry, user counter starts at 1
324 self.input_hist = InputList(['\n'])
324 self.input_hist = InputList(['\n'])
325
325
326 # list of visited directories
326 # list of visited directories
327 try:
327 try:
328 self.dir_hist = [os.getcwd()]
328 self.dir_hist = [os.getcwd()]
329 except IOError, e:
329 except IOError, e:
330 self.dir_hist = []
330 self.dir_hist = []
331
331
332 # dict of output history
332 # dict of output history
333 self.output_hist = {}
333 self.output_hist = {}
334
334
335 # dict of things NOT to alias (keywords, builtins and some magics)
335 # dict of things NOT to alias (keywords, builtins and some magics)
336 no_alias = {}
336 no_alias = {}
337 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
337 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
338 for key in keyword.kwlist + no_alias_magics:
338 for key in keyword.kwlist + no_alias_magics:
339 no_alias[key] = 1
339 no_alias[key] = 1
340 no_alias.update(__builtin__.__dict__)
340 no_alias.update(__builtin__.__dict__)
341 self.no_alias = no_alias
341 self.no_alias = no_alias
342
342
343 # make global variables for user access to these
343 # make global variables for user access to these
344 self.user_ns['_ih'] = self.input_hist
344 self.user_ns['_ih'] = self.input_hist
345 self.user_ns['_oh'] = self.output_hist
345 self.user_ns['_oh'] = self.output_hist
346 self.user_ns['_dh'] = self.dir_hist
346 self.user_ns['_dh'] = self.dir_hist
347
347
348 # user aliases to input and output histories
348 # user aliases to input and output histories
349 self.user_ns['In'] = self.input_hist
349 self.user_ns['In'] = self.input_hist
350 self.user_ns['Out'] = self.output_hist
350 self.user_ns['Out'] = self.output_hist
351
351
352 # Object variable to store code object waiting execution. This is
352 # Object variable to store code object waiting execution. This is
353 # used mainly by the multithreaded shells, but it can come in handy in
353 # used mainly by the multithreaded shells, but it can come in handy in
354 # other situations. No need to use a Queue here, since it's a single
354 # other situations. No need to use a Queue here, since it's a single
355 # item which gets cleared once run.
355 # item which gets cleared once run.
356 self.code_to_run = None
356 self.code_to_run = None
357
357
358 # escapes for automatic behavior on the command line
358 # escapes for automatic behavior on the command line
359 self.ESC_SHELL = '!'
359 self.ESC_SHELL = '!'
360 self.ESC_HELP = '?'
360 self.ESC_HELP = '?'
361 self.ESC_MAGIC = '%'
361 self.ESC_MAGIC = '%'
362 self.ESC_QUOTE = ','
362 self.ESC_QUOTE = ','
363 self.ESC_QUOTE2 = ';'
363 self.ESC_QUOTE2 = ';'
364 self.ESC_PAREN = '/'
364 self.ESC_PAREN = '/'
365
365
366 # And their associated handlers
366 # And their associated handlers
367 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
367 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
368 self.ESC_QUOTE : self.handle_auto,
368 self.ESC_QUOTE : self.handle_auto,
369 self.ESC_QUOTE2 : self.handle_auto,
369 self.ESC_QUOTE2 : self.handle_auto,
370 self.ESC_MAGIC : self.handle_magic,
370 self.ESC_MAGIC : self.handle_magic,
371 self.ESC_HELP : self.handle_help,
371 self.ESC_HELP : self.handle_help,
372 self.ESC_SHELL : self.handle_shell_escape,
372 self.ESC_SHELL : self.handle_shell_escape,
373 }
373 }
374
374
375 # class initializations
375 # class initializations
376 Magic.__init__(self,self)
376 Magic.__init__(self,self)
377
377
378 # Python source parser/formatter for syntax highlighting
378 # Python source parser/formatter for syntax highlighting
379 pyformat = PyColorize.Parser().format
379 pyformat = PyColorize.Parser().format
380 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
380 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
381
381
382 # hooks holds pointers used for user-side customizations
382 # hooks holds pointers used for user-side customizations
383 self.hooks = Struct()
383 self.hooks = Struct()
384
384
385 # Set all default hooks, defined in the IPython.hooks module.
385 # Set all default hooks, defined in the IPython.hooks module.
386 hooks = IPython.hooks
386 hooks = IPython.hooks
387 for hook_name in hooks.__all__:
387 for hook_name in hooks.__all__:
388 self.set_hook(hook_name,getattr(hooks,hook_name))
388 self.set_hook(hook_name,getattr(hooks,hook_name))
389
389
390 # Flag to mark unconditional exit
390 # Flag to mark unconditional exit
391 self.exit_now = False
391 self.exit_now = False
392
392
393 self.usage_min = """\
393 self.usage_min = """\
394 An enhanced console for Python.
394 An enhanced console for Python.
395 Some of its features are:
395 Some of its features are:
396 - Readline support if the readline library is present.
396 - Readline support if the readline library is present.
397 - Tab completion in the local namespace.
397 - Tab completion in the local namespace.
398 - Logging of input, see command-line options.
398 - Logging of input, see command-line options.
399 - System shell escape via ! , eg !ls.
399 - System shell escape via ! , eg !ls.
400 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
400 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
401 - Keeps track of locally defined variables via %who, %whos.
401 - Keeps track of locally defined variables via %who, %whos.
402 - Show object information with a ? eg ?x or x? (use ?? for more info).
402 - Show object information with a ? eg ?x or x? (use ?? for more info).
403 """
403 """
404 if usage: self.usage = usage
404 if usage: self.usage = usage
405 else: self.usage = self.usage_min
405 else: self.usage = self.usage_min
406
406
407 # Storage
407 # Storage
408 self.rc = rc # This will hold all configuration information
408 self.rc = rc # This will hold all configuration information
409 self.pager = 'less'
409 self.pager = 'less'
410 # temporary files used for various purposes. Deleted at exit.
410 # temporary files used for various purposes. Deleted at exit.
411 self.tempfiles = []
411 self.tempfiles = []
412
412
413 # Keep track of readline usage (later set by init_readline)
413 # Keep track of readline usage (later set by init_readline)
414 self.has_readline = False
414 self.has_readline = False
415
415
416 # template for logfile headers. It gets resolved at runtime by the
416 # template for logfile headers. It gets resolved at runtime by the
417 # logstart method.
417 # logstart method.
418 self.loghead_tpl = \
418 self.loghead_tpl = \
419 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
419 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
420 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
420 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
421 #log# opts = %s
421 #log# opts = %s
422 #log# args = %s
422 #log# args = %s
423 #log# It is safe to make manual edits below here.
423 #log# It is safe to make manual edits below here.
424 #log#-----------------------------------------------------------------------
424 #log#-----------------------------------------------------------------------
425 """
425 """
426 # for pushd/popd management
426 # for pushd/popd management
427 try:
427 try:
428 self.home_dir = get_home_dir()
428 self.home_dir = get_home_dir()
429 except HomeDirError,msg:
429 except HomeDirError,msg:
430 fatal(msg)
430 fatal(msg)
431
431
432 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
432 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
433
433
434 # Functions to call the underlying shell.
434 # Functions to call the underlying shell.
435
435
436 # utility to expand user variables via Itpl
436 # utility to expand user variables via Itpl
437 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
437 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
438 self.user_ns))
438 self.user_ns))
439 # The first is similar to os.system, but it doesn't return a value,
439 # The first is similar to os.system, but it doesn't return a value,
440 # and it allows interpolation of variables in the user's namespace.
440 # and it allows interpolation of variables in the user's namespace.
441 self.system = lambda cmd: shell(self.var_expand(cmd),
441 self.system = lambda cmd: shell(self.var_expand(cmd),
442 header='IPython system call: ',
442 header='IPython system call: ',
443 verbose=self.rc.system_verbose)
443 verbose=self.rc.system_verbose)
444 # These are for getoutput and getoutputerror:
444 # These are for getoutput and getoutputerror:
445 self.getoutput = lambda cmd: \
445 self.getoutput = lambda cmd: \
446 getoutput(self.var_expand(cmd),
446 getoutput(self.var_expand(cmd),
447 header='IPython system call: ',
447 header='IPython system call: ',
448 verbose=self.rc.system_verbose)
448 verbose=self.rc.system_verbose)
449 self.getoutputerror = lambda cmd: \
449 self.getoutputerror = lambda cmd: \
450 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
450 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
451 self.user_ns)),
451 self.user_ns)),
452 header='IPython system call: ',
452 header='IPython system call: ',
453 verbose=self.rc.system_verbose)
453 verbose=self.rc.system_verbose)
454
454
455 # RegExp for splitting line contents into pre-char//first
455 # RegExp for splitting line contents into pre-char//first
456 # word-method//rest. For clarity, each group in on one line.
456 # word-method//rest. For clarity, each group in on one line.
457
457
458 # WARNING: update the regexp if the above escapes are changed, as they
458 # WARNING: update the regexp if the above escapes are changed, as they
459 # are hardwired in.
459 # are hardwired in.
460
460
461 # Don't get carried away with trying to make the autocalling catch too
461 # Don't get carried away with trying to make the autocalling catch too
462 # much: it's better to be conservative rather than to trigger hidden
462 # much: it's better to be conservative rather than to trigger hidden
463 # evals() somewhere and end up causing side effects.
463 # evals() somewhere and end up causing side effects.
464
464
465 self.line_split = re.compile(r'^([\s*,;/])'
465 self.line_split = re.compile(r'^([\s*,;/])'
466 r'([\?\w\.]+\w*\s*)'
466 r'([\?\w\.]+\w*\s*)'
467 r'(\(?.*$)')
467 r'(\(?.*$)')
468
468
469 # Original re, keep around for a while in case changes break something
469 # Original re, keep around for a while in case changes break something
470 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
470 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
471 # r'(\s*[\?\w\.]+\w*\s*)'
471 # r'(\s*[\?\w\.]+\w*\s*)'
472 # r'(\(?.*$)')
472 # r'(\(?.*$)')
473
473
474 # RegExp to identify potential function names
474 # RegExp to identify potential function names
475 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
475 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
476 # RegExp to exclude strings with this start from autocalling
476 # RegExp to exclude strings with this start from autocalling
477 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
477 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
478
478
479 # try to catch also methods for stuff in lists/tuples/dicts: off
479 # try to catch also methods for stuff in lists/tuples/dicts: off
480 # (experimental). For this to work, the line_split regexp would need
480 # (experimental). For this to work, the line_split regexp would need
481 # to be modified so it wouldn't break things at '['. That line is
481 # to be modified so it wouldn't break things at '['. That line is
482 # nasty enough that I shouldn't change it until I can test it _well_.
482 # nasty enough that I shouldn't change it until I can test it _well_.
483 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
483 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
484
484
485 # keep track of where we started running (mainly for crash post-mortem)
485 # keep track of where we started running (mainly for crash post-mortem)
486 self.starting_dir = os.getcwd()
486 self.starting_dir = os.getcwd()
487
487
488 # Various switches which can be set
488 # Various switches which can be set
489 self.CACHELENGTH = 5000 # this is cheap, it's just text
489 self.CACHELENGTH = 5000 # this is cheap, it's just text
490 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
490 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
491 self.banner2 = banner2
491 self.banner2 = banner2
492
492
493 # TraceBack handlers:
493 # TraceBack handlers:
494
494
495 # Syntax error handler.
495 # Syntax error handler.
496 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
496 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
497
497
498 # The interactive one is initialized with an offset, meaning we always
498 # The interactive one is initialized with an offset, meaning we always
499 # want to remove the topmost item in the traceback, which is our own
499 # want to remove the topmost item in the traceback, which is our own
500 # internal code. Valid modes: ['Plain','Context','Verbose']
500 # internal code. Valid modes: ['Plain','Context','Verbose']
501 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
501 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
502 color_scheme='NoColor',
502 color_scheme='NoColor',
503 tb_offset = 1)
503 tb_offset = 1)
504
504
505 # IPython itself shouldn't crash. This will produce a detailed
505 # IPython itself shouldn't crash. This will produce a detailed
506 # post-mortem if it does. But we only install the crash handler for
506 # post-mortem if it does. But we only install the crash handler for
507 # non-threaded shells, the threaded ones use a normal verbose reporter
507 # non-threaded shells, the threaded ones use a normal verbose reporter
508 # and lose the crash handler. This is because exceptions in the main
508 # and lose the crash handler. This is because exceptions in the main
509 # thread (such as in GUI code) propagate directly to sys.excepthook,
509 # thread (such as in GUI code) propagate directly to sys.excepthook,
510 # and there's no point in printing crash dumps for every user exception.
510 # and there's no point in printing crash dumps for every user exception.
511 if self.isthreaded:
511 if self.isthreaded:
512 sys.excepthook = ultraTB.FormattedTB()
512 sys.excepthook = ultraTB.FormattedTB()
513 else:
513 else:
514 from IPython import CrashHandler
514 from IPython import CrashHandler
515 sys.excepthook = CrashHandler.CrashHandler(self)
515 sys.excepthook = CrashHandler.CrashHandler(self)
516
516
517 # The instance will store a pointer to this, so that runtime code
517 # The instance will store a pointer to this, so that runtime code
518 # (such as magics) can access it. This is because during the
518 # (such as magics) can access it. This is because during the
519 # read-eval loop, it gets temporarily overwritten (to deal with GUI
519 # read-eval loop, it gets temporarily overwritten (to deal with GUI
520 # frameworks).
520 # frameworks).
521 self.sys_excepthook = sys.excepthook
521 self.sys_excepthook = sys.excepthook
522
522
523 # and add any custom exception handlers the user may have specified
523 # and add any custom exception handlers the user may have specified
524 self.set_custom_exc(*custom_exceptions)
524 self.set_custom_exc(*custom_exceptions)
525
525
526 # Object inspector
526 # Object inspector
527 self.inspector = OInspect.Inspector(OInspect.InspectColors,
527 self.inspector = OInspect.Inspector(OInspect.InspectColors,
528 PyColorize.ANSICodeColors,
528 PyColorize.ANSICodeColors,
529 'NoColor')
529 'NoColor')
530 # indentation management
530 # indentation management
531 self.autoindent = False
531 self.autoindent = False
532 self.indent_current_nsp = 0
532 self.indent_current_nsp = 0
533 self.indent_current = '' # actual indent string
533 self.indent_current = '' # actual indent string
534
534
535 # Make some aliases automatically
535 # Make some aliases automatically
536 # Prepare list of shell aliases to auto-define
536 # Prepare list of shell aliases to auto-define
537 if os.name == 'posix':
537 if os.name == 'posix':
538 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
538 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
539 'mv mv -i','rm rm -i','cp cp -i',
539 'mv mv -i','rm rm -i','cp cp -i',
540 'cat cat','less less','clear clear',
540 'cat cat','less less','clear clear',
541 # a better ls
541 # a better ls
542 'ls ls -F',
542 'ls ls -F',
543 # long ls
543 # long ls
544 'll ls -lF',
544 'll ls -lF',
545 # color ls
545 # color ls
546 'lc ls -F -o --color',
546 'lc ls -F -o --color',
547 # ls normal files only
547 # ls normal files only
548 'lf ls -F -o --color %l | grep ^-',
548 'lf ls -F -o --color %l | grep ^-',
549 # ls symbolic links
549 # ls symbolic links
550 'lk ls -F -o --color %l | grep ^l',
550 'lk ls -F -o --color %l | grep ^l',
551 # directories or links to directories,
551 # directories or links to directories,
552 'ldir ls -F -o --color %l | grep /$',
552 'ldir ls -F -o --color %l | grep /$',
553 # things which are executable
553 # things which are executable
554 'lx ls -F -o --color %l | grep ^-..x',
554 'lx ls -F -o --color %l | grep ^-..x',
555 )
555 )
556 elif os.name in ['nt','dos']:
556 elif os.name in ['nt','dos']:
557 auto_alias = ('dir dir /on', 'ls dir /on',
557 auto_alias = ('dir dir /on', 'ls dir /on',
558 'ddir dir /ad /on', 'ldir dir /ad /on',
558 'ddir dir /ad /on', 'ldir dir /ad /on',
559 'mkdir mkdir','rmdir rmdir','echo echo',
559 'mkdir mkdir','rmdir rmdir','echo echo',
560 'ren ren','cls cls','copy copy')
560 'ren ren','cls cls','copy copy')
561 else:
561 else:
562 auto_alias = ()
562 auto_alias = ()
563 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
563 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
564 # Call the actual (public) initializer
564 # Call the actual (public) initializer
565 self.init_auto_alias()
565 self.init_auto_alias()
566 # end __init__
566 # end __init__
567
567
568 def post_config_initialization(self):
568 def post_config_initialization(self):
569 """Post configuration init method
569 """Post configuration init method
570
570
571 This is called after the configuration files have been processed to
571 This is called after the configuration files have been processed to
572 'finalize' the initialization."""
572 'finalize' the initialization."""
573
573
574 rc = self.rc
574 rc = self.rc
575
575
576 # Load readline proper
576 # Load readline proper
577 if rc.readline:
577 if rc.readline:
578 self.init_readline()
578 self.init_readline()
579
579
580 # log system
580 # log system
581 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
581 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
582 # local shortcut, this is used a LOT
582 # local shortcut, this is used a LOT
583 self.log = self.logger.log
583 self.log = self.logger.log
584
584
585 # Initialize cache, set in/out prompts and printing system
585 # Initialize cache, set in/out prompts and printing system
586 self.outputcache = CachedOutput(self,
586 self.outputcache = CachedOutput(self,
587 rc.cache_size,
587 rc.cache_size,
588 rc.pprint,
588 rc.pprint,
589 input_sep = rc.separate_in,
589 input_sep = rc.separate_in,
590 output_sep = rc.separate_out,
590 output_sep = rc.separate_out,
591 output_sep2 = rc.separate_out2,
591 output_sep2 = rc.separate_out2,
592 ps1 = rc.prompt_in1,
592 ps1 = rc.prompt_in1,
593 ps2 = rc.prompt_in2,
593 ps2 = rc.prompt_in2,
594 ps_out = rc.prompt_out,
594 ps_out = rc.prompt_out,
595 pad_left = rc.prompts_pad_left)
595 pad_left = rc.prompts_pad_left)
596
596
597 # user may have over-ridden the default print hook:
597 # user may have over-ridden the default print hook:
598 try:
598 try:
599 self.outputcache.__class__.display = self.hooks.display
599 self.outputcache.__class__.display = self.hooks.display
600 except AttributeError:
600 except AttributeError:
601 pass
601 pass
602
602
603 # I don't like assigning globally to sys, because it means when embedding
603 # I don't like assigning globally to sys, because it means when embedding
604 # instances, each embedded instance overrides the previous choice. But
604 # instances, each embedded instance overrides the previous choice. But
605 # sys.displayhook seems to be called internally by exec, so I don't see a
605 # sys.displayhook seems to be called internally by exec, so I don't see a
606 # way around it.
606 # way around it.
607 sys.displayhook = self.outputcache
607 sys.displayhook = self.outputcache
608
608
609 # Set user colors (don't do it in the constructor above so that it
609 # Set user colors (don't do it in the constructor above so that it
610 # doesn't crash if colors option is invalid)
610 # doesn't crash if colors option is invalid)
611 self.magic_colors(rc.colors)
611 self.magic_colors(rc.colors)
612
612
613 # Set calling of pdb on exceptions
613 # Set calling of pdb on exceptions
614 self.call_pdb = rc.pdb
614 self.call_pdb = rc.pdb
615
615
616 # Load user aliases
616 # Load user aliases
617 for alias in rc.alias:
617 for alias in rc.alias:
618 self.magic_alias(alias)
618 self.magic_alias(alias)
619
619
620 # dynamic data that survives through sessions
620 # dynamic data that survives through sessions
621 # XXX make the filename a config option?
621 # XXX make the filename a config option?
622 persist_base = 'persist'
622 persist_base = 'persist'
623 if rc.profile:
623 if rc.profile:
624 persist_base += '_%s' % rc.profile
624 persist_base += '_%s' % rc.profile
625 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
625 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
626
626
627 try:
627 try:
628 self.persist = pickle.load(file(self.persist_fname))
628 self.persist = pickle.load(file(self.persist_fname))
629 except:
629 except:
630 self.persist = {}
630 self.persist = {}
631
631
632
632
633 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
633 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
634 try:
634 try:
635 obj = pickle.loads(value)
635 obj = pickle.loads(value)
636 except:
636 except:
637
637
638 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
638 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
639 print "The error was:",sys.exc_info()[0]
639 print "The error was:",sys.exc_info()[0]
640 continue
640 continue
641
641
642
642
643 self.user_ns[key] = obj
643 self.user_ns[key] = obj
644
644
645 def add_builtins(self):
645 def add_builtins(self):
646 """Store ipython references into the builtin namespace.
646 """Store ipython references into the builtin namespace.
647
647
648 Some parts of ipython operate via builtins injected here, which hold a
648 Some parts of ipython operate via builtins injected here, which hold a
649 reference to IPython itself."""
649 reference to IPython itself."""
650
650
651 builtins_new = dict(__IPYTHON__ = self,
651 builtins_new = dict(__IPYTHON__ = self,
652 ip_set_hook = self.set_hook,
652 ip_set_hook = self.set_hook,
653 jobs = self.jobs,
653 jobs = self.jobs,
654 ipmagic = self.ipmagic,
654 ipmagic = self.ipmagic,
655 ipalias = self.ipalias,
655 ipalias = self.ipalias,
656 ipsystem = self.ipsystem,
656 ipsystem = self.ipsystem,
657 )
657 )
658 for biname,bival in builtins_new.items():
658 for biname,bival in builtins_new.items():
659 try:
659 try:
660 # store the orignal value so we can restore it
660 # store the orignal value so we can restore it
661 self.builtins_added[biname] = __builtin__.__dict__[biname]
661 self.builtins_added[biname] = __builtin__.__dict__[biname]
662 except KeyError:
662 except KeyError:
663 # or mark that it wasn't defined, and we'll just delete it at
663 # or mark that it wasn't defined, and we'll just delete it at
664 # cleanup
664 # cleanup
665 self.builtins_added[biname] = Undefined
665 self.builtins_added[biname] = Undefined
666 __builtin__.__dict__[biname] = bival
666 __builtin__.__dict__[biname] = bival
667
667
668 # Keep in the builtins a flag for when IPython is active. We set it
668 # Keep in the builtins a flag for when IPython is active. We set it
669 # with setdefault so that multiple nested IPythons don't clobber one
669 # with setdefault so that multiple nested IPythons don't clobber one
670 # another. Each will increase its value by one upon being activated,
670 # another. Each will increase its value by one upon being activated,
671 # which also gives us a way to determine the nesting level.
671 # which also gives us a way to determine the nesting level.
672 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
672 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
673
673
674 def clean_builtins(self):
674 def clean_builtins(self):
675 """Remove any builtins which might have been added by add_builtins, or
675 """Remove any builtins which might have been added by add_builtins, or
676 restore overwritten ones to their previous values."""
676 restore overwritten ones to their previous values."""
677 for biname,bival in self.builtins_added.items():
677 for biname,bival in self.builtins_added.items():
678 if bival is Undefined:
678 if bival is Undefined:
679 del __builtin__.__dict__[biname]
679 del __builtin__.__dict__[biname]
680 else:
680 else:
681 __builtin__.__dict__[biname] = bival
681 __builtin__.__dict__[biname] = bival
682 self.builtins_added.clear()
682 self.builtins_added.clear()
683
683
684 def set_hook(self,name,hook):
684 def set_hook(self,name,hook):
685 """set_hook(name,hook) -> sets an internal IPython hook.
685 """set_hook(name,hook) -> sets an internal IPython hook.
686
686
687 IPython exposes some of its internal API as user-modifiable hooks. By
687 IPython exposes some of its internal API as user-modifiable hooks. By
688 resetting one of these hooks, you can modify IPython's behavior to
688 resetting one of these hooks, you can modify IPython's behavior to
689 call at runtime your own routines."""
689 call at runtime your own routines."""
690
690
691 # At some point in the future, this should validate the hook before it
691 # At some point in the future, this should validate the hook before it
692 # accepts it. Probably at least check that the hook takes the number
692 # accepts it. Probably at least check that the hook takes the number
693 # of args it's supposed to.
693 # of args it's supposed to.
694 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
694 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
695
695
696 def set_custom_exc(self,exc_tuple,handler):
696 def set_custom_exc(self,exc_tuple,handler):
697 """set_custom_exc(exc_tuple,handler)
697 """set_custom_exc(exc_tuple,handler)
698
698
699 Set a custom exception handler, which will be called if any of the
699 Set a custom exception handler, which will be called if any of the
700 exceptions in exc_tuple occur in the mainloop (specifically, in the
700 exceptions in exc_tuple occur in the mainloop (specifically, in the
701 runcode() method.
701 runcode() method.
702
702
703 Inputs:
703 Inputs:
704
704
705 - exc_tuple: a *tuple* of valid exceptions to call the defined
705 - exc_tuple: a *tuple* of valid exceptions to call the defined
706 handler for. It is very important that you use a tuple, and NOT A
706 handler for. It is very important that you use a tuple, and NOT A
707 LIST here, because of the way Python's except statement works. If
707 LIST here, because of the way Python's except statement works. If
708 you only want to trap a single exception, use a singleton tuple:
708 you only want to trap a single exception, use a singleton tuple:
709
709
710 exc_tuple == (MyCustomException,)
710 exc_tuple == (MyCustomException,)
711
711
712 - handler: this must be defined as a function with the following
712 - handler: this must be defined as a function with the following
713 basic interface: def my_handler(self,etype,value,tb).
713 basic interface: def my_handler(self,etype,value,tb).
714
714
715 This will be made into an instance method (via new.instancemethod)
715 This will be made into an instance method (via new.instancemethod)
716 of IPython itself, and it will be called if any of the exceptions
716 of IPython itself, and it will be called if any of the exceptions
717 listed in the exc_tuple are caught. If the handler is None, an
717 listed in the exc_tuple are caught. If the handler is None, an
718 internal basic one is used, which just prints basic info.
718 internal basic one is used, which just prints basic info.
719
719
720 WARNING: by putting in your own exception handler into IPython's main
720 WARNING: by putting in your own exception handler into IPython's main
721 execution loop, you run a very good chance of nasty crashes. This
721 execution loop, you run a very good chance of nasty crashes. This
722 facility should only be used if you really know what you are doing."""
722 facility should only be used if you really know what you are doing."""
723
723
724 assert type(exc_tuple)==type(()) , \
724 assert type(exc_tuple)==type(()) , \
725 "The custom exceptions must be given AS A TUPLE."
725 "The custom exceptions must be given AS A TUPLE."
726
726
727 def dummy_handler(self,etype,value,tb):
727 def dummy_handler(self,etype,value,tb):
728 print '*** Simple custom exception handler ***'
728 print '*** Simple custom exception handler ***'
729 print 'Exception type :',etype
729 print 'Exception type :',etype
730 print 'Exception value:',value
730 print 'Exception value:',value
731 print 'Traceback :',tb
731 print 'Traceback :',tb
732 print 'Source code :','\n'.join(self.buffer)
732 print 'Source code :','\n'.join(self.buffer)
733
733
734 if handler is None: handler = dummy_handler
734 if handler is None: handler = dummy_handler
735
735
736 self.CustomTB = new.instancemethod(handler,self,self.__class__)
736 self.CustomTB = new.instancemethod(handler,self,self.__class__)
737 self.custom_exceptions = exc_tuple
737 self.custom_exceptions = exc_tuple
738
738
739 def set_custom_completer(self,completer,pos=0):
739 def set_custom_completer(self,completer,pos=0):
740 """set_custom_completer(completer,pos=0)
740 """set_custom_completer(completer,pos=0)
741
741
742 Adds a new custom completer function.
742 Adds a new custom completer function.
743
743
744 The position argument (defaults to 0) is the index in the completers
744 The position argument (defaults to 0) is the index in the completers
745 list where you want the completer to be inserted."""
745 list where you want the completer to be inserted."""
746
746
747 newcomp = new.instancemethod(completer,self.Completer,
747 newcomp = new.instancemethod(completer,self.Completer,
748 self.Completer.__class__)
748 self.Completer.__class__)
749 self.Completer.matchers.insert(pos,newcomp)
749 self.Completer.matchers.insert(pos,newcomp)
750
750
751 def _get_call_pdb(self):
751 def _get_call_pdb(self):
752 return self._call_pdb
752 return self._call_pdb
753
753
754 def _set_call_pdb(self,val):
754 def _set_call_pdb(self,val):
755
755
756 if val not in (0,1,False,True):
756 if val not in (0,1,False,True):
757 raise ValueError,'new call_pdb value must be boolean'
757 raise ValueError,'new call_pdb value must be boolean'
758
758
759 # store value in instance
759 # store value in instance
760 self._call_pdb = val
760 self._call_pdb = val
761
761
762 # notify the actual exception handlers
762 # notify the actual exception handlers
763 self.InteractiveTB.call_pdb = val
763 self.InteractiveTB.call_pdb = val
764 if self.isthreaded:
764 if self.isthreaded:
765 try:
765 try:
766 self.sys_excepthook.call_pdb = val
766 self.sys_excepthook.call_pdb = val
767 except:
767 except:
768 warn('Failed to activate pdb for threaded exception handler')
768 warn('Failed to activate pdb for threaded exception handler')
769
769
770 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
770 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
771 'Control auto-activation of pdb at exceptions')
771 'Control auto-activation of pdb at exceptions')
772
772
773
773
774 # These special functions get installed in the builtin namespace, to
774 # These special functions get installed in the builtin namespace, to
775 # provide programmatic (pure python) access to magics, aliases and system
775 # provide programmatic (pure python) access to magics, aliases and system
776 # calls. This is important for logging, user scripting, and more.
776 # calls. This is important for logging, user scripting, and more.
777
777
778 # We are basically exposing, via normal python functions, the three
778 # We are basically exposing, via normal python functions, the three
779 # mechanisms in which ipython offers special call modes (magics for
779 # mechanisms in which ipython offers special call modes (magics for
780 # internal control, aliases for direct system access via pre-selected
780 # internal control, aliases for direct system access via pre-selected
781 # names, and !cmd for calling arbitrary system commands).
781 # names, and !cmd for calling arbitrary system commands).
782
782
783 def ipmagic(self,arg_s):
783 def ipmagic(self,arg_s):
784 """Call a magic function by name.
784 """Call a magic function by name.
785
785
786 Input: a string containing the name of the magic function to call and any
786 Input: a string containing the name of the magic function to call and any
787 additional arguments to be passed to the magic.
787 additional arguments to be passed to the magic.
788
788
789 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
789 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
790 prompt:
790 prompt:
791
791
792 In[1]: %name -opt foo bar
792 In[1]: %name -opt foo bar
793
793
794 To call a magic without arguments, simply use ipmagic('name').
794 To call a magic without arguments, simply use ipmagic('name').
795
795
796 This provides a proper Python function to call IPython's magics in any
796 This provides a proper Python function to call IPython's magics in any
797 valid Python code you can type at the interpreter, including loops and
797 valid Python code you can type at the interpreter, including loops and
798 compound statements. It is added by IPython to the Python builtin
798 compound statements. It is added by IPython to the Python builtin
799 namespace upon initialization."""
799 namespace upon initialization."""
800
800
801 args = arg_s.split(' ',1)
801 args = arg_s.split(' ',1)
802 magic_name = args[0]
802 magic_name = args[0]
803 if magic_name.startswith(self.ESC_MAGIC):
803 if magic_name.startswith(self.ESC_MAGIC):
804 magic_name = magic_name[1:]
804 magic_name = magic_name[1:]
805 try:
805 try:
806 magic_args = args[1]
806 magic_args = args[1]
807 except IndexError:
807 except IndexError:
808 magic_args = ''
808 magic_args = ''
809 fn = getattr(self,'magic_'+magic_name,None)
809 fn = getattr(self,'magic_'+magic_name,None)
810 if fn is None:
810 if fn is None:
811 error("Magic function `%s` not found." % magic_name)
811 error("Magic function `%s` not found." % magic_name)
812 else:
812 else:
813 magic_args = self.var_expand(magic_args)
813 magic_args = self.var_expand(magic_args)
814 return fn(magic_args)
814 return fn(magic_args)
815
815
816 def ipalias(self,arg_s):
816 def ipalias(self,arg_s):
817 """Call an alias by name.
817 """Call an alias by name.
818
818
819 Input: a string containing the name of the alias to call and any
819 Input: a string containing the name of the alias to call and any
820 additional arguments to be passed to the magic.
820 additional arguments to be passed to the magic.
821
821
822 ipalias('name -opt foo bar') is equivalent to typing at the ipython
822 ipalias('name -opt foo bar') is equivalent to typing at the ipython
823 prompt:
823 prompt:
824
824
825 In[1]: name -opt foo bar
825 In[1]: name -opt foo bar
826
826
827 To call an alias without arguments, simply use ipalias('name').
827 To call an alias without arguments, simply use ipalias('name').
828
828
829 This provides a proper Python function to call IPython's aliases in any
829 This provides a proper Python function to call IPython's aliases in any
830 valid Python code you can type at the interpreter, including loops and
830 valid Python code you can type at the interpreter, including loops and
831 compound statements. It is added by IPython to the Python builtin
831 compound statements. It is added by IPython to the Python builtin
832 namespace upon initialization."""
832 namespace upon initialization."""
833
833
834 args = arg_s.split(' ',1)
834 args = arg_s.split(' ',1)
835 alias_name = args[0]
835 alias_name = args[0]
836 try:
836 try:
837 alias_args = args[1]
837 alias_args = args[1]
838 except IndexError:
838 except IndexError:
839 alias_args = ''
839 alias_args = ''
840 if alias_name in self.alias_table:
840 if alias_name in self.alias_table:
841 self.call_alias(alias_name,alias_args)
841 self.call_alias(alias_name,alias_args)
842 else:
842 else:
843 error("Alias `%s` not found." % alias_name)
843 error("Alias `%s` not found." % alias_name)
844
844
845 def ipsystem(self,arg_s):
845 def ipsystem(self,arg_s):
846 """Make a system call, using IPython."""
846 """Make a system call, using IPython."""
847
847
848 self.system(arg_s)
848 self.system(arg_s)
849
849
850 def complete(self,text):
850 def complete(self,text):
851 """Return a sorted list of all possible completions on text.
851 """Return a sorted list of all possible completions on text.
852
852
853 Inputs:
853 Inputs:
854
854
855 - text: a string of text to be completed on.
855 - text: a string of text to be completed on.
856
856
857 This is a wrapper around the completion mechanism, similar to what
857 This is a wrapper around the completion mechanism, similar to what
858 readline does at the command line when the TAB key is hit. By
858 readline does at the command line when the TAB key is hit. By
859 exposing it as a method, it can be used by other non-readline
859 exposing it as a method, it can be used by other non-readline
860 environments (such as GUIs) for text completion.
860 environments (such as GUIs) for text completion.
861
861
862 Simple usage example:
862 Simple usage example:
863
863
864 In [1]: x = 'hello'
864 In [1]: x = 'hello'
865
865
866 In [2]: __IP.complete('x.l')
866 In [2]: __IP.complete('x.l')
867 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
867 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
868
868
869 complete = self.Completer.complete
869 complete = self.Completer.complete
870 state = 0
870 state = 0
871 # use a dict so we get unique keys, since ipyhton's multiple
871 # use a dict so we get unique keys, since ipyhton's multiple
872 # completers can return duplicates.
872 # completers can return duplicates.
873 comps = {}
873 comps = {}
874 while True:
874 while True:
875 newcomp = complete(text,state)
875 newcomp = complete(text,state)
876 if newcomp is None:
876 if newcomp is None:
877 break
877 break
878 comps[newcomp] = 1
878 comps[newcomp] = 1
879 state += 1
879 state += 1
880 outcomps = comps.keys()
880 outcomps = comps.keys()
881 outcomps.sort()
881 outcomps.sort()
882 return outcomps
882 return outcomps
883
883
884 def set_completer_frame(self, frame=None):
884 def set_completer_frame(self, frame=None):
885 if frame:
885 if frame:
886 self.Completer.namespace = frame.f_locals
886 self.Completer.namespace = frame.f_locals
887 self.Completer.global_namespace = frame.f_globals
887 self.Completer.global_namespace = frame.f_globals
888 else:
888 else:
889 self.Completer.namespace = self.user_ns
889 self.Completer.namespace = self.user_ns
890 self.Completer.global_namespace = self.user_global_ns
890 self.Completer.global_namespace = self.user_global_ns
891
891
892 def init_auto_alias(self):
892 def init_auto_alias(self):
893 """Define some aliases automatically.
893 """Define some aliases automatically.
894
894
895 These are ALL parameter-less aliases"""
895 These are ALL parameter-less aliases"""
896
896
897 for alias,cmd in self.auto_alias:
897 for alias,cmd in self.auto_alias:
898 self.alias_table[alias] = (0,cmd)
898 self.alias_table[alias] = (0,cmd)
899
899
900 def alias_table_validate(self,verbose=0):
900 def alias_table_validate(self,verbose=0):
901 """Update information about the alias table.
901 """Update information about the alias table.
902
902
903 In particular, make sure no Python keywords/builtins are in it."""
903 In particular, make sure no Python keywords/builtins are in it."""
904
904
905 no_alias = self.no_alias
905 no_alias = self.no_alias
906 for k in self.alias_table.keys():
906 for k in self.alias_table.keys():
907 if k in no_alias:
907 if k in no_alias:
908 del self.alias_table[k]
908 del self.alias_table[k]
909 if verbose:
909 if verbose:
910 print ("Deleting alias <%s>, it's a Python "
910 print ("Deleting alias <%s>, it's a Python "
911 "keyword or builtin." % k)
911 "keyword or builtin." % k)
912
912
913 def set_autoindent(self,value=None):
913 def set_autoindent(self,value=None):
914 """Set the autoindent flag, checking for readline support.
914 """Set the autoindent flag, checking for readline support.
915
915
916 If called with no arguments, it acts as a toggle."""
916 If called with no arguments, it acts as a toggle."""
917
917
918 if not self.has_readline:
918 if not self.has_readline:
919 if os.name == 'posix':
919 if os.name == 'posix':
920 warn("The auto-indent feature requires the readline library")
920 warn("The auto-indent feature requires the readline library")
921 self.autoindent = 0
921 self.autoindent = 0
922 return
922 return
923 if value is None:
923 if value is None:
924 self.autoindent = not self.autoindent
924 self.autoindent = not self.autoindent
925 else:
925 else:
926 self.autoindent = value
926 self.autoindent = value
927
927
928 def rc_set_toggle(self,rc_field,value=None):
928 def rc_set_toggle(self,rc_field,value=None):
929 """Set or toggle a field in IPython's rc config. structure.
929 """Set or toggle a field in IPython's rc config. structure.
930
930
931 If called with no arguments, it acts as a toggle.
931 If called with no arguments, it acts as a toggle.
932
932
933 If called with a non-existent field, the resulting AttributeError
933 If called with a non-existent field, the resulting AttributeError
934 exception will propagate out."""
934 exception will propagate out."""
935
935
936 rc_val = getattr(self.rc,rc_field)
936 rc_val = getattr(self.rc,rc_field)
937 if value is None:
937 if value is None:
938 value = not rc_val
938 value = not rc_val
939 setattr(self.rc,rc_field,value)
939 setattr(self.rc,rc_field,value)
940
940
941 def user_setup(self,ipythondir,rc_suffix,mode='install'):
941 def user_setup(self,ipythondir,rc_suffix,mode='install'):
942 """Install the user configuration directory.
942 """Install the user configuration directory.
943
943
944 Can be called when running for the first time or to upgrade the user's
944 Can be called when running for the first time or to upgrade the user's
945 .ipython/ directory with the mode parameter. Valid modes are 'install'
945 .ipython/ directory with the mode parameter. Valid modes are 'install'
946 and 'upgrade'."""
946 and 'upgrade'."""
947
947
948 def wait():
948 def wait():
949 try:
949 try:
950 raw_input("Please press <RETURN> to start IPython.")
950 raw_input("Please press <RETURN> to start IPython.")
951 except EOFError:
951 except EOFError:
952 print >> Term.cout
952 print >> Term.cout
953 print '*'*70
953 print '*'*70
954
954
955 cwd = os.getcwd() # remember where we started
955 cwd = os.getcwd() # remember where we started
956 glb = glob.glob
956 glb = glob.glob
957 print '*'*70
957 print '*'*70
958 if mode == 'install':
958 if mode == 'install':
959 print \
959 print \
960 """Welcome to IPython. I will try to create a personal configuration directory
960 """Welcome to IPython. I will try to create a personal configuration directory
961 where you can customize many aspects of IPython's functionality in:\n"""
961 where you can customize many aspects of IPython's functionality in:\n"""
962 else:
962 else:
963 print 'I am going to upgrade your configuration in:'
963 print 'I am going to upgrade your configuration in:'
964
964
965 print ipythondir
965 print ipythondir
966
966
967 rcdirend = os.path.join('IPython','UserConfig')
967 rcdirend = os.path.join('IPython','UserConfig')
968 cfg = lambda d: os.path.join(d,rcdirend)
968 cfg = lambda d: os.path.join(d,rcdirend)
969 try:
969 try:
970 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
970 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
971 except IOError:
971 except IOError:
972 warning = """
972 warning = """
973 Installation error. IPython's directory was not found.
973 Installation error. IPython's directory was not found.
974
974
975 Check the following:
975 Check the following:
976
976
977 The ipython/IPython directory should be in a directory belonging to your
977 The ipython/IPython directory should be in a directory belonging to your
978 PYTHONPATH environment variable (that is, it should be in a directory
978 PYTHONPATH environment variable (that is, it should be in a directory
979 belonging to sys.path). You can copy it explicitly there or just link to it.
979 belonging to sys.path). You can copy it explicitly there or just link to it.
980
980
981 IPython will proceed with builtin defaults.
981 IPython will proceed with builtin defaults.
982 """
982 """
983 warn(warning)
983 warn(warning)
984 wait()
984 wait()
985 return
985 return
986
986
987 if mode == 'install':
987 if mode == 'install':
988 try:
988 try:
989 shutil.copytree(rcdir,ipythondir)
989 shutil.copytree(rcdir,ipythondir)
990 os.chdir(ipythondir)
990 os.chdir(ipythondir)
991 rc_files = glb("ipythonrc*")
991 rc_files = glb("ipythonrc*")
992 for rc_file in rc_files:
992 for rc_file in rc_files:
993 os.rename(rc_file,rc_file+rc_suffix)
993 os.rename(rc_file,rc_file+rc_suffix)
994 except:
994 except:
995 warning = """
995 warning = """
996
996
997 There was a problem with the installation:
997 There was a problem with the installation:
998 %s
998 %s
999 Try to correct it or contact the developers if you think it's a bug.
999 Try to correct it or contact the developers if you think it's a bug.
1000 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1000 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1001 warn(warning)
1001 warn(warning)
1002 wait()
1002 wait()
1003 return
1003 return
1004
1004
1005 elif mode == 'upgrade':
1005 elif mode == 'upgrade':
1006 try:
1006 try:
1007 os.chdir(ipythondir)
1007 os.chdir(ipythondir)
1008 except:
1008 except:
1009 print """
1009 print """
1010 Can not upgrade: changing to directory %s failed. Details:
1010 Can not upgrade: changing to directory %s failed. Details:
1011 %s
1011 %s
1012 """ % (ipythondir,sys.exc_info()[1])
1012 """ % (ipythondir,sys.exc_info()[1])
1013 wait()
1013 wait()
1014 return
1014 return
1015 else:
1015 else:
1016 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1016 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1017 for new_full_path in sources:
1017 for new_full_path in sources:
1018 new_filename = os.path.basename(new_full_path)
1018 new_filename = os.path.basename(new_full_path)
1019 if new_filename.startswith('ipythonrc'):
1019 if new_filename.startswith('ipythonrc'):
1020 new_filename = new_filename + rc_suffix
1020 new_filename = new_filename + rc_suffix
1021 # The config directory should only contain files, skip any
1021 # The config directory should only contain files, skip any
1022 # directories which may be there (like CVS)
1022 # directories which may be there (like CVS)
1023 if os.path.isdir(new_full_path):
1023 if os.path.isdir(new_full_path):
1024 continue
1024 continue
1025 if os.path.exists(new_filename):
1025 if os.path.exists(new_filename):
1026 old_file = new_filename+'.old'
1026 old_file = new_filename+'.old'
1027 if os.path.exists(old_file):
1027 if os.path.exists(old_file):
1028 os.remove(old_file)
1028 os.remove(old_file)
1029 os.rename(new_filename,old_file)
1029 os.rename(new_filename,old_file)
1030 shutil.copy(new_full_path,new_filename)
1030 shutil.copy(new_full_path,new_filename)
1031 else:
1031 else:
1032 raise ValueError,'unrecognized mode for install:',`mode`
1032 raise ValueError,'unrecognized mode for install:',`mode`
1033
1033
1034 # Fix line-endings to those native to each platform in the config
1034 # Fix line-endings to those native to each platform in the config
1035 # directory.
1035 # directory.
1036 try:
1036 try:
1037 os.chdir(ipythondir)
1037 os.chdir(ipythondir)
1038 except:
1038 except:
1039 print """
1039 print """
1040 Problem: changing to directory %s failed.
1040 Problem: changing to directory %s failed.
1041 Details:
1041 Details:
1042 %s
1042 %s
1043
1043
1044 Some configuration files may have incorrect line endings. This should not
1044 Some configuration files may have incorrect line endings. This should not
1045 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1045 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1046 wait()
1046 wait()
1047 else:
1047 else:
1048 for fname in glb('ipythonrc*'):
1048 for fname in glb('ipythonrc*'):
1049 try:
1049 try:
1050 native_line_ends(fname,backup=0)
1050 native_line_ends(fname,backup=0)
1051 except IOError:
1051 except IOError:
1052 pass
1052 pass
1053
1053
1054 if mode == 'install':
1054 if mode == 'install':
1055 print """
1055 print """
1056 Successful installation!
1056 Successful installation!
1057
1057
1058 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1058 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1059 IPython manual (there are both HTML and PDF versions supplied with the
1059 IPython manual (there are both HTML and PDF versions supplied with the
1060 distribution) to make sure that your system environment is properly configured
1060 distribution) to make sure that your system environment is properly configured
1061 to take advantage of IPython's features."""
1061 to take advantage of IPython's features."""
1062 else:
1062 else:
1063 print """
1063 print """
1064 Successful upgrade!
1064 Successful upgrade!
1065
1065
1066 All files in your directory:
1066 All files in your directory:
1067 %(ipythondir)s
1067 %(ipythondir)s
1068 which would have been overwritten by the upgrade were backed up with a .old
1068 which would have been overwritten by the upgrade were backed up with a .old
1069 extension. If you had made particular customizations in those files you may
1069 extension. If you had made particular customizations in those files you may
1070 want to merge them back into the new files.""" % locals()
1070 want to merge them back into the new files.""" % locals()
1071 wait()
1071 wait()
1072 os.chdir(cwd)
1072 os.chdir(cwd)
1073 # end user_setup()
1073 # end user_setup()
1074
1074
1075 def atexit_operations(self):
1075 def atexit_operations(self):
1076 """This will be executed at the time of exit.
1076 """This will be executed at the time of exit.
1077
1077
1078 Saving of persistent data should be performed here. """
1078 Saving of persistent data should be performed here. """
1079
1079
1080 # input history
1080 # input history
1081 self.savehist()
1081 self.savehist()
1082
1082
1083 # Cleanup all tempfiles left around
1083 # Cleanup all tempfiles left around
1084 for tfile in self.tempfiles:
1084 for tfile in self.tempfiles:
1085 try:
1085 try:
1086 os.unlink(tfile)
1086 os.unlink(tfile)
1087 except OSError:
1087 except OSError:
1088 pass
1088 pass
1089
1089
1090 # save the "persistent data" catch-all dictionary
1090 # save the "persistent data" catch-all dictionary
1091 try:
1091 try:
1092 pickle.dump(self.persist, open(self.persist_fname,"w"))
1092 pickle.dump(self.persist, open(self.persist_fname,"w"))
1093 except:
1093 except:
1094 print "*** ERROR *** persistent data saving failed."
1094 print "*** ERROR *** persistent data saving failed."
1095
1095
1096 def savehist(self):
1096 def savehist(self):
1097 """Save input history to a file (via readline library)."""
1097 """Save input history to a file (via readline library)."""
1098 try:
1098 try:
1099 self.readline.write_history_file(self.histfile)
1099 self.readline.write_history_file(self.histfile)
1100 except:
1100 except:
1101 print 'Unable to save IPython command history to file: ' + \
1101 print 'Unable to save IPython command history to file: ' + \
1102 `self.histfile`
1102 `self.histfile`
1103
1103
1104 def pre_readline(self):
1104 def pre_readline(self):
1105 """readline hook to be used at the start of each line.
1105 """readline hook to be used at the start of each line.
1106
1106
1107 Currently it handles auto-indent only."""
1107 Currently it handles auto-indent only."""
1108
1108
1109 self.readline.insert_text(self.indent_current)
1109 self.readline.insert_text(self.indent_current)
1110
1110
1111 def init_readline(self):
1111 def init_readline(self):
1112 """Command history completion/saving/reloading."""
1112 """Command history completion/saving/reloading."""
1113 try:
1113 try:
1114 import readline
1114 import readline
1115 except ImportError:
1115 except ImportError:
1116 self.has_readline = 0
1116 self.has_readline = 0
1117 self.readline = None
1117 self.readline = None
1118 # no point in bugging windows users with this every time:
1118 # no point in bugging windows users with this every time:
1119 if os.name == 'posix':
1119 if os.name == 'posix':
1120 warn('Readline services not available on this platform.')
1120 warn('Readline services not available on this platform.')
1121 else:
1121 else:
1122 import atexit
1122 import atexit
1123 from IPython.completer import IPCompleter
1123 from IPython.completer import IPCompleter
1124 self.Completer = IPCompleter(self,
1124 self.Completer = IPCompleter(self,
1125 self.user_ns,
1125 self.user_ns,
1126 self.user_global_ns,
1126 self.user_global_ns,
1127 self.rc.readline_omit__names,
1127 self.rc.readline_omit__names,
1128 self.alias_table)
1128 self.alias_table)
1129
1129
1130 # Platform-specific configuration
1130 # Platform-specific configuration
1131 if os.name == 'nt':
1131 if os.name == 'nt':
1132 self.readline_startup_hook = readline.set_pre_input_hook
1132 self.readline_startup_hook = readline.set_pre_input_hook
1133 else:
1133 else:
1134 self.readline_startup_hook = readline.set_startup_hook
1134 self.readline_startup_hook = readline.set_startup_hook
1135
1135
1136 # Load user's initrc file (readline config)
1136 # Load user's initrc file (readline config)
1137 inputrc_name = os.environ.get('INPUTRC')
1137 inputrc_name = os.environ.get('INPUTRC')
1138 if inputrc_name is None:
1138 if inputrc_name is None:
1139 home_dir = get_home_dir()
1139 home_dir = get_home_dir()
1140 if home_dir is not None:
1140 if home_dir is not None:
1141 inputrc_name = os.path.join(home_dir,'.inputrc')
1141 inputrc_name = os.path.join(home_dir,'.inputrc')
1142 if os.path.isfile(inputrc_name):
1142 if os.path.isfile(inputrc_name):
1143 try:
1143 try:
1144 readline.read_init_file(inputrc_name)
1144 readline.read_init_file(inputrc_name)
1145 except:
1145 except:
1146 warn('Problems reading readline initialization file <%s>'
1146 warn('Problems reading readline initialization file <%s>'
1147 % inputrc_name)
1147 % inputrc_name)
1148
1148
1149 self.has_readline = 1
1149 self.has_readline = 1
1150 self.readline = readline
1150 self.readline = readline
1151 # save this in sys so embedded copies can restore it properly
1151 # save this in sys so embedded copies can restore it properly
1152 sys.ipcompleter = self.Completer.complete
1152 sys.ipcompleter = self.Completer.complete
1153 readline.set_completer(self.Completer.complete)
1153 readline.set_completer(self.Completer.complete)
1154
1154
1155 # Configure readline according to user's prefs
1155 # Configure readline according to user's prefs
1156 for rlcommand in self.rc.readline_parse_and_bind:
1156 for rlcommand in self.rc.readline_parse_and_bind:
1157 readline.parse_and_bind(rlcommand)
1157 readline.parse_and_bind(rlcommand)
1158
1158
1159 # remove some chars from the delimiters list
1159 # remove some chars from the delimiters list
1160 delims = readline.get_completer_delims()
1160 delims = readline.get_completer_delims()
1161 delims = delims.translate(string._idmap,
1161 delims = delims.translate(string._idmap,
1162 self.rc.readline_remove_delims)
1162 self.rc.readline_remove_delims)
1163 readline.set_completer_delims(delims)
1163 readline.set_completer_delims(delims)
1164 # otherwise we end up with a monster history after a while:
1164 # otherwise we end up with a monster history after a while:
1165 readline.set_history_length(1000)
1165 readline.set_history_length(1000)
1166 try:
1166 try:
1167 #print '*** Reading readline history' # dbg
1167 #print '*** Reading readline history' # dbg
1168 readline.read_history_file(self.histfile)
1168 readline.read_history_file(self.histfile)
1169 except IOError:
1169 except IOError:
1170 pass # It doesn't exist yet.
1170 pass # It doesn't exist yet.
1171
1171
1172 atexit.register(self.atexit_operations)
1172 atexit.register(self.atexit_operations)
1173 del atexit
1173 del atexit
1174
1174
1175 # Configure auto-indent for all platforms
1175 # Configure auto-indent for all platforms
1176 self.set_autoindent(self.rc.autoindent)
1176 self.set_autoindent(self.rc.autoindent)
1177
1177
1178 def _should_recompile(self,e):
1178 def _should_recompile(self,e):
1179 """Utility routine for edit_syntax_error"""
1179 """Utility routine for edit_syntax_error"""
1180
1180
1181 if e.filename in ('<ipython console>','<input>','<string>',
1181 if e.filename in ('<ipython console>','<input>','<string>',
1182 '<console>'):
1182 '<console>',None):
1183 return False
1183 return False
1184 try:
1184 try:
1185 if not ask_yes_no('Return to editor to correct syntax error? '
1185 if not ask_yes_no('Return to editor to correct syntax error? '
1186 '[Y/n] ','y'):
1186 '[Y/n] ','y'):
1187 return False
1187 return False
1188 except EOFError:
1188 except EOFError:
1189 return False
1189 return False
1190
1190
1191 def int0(x):
1191 def int0(x):
1192 try:
1192 try:
1193 return int(x)
1193 return int(x)
1194 except TypeError:
1194 except TypeError:
1195 return 0
1195 return 0
1196 # always pass integer line and offset values to editor hook
1196 # always pass integer line and offset values to editor hook
1197 self.hooks.fix_error_editor(e.filename,
1197 self.hooks.fix_error_editor(e.filename,
1198 int0(e.lineno),int0(e.offset),e.msg)
1198 int0(e.lineno),int0(e.offset),e.msg)
1199 return True
1199 return True
1200
1200
1201 def edit_syntax_error(self):
1201 def edit_syntax_error(self):
1202 """The bottom half of the syntax error handler called in the main loop.
1202 """The bottom half of the syntax error handler called in the main loop.
1203
1203
1204 Loop until syntax error is fixed or user cancels.
1204 Loop until syntax error is fixed or user cancels.
1205 """
1205 """
1206
1206
1207 while self.SyntaxTB.last_syntax_error:
1207 while self.SyntaxTB.last_syntax_error:
1208 # copy and clear last_syntax_error
1208 # copy and clear last_syntax_error
1209 err = self.SyntaxTB.clear_err_state()
1209 err = self.SyntaxTB.clear_err_state()
1210 if not self._should_recompile(err):
1210 if not self._should_recompile(err):
1211 return
1211 return
1212 try:
1212 try:
1213 # may set last_syntax_error again if a SyntaxError is raised
1213 # may set last_syntax_error again if a SyntaxError is raised
1214 self.safe_execfile(err.filename,self.shell.user_ns)
1214 self.safe_execfile(err.filename,self.shell.user_ns)
1215 except:
1215 except:
1216 self.showtraceback()
1216 self.showtraceback()
1217 else:
1217 else:
1218 f = file(err.filename)
1218 f = file(err.filename)
1219 try:
1219 try:
1220 sys.displayhook(f.read())
1220 sys.displayhook(f.read())
1221 finally:
1221 finally:
1222 f.close()
1222 f.close()
1223
1223
1224 def showsyntaxerror(self, filename=None):
1224 def showsyntaxerror(self, filename=None):
1225 """Display the syntax error that just occurred.
1225 """Display the syntax error that just occurred.
1226
1226
1227 This doesn't display a stack trace because there isn't one.
1227 This doesn't display a stack trace because there isn't one.
1228
1228
1229 If a filename is given, it is stuffed in the exception instead
1229 If a filename is given, it is stuffed in the exception instead
1230 of what was there before (because Python's parser always uses
1230 of what was there before (because Python's parser always uses
1231 "<string>" when reading from a string).
1231 "<string>" when reading from a string).
1232 """
1232 """
1233 etype, value, last_traceback = sys.exc_info()
1233 etype, value, last_traceback = sys.exc_info()
1234 if filename and etype is SyntaxError:
1234 if filename and etype is SyntaxError:
1235 # Work hard to stuff the correct filename in the exception
1235 # Work hard to stuff the correct filename in the exception
1236 try:
1236 try:
1237 msg, (dummy_filename, lineno, offset, line) = value
1237 msg, (dummy_filename, lineno, offset, line) = value
1238 except:
1238 except:
1239 # Not the format we expect; leave it alone
1239 # Not the format we expect; leave it alone
1240 pass
1240 pass
1241 else:
1241 else:
1242 # Stuff in the right filename
1242 # Stuff in the right filename
1243 try:
1243 try:
1244 # Assume SyntaxError is a class exception
1244 # Assume SyntaxError is a class exception
1245 value = SyntaxError(msg, (filename, lineno, offset, line))
1245 value = SyntaxError(msg, (filename, lineno, offset, line))
1246 except:
1246 except:
1247 # If that failed, assume SyntaxError is a string
1247 # If that failed, assume SyntaxError is a string
1248 value = msg, (filename, lineno, offset, line)
1248 value = msg, (filename, lineno, offset, line)
1249 self.SyntaxTB(etype,value,[])
1249 self.SyntaxTB(etype,value,[])
1250
1250
1251 def debugger(self):
1251 def debugger(self):
1252 """Call the pdb debugger."""
1252 """Call the pdb debugger."""
1253
1253
1254 if not self.rc.pdb:
1254 if not self.rc.pdb:
1255 return
1255 return
1256 pdb.pm()
1256 pdb.pm()
1257
1257
1258 def showtraceback(self,exc_tuple = None,filename=None):
1258 def showtraceback(self,exc_tuple = None,filename=None):
1259 """Display the exception that just occurred."""
1259 """Display the exception that just occurred."""
1260
1260
1261 # Though this won't be called by syntax errors in the input line,
1261 # Though this won't be called by syntax errors in the input line,
1262 # there may be SyntaxError cases whith imported code.
1262 # there may be SyntaxError cases whith imported code.
1263 if exc_tuple is None:
1263 if exc_tuple is None:
1264 type, value, tb = sys.exc_info()
1264 type, value, tb = sys.exc_info()
1265 else:
1265 else:
1266 type, value, tb = exc_tuple
1266 type, value, tb = exc_tuple
1267 if type is SyntaxError:
1267 if type is SyntaxError:
1268 self.showsyntaxerror(filename)
1268 self.showsyntaxerror(filename)
1269 else:
1269 else:
1270 self.InteractiveTB()
1270 self.InteractiveTB()
1271 if self.InteractiveTB.call_pdb and self.has_readline:
1271 if self.InteractiveTB.call_pdb and self.has_readline:
1272 # pdb mucks up readline, fix it back
1272 # pdb mucks up readline, fix it back
1273 self.readline.set_completer(self.Completer.complete)
1273 self.readline.set_completer(self.Completer.complete)
1274
1274
1275 def mainloop(self,banner=None):
1275 def mainloop(self,banner=None):
1276 """Creates the local namespace and starts the mainloop.
1276 """Creates the local namespace and starts the mainloop.
1277
1277
1278 If an optional banner argument is given, it will override the
1278 If an optional banner argument is given, it will override the
1279 internally created default banner."""
1279 internally created default banner."""
1280
1280
1281 if self.rc.c: # Emulate Python's -c option
1281 if self.rc.c: # Emulate Python's -c option
1282 self.exec_init_cmd()
1282 self.exec_init_cmd()
1283 if banner is None:
1283 if banner is None:
1284 if self.rc.banner:
1284 if self.rc.banner:
1285 banner = self.BANNER+self.banner2
1285 banner = self.BANNER+self.banner2
1286 else:
1286 else:
1287 banner = ''
1287 banner = ''
1288 self.interact(banner)
1288 self.interact(banner)
1289
1289
1290 def exec_init_cmd(self):
1290 def exec_init_cmd(self):
1291 """Execute a command given at the command line.
1291 """Execute a command given at the command line.
1292
1292
1293 This emulates Python's -c option."""
1293 This emulates Python's -c option."""
1294
1294
1295 sys.argv = ['-c']
1295 sys.argv = ['-c']
1296 self.push(self.rc.c)
1296 self.push(self.rc.c)
1297
1297
1298 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1298 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1299 """Embeds IPython into a running python program.
1299 """Embeds IPython into a running python program.
1300
1300
1301 Input:
1301 Input:
1302
1302
1303 - header: An optional header message can be specified.
1303 - header: An optional header message can be specified.
1304
1304
1305 - local_ns, global_ns: working namespaces. If given as None, the
1305 - local_ns, global_ns: working namespaces. If given as None, the
1306 IPython-initialized one is updated with __main__.__dict__, so that
1306 IPython-initialized one is updated with __main__.__dict__, so that
1307 program variables become visible but user-specific configuration
1307 program variables become visible but user-specific configuration
1308 remains possible.
1308 remains possible.
1309
1309
1310 - stack_depth: specifies how many levels in the stack to go to
1310 - stack_depth: specifies how many levels in the stack to go to
1311 looking for namespaces (when local_ns and global_ns are None). This
1311 looking for namespaces (when local_ns and global_ns are None). This
1312 allows an intermediate caller to make sure that this function gets
1312 allows an intermediate caller to make sure that this function gets
1313 the namespace from the intended level in the stack. By default (0)
1313 the namespace from the intended level in the stack. By default (0)
1314 it will get its locals and globals from the immediate caller.
1314 it will get its locals and globals from the immediate caller.
1315
1315
1316 Warning: it's possible to use this in a program which is being run by
1316 Warning: it's possible to use this in a program which is being run by
1317 IPython itself (via %run), but some funny things will happen (a few
1317 IPython itself (via %run), but some funny things will happen (a few
1318 globals get overwritten). In the future this will be cleaned up, as
1318 globals get overwritten). In the future this will be cleaned up, as
1319 there is no fundamental reason why it can't work perfectly."""
1319 there is no fundamental reason why it can't work perfectly."""
1320
1320
1321 # Get locals and globals from caller
1321 # Get locals and globals from caller
1322 if local_ns is None or global_ns is None:
1322 if local_ns is None or global_ns is None:
1323 call_frame = sys._getframe(stack_depth).f_back
1323 call_frame = sys._getframe(stack_depth).f_back
1324
1324
1325 if local_ns is None:
1325 if local_ns is None:
1326 local_ns = call_frame.f_locals
1326 local_ns = call_frame.f_locals
1327 if global_ns is None:
1327 if global_ns is None:
1328 global_ns = call_frame.f_globals
1328 global_ns = call_frame.f_globals
1329
1329
1330 # Update namespaces and fire up interpreter
1330 # Update namespaces and fire up interpreter
1331
1331
1332 # The global one is easy, we can just throw it in
1332 # The global one is easy, we can just throw it in
1333 self.user_global_ns = global_ns
1333 self.user_global_ns = global_ns
1334
1334
1335 # but the user/local one is tricky: ipython needs it to store internal
1335 # but the user/local one is tricky: ipython needs it to store internal
1336 # data, but we also need the locals. We'll copy locals in the user
1336 # data, but we also need the locals. We'll copy locals in the user
1337 # one, but will track what got copied so we can delete them at exit.
1337 # one, but will track what got copied so we can delete them at exit.
1338 # This is so that a later embedded call doesn't see locals from a
1338 # This is so that a later embedded call doesn't see locals from a
1339 # previous call (which most likely existed in a separate scope).
1339 # previous call (which most likely existed in a separate scope).
1340 local_varnames = local_ns.keys()
1340 local_varnames = local_ns.keys()
1341 self.user_ns.update(local_ns)
1341 self.user_ns.update(local_ns)
1342
1342
1343 # Patch for global embedding to make sure that things don't overwrite
1343 # Patch for global embedding to make sure that things don't overwrite
1344 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1344 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1345 # FIXME. Test this a bit more carefully (the if.. is new)
1345 # FIXME. Test this a bit more carefully (the if.. is new)
1346 if local_ns is None and global_ns is None:
1346 if local_ns is None and global_ns is None:
1347 self.user_global_ns.update(__main__.__dict__)
1347 self.user_global_ns.update(__main__.__dict__)
1348
1348
1349 # make sure the tab-completer has the correct frame information, so it
1349 # make sure the tab-completer has the correct frame information, so it
1350 # actually completes using the frame's locals/globals
1350 # actually completes using the frame's locals/globals
1351 self.set_completer_frame()
1351 self.set_completer_frame()
1352
1352
1353 # before activating the interactive mode, we need to make sure that
1353 # before activating the interactive mode, we need to make sure that
1354 # all names in the builtin namespace needed by ipython point to
1354 # all names in the builtin namespace needed by ipython point to
1355 # ourselves, and not to other instances.
1355 # ourselves, and not to other instances.
1356 self.add_builtins()
1356 self.add_builtins()
1357
1357
1358 self.interact(header)
1358 self.interact(header)
1359
1359
1360 # now, purge out the user namespace from anything we might have added
1360 # now, purge out the user namespace from anything we might have added
1361 # from the caller's local namespace
1361 # from the caller's local namespace
1362 delvar = self.user_ns.pop
1362 delvar = self.user_ns.pop
1363 for var in local_varnames:
1363 for var in local_varnames:
1364 delvar(var,None)
1364 delvar(var,None)
1365 # and clean builtins we may have overridden
1365 # and clean builtins we may have overridden
1366 self.clean_builtins()
1366 self.clean_builtins()
1367
1367
1368 def interact(self, banner=None):
1368 def interact(self, banner=None):
1369 """Closely emulate the interactive Python console.
1369 """Closely emulate the interactive Python console.
1370
1370
1371 The optional banner argument specify the banner to print
1371 The optional banner argument specify the banner to print
1372 before the first interaction; by default it prints a banner
1372 before the first interaction; by default it prints a banner
1373 similar to the one printed by the real Python interpreter,
1373 similar to the one printed by the real Python interpreter,
1374 followed by the current class name in parentheses (so as not
1374 followed by the current class name in parentheses (so as not
1375 to confuse this with the real interpreter -- since it's so
1375 to confuse this with the real interpreter -- since it's so
1376 close!).
1376 close!).
1377
1377
1378 """
1378 """
1379 cprt = 'Type "copyright", "credits" or "license" for more information.'
1379 cprt = 'Type "copyright", "credits" or "license" for more information.'
1380 if banner is None:
1380 if banner is None:
1381 self.write("Python %s on %s\n%s\n(%s)\n" %
1381 self.write("Python %s on %s\n%s\n(%s)\n" %
1382 (sys.version, sys.platform, cprt,
1382 (sys.version, sys.platform, cprt,
1383 self.__class__.__name__))
1383 self.__class__.__name__))
1384 else:
1384 else:
1385 self.write(banner)
1385 self.write(banner)
1386
1386
1387 more = 0
1387 more = 0
1388
1388
1389 # Mark activity in the builtins
1389 # Mark activity in the builtins
1390 __builtin__.__dict__['__IPYTHON__active'] += 1
1390 __builtin__.__dict__['__IPYTHON__active'] += 1
1391
1391
1392 # exit_now is set by a call to %Exit or %Quit
1392 # exit_now is set by a call to %Exit or %Quit
1393 self.exit_now = False
1393 self.exit_now = False
1394 while not self.exit_now:
1394 while not self.exit_now:
1395
1395
1396 try:
1396 try:
1397 if more:
1397 if more:
1398 prompt = self.outputcache.prompt2
1398 prompt = self.outputcache.prompt2
1399 if self.autoindent:
1399 if self.autoindent:
1400 self.readline_startup_hook(self.pre_readline)
1400 self.readline_startup_hook(self.pre_readline)
1401 else:
1401 else:
1402 prompt = self.outputcache.prompt1
1402 prompt = self.outputcache.prompt1
1403 try:
1403 try:
1404 line = self.raw_input(prompt,more)
1404 line = self.raw_input(prompt,more)
1405 if self.autoindent:
1405 if self.autoindent:
1406 self.readline_startup_hook(None)
1406 self.readline_startup_hook(None)
1407 except EOFError:
1407 except EOFError:
1408 if self.autoindent:
1408 if self.autoindent:
1409 self.readline_startup_hook(None)
1409 self.readline_startup_hook(None)
1410 self.write("\n")
1410 self.write("\n")
1411 self.exit()
1411 self.exit()
1412 else:
1412 else:
1413 more = self.push(line)
1413 more = self.push(line)
1414
1414
1415 if (self.SyntaxTB.last_syntax_error and
1415 if (self.SyntaxTB.last_syntax_error and
1416 self.rc.autoedit_syntax):
1416 self.rc.autoedit_syntax):
1417 self.edit_syntax_error()
1417 self.edit_syntax_error()
1418
1418
1419 except KeyboardInterrupt:
1419 except KeyboardInterrupt:
1420 self.write("\nKeyboardInterrupt\n")
1420 self.write("\nKeyboardInterrupt\n")
1421 self.resetbuffer()
1421 self.resetbuffer()
1422 more = 0
1422 more = 0
1423 # keep cache in sync with the prompt counter:
1423 # keep cache in sync with the prompt counter:
1424 self.outputcache.prompt_count -= 1
1424 self.outputcache.prompt_count -= 1
1425
1425
1426 if self.autoindent:
1426 if self.autoindent:
1427 self.indent_current_nsp = 0
1427 self.indent_current_nsp = 0
1428 self.indent_current = ' '* self.indent_current_nsp
1428 self.indent_current = ' '* self.indent_current_nsp
1429
1429
1430 except bdb.BdbQuit:
1430 except bdb.BdbQuit:
1431 warn("The Python debugger has exited with a BdbQuit exception.\n"
1431 warn("The Python debugger has exited with a BdbQuit exception.\n"
1432 "Because of how pdb handles the stack, it is impossible\n"
1432 "Because of how pdb handles the stack, it is impossible\n"
1433 "for IPython to properly format this particular exception.\n"
1433 "for IPython to properly format this particular exception.\n"
1434 "IPython will resume normal operation.")
1434 "IPython will resume normal operation.")
1435
1435
1436 # We are off again...
1436 # We are off again...
1437 __builtin__.__dict__['__IPYTHON__active'] -= 1
1437 __builtin__.__dict__['__IPYTHON__active'] -= 1
1438
1438
1439 def excepthook(self, type, value, tb):
1439 def excepthook(self, type, value, tb):
1440 """One more defense for GUI apps that call sys.excepthook.
1440 """One more defense for GUI apps that call sys.excepthook.
1441
1441
1442 GUI frameworks like wxPython trap exceptions and call
1442 GUI frameworks like wxPython trap exceptions and call
1443 sys.excepthook themselves. I guess this is a feature that
1443 sys.excepthook themselves. I guess this is a feature that
1444 enables them to keep running after exceptions that would
1444 enables them to keep running after exceptions that would
1445 otherwise kill their mainloop. This is a bother for IPython
1445 otherwise kill their mainloop. This is a bother for IPython
1446 which excepts to catch all of the program exceptions with a try:
1446 which excepts to catch all of the program exceptions with a try:
1447 except: statement.
1447 except: statement.
1448
1448
1449 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1449 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1450 any app directly invokes sys.excepthook, it will look to the user like
1450 any app directly invokes sys.excepthook, it will look to the user like
1451 IPython crashed. In order to work around this, we can disable the
1451 IPython crashed. In order to work around this, we can disable the
1452 CrashHandler and replace it with this excepthook instead, which prints a
1452 CrashHandler and replace it with this excepthook instead, which prints a
1453 regular traceback using our InteractiveTB. In this fashion, apps which
1453 regular traceback using our InteractiveTB. In this fashion, apps which
1454 call sys.excepthook will generate a regular-looking exception from
1454 call sys.excepthook will generate a regular-looking exception from
1455 IPython, and the CrashHandler will only be triggered by real IPython
1455 IPython, and the CrashHandler will only be triggered by real IPython
1456 crashes.
1456 crashes.
1457
1457
1458 This hook should be used sparingly, only in places which are not likely
1458 This hook should be used sparingly, only in places which are not likely
1459 to be true IPython errors.
1459 to be true IPython errors.
1460 """
1460 """
1461
1461
1462 self.InteractiveTB(type, value, tb, tb_offset=0)
1462 self.InteractiveTB(type, value, tb, tb_offset=0)
1463 if self.InteractiveTB.call_pdb and self.has_readline:
1463 if self.InteractiveTB.call_pdb and self.has_readline:
1464 self.readline.set_completer(self.Completer.complete)
1464 self.readline.set_completer(self.Completer.complete)
1465
1465
1466 def call_alias(self,alias,rest=''):
1466 def call_alias(self,alias,rest=''):
1467 """Call an alias given its name and the rest of the line.
1467 """Call an alias given its name and the rest of the line.
1468
1468
1469 This function MUST be given a proper alias, because it doesn't make
1469 This function MUST be given a proper alias, because it doesn't make
1470 any checks when looking up into the alias table. The caller is
1470 any checks when looking up into the alias table. The caller is
1471 responsible for invoking it only with a valid alias."""
1471 responsible for invoking it only with a valid alias."""
1472
1472
1473 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1473 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1474 nargs,cmd = self.alias_table[alias]
1474 nargs,cmd = self.alias_table[alias]
1475 # Expand the %l special to be the user's input line
1475 # Expand the %l special to be the user's input line
1476 if cmd.find('%l') >= 0:
1476 if cmd.find('%l') >= 0:
1477 cmd = cmd.replace('%l',rest)
1477 cmd = cmd.replace('%l',rest)
1478 rest = ''
1478 rest = ''
1479 if nargs==0:
1479 if nargs==0:
1480 # Simple, argument-less aliases
1480 # Simple, argument-less aliases
1481 cmd = '%s %s' % (cmd,rest)
1481 cmd = '%s %s' % (cmd,rest)
1482 else:
1482 else:
1483 # Handle aliases with positional arguments
1483 # Handle aliases with positional arguments
1484 args = rest.split(None,nargs)
1484 args = rest.split(None,nargs)
1485 if len(args)< nargs:
1485 if len(args)< nargs:
1486 error('Alias <%s> requires %s arguments, %s given.' %
1486 error('Alias <%s> requires %s arguments, %s given.' %
1487 (alias,nargs,len(args)))
1487 (alias,nargs,len(args)))
1488 return
1488 return
1489 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1489 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1490 # Now call the macro, evaluating in the user's namespace
1490 # Now call the macro, evaluating in the user's namespace
1491 try:
1491 try:
1492 self.system(cmd)
1492 self.system(cmd)
1493 except:
1493 except:
1494 self.showtraceback()
1494 self.showtraceback()
1495
1495
1496 def autoindent_update(self,line):
1496 def autoindent_update(self,line):
1497 """Keep track of the indent level."""
1497 """Keep track of the indent level."""
1498 if self.autoindent:
1498 if self.autoindent:
1499 if line:
1499 if line:
1500 ini_spaces = ini_spaces_re.match(line)
1500 ini_spaces = ini_spaces_re.match(line)
1501 if ini_spaces:
1501 if ini_spaces:
1502 nspaces = ini_spaces.end()
1502 nspaces = ini_spaces.end()
1503 else:
1503 else:
1504 nspaces = 0
1504 nspaces = 0
1505 self.indent_current_nsp = nspaces
1505 self.indent_current_nsp = nspaces
1506
1506
1507 if line[-1] == ':':
1507 if line[-1] == ':':
1508 self.indent_current_nsp += 4
1508 self.indent_current_nsp += 4
1509 elif dedent_re.match(line):
1509 elif dedent_re.match(line):
1510 self.indent_current_nsp -= 4
1510 self.indent_current_nsp -= 4
1511 else:
1511 else:
1512 self.indent_current_nsp = 0
1512 self.indent_current_nsp = 0
1513
1513
1514 # indent_current is the actual string to be inserted
1514 # indent_current is the actual string to be inserted
1515 # by the readline hooks for indentation
1515 # by the readline hooks for indentation
1516 self.indent_current = ' '* self.indent_current_nsp
1516 self.indent_current = ' '* self.indent_current_nsp
1517
1517
1518 def runlines(self,lines):
1518 def runlines(self,lines):
1519 """Run a string of one or more lines of source.
1519 """Run a string of one or more lines of source.
1520
1520
1521 This method is capable of running a string containing multiple source
1521 This method is capable of running a string containing multiple source
1522 lines, as if they had been entered at the IPython prompt. Since it
1522 lines, as if they had been entered at the IPython prompt. Since it
1523 exposes IPython's processing machinery, the given strings can contain
1523 exposes IPython's processing machinery, the given strings can contain
1524 magic calls (%magic), special shell access (!cmd), etc."""
1524 magic calls (%magic), special shell access (!cmd), etc."""
1525
1525
1526 # We must start with a clean buffer, in case this is run from an
1526 # We must start with a clean buffer, in case this is run from an
1527 # interactive IPython session (via a magic, for example).
1527 # interactive IPython session (via a magic, for example).
1528 self.resetbuffer()
1528 self.resetbuffer()
1529 lines = lines.split('\n')
1529 lines = lines.split('\n')
1530 more = 0
1530 more = 0
1531 for line in lines:
1531 for line in lines:
1532 # skip blank lines so we don't mess up the prompt counter, but do
1532 # skip blank lines so we don't mess up the prompt counter, but do
1533 # NOT skip even a blank line if we are in a code block (more is
1533 # NOT skip even a blank line if we are in a code block (more is
1534 # true)
1534 # true)
1535 if line or more:
1535 if line or more:
1536 more = self.push(self.prefilter(line,more))
1536 more = self.push(self.prefilter(line,more))
1537 # IPython's runsource returns None if there was an error
1537 # IPython's runsource returns None if there was an error
1538 # compiling the code. This allows us to stop processing right
1538 # compiling the code. This allows us to stop processing right
1539 # away, so the user gets the error message at the right place.
1539 # away, so the user gets the error message at the right place.
1540 if more is None:
1540 if more is None:
1541 break
1541 break
1542 # final newline in case the input didn't have it, so that the code
1542 # final newline in case the input didn't have it, so that the code
1543 # actually does get executed
1543 # actually does get executed
1544 if more:
1544 if more:
1545 self.push('\n')
1545 self.push('\n')
1546
1546
1547 def runsource(self, source, filename='<input>', symbol='single'):
1547 def runsource(self, source, filename='<input>', symbol='single'):
1548 """Compile and run some source in the interpreter.
1548 """Compile and run some source in the interpreter.
1549
1549
1550 Arguments are as for compile_command().
1550 Arguments are as for compile_command().
1551
1551
1552 One several things can happen:
1552 One several things can happen:
1553
1553
1554 1) The input is incorrect; compile_command() raised an
1554 1) The input is incorrect; compile_command() raised an
1555 exception (SyntaxError or OverflowError). A syntax traceback
1555 exception (SyntaxError or OverflowError). A syntax traceback
1556 will be printed by calling the showsyntaxerror() method.
1556 will be printed by calling the showsyntaxerror() method.
1557
1557
1558 2) The input is incomplete, and more input is required;
1558 2) The input is incomplete, and more input is required;
1559 compile_command() returned None. Nothing happens.
1559 compile_command() returned None. Nothing happens.
1560
1560
1561 3) The input is complete; compile_command() returned a code
1561 3) The input is complete; compile_command() returned a code
1562 object. The code is executed by calling self.runcode() (which
1562 object. The code is executed by calling self.runcode() (which
1563 also handles run-time exceptions, except for SystemExit).
1563 also handles run-time exceptions, except for SystemExit).
1564
1564
1565 The return value is:
1565 The return value is:
1566
1566
1567 - True in case 2
1567 - True in case 2
1568
1568
1569 - False in the other cases, unless an exception is raised, where
1569 - False in the other cases, unless an exception is raised, where
1570 None is returned instead. This can be used by external callers to
1570 None is returned instead. This can be used by external callers to
1571 know whether to continue feeding input or not.
1571 know whether to continue feeding input or not.
1572
1572
1573 The return value can be used to decide whether to use sys.ps1 or
1573 The return value can be used to decide whether to use sys.ps1 or
1574 sys.ps2 to prompt the next line."""
1574 sys.ps2 to prompt the next line."""
1575
1575
1576 try:
1576 try:
1577 code = self.compile(source,filename,symbol)
1577 code = self.compile(source,filename,symbol)
1578 except (OverflowError, SyntaxError, ValueError):
1578 except (OverflowError, SyntaxError, ValueError):
1579 # Case 1
1579 # Case 1
1580 self.showsyntaxerror(filename)
1580 self.showsyntaxerror(filename)
1581 return None
1581 return None
1582
1582
1583 if code is None:
1583 if code is None:
1584 # Case 2
1584 # Case 2
1585 return True
1585 return True
1586
1586
1587 # Case 3
1587 # Case 3
1588 # We store the code object so that threaded shells and
1588 # We store the code object so that threaded shells and
1589 # custom exception handlers can access all this info if needed.
1589 # custom exception handlers can access all this info if needed.
1590 # The source corresponding to this can be obtained from the
1590 # The source corresponding to this can be obtained from the
1591 # buffer attribute as '\n'.join(self.buffer).
1591 # buffer attribute as '\n'.join(self.buffer).
1592 self.code_to_run = code
1592 self.code_to_run = code
1593 # now actually execute the code object
1593 # now actually execute the code object
1594 if self.runcode(code) == 0:
1594 if self.runcode(code) == 0:
1595 return False
1595 return False
1596 else:
1596 else:
1597 return None
1597 return None
1598
1598
1599 def runcode(self,code_obj):
1599 def runcode(self,code_obj):
1600 """Execute a code object.
1600 """Execute a code object.
1601
1601
1602 When an exception occurs, self.showtraceback() is called to display a
1602 When an exception occurs, self.showtraceback() is called to display a
1603 traceback.
1603 traceback.
1604
1604
1605 Return value: a flag indicating whether the code to be run completed
1605 Return value: a flag indicating whether the code to be run completed
1606 successfully:
1606 successfully:
1607
1607
1608 - 0: successful execution.
1608 - 0: successful execution.
1609 - 1: an error occurred.
1609 - 1: an error occurred.
1610 """
1610 """
1611
1611
1612 # Set our own excepthook in case the user code tries to call it
1612 # Set our own excepthook in case the user code tries to call it
1613 # directly, so that the IPython crash handler doesn't get triggered
1613 # directly, so that the IPython crash handler doesn't get triggered
1614 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1614 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1615
1615
1616 # we save the original sys.excepthook in the instance, in case config
1616 # we save the original sys.excepthook in the instance, in case config
1617 # code (such as magics) needs access to it.
1617 # code (such as magics) needs access to it.
1618 self.sys_excepthook = old_excepthook
1618 self.sys_excepthook = old_excepthook
1619 outflag = 1 # happens in more places, so it's easier as default
1619 outflag = 1 # happens in more places, so it's easier as default
1620 try:
1620 try:
1621 try:
1621 try:
1622 # Embedded instances require separate global/local namespaces
1622 # Embedded instances require separate global/local namespaces
1623 # so they can see both the surrounding (local) namespace and
1623 # so they can see both the surrounding (local) namespace and
1624 # the module-level globals when called inside another function.
1624 # the module-level globals when called inside another function.
1625 if self.embedded:
1625 if self.embedded:
1626 exec code_obj in self.user_global_ns, self.user_ns
1626 exec code_obj in self.user_global_ns, self.user_ns
1627 # Normal (non-embedded) instances should only have a single
1627 # Normal (non-embedded) instances should only have a single
1628 # namespace for user code execution, otherwise functions won't
1628 # namespace for user code execution, otherwise functions won't
1629 # see interactive top-level globals.
1629 # see interactive top-level globals.
1630 else:
1630 else:
1631 exec code_obj in self.user_ns
1631 exec code_obj in self.user_ns
1632 finally:
1632 finally:
1633 # Reset our crash handler in place
1633 # Reset our crash handler in place
1634 sys.excepthook = old_excepthook
1634 sys.excepthook = old_excepthook
1635 except SystemExit:
1635 except SystemExit:
1636 self.resetbuffer()
1636 self.resetbuffer()
1637 self.showtraceback()
1637 self.showtraceback()
1638 warn("Type exit or quit to exit IPython "
1638 warn("Type exit or quit to exit IPython "
1639 "(%Exit or %Quit do so unconditionally).",level=1)
1639 "(%Exit or %Quit do so unconditionally).",level=1)
1640 except self.custom_exceptions:
1640 except self.custom_exceptions:
1641 etype,value,tb = sys.exc_info()
1641 etype,value,tb = sys.exc_info()
1642 self.CustomTB(etype,value,tb)
1642 self.CustomTB(etype,value,tb)
1643 except:
1643 except:
1644 self.showtraceback()
1644 self.showtraceback()
1645 else:
1645 else:
1646 outflag = 0
1646 outflag = 0
1647 if softspace(sys.stdout, 0):
1647 if softspace(sys.stdout, 0):
1648 print
1648 print
1649 # Flush out code object which has been run (and source)
1649 # Flush out code object which has been run (and source)
1650 self.code_to_run = None
1650 self.code_to_run = None
1651 return outflag
1651 return outflag
1652
1652
1653 def push(self, line):
1653 def push(self, line):
1654 """Push a line to the interpreter.
1654 """Push a line to the interpreter.
1655
1655
1656 The line should not have a trailing newline; it may have
1656 The line should not have a trailing newline; it may have
1657 internal newlines. The line is appended to a buffer and the
1657 internal newlines. The line is appended to a buffer and the
1658 interpreter's runsource() method is called with the
1658 interpreter's runsource() method is called with the
1659 concatenated contents of the buffer as source. If this
1659 concatenated contents of the buffer as source. If this
1660 indicates that the command was executed or invalid, the buffer
1660 indicates that the command was executed or invalid, the buffer
1661 is reset; otherwise, the command is incomplete, and the buffer
1661 is reset; otherwise, the command is incomplete, and the buffer
1662 is left as it was after the line was appended. The return
1662 is left as it was after the line was appended. The return
1663 value is 1 if more input is required, 0 if the line was dealt
1663 value is 1 if more input is required, 0 if the line was dealt
1664 with in some way (this is the same as runsource()).
1664 with in some way (this is the same as runsource()).
1665 """
1665 """
1666
1666
1667 # autoindent management should be done here, and not in the
1667 # autoindent management should be done here, and not in the
1668 # interactive loop, since that one is only seen by keyboard input. We
1668 # interactive loop, since that one is only seen by keyboard input. We
1669 # need this done correctly even for code run via runlines (which uses
1669 # need this done correctly even for code run via runlines (which uses
1670 # push).
1670 # push).
1671
1671
1672 #print 'push line: <%s>' % line # dbg
1672 #print 'push line: <%s>' % line # dbg
1673 self.autoindent_update(line)
1673 self.autoindent_update(line)
1674
1674
1675 self.buffer.append(line)
1675 self.buffer.append(line)
1676 more = self.runsource('\n'.join(self.buffer), self.filename)
1676 more = self.runsource('\n'.join(self.buffer), self.filename)
1677 if not more:
1677 if not more:
1678 self.resetbuffer()
1678 self.resetbuffer()
1679 return more
1679 return more
1680
1680
1681 def resetbuffer(self):
1681 def resetbuffer(self):
1682 """Reset the input buffer."""
1682 """Reset the input buffer."""
1683 self.buffer[:] = []
1683 self.buffer[:] = []
1684
1684
1685 def raw_input(self,prompt='',continue_prompt=False):
1685 def raw_input(self,prompt='',continue_prompt=False):
1686 """Write a prompt and read a line.
1686 """Write a prompt and read a line.
1687
1687
1688 The returned line does not include the trailing newline.
1688 The returned line does not include the trailing newline.
1689 When the user enters the EOF key sequence, EOFError is raised.
1689 When the user enters the EOF key sequence, EOFError is raised.
1690
1690
1691 Optional inputs:
1691 Optional inputs:
1692
1692
1693 - prompt(''): a string to be printed to prompt the user.
1693 - prompt(''): a string to be printed to prompt the user.
1694
1694
1695 - continue_prompt(False): whether this line is the first one or a
1695 - continue_prompt(False): whether this line is the first one or a
1696 continuation in a sequence of inputs.
1696 continuation in a sequence of inputs.
1697 """
1697 """
1698
1698
1699 line = raw_input_original(prompt)
1699 line = raw_input_original(prompt)
1700 # Try to be reasonably smart about not re-indenting pasted input more
1700 # Try to be reasonably smart about not re-indenting pasted input more
1701 # than necessary. We do this by trimming out the auto-indent initial
1701 # than necessary. We do this by trimming out the auto-indent initial
1702 # spaces, if the user's actual input started itself with whitespace.
1702 # spaces, if the user's actual input started itself with whitespace.
1703 if self.autoindent:
1703 if self.autoindent:
1704 line2 = line[self.indent_current_nsp:]
1704 line2 = line[self.indent_current_nsp:]
1705 if line2[0:1] in (' ','\t'):
1705 if line2[0:1] in (' ','\t'):
1706 line = line2
1706 line = line2
1707 return self.prefilter(line,continue_prompt)
1707 return self.prefilter(line,continue_prompt)
1708
1708
1709 def split_user_input(self,line):
1709 def split_user_input(self,line):
1710 """Split user input into pre-char, function part and rest."""
1710 """Split user input into pre-char, function part and rest."""
1711
1711
1712 lsplit = self.line_split.match(line)
1712 lsplit = self.line_split.match(line)
1713 if lsplit is None: # no regexp match returns None
1713 if lsplit is None: # no regexp match returns None
1714 try:
1714 try:
1715 iFun,theRest = line.split(None,1)
1715 iFun,theRest = line.split(None,1)
1716 except ValueError:
1716 except ValueError:
1717 iFun,theRest = line,''
1717 iFun,theRest = line,''
1718 pre = re.match('^(\s*)(.*)',line).groups()[0]
1718 pre = re.match('^(\s*)(.*)',line).groups()[0]
1719 else:
1719 else:
1720 pre,iFun,theRest = lsplit.groups()
1720 pre,iFun,theRest = lsplit.groups()
1721
1721
1722 #print 'line:<%s>' % line # dbg
1722 #print 'line:<%s>' % line # dbg
1723 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1723 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1724 return pre,iFun.strip(),theRest
1724 return pre,iFun.strip(),theRest
1725
1725
1726 def _prefilter(self, line, continue_prompt):
1726 def _prefilter(self, line, continue_prompt):
1727 """Calls different preprocessors, depending on the form of line."""
1727 """Calls different preprocessors, depending on the form of line."""
1728
1728
1729 # All handlers *must* return a value, even if it's blank ('').
1729 # All handlers *must* return a value, even if it's blank ('').
1730
1730
1731 # Lines are NOT logged here. Handlers should process the line as
1731 # Lines are NOT logged here. Handlers should process the line as
1732 # needed, update the cache AND log it (so that the input cache array
1732 # needed, update the cache AND log it (so that the input cache array
1733 # stays synced).
1733 # stays synced).
1734
1734
1735 # This function is _very_ delicate, and since it's also the one which
1735 # This function is _very_ delicate, and since it's also the one which
1736 # determines IPython's response to user input, it must be as efficient
1736 # determines IPython's response to user input, it must be as efficient
1737 # as possible. For this reason it has _many_ returns in it, trying
1737 # as possible. For this reason it has _many_ returns in it, trying
1738 # always to exit as quickly as it can figure out what it needs to do.
1738 # always to exit as quickly as it can figure out what it needs to do.
1739
1739
1740 # This function is the main responsible for maintaining IPython's
1740 # This function is the main responsible for maintaining IPython's
1741 # behavior respectful of Python's semantics. So be _very_ careful if
1741 # behavior respectful of Python's semantics. So be _very_ careful if
1742 # making changes to anything here.
1742 # making changes to anything here.
1743
1743
1744 #.....................................................................
1744 #.....................................................................
1745 # Code begins
1745 # Code begins
1746
1746
1747 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1747 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1748
1748
1749 # save the line away in case we crash, so the post-mortem handler can
1749 # save the line away in case we crash, so the post-mortem handler can
1750 # record it
1750 # record it
1751 self._last_input_line = line
1751 self._last_input_line = line
1752
1752
1753 #print '***line: <%s>' % line # dbg
1753 #print '***line: <%s>' % line # dbg
1754
1754
1755 # the input history needs to track even empty lines
1755 # the input history needs to track even empty lines
1756 if not line.strip():
1756 if not line.strip():
1757 if not continue_prompt:
1757 if not continue_prompt:
1758 self.outputcache.prompt_count -= 1
1758 self.outputcache.prompt_count -= 1
1759 return self.handle_normal(line,continue_prompt)
1759 return self.handle_normal(line,continue_prompt)
1760 #return self.handle_normal('',continue_prompt)
1760 #return self.handle_normal('',continue_prompt)
1761
1761
1762 # print '***cont',continue_prompt # dbg
1762 # print '***cont',continue_prompt # dbg
1763 # special handlers are only allowed for single line statements
1763 # special handlers are only allowed for single line statements
1764 if continue_prompt and not self.rc.multi_line_specials:
1764 if continue_prompt and not self.rc.multi_line_specials:
1765 return self.handle_normal(line,continue_prompt)
1765 return self.handle_normal(line,continue_prompt)
1766
1766
1767 # For the rest, we need the structure of the input
1767 # For the rest, we need the structure of the input
1768 pre,iFun,theRest = self.split_user_input(line)
1768 pre,iFun,theRest = self.split_user_input(line)
1769 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1769 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1770
1770
1771 # First check for explicit escapes in the last/first character
1771 # First check for explicit escapes in the last/first character
1772 handler = None
1772 handler = None
1773 if line[-1] == self.ESC_HELP:
1773 if line[-1] == self.ESC_HELP:
1774 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1774 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1775 if handler is None:
1775 if handler is None:
1776 # look at the first character of iFun, NOT of line, so we skip
1776 # look at the first character of iFun, NOT of line, so we skip
1777 # leading whitespace in multiline input
1777 # leading whitespace in multiline input
1778 handler = self.esc_handlers.get(iFun[0:1])
1778 handler = self.esc_handlers.get(iFun[0:1])
1779 if handler is not None:
1779 if handler is not None:
1780 return handler(line,continue_prompt,pre,iFun,theRest)
1780 return handler(line,continue_prompt,pre,iFun,theRest)
1781 # Emacs ipython-mode tags certain input lines
1781 # Emacs ipython-mode tags certain input lines
1782 if line.endswith('# PYTHON-MODE'):
1782 if line.endswith('# PYTHON-MODE'):
1783 return self.handle_emacs(line,continue_prompt)
1783 return self.handle_emacs(line,continue_prompt)
1784
1784
1785 # Next, check if we can automatically execute this thing
1785 # Next, check if we can automatically execute this thing
1786
1786
1787 # Allow ! in multi-line statements if multi_line_specials is on:
1787 # Allow ! in multi-line statements if multi_line_specials is on:
1788 if continue_prompt and self.rc.multi_line_specials and \
1788 if continue_prompt and self.rc.multi_line_specials and \
1789 iFun.startswith(self.ESC_SHELL):
1789 iFun.startswith(self.ESC_SHELL):
1790 return self.handle_shell_escape(line,continue_prompt,
1790 return self.handle_shell_escape(line,continue_prompt,
1791 pre=pre,iFun=iFun,
1791 pre=pre,iFun=iFun,
1792 theRest=theRest)
1792 theRest=theRest)
1793
1793
1794 # Let's try to find if the input line is a magic fn
1794 # Let's try to find if the input line is a magic fn
1795 oinfo = None
1795 oinfo = None
1796 if hasattr(self,'magic_'+iFun):
1796 if hasattr(self,'magic_'+iFun):
1797 # WARNING: _ofind uses getattr(), so it can consume generators and
1797 # WARNING: _ofind uses getattr(), so it can consume generators and
1798 # cause other side effects.
1798 # cause other side effects.
1799 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1799 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1800 if oinfo['ismagic']:
1800 if oinfo['ismagic']:
1801 # Be careful not to call magics when a variable assignment is
1801 # Be careful not to call magics when a variable assignment is
1802 # being made (ls='hi', for example)
1802 # being made (ls='hi', for example)
1803 if self.rc.automagic and \
1803 if self.rc.automagic and \
1804 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1804 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1805 (self.rc.multi_line_specials or not continue_prompt):
1805 (self.rc.multi_line_specials or not continue_prompt):
1806 return self.handle_magic(line,continue_prompt,
1806 return self.handle_magic(line,continue_prompt,
1807 pre,iFun,theRest)
1807 pre,iFun,theRest)
1808 else:
1808 else:
1809 return self.handle_normal(line,continue_prompt)
1809 return self.handle_normal(line,continue_prompt)
1810
1810
1811 # If the rest of the line begins with an (in)equality, assginment or
1811 # If the rest of the line begins with an (in)equality, assginment or
1812 # function call, we should not call _ofind but simply execute it.
1812 # function call, we should not call _ofind but simply execute it.
1813 # This avoids spurious geattr() accesses on objects upon assignment.
1813 # This avoids spurious geattr() accesses on objects upon assignment.
1814 #
1814 #
1815 # It also allows users to assign to either alias or magic names true
1815 # It also allows users to assign to either alias or magic names true
1816 # python variables (the magic/alias systems always take second seat to
1816 # python variables (the magic/alias systems always take second seat to
1817 # true python code).
1817 # true python code).
1818 if theRest and theRest[0] in '!=()':
1818 if theRest and theRest[0] in '!=()':
1819 return self.handle_normal(line,continue_prompt)
1819 return self.handle_normal(line,continue_prompt)
1820
1820
1821 if oinfo is None:
1821 if oinfo is None:
1822 # let's try to ensure that _oinfo is ONLY called when autocall is
1822 # let's try to ensure that _oinfo is ONLY called when autocall is
1823 # on. Since it has inevitable potential side effects, at least
1823 # on. Since it has inevitable potential side effects, at least
1824 # having autocall off should be a guarantee to the user that no
1824 # having autocall off should be a guarantee to the user that no
1825 # weird things will happen.
1825 # weird things will happen.
1826
1826
1827 if self.rc.autocall:
1827 if self.rc.autocall:
1828 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1828 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1829 else:
1829 else:
1830 # in this case, all that's left is either an alias or
1830 # in this case, all that's left is either an alias or
1831 # processing the line normally.
1831 # processing the line normally.
1832 if iFun in self.alias_table:
1832 if iFun in self.alias_table:
1833 return self.handle_alias(line,continue_prompt,
1833 return self.handle_alias(line,continue_prompt,
1834 pre,iFun,theRest)
1834 pre,iFun,theRest)
1835 else:
1835 else:
1836 return self.handle_normal(line,continue_prompt)
1836 return self.handle_normal(line,continue_prompt)
1837
1837
1838 if not oinfo['found']:
1838 if not oinfo['found']:
1839 return self.handle_normal(line,continue_prompt)
1839 return self.handle_normal(line,continue_prompt)
1840 else:
1840 else:
1841 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1841 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1842 if oinfo['isalias']:
1842 if oinfo['isalias']:
1843 return self.handle_alias(line,continue_prompt,
1843 return self.handle_alias(line,continue_prompt,
1844 pre,iFun,theRest)
1844 pre,iFun,theRest)
1845
1845
1846 if self.rc.autocall and \
1846 if self.rc.autocall and \
1847 not self.re_exclude_auto.match(theRest) and \
1847 not self.re_exclude_auto.match(theRest) and \
1848 self.re_fun_name.match(iFun) and \
1848 self.re_fun_name.match(iFun) and \
1849 callable(oinfo['obj']) :
1849 callable(oinfo['obj']) :
1850 #print 'going auto' # dbg
1850 #print 'going auto' # dbg
1851 return self.handle_auto(line,continue_prompt,
1851 return self.handle_auto(line,continue_prompt,
1852 pre,iFun,theRest,oinfo['obj'])
1852 pre,iFun,theRest,oinfo['obj'])
1853 else:
1853 else:
1854 #print 'was callable?', callable(oinfo['obj']) # dbg
1854 #print 'was callable?', callable(oinfo['obj']) # dbg
1855 return self.handle_normal(line,continue_prompt)
1855 return self.handle_normal(line,continue_prompt)
1856
1856
1857 # If we get here, we have a normal Python line. Log and return.
1857 # If we get here, we have a normal Python line. Log and return.
1858 return self.handle_normal(line,continue_prompt)
1858 return self.handle_normal(line,continue_prompt)
1859
1859
1860 def _prefilter_dumb(self, line, continue_prompt):
1860 def _prefilter_dumb(self, line, continue_prompt):
1861 """simple prefilter function, for debugging"""
1861 """simple prefilter function, for debugging"""
1862 return self.handle_normal(line,continue_prompt)
1862 return self.handle_normal(line,continue_prompt)
1863
1863
1864 # Set the default prefilter() function (this can be user-overridden)
1864 # Set the default prefilter() function (this can be user-overridden)
1865 prefilter = _prefilter
1865 prefilter = _prefilter
1866
1866
1867 def handle_normal(self,line,continue_prompt=None,
1867 def handle_normal(self,line,continue_prompt=None,
1868 pre=None,iFun=None,theRest=None):
1868 pre=None,iFun=None,theRest=None):
1869 """Handle normal input lines. Use as a template for handlers."""
1869 """Handle normal input lines. Use as a template for handlers."""
1870
1870
1871 # With autoindent on, we need some way to exit the input loop, and I
1871 # With autoindent on, we need some way to exit the input loop, and I
1872 # don't want to force the user to have to backspace all the way to
1872 # don't want to force the user to have to backspace all the way to
1873 # clear the line. The rule will be in this case, that either two
1873 # clear the line. The rule will be in this case, that either two
1874 # lines of pure whitespace in a row, or a line of pure whitespace but
1874 # lines of pure whitespace in a row, or a line of pure whitespace but
1875 # of a size different to the indent level, will exit the input loop.
1875 # of a size different to the indent level, will exit the input loop.
1876
1876
1877 if (continue_prompt and self.autoindent and isspace(line) and
1877 if (continue_prompt and self.autoindent and isspace(line) and
1878 (line != self.indent_current or isspace(self.buffer[-1]))):
1878 (line != self.indent_current or isspace(self.buffer[-1]))):
1879 line = ''
1879 line = ''
1880
1880
1881 self.log(line,continue_prompt)
1881 self.log(line,continue_prompt)
1882 return line
1882 return line
1883
1883
1884 def handle_alias(self,line,continue_prompt=None,
1884 def handle_alias(self,line,continue_prompt=None,
1885 pre=None,iFun=None,theRest=None):
1885 pre=None,iFun=None,theRest=None):
1886 """Handle alias input lines. """
1886 """Handle alias input lines. """
1887
1887
1888 # pre is needed, because it carries the leading whitespace. Otherwise
1888 # pre is needed, because it carries the leading whitespace. Otherwise
1889 # aliases won't work in indented sections.
1889 # aliases won't work in indented sections.
1890 line_out = '%sipalias("%s %s")' % (pre,iFun,esc_quotes(theRest))
1890 line_out = '%sipalias("%s %s")' % (pre,iFun,esc_quotes(theRest))
1891 self.log(line_out,continue_prompt)
1891 self.log(line_out,continue_prompt)
1892 return line_out
1892 return line_out
1893
1893
1894 def handle_shell_escape(self, line, continue_prompt=None,
1894 def handle_shell_escape(self, line, continue_prompt=None,
1895 pre=None,iFun=None,theRest=None):
1895 pre=None,iFun=None,theRest=None):
1896 """Execute the line in a shell, empty return value"""
1896 """Execute the line in a shell, empty return value"""
1897
1897
1898 #print 'line in :', `line` # dbg
1898 #print 'line in :', `line` # dbg
1899 # Example of a special handler. Others follow a similar pattern.
1899 # Example of a special handler. Others follow a similar pattern.
1900 if continue_prompt: # multi-line statements
1900 if continue_prompt: # multi-line statements
1901 if iFun.startswith('!!'):
1901 if iFun.startswith('!!'):
1902 print 'SyntaxError: !! is not allowed in multiline statements'
1902 print 'SyntaxError: !! is not allowed in multiline statements'
1903 return pre
1903 return pre
1904 else:
1904 else:
1905 cmd = ("%s %s" % (iFun[1:],theRest))
1905 cmd = ("%s %s" % (iFun[1:],theRest))
1906 line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd + "_")
1906 line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd + "_")
1907 else: # single-line input
1907 else: # single-line input
1908 if line.startswith('!!'):
1908 if line.startswith('!!'):
1909 # rewrite iFun/theRest to properly hold the call to %sx and
1909 # rewrite iFun/theRest to properly hold the call to %sx and
1910 # the actual command to be executed, so handle_magic can work
1910 # the actual command to be executed, so handle_magic can work
1911 # correctly
1911 # correctly
1912 theRest = '%s %s' % (iFun[2:],theRest)
1912 theRest = '%s %s' % (iFun[2:],theRest)
1913 iFun = 'sx'
1913 iFun = 'sx'
1914 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1914 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1915 continue_prompt,pre,iFun,theRest)
1915 continue_prompt,pre,iFun,theRest)
1916 else:
1916 else:
1917 cmd=line[1:]
1917 cmd=line[1:]
1918 line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd +"_")
1918 line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd +"_")
1919 # update cache/log and return
1919 # update cache/log and return
1920 self.log(line_out,continue_prompt)
1920 self.log(line_out,continue_prompt)
1921 return line_out
1921 return line_out
1922
1922
1923 def handle_magic(self, line, continue_prompt=None,
1923 def handle_magic(self, line, continue_prompt=None,
1924 pre=None,iFun=None,theRest=None):
1924 pre=None,iFun=None,theRest=None):
1925 """Execute magic functions.
1925 """Execute magic functions.
1926
1926
1927 Also log them with a prepended # so the log is clean Python."""
1927 Also log them with a prepended # so the log is clean Python."""
1928
1928
1929 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1929 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1930 self.log(cmd,continue_prompt)
1930 self.log(cmd,continue_prompt)
1931 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1931 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1932 return cmd
1932 return cmd
1933
1933
1934 def handle_auto(self, line, continue_prompt=None,
1934 def handle_auto(self, line, continue_prompt=None,
1935 pre=None,iFun=None,theRest=None,obj=None):
1935 pre=None,iFun=None,theRest=None,obj=None):
1936 """Hande lines which can be auto-executed, quoting if requested."""
1936 """Hande lines which can be auto-executed, quoting if requested."""
1937
1937
1938 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1938 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1939
1939
1940 # This should only be active for single-line input!
1940 # This should only be active for single-line input!
1941 if continue_prompt:
1941 if continue_prompt:
1942 self.log(line,continue_prompt)
1942 self.log(line,continue_prompt)
1943 return line
1943 return line
1944
1944
1945 auto_rewrite = True
1945 auto_rewrite = True
1946 if pre == self.ESC_QUOTE:
1946 if pre == self.ESC_QUOTE:
1947 # Auto-quote splitting on whitespace
1947 # Auto-quote splitting on whitespace
1948 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1948 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1949 elif pre == self.ESC_QUOTE2:
1949 elif pre == self.ESC_QUOTE2:
1950 # Auto-quote whole string
1950 # Auto-quote whole string
1951 newcmd = '%s("%s")' % (iFun,theRest)
1951 newcmd = '%s("%s")' % (iFun,theRest)
1952 else:
1952 else:
1953 # Auto-paren.
1953 # Auto-paren.
1954 # We only apply it to argument-less calls if the autocall
1954 # We only apply it to argument-less calls if the autocall
1955 # parameter is set to 2. We only need to check that autocall is <
1955 # parameter is set to 2. We only need to check that autocall is <
1956 # 2, since this function isn't called unless it's at least 1.
1956 # 2, since this function isn't called unless it's at least 1.
1957 if not theRest and (self.rc.autocall < 2):
1957 if not theRest and (self.rc.autocall < 2):
1958 newcmd = '%s %s' % (iFun,theRest)
1958 newcmd = '%s %s' % (iFun,theRest)
1959 auto_rewrite = False
1959 auto_rewrite = False
1960 else:
1960 else:
1961 if theRest.startswith('['):
1961 if theRest.startswith('['):
1962 if hasattr(obj,'__getitem__'):
1962 if hasattr(obj,'__getitem__'):
1963 # Don't autocall in this case: item access for an object
1963 # Don't autocall in this case: item access for an object
1964 # which is BOTH callable and implements __getitem__.
1964 # which is BOTH callable and implements __getitem__.
1965 newcmd = '%s %s' % (iFun,theRest)
1965 newcmd = '%s %s' % (iFun,theRest)
1966 auto_rewrite = False
1966 auto_rewrite = False
1967 else:
1967 else:
1968 # if the object doesn't support [] access, go ahead and
1968 # if the object doesn't support [] access, go ahead and
1969 # autocall
1969 # autocall
1970 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1970 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1971 elif theRest.endswith(';'):
1971 elif theRest.endswith(';'):
1972 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1972 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1973 else:
1973 else:
1974 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1974 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1975
1975
1976 if auto_rewrite:
1976 if auto_rewrite:
1977 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1977 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1978 # log what is now valid Python, not the actual user input (without the
1978 # log what is now valid Python, not the actual user input (without the
1979 # final newline)
1979 # final newline)
1980 self.log(newcmd,continue_prompt)
1980 self.log(newcmd,continue_prompt)
1981 return newcmd
1981 return newcmd
1982
1982
1983 def handle_help(self, line, continue_prompt=None,
1983 def handle_help(self, line, continue_prompt=None,
1984 pre=None,iFun=None,theRest=None):
1984 pre=None,iFun=None,theRest=None):
1985 """Try to get some help for the object.
1985 """Try to get some help for the object.
1986
1986
1987 obj? or ?obj -> basic information.
1987 obj? or ?obj -> basic information.
1988 obj?? or ??obj -> more details.
1988 obj?? or ??obj -> more details.
1989 """
1989 """
1990
1990
1991 # We need to make sure that we don't process lines which would be
1991 # We need to make sure that we don't process lines which would be
1992 # otherwise valid python, such as "x=1 # what?"
1992 # otherwise valid python, such as "x=1 # what?"
1993 try:
1993 try:
1994 codeop.compile_command(line)
1994 codeop.compile_command(line)
1995 except SyntaxError:
1995 except SyntaxError:
1996 # We should only handle as help stuff which is NOT valid syntax
1996 # We should only handle as help stuff which is NOT valid syntax
1997 if line[0]==self.ESC_HELP:
1997 if line[0]==self.ESC_HELP:
1998 line = line[1:]
1998 line = line[1:]
1999 elif line[-1]==self.ESC_HELP:
1999 elif line[-1]==self.ESC_HELP:
2000 line = line[:-1]
2000 line = line[:-1]
2001 self.log('#?'+line)
2001 self.log('#?'+line)
2002 if line:
2002 if line:
2003 self.magic_pinfo(line)
2003 self.magic_pinfo(line)
2004 else:
2004 else:
2005 page(self.usage,screen_lines=self.rc.screen_length)
2005 page(self.usage,screen_lines=self.rc.screen_length)
2006 return '' # Empty string is needed here!
2006 return '' # Empty string is needed here!
2007 except:
2007 except:
2008 # Pass any other exceptions through to the normal handler
2008 # Pass any other exceptions through to the normal handler
2009 return self.handle_normal(line,continue_prompt)
2009 return self.handle_normal(line,continue_prompt)
2010 else:
2010 else:
2011 # If the code compiles ok, we should handle it normally
2011 # If the code compiles ok, we should handle it normally
2012 return self.handle_normal(line,continue_prompt)
2012 return self.handle_normal(line,continue_prompt)
2013
2013
2014 def handle_emacs(self,line,continue_prompt=None,
2014 def handle_emacs(self,line,continue_prompt=None,
2015 pre=None,iFun=None,theRest=None):
2015 pre=None,iFun=None,theRest=None):
2016 """Handle input lines marked by python-mode."""
2016 """Handle input lines marked by python-mode."""
2017
2017
2018 # Currently, nothing is done. Later more functionality can be added
2018 # Currently, nothing is done. Later more functionality can be added
2019 # here if needed.
2019 # here if needed.
2020
2020
2021 # The input cache shouldn't be updated
2021 # The input cache shouldn't be updated
2022
2022
2023 return line
2023 return line
2024
2024
2025 def mktempfile(self,data=None):
2025 def mktempfile(self,data=None):
2026 """Make a new tempfile and return its filename.
2026 """Make a new tempfile and return its filename.
2027
2027
2028 This makes a call to tempfile.mktemp, but it registers the created
2028 This makes a call to tempfile.mktemp, but it registers the created
2029 filename internally so ipython cleans it up at exit time.
2029 filename internally so ipython cleans it up at exit time.
2030
2030
2031 Optional inputs:
2031 Optional inputs:
2032
2032
2033 - data(None): if data is given, it gets written out to the temp file
2033 - data(None): if data is given, it gets written out to the temp file
2034 immediately, and the file is closed again."""
2034 immediately, and the file is closed again."""
2035
2035
2036 filename = tempfile.mktemp('.py','ipython_edit_')
2036 filename = tempfile.mktemp('.py','ipython_edit_')
2037 self.tempfiles.append(filename)
2037 self.tempfiles.append(filename)
2038
2038
2039 if data:
2039 if data:
2040 tmp_file = open(filename,'w')
2040 tmp_file = open(filename,'w')
2041 tmp_file.write(data)
2041 tmp_file.write(data)
2042 tmp_file.close()
2042 tmp_file.close()
2043 return filename
2043 return filename
2044
2044
2045 def write(self,data):
2045 def write(self,data):
2046 """Write a string to the default output"""
2046 """Write a string to the default output"""
2047 Term.cout.write(data)
2047 Term.cout.write(data)
2048
2048
2049 def write_err(self,data):
2049 def write_err(self,data):
2050 """Write a string to the default error output"""
2050 """Write a string to the default error output"""
2051 Term.cerr.write(data)
2051 Term.cerr.write(data)
2052
2052
2053 def exit(self):
2053 def exit(self):
2054 """Handle interactive exit.
2054 """Handle interactive exit.
2055
2055
2056 This method sets the exit_now attribute."""
2056 This method sets the exit_now attribute."""
2057
2057
2058 if self.rc.confirm_exit:
2058 if self.rc.confirm_exit:
2059 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2059 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2060 self.exit_now = True
2060 self.exit_now = True
2061 else:
2061 else:
2062 self.exit_now = True
2062 self.exit_now = True
2063 return self.exit_now
2063 return self.exit_now
2064
2064
2065 def safe_execfile(self,fname,*where,**kw):
2065 def safe_execfile(self,fname,*where,**kw):
2066 fname = os.path.expanduser(fname)
2066 fname = os.path.expanduser(fname)
2067
2067
2068 # find things also in current directory
2068 # find things also in current directory
2069 dname = os.path.dirname(fname)
2069 dname = os.path.dirname(fname)
2070 if not sys.path.count(dname):
2070 if not sys.path.count(dname):
2071 sys.path.append(dname)
2071 sys.path.append(dname)
2072
2072
2073 try:
2073 try:
2074 xfile = open(fname)
2074 xfile = open(fname)
2075 except:
2075 except:
2076 print >> Term.cerr, \
2076 print >> Term.cerr, \
2077 'Could not open file <%s> for safe execution.' % fname
2077 'Could not open file <%s> for safe execution.' % fname
2078 return None
2078 return None
2079
2079
2080 kw.setdefault('islog',0)
2080 kw.setdefault('islog',0)
2081 kw.setdefault('quiet',1)
2081 kw.setdefault('quiet',1)
2082 kw.setdefault('exit_ignore',0)
2082 kw.setdefault('exit_ignore',0)
2083 first = xfile.readline()
2083 first = xfile.readline()
2084 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2084 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2085 xfile.close()
2085 xfile.close()
2086 # line by line execution
2086 # line by line execution
2087 if first.startswith(loghead) or kw['islog']:
2087 if first.startswith(loghead) or kw['islog']:
2088 print 'Loading log file <%s> one line at a time...' % fname
2088 print 'Loading log file <%s> one line at a time...' % fname
2089 if kw['quiet']:
2089 if kw['quiet']:
2090 stdout_save = sys.stdout
2090 stdout_save = sys.stdout
2091 sys.stdout = StringIO.StringIO()
2091 sys.stdout = StringIO.StringIO()
2092 try:
2092 try:
2093 globs,locs = where[0:2]
2093 globs,locs = where[0:2]
2094 except:
2094 except:
2095 try:
2095 try:
2096 globs = locs = where[0]
2096 globs = locs = where[0]
2097 except:
2097 except:
2098 globs = locs = globals()
2098 globs = locs = globals()
2099 badblocks = []
2099 badblocks = []
2100
2100
2101 # we also need to identify indented blocks of code when replaying
2101 # we also need to identify indented blocks of code when replaying
2102 # logs and put them together before passing them to an exec
2102 # logs and put them together before passing them to an exec
2103 # statement. This takes a bit of regexp and look-ahead work in the
2103 # statement. This takes a bit of regexp and look-ahead work in the
2104 # file. It's easiest if we swallow the whole thing in memory
2104 # file. It's easiest if we swallow the whole thing in memory
2105 # first, and manually walk through the lines list moving the
2105 # first, and manually walk through the lines list moving the
2106 # counter ourselves.
2106 # counter ourselves.
2107 indent_re = re.compile('\s+\S')
2107 indent_re = re.compile('\s+\S')
2108 xfile = open(fname)
2108 xfile = open(fname)
2109 filelines = xfile.readlines()
2109 filelines = xfile.readlines()
2110 xfile.close()
2110 xfile.close()
2111 nlines = len(filelines)
2111 nlines = len(filelines)
2112 lnum = 0
2112 lnum = 0
2113 while lnum < nlines:
2113 while lnum < nlines:
2114 line = filelines[lnum]
2114 line = filelines[lnum]
2115 lnum += 1
2115 lnum += 1
2116 # don't re-insert logger status info into cache
2116 # don't re-insert logger status info into cache
2117 if line.startswith('#log#'):
2117 if line.startswith('#log#'):
2118 continue
2118 continue
2119 else:
2119 else:
2120 # build a block of code (maybe a single line) for execution
2120 # build a block of code (maybe a single line) for execution
2121 block = line
2121 block = line
2122 try:
2122 try:
2123 next = filelines[lnum] # lnum has already incremented
2123 next = filelines[lnum] # lnum has already incremented
2124 except:
2124 except:
2125 next = None
2125 next = None
2126 while next and indent_re.match(next):
2126 while next and indent_re.match(next):
2127 block += next
2127 block += next
2128 lnum += 1
2128 lnum += 1
2129 try:
2129 try:
2130 next = filelines[lnum]
2130 next = filelines[lnum]
2131 except:
2131 except:
2132 next = None
2132 next = None
2133 # now execute the block of one or more lines
2133 # now execute the block of one or more lines
2134 try:
2134 try:
2135 exec block in globs,locs
2135 exec block in globs,locs
2136 except SystemExit:
2136 except SystemExit:
2137 pass
2137 pass
2138 except:
2138 except:
2139 badblocks.append(block.rstrip())
2139 badblocks.append(block.rstrip())
2140 if kw['quiet']: # restore stdout
2140 if kw['quiet']: # restore stdout
2141 sys.stdout.close()
2141 sys.stdout.close()
2142 sys.stdout = stdout_save
2142 sys.stdout = stdout_save
2143 print 'Finished replaying log file <%s>' % fname
2143 print 'Finished replaying log file <%s>' % fname
2144 if badblocks:
2144 if badblocks:
2145 print >> sys.stderr, ('\nThe following lines/blocks in file '
2145 print >> sys.stderr, ('\nThe following lines/blocks in file '
2146 '<%s> reported errors:' % fname)
2146 '<%s> reported errors:' % fname)
2147
2147
2148 for badline in badblocks:
2148 for badline in badblocks:
2149 print >> sys.stderr, badline
2149 print >> sys.stderr, badline
2150 else: # regular file execution
2150 else: # regular file execution
2151 try:
2151 try:
2152 execfile(fname,*where)
2152 execfile(fname,*where)
2153 except SyntaxError:
2153 except SyntaxError:
2154 etype,evalue = sys.exc_info()[:2]
2154 etype,evalue = sys.exc_info()[:2]
2155 self.SyntaxTB(etype,evalue,[])
2155 self.SyntaxTB(etype,evalue,[])
2156 warn('Failure executing file: <%s>' % fname)
2156 warn('Failure executing file: <%s>' % fname)
2157 except SystemExit,status:
2157 except SystemExit,status:
2158 if not kw['exit_ignore']:
2158 if not kw['exit_ignore']:
2159 self.InteractiveTB()
2159 self.InteractiveTB()
2160 warn('Failure executing file: <%s>' % fname)
2160 warn('Failure executing file: <%s>' % fname)
2161 except:
2161 except:
2162 self.InteractiveTB()
2162 self.InteractiveTB()
2163 warn('Failure executing file: <%s>' % fname)
2163 warn('Failure executing file: <%s>' % fname)
2164
2164
2165 #************************* end of file <iplib.py> *****************************
2165 #************************* end of file <iplib.py> *****************************
@@ -1,4814 +1,4822 b''
1 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
4 problem of excessive CPU usage under *nix and keyboard lag under
5 win32.
6
7 2006-01-10 *** Released version 0.7.0
8
1 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
9 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
2
10
3 * IPython/Release.py (revision): tag version number to 0.7.0,
11 * IPython/Release.py (revision): tag version number to 0.7.0,
4 ready for release.
12 ready for release.
5
13
6 * IPython/Magic.py (magic_edit): Add print statement to %edit so
14 * IPython/Magic.py (magic_edit): Add print statement to %edit so
7 it informs the user of the name of the temp. file used. This can
15 it informs the user of the name of the temp. file used. This can
8 help if you decide later to reuse that same file, so you know
16 help if you decide later to reuse that same file, so you know
9 where to copy the info from.
17 where to copy the info from.
10
18
11 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
19 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
12
20
13 * setup_bdist_egg.py: little script to build an egg. Added
21 * setup_bdist_egg.py: little script to build an egg. Added
14 support in the release tools as well.
22 support in the release tools as well.
15
23
16 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
24 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
17
25
18 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
26 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
19 version selection (new -wxversion command line and ipythonrc
27 version selection (new -wxversion command line and ipythonrc
20 parameter). Patch contributed by Arnd Baecker
28 parameter). Patch contributed by Arnd Baecker
21 <arnd.baecker-AT-web.de>.
29 <arnd.baecker-AT-web.de>.
22
30
23 * IPython/iplib.py (embed_mainloop): fix tab-completion in
31 * IPython/iplib.py (embed_mainloop): fix tab-completion in
24 embedded instances, for variables defined at the interactive
32 embedded instances, for variables defined at the interactive
25 prompt of the embedded ipython. Reported by Arnd.
33 prompt of the embedded ipython. Reported by Arnd.
26
34
27 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
35 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
28 it can be used as a (stateful) toggle, or with a direct parameter.
36 it can be used as a (stateful) toggle, or with a direct parameter.
29
37
30 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
38 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
31 could be triggered in certain cases and cause the traceback
39 could be triggered in certain cases and cause the traceback
32 printer not to work.
40 printer not to work.
33
41
34 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
42 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
35
43
36 * IPython/iplib.py (_should_recompile): Small fix, closes
44 * IPython/iplib.py (_should_recompile): Small fix, closes
37 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
45 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
38
46
39 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
47 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
40
48
41 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
49 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
42 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
50 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
43 Moad for help with tracking it down.
51 Moad for help with tracking it down.
44
52
45 * IPython/iplib.py (handle_auto): fix autocall handling for
53 * IPython/iplib.py (handle_auto): fix autocall handling for
46 objects which support BOTH __getitem__ and __call__ (so that f [x]
54 objects which support BOTH __getitem__ and __call__ (so that f [x]
47 is left alone, instead of becoming f([x]) automatically).
55 is left alone, instead of becoming f([x]) automatically).
48
56
49 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
57 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
50 Ville's patch.
58 Ville's patch.
51
59
52 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
60 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
53
61
54 * IPython/iplib.py (handle_auto): changed autocall semantics to
62 * IPython/iplib.py (handle_auto): changed autocall semantics to
55 include 'smart' mode, where the autocall transformation is NOT
63 include 'smart' mode, where the autocall transformation is NOT
56 applied if there are no arguments on the line. This allows you to
64 applied if there are no arguments on the line. This allows you to
57 just type 'foo' if foo is a callable to see its internal form,
65 just type 'foo' if foo is a callable to see its internal form,
58 instead of having it called with no arguments (typically a
66 instead of having it called with no arguments (typically a
59 mistake). The old 'full' autocall still exists: for that, you
67 mistake). The old 'full' autocall still exists: for that, you
60 need to set the 'autocall' parameter to 2 in your ipythonrc file.
68 need to set the 'autocall' parameter to 2 in your ipythonrc file.
61
69
62 * IPython/completer.py (Completer.attr_matches): add
70 * IPython/completer.py (Completer.attr_matches): add
63 tab-completion support for Enthoughts' traits. After a report by
71 tab-completion support for Enthoughts' traits. After a report by
64 Arnd and a patch by Prabhu.
72 Arnd and a patch by Prabhu.
65
73
66 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
74 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
67
75
68 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
76 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
69 Schmolck's patch to fix inspect.getinnerframes().
77 Schmolck's patch to fix inspect.getinnerframes().
70
78
71 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
79 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
72 for embedded instances, regarding handling of namespaces and items
80 for embedded instances, regarding handling of namespaces and items
73 added to the __builtin__ one. Multiple embedded instances and
81 added to the __builtin__ one. Multiple embedded instances and
74 recursive embeddings should work better now (though I'm not sure
82 recursive embeddings should work better now (though I'm not sure
75 I've got all the corner cases fixed, that code is a bit of a brain
83 I've got all the corner cases fixed, that code is a bit of a brain
76 twister).
84 twister).
77
85
78 * IPython/Magic.py (magic_edit): added support to edit in-memory
86 * IPython/Magic.py (magic_edit): added support to edit in-memory
79 macros (automatically creates the necessary temp files). %edit
87 macros (automatically creates the necessary temp files). %edit
80 also doesn't return the file contents anymore, it's just noise.
88 also doesn't return the file contents anymore, it's just noise.
81
89
82 * IPython/completer.py (Completer.attr_matches): revert change to
90 * IPython/completer.py (Completer.attr_matches): revert change to
83 complete only on attributes listed in __all__. I realized it
91 complete only on attributes listed in __all__. I realized it
84 cripples the tab-completion system as a tool for exploring the
92 cripples the tab-completion system as a tool for exploring the
85 internals of unknown libraries (it renders any non-__all__
93 internals of unknown libraries (it renders any non-__all__
86 attribute off-limits). I got bit by this when trying to see
94 attribute off-limits). I got bit by this when trying to see
87 something inside the dis module.
95 something inside the dis module.
88
96
89 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
97 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
90
98
91 * IPython/iplib.py (InteractiveShell.__init__): add .meta
99 * IPython/iplib.py (InteractiveShell.__init__): add .meta
92 namespace for users and extension writers to hold data in. This
100 namespace for users and extension writers to hold data in. This
93 follows the discussion in
101 follows the discussion in
94 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
102 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
95
103
96 * IPython/completer.py (IPCompleter.complete): small patch to help
104 * IPython/completer.py (IPCompleter.complete): small patch to help
97 tab-completion under Emacs, after a suggestion by John Barnard
105 tab-completion under Emacs, after a suggestion by John Barnard
98 <barnarj-AT-ccf.org>.
106 <barnarj-AT-ccf.org>.
99
107
100 * IPython/Magic.py (Magic.extract_input_slices): added support for
108 * IPython/Magic.py (Magic.extract_input_slices): added support for
101 the slice notation in magics to use N-M to represent numbers N...M
109 the slice notation in magics to use N-M to represent numbers N...M
102 (closed endpoints). This is used by %macro and %save.
110 (closed endpoints). This is used by %macro and %save.
103
111
104 * IPython/completer.py (Completer.attr_matches): for modules which
112 * IPython/completer.py (Completer.attr_matches): for modules which
105 define __all__, complete only on those. After a patch by Jeffrey
113 define __all__, complete only on those. After a patch by Jeffrey
106 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
114 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
107 speed up this routine.
115 speed up this routine.
108
116
109 * IPython/Logger.py (Logger.log): fix a history handling bug. I
117 * IPython/Logger.py (Logger.log): fix a history handling bug. I
110 don't know if this is the end of it, but the behavior now is
118 don't know if this is the end of it, but the behavior now is
111 certainly much more correct. Note that coupled with macros,
119 certainly much more correct. Note that coupled with macros,
112 slightly surprising (at first) behavior may occur: a macro will in
120 slightly surprising (at first) behavior may occur: a macro will in
113 general expand to multiple lines of input, so upon exiting, the
121 general expand to multiple lines of input, so upon exiting, the
114 in/out counters will both be bumped by the corresponding amount
122 in/out counters will both be bumped by the corresponding amount
115 (as if the macro's contents had been typed interactively). Typing
123 (as if the macro's contents had been typed interactively). Typing
116 %hist will reveal the intermediate (silently processed) lines.
124 %hist will reveal the intermediate (silently processed) lines.
117
125
118 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
126 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
119 pickle to fail (%run was overwriting __main__ and not restoring
127 pickle to fail (%run was overwriting __main__ and not restoring
120 it, but pickle relies on __main__ to operate).
128 it, but pickle relies on __main__ to operate).
121
129
122 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
130 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
123 using properties, but forgot to make the main InteractiveShell
131 using properties, but forgot to make the main InteractiveShell
124 class a new-style class. Properties fail silently, and
132 class a new-style class. Properties fail silently, and
125 misteriously, with old-style class (getters work, but
133 misteriously, with old-style class (getters work, but
126 setters don't do anything).
134 setters don't do anything).
127
135
128 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
136 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
129
137
130 * IPython/Magic.py (magic_history): fix history reporting bug (I
138 * IPython/Magic.py (magic_history): fix history reporting bug (I
131 know some nasties are still there, I just can't seem to find a
139 know some nasties are still there, I just can't seem to find a
132 reproducible test case to track them down; the input history is
140 reproducible test case to track them down; the input history is
133 falling out of sync...)
141 falling out of sync...)
134
142
135 * IPython/iplib.py (handle_shell_escape): fix bug where both
143 * IPython/iplib.py (handle_shell_escape): fix bug where both
136 aliases and system accesses where broken for indented code (such
144 aliases and system accesses where broken for indented code (such
137 as loops).
145 as loops).
138
146
139 * IPython/genutils.py (shell): fix small but critical bug for
147 * IPython/genutils.py (shell): fix small but critical bug for
140 win32 system access.
148 win32 system access.
141
149
142 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
150 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
143
151
144 * IPython/iplib.py (showtraceback): remove use of the
152 * IPython/iplib.py (showtraceback): remove use of the
145 sys.last_{type/value/traceback} structures, which are non
153 sys.last_{type/value/traceback} structures, which are non
146 thread-safe.
154 thread-safe.
147 (_prefilter): change control flow to ensure that we NEVER
155 (_prefilter): change control flow to ensure that we NEVER
148 introspect objects when autocall is off. This will guarantee that
156 introspect objects when autocall is off. This will guarantee that
149 having an input line of the form 'x.y', where access to attribute
157 having an input line of the form 'x.y', where access to attribute
150 'y' has side effects, doesn't trigger the side effect TWICE. It
158 'y' has side effects, doesn't trigger the side effect TWICE. It
151 is important to note that, with autocall on, these side effects
159 is important to note that, with autocall on, these side effects
152 can still happen.
160 can still happen.
153 (ipsystem): new builtin, to complete the ip{magic/alias/system}
161 (ipsystem): new builtin, to complete the ip{magic/alias/system}
154 trio. IPython offers these three kinds of special calls which are
162 trio. IPython offers these three kinds of special calls which are
155 not python code, and it's a good thing to have their call method
163 not python code, and it's a good thing to have their call method
156 be accessible as pure python functions (not just special syntax at
164 be accessible as pure python functions (not just special syntax at
157 the command line). It gives us a better internal implementation
165 the command line). It gives us a better internal implementation
158 structure, as well as exposing these for user scripting more
166 structure, as well as exposing these for user scripting more
159 cleanly.
167 cleanly.
160
168
161 * IPython/macro.py (Macro.__init__): moved macros to a standalone
169 * IPython/macro.py (Macro.__init__): moved macros to a standalone
162 file. Now that they'll be more likely to be used with the
170 file. Now that they'll be more likely to be used with the
163 persistance system (%store), I want to make sure their module path
171 persistance system (%store), I want to make sure their module path
164 doesn't change in the future, so that we don't break things for
172 doesn't change in the future, so that we don't break things for
165 users' persisted data.
173 users' persisted data.
166
174
167 * IPython/iplib.py (autoindent_update): move indentation
175 * IPython/iplib.py (autoindent_update): move indentation
168 management into the _text_ processing loop, not the keyboard
176 management into the _text_ processing loop, not the keyboard
169 interactive one. This is necessary to correctly process non-typed
177 interactive one. This is necessary to correctly process non-typed
170 multiline input (such as macros).
178 multiline input (such as macros).
171
179
172 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
180 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
173 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
181 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
174 which was producing problems in the resulting manual.
182 which was producing problems in the resulting manual.
175 (magic_whos): improve reporting of instances (show their class,
183 (magic_whos): improve reporting of instances (show their class,
176 instead of simply printing 'instance' which isn't terribly
184 instead of simply printing 'instance' which isn't terribly
177 informative).
185 informative).
178
186
179 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
187 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
180 (minor mods) to support network shares under win32.
188 (minor mods) to support network shares under win32.
181
189
182 * IPython/winconsole.py (get_console_size): add new winconsole
190 * IPython/winconsole.py (get_console_size): add new winconsole
183 module and fixes to page_dumb() to improve its behavior under
191 module and fixes to page_dumb() to improve its behavior under
184 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
192 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
185
193
186 * IPython/Magic.py (Macro): simplified Macro class to just
194 * IPython/Magic.py (Macro): simplified Macro class to just
187 subclass list. We've had only 2.2 compatibility for a very long
195 subclass list. We've had only 2.2 compatibility for a very long
188 time, yet I was still avoiding subclassing the builtin types. No
196 time, yet I was still avoiding subclassing the builtin types. No
189 more (I'm also starting to use properties, though I won't shift to
197 more (I'm also starting to use properties, though I won't shift to
190 2.3-specific features quite yet).
198 2.3-specific features quite yet).
191 (magic_store): added Ville's patch for lightweight variable
199 (magic_store): added Ville's patch for lightweight variable
192 persistence, after a request on the user list by Matt Wilkie
200 persistence, after a request on the user list by Matt Wilkie
193 <maphew-AT-gmail.com>. The new %store magic's docstring has full
201 <maphew-AT-gmail.com>. The new %store magic's docstring has full
194 details.
202 details.
195
203
196 * IPython/iplib.py (InteractiveShell.post_config_initialization):
204 * IPython/iplib.py (InteractiveShell.post_config_initialization):
197 changed the default logfile name from 'ipython.log' to
205 changed the default logfile name from 'ipython.log' to
198 'ipython_log.py'. These logs are real python files, and now that
206 'ipython_log.py'. These logs are real python files, and now that
199 we have much better multiline support, people are more likely to
207 we have much better multiline support, people are more likely to
200 want to use them as such. Might as well name them correctly.
208 want to use them as such. Might as well name them correctly.
201
209
202 * IPython/Magic.py: substantial cleanup. While we can't stop
210 * IPython/Magic.py: substantial cleanup. While we can't stop
203 using magics as mixins, due to the existing customizations 'out
211 using magics as mixins, due to the existing customizations 'out
204 there' which rely on the mixin naming conventions, at least I
212 there' which rely on the mixin naming conventions, at least I
205 cleaned out all cross-class name usage. So once we are OK with
213 cleaned out all cross-class name usage. So once we are OK with
206 breaking compatibility, the two systems can be separated.
214 breaking compatibility, the two systems can be separated.
207
215
208 * IPython/Logger.py: major cleanup. This one is NOT a mixin
216 * IPython/Logger.py: major cleanup. This one is NOT a mixin
209 anymore, and the class is a fair bit less hideous as well. New
217 anymore, and the class is a fair bit less hideous as well. New
210 features were also introduced: timestamping of input, and logging
218 features were also introduced: timestamping of input, and logging
211 of output results. These are user-visible with the -t and -o
219 of output results. These are user-visible with the -t and -o
212 options to %logstart. Closes
220 options to %logstart. Closes
213 http://www.scipy.net/roundup/ipython/issue11 and a request by
221 http://www.scipy.net/roundup/ipython/issue11 and a request by
214 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
222 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
215
223
216 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
224 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
217
225
218 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
226 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
219 better hadnle backslashes in paths. See the thread 'More Windows
227 better hadnle backslashes in paths. See the thread 'More Windows
220 questions part 2 - \/ characters revisited' on the iypthon user
228 questions part 2 - \/ characters revisited' on the iypthon user
221 list:
229 list:
222 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
230 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
223
231
224 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
232 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
225
233
226 (InteractiveShell.__init__): change threaded shells to not use the
234 (InteractiveShell.__init__): change threaded shells to not use the
227 ipython crash handler. This was causing more problems than not,
235 ipython crash handler. This was causing more problems than not,
228 as exceptions in the main thread (GUI code, typically) would
236 as exceptions in the main thread (GUI code, typically) would
229 always show up as a 'crash', when they really weren't.
237 always show up as a 'crash', when they really weren't.
230
238
231 The colors and exception mode commands (%colors/%xmode) have been
239 The colors and exception mode commands (%colors/%xmode) have been
232 synchronized to also take this into account, so users can get
240 synchronized to also take this into account, so users can get
233 verbose exceptions for their threaded code as well. I also added
241 verbose exceptions for their threaded code as well. I also added
234 support for activating pdb inside this exception handler as well,
242 support for activating pdb inside this exception handler as well,
235 so now GUI authors can use IPython's enhanced pdb at runtime.
243 so now GUI authors can use IPython's enhanced pdb at runtime.
236
244
237 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
245 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
238 true by default, and add it to the shipped ipythonrc file. Since
246 true by default, and add it to the shipped ipythonrc file. Since
239 this asks the user before proceeding, I think it's OK to make it
247 this asks the user before proceeding, I think it's OK to make it
240 true by default.
248 true by default.
241
249
242 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
250 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
243 of the previous special-casing of input in the eval loop. I think
251 of the previous special-casing of input in the eval loop. I think
244 this is cleaner, as they really are commands and shouldn't have
252 this is cleaner, as they really are commands and shouldn't have
245 a special role in the middle of the core code.
253 a special role in the middle of the core code.
246
254
247 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
255 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
248
256
249 * IPython/iplib.py (edit_syntax_error): added support for
257 * IPython/iplib.py (edit_syntax_error): added support for
250 automatically reopening the editor if the file had a syntax error
258 automatically reopening the editor if the file had a syntax error
251 in it. Thanks to scottt who provided the patch at:
259 in it. Thanks to scottt who provided the patch at:
252 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
260 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
253 version committed).
261 version committed).
254
262
255 * IPython/iplib.py (handle_normal): add suport for multi-line
263 * IPython/iplib.py (handle_normal): add suport for multi-line
256 input with emtpy lines. This fixes
264 input with emtpy lines. This fixes
257 http://www.scipy.net/roundup/ipython/issue43 and a similar
265 http://www.scipy.net/roundup/ipython/issue43 and a similar
258 discussion on the user list.
266 discussion on the user list.
259
267
260 WARNING: a behavior change is necessarily introduced to support
268 WARNING: a behavior change is necessarily introduced to support
261 blank lines: now a single blank line with whitespace does NOT
269 blank lines: now a single blank line with whitespace does NOT
262 break the input loop, which means that when autoindent is on, by
270 break the input loop, which means that when autoindent is on, by
263 default hitting return on the next (indented) line does NOT exit.
271 default hitting return on the next (indented) line does NOT exit.
264
272
265 Instead, to exit a multiline input you can either have:
273 Instead, to exit a multiline input you can either have:
266
274
267 - TWO whitespace lines (just hit return again), or
275 - TWO whitespace lines (just hit return again), or
268 - a single whitespace line of a different length than provided
276 - a single whitespace line of a different length than provided
269 by the autoindent (add or remove a space).
277 by the autoindent (add or remove a space).
270
278
271 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
279 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
272 module to better organize all readline-related functionality.
280 module to better organize all readline-related functionality.
273 I've deleted FlexCompleter and put all completion clases here.
281 I've deleted FlexCompleter and put all completion clases here.
274
282
275 * IPython/iplib.py (raw_input): improve indentation management.
283 * IPython/iplib.py (raw_input): improve indentation management.
276 It is now possible to paste indented code with autoindent on, and
284 It is now possible to paste indented code with autoindent on, and
277 the code is interpreted correctly (though it still looks bad on
285 the code is interpreted correctly (though it still looks bad on
278 screen, due to the line-oriented nature of ipython).
286 screen, due to the line-oriented nature of ipython).
279 (MagicCompleter.complete): change behavior so that a TAB key on an
287 (MagicCompleter.complete): change behavior so that a TAB key on an
280 otherwise empty line actually inserts a tab, instead of completing
288 otherwise empty line actually inserts a tab, instead of completing
281 on the entire global namespace. This makes it easier to use the
289 on the entire global namespace. This makes it easier to use the
282 TAB key for indentation. After a request by Hans Meine
290 TAB key for indentation. After a request by Hans Meine
283 <hans_meine-AT-gmx.net>
291 <hans_meine-AT-gmx.net>
284 (_prefilter): add support so that typing plain 'exit' or 'quit'
292 (_prefilter): add support so that typing plain 'exit' or 'quit'
285 does a sensible thing. Originally I tried to deviate as little as
293 does a sensible thing. Originally I tried to deviate as little as
286 possible from the default python behavior, but even that one may
294 possible from the default python behavior, but even that one may
287 change in this direction (thread on python-dev to that effect).
295 change in this direction (thread on python-dev to that effect).
288 Regardless, ipython should do the right thing even if CPython's
296 Regardless, ipython should do the right thing even if CPython's
289 '>>>' prompt doesn't.
297 '>>>' prompt doesn't.
290 (InteractiveShell): removed subclassing code.InteractiveConsole
298 (InteractiveShell): removed subclassing code.InteractiveConsole
291 class. By now we'd overridden just about all of its methods: I've
299 class. By now we'd overridden just about all of its methods: I've
292 copied the remaining two over, and now ipython is a standalone
300 copied the remaining two over, and now ipython is a standalone
293 class. This will provide a clearer picture for the chainsaw
301 class. This will provide a clearer picture for the chainsaw
294 branch refactoring.
302 branch refactoring.
295
303
296 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
304 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
297
305
298 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
306 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
299 failures for objects which break when dir() is called on them.
307 failures for objects which break when dir() is called on them.
300
308
301 * IPython/FlexCompleter.py (Completer.__init__): Added support for
309 * IPython/FlexCompleter.py (Completer.__init__): Added support for
302 distinct local and global namespaces in the completer API. This
310 distinct local and global namespaces in the completer API. This
303 change allows us top properly handle completion with distinct
311 change allows us top properly handle completion with distinct
304 scopes, including in embedded instances (this had never really
312 scopes, including in embedded instances (this had never really
305 worked correctly).
313 worked correctly).
306
314
307 Note: this introduces a change in the constructor for
315 Note: this introduces a change in the constructor for
308 MagicCompleter, as a new global_namespace parameter is now the
316 MagicCompleter, as a new global_namespace parameter is now the
309 second argument (the others were bumped one position).
317 second argument (the others were bumped one position).
310
318
311 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
319 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
312
320
313 * IPython/iplib.py (embed_mainloop): fix tab-completion in
321 * IPython/iplib.py (embed_mainloop): fix tab-completion in
314 embedded instances (which can be done now thanks to Vivian's
322 embedded instances (which can be done now thanks to Vivian's
315 frame-handling fixes for pdb).
323 frame-handling fixes for pdb).
316 (InteractiveShell.__init__): Fix namespace handling problem in
324 (InteractiveShell.__init__): Fix namespace handling problem in
317 embedded instances. We were overwriting __main__ unconditionally,
325 embedded instances. We were overwriting __main__ unconditionally,
318 and this should only be done for 'full' (non-embedded) IPython;
326 and this should only be done for 'full' (non-embedded) IPython;
319 embedded instances must respect the caller's __main__. Thanks to
327 embedded instances must respect the caller's __main__. Thanks to
320 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
328 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
321
329
322 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
330 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
323
331
324 * setup.py: added download_url to setup(). This registers the
332 * setup.py: added download_url to setup(). This registers the
325 download address at PyPI, which is not only useful to humans
333 download address at PyPI, which is not only useful to humans
326 browsing the site, but is also picked up by setuptools (the Eggs
334 browsing the site, but is also picked up by setuptools (the Eggs
327 machinery). Thanks to Ville and R. Kern for the info/discussion
335 machinery). Thanks to Ville and R. Kern for the info/discussion
328 on this.
336 on this.
329
337
330 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
338 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
331
339
332 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
340 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
333 This brings a lot of nice functionality to the pdb mode, which now
341 This brings a lot of nice functionality to the pdb mode, which now
334 has tab-completion, syntax highlighting, and better stack handling
342 has tab-completion, syntax highlighting, and better stack handling
335 than before. Many thanks to Vivian De Smedt
343 than before. Many thanks to Vivian De Smedt
336 <vivian-AT-vdesmedt.com> for the original patches.
344 <vivian-AT-vdesmedt.com> for the original patches.
337
345
338 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
346 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
339
347
340 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
348 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
341 sequence to consistently accept the banner argument. The
349 sequence to consistently accept the banner argument. The
342 inconsistency was tripping SAGE, thanks to Gary Zablackis
350 inconsistency was tripping SAGE, thanks to Gary Zablackis
343 <gzabl-AT-yahoo.com> for the report.
351 <gzabl-AT-yahoo.com> for the report.
344
352
345 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
353 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
346
354
347 * IPython/iplib.py (InteractiveShell.post_config_initialization):
355 * IPython/iplib.py (InteractiveShell.post_config_initialization):
348 Fix bug where a naked 'alias' call in the ipythonrc file would
356 Fix bug where a naked 'alias' call in the ipythonrc file would
349 cause a crash. Bug reported by Jorgen Stenarson.
357 cause a crash. Bug reported by Jorgen Stenarson.
350
358
351 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
359 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
352
360
353 * IPython/ipmaker.py (make_IPython): cleanups which should improve
361 * IPython/ipmaker.py (make_IPython): cleanups which should improve
354 startup time.
362 startup time.
355
363
356 * IPython/iplib.py (runcode): my globals 'fix' for embedded
364 * IPython/iplib.py (runcode): my globals 'fix' for embedded
357 instances had introduced a bug with globals in normal code. Now
365 instances had introduced a bug with globals in normal code. Now
358 it's working in all cases.
366 it's working in all cases.
359
367
360 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
368 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
361 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
369 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
362 has been introduced to set the default case sensitivity of the
370 has been introduced to set the default case sensitivity of the
363 searches. Users can still select either mode at runtime on a
371 searches. Users can still select either mode at runtime on a
364 per-search basis.
372 per-search basis.
365
373
366 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
374 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
367
375
368 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
376 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
369 attributes in wildcard searches for subclasses. Modified version
377 attributes in wildcard searches for subclasses. Modified version
370 of a patch by Jorgen.
378 of a patch by Jorgen.
371
379
372 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
380 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
373
381
374 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
382 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
375 embedded instances. I added a user_global_ns attribute to the
383 embedded instances. I added a user_global_ns attribute to the
376 InteractiveShell class to handle this.
384 InteractiveShell class to handle this.
377
385
378 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
386 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
379
387
380 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
388 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
381 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
389 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
382 (reported under win32, but may happen also in other platforms).
390 (reported under win32, but may happen also in other platforms).
383 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
391 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
384
392
385 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
393 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
386
394
387 * IPython/Magic.py (magic_psearch): new support for wildcard
395 * IPython/Magic.py (magic_psearch): new support for wildcard
388 patterns. Now, typing ?a*b will list all names which begin with a
396 patterns. Now, typing ?a*b will list all names which begin with a
389 and end in b, for example. The %psearch magic has full
397 and end in b, for example. The %psearch magic has full
390 docstrings. Many thanks to JΓΆrgen Stenarson
398 docstrings. Many thanks to JΓΆrgen Stenarson
391 <jorgen.stenarson-AT-bostream.nu>, author of the patches
399 <jorgen.stenarson-AT-bostream.nu>, author of the patches
392 implementing this functionality.
400 implementing this functionality.
393
401
394 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
402 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
395
403
396 * Manual: fixed long-standing annoyance of double-dashes (as in
404 * Manual: fixed long-standing annoyance of double-dashes (as in
397 --prefix=~, for example) being stripped in the HTML version. This
405 --prefix=~, for example) being stripped in the HTML version. This
398 is a latex2html bug, but a workaround was provided. Many thanks
406 is a latex2html bug, but a workaround was provided. Many thanks
399 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
407 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
400 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
408 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
401 rolling. This seemingly small issue had tripped a number of users
409 rolling. This seemingly small issue had tripped a number of users
402 when first installing, so I'm glad to see it gone.
410 when first installing, so I'm glad to see it gone.
403
411
404 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
412 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
405
413
406 * IPython/Extensions/numeric_formats.py: fix missing import,
414 * IPython/Extensions/numeric_formats.py: fix missing import,
407 reported by Stephen Walton.
415 reported by Stephen Walton.
408
416
409 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
417 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
410
418
411 * IPython/demo.py: finish demo module, fully documented now.
419 * IPython/demo.py: finish demo module, fully documented now.
412
420
413 * IPython/genutils.py (file_read): simple little utility to read a
421 * IPython/genutils.py (file_read): simple little utility to read a
414 file and ensure it's closed afterwards.
422 file and ensure it's closed afterwards.
415
423
416 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
424 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
417
425
418 * IPython/demo.py (Demo.__init__): added support for individually
426 * IPython/demo.py (Demo.__init__): added support for individually
419 tagging blocks for automatic execution.
427 tagging blocks for automatic execution.
420
428
421 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
429 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
422 syntax-highlighted python sources, requested by John.
430 syntax-highlighted python sources, requested by John.
423
431
424 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
432 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
425
433
426 * IPython/demo.py (Demo.again): fix bug where again() blocks after
434 * IPython/demo.py (Demo.again): fix bug where again() blocks after
427 finishing.
435 finishing.
428
436
429 * IPython/genutils.py (shlex_split): moved from Magic to here,
437 * IPython/genutils.py (shlex_split): moved from Magic to here,
430 where all 2.2 compatibility stuff lives. I needed it for demo.py.
438 where all 2.2 compatibility stuff lives. I needed it for demo.py.
431
439
432 * IPython/demo.py (Demo.__init__): added support for silent
440 * IPython/demo.py (Demo.__init__): added support for silent
433 blocks, improved marks as regexps, docstrings written.
441 blocks, improved marks as regexps, docstrings written.
434 (Demo.__init__): better docstring, added support for sys.argv.
442 (Demo.__init__): better docstring, added support for sys.argv.
435
443
436 * IPython/genutils.py (marquee): little utility used by the demo
444 * IPython/genutils.py (marquee): little utility used by the demo
437 code, handy in general.
445 code, handy in general.
438
446
439 * IPython/demo.py (Demo.__init__): new class for interactive
447 * IPython/demo.py (Demo.__init__): new class for interactive
440 demos. Not documented yet, I just wrote it in a hurry for
448 demos. Not documented yet, I just wrote it in a hurry for
441 scipy'05. Will docstring later.
449 scipy'05. Will docstring later.
442
450
443 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
451 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
444
452
445 * IPython/Shell.py (sigint_handler): Drastic simplification which
453 * IPython/Shell.py (sigint_handler): Drastic simplification which
446 also seems to make Ctrl-C work correctly across threads! This is
454 also seems to make Ctrl-C work correctly across threads! This is
447 so simple, that I can't beleive I'd missed it before. Needs more
455 so simple, that I can't beleive I'd missed it before. Needs more
448 testing, though.
456 testing, though.
449 (KBINT): Never mind, revert changes. I'm sure I'd tried something
457 (KBINT): Never mind, revert changes. I'm sure I'd tried something
450 like this before...
458 like this before...
451
459
452 * IPython/genutils.py (get_home_dir): add protection against
460 * IPython/genutils.py (get_home_dir): add protection against
453 non-dirs in win32 registry.
461 non-dirs in win32 registry.
454
462
455 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
463 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
456 bug where dict was mutated while iterating (pysh crash).
464 bug where dict was mutated while iterating (pysh crash).
457
465
458 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
466 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
459
467
460 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
468 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
461 spurious newlines added by this routine. After a report by
469 spurious newlines added by this routine. After a report by
462 F. Mantegazza.
470 F. Mantegazza.
463
471
464 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
472 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
465
473
466 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
474 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
467 calls. These were a leftover from the GTK 1.x days, and can cause
475 calls. These were a leftover from the GTK 1.x days, and can cause
468 problems in certain cases (after a report by John Hunter).
476 problems in certain cases (after a report by John Hunter).
469
477
470 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
478 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
471 os.getcwd() fails at init time. Thanks to patch from David Remahl
479 os.getcwd() fails at init time. Thanks to patch from David Remahl
472 <chmod007-AT-mac.com>.
480 <chmod007-AT-mac.com>.
473 (InteractiveShell.__init__): prevent certain special magics from
481 (InteractiveShell.__init__): prevent certain special magics from
474 being shadowed by aliases. Closes
482 being shadowed by aliases. Closes
475 http://www.scipy.net/roundup/ipython/issue41.
483 http://www.scipy.net/roundup/ipython/issue41.
476
484
477 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
485 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
478
486
479 * IPython/iplib.py (InteractiveShell.complete): Added new
487 * IPython/iplib.py (InteractiveShell.complete): Added new
480 top-level completion method to expose the completion mechanism
488 top-level completion method to expose the completion mechanism
481 beyond readline-based environments.
489 beyond readline-based environments.
482
490
483 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
491 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
484
492
485 * tools/ipsvnc (svnversion): fix svnversion capture.
493 * tools/ipsvnc (svnversion): fix svnversion capture.
486
494
487 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
495 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
488 attribute to self, which was missing. Before, it was set by a
496 attribute to self, which was missing. Before, it was set by a
489 routine which in certain cases wasn't being called, so the
497 routine which in certain cases wasn't being called, so the
490 instance could end up missing the attribute. This caused a crash.
498 instance could end up missing the attribute. This caused a crash.
491 Closes http://www.scipy.net/roundup/ipython/issue40.
499 Closes http://www.scipy.net/roundup/ipython/issue40.
492
500
493 2005-08-16 Fernando Perez <fperez@colorado.edu>
501 2005-08-16 Fernando Perez <fperez@colorado.edu>
494
502
495 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
503 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
496 contains non-string attribute. Closes
504 contains non-string attribute. Closes
497 http://www.scipy.net/roundup/ipython/issue38.
505 http://www.scipy.net/roundup/ipython/issue38.
498
506
499 2005-08-14 Fernando Perez <fperez@colorado.edu>
507 2005-08-14 Fernando Perez <fperez@colorado.edu>
500
508
501 * tools/ipsvnc: Minor improvements, to add changeset info.
509 * tools/ipsvnc: Minor improvements, to add changeset info.
502
510
503 2005-08-12 Fernando Perez <fperez@colorado.edu>
511 2005-08-12 Fernando Perez <fperez@colorado.edu>
504
512
505 * IPython/iplib.py (runsource): remove self.code_to_run_src
513 * IPython/iplib.py (runsource): remove self.code_to_run_src
506 attribute. I realized this is nothing more than
514 attribute. I realized this is nothing more than
507 '\n'.join(self.buffer), and having the same data in two different
515 '\n'.join(self.buffer), and having the same data in two different
508 places is just asking for synchronization bugs. This may impact
516 places is just asking for synchronization bugs. This may impact
509 people who have custom exception handlers, so I need to warn
517 people who have custom exception handlers, so I need to warn
510 ipython-dev about it (F. Mantegazza may use them).
518 ipython-dev about it (F. Mantegazza may use them).
511
519
512 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
520 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
513
521
514 * IPython/genutils.py: fix 2.2 compatibility (generators)
522 * IPython/genutils.py: fix 2.2 compatibility (generators)
515
523
516 2005-07-18 Fernando Perez <fperez@colorado.edu>
524 2005-07-18 Fernando Perez <fperez@colorado.edu>
517
525
518 * IPython/genutils.py (get_home_dir): fix to help users with
526 * IPython/genutils.py (get_home_dir): fix to help users with
519 invalid $HOME under win32.
527 invalid $HOME under win32.
520
528
521 2005-07-17 Fernando Perez <fperez@colorado.edu>
529 2005-07-17 Fernando Perez <fperez@colorado.edu>
522
530
523 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
531 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
524 some old hacks and clean up a bit other routines; code should be
532 some old hacks and clean up a bit other routines; code should be
525 simpler and a bit faster.
533 simpler and a bit faster.
526
534
527 * IPython/iplib.py (interact): removed some last-resort attempts
535 * IPython/iplib.py (interact): removed some last-resort attempts
528 to survive broken stdout/stderr. That code was only making it
536 to survive broken stdout/stderr. That code was only making it
529 harder to abstract out the i/o (necessary for gui integration),
537 harder to abstract out the i/o (necessary for gui integration),
530 and the crashes it could prevent were extremely rare in practice
538 and the crashes it could prevent were extremely rare in practice
531 (besides being fully user-induced in a pretty violent manner).
539 (besides being fully user-induced in a pretty violent manner).
532
540
533 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
541 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
534 Nothing major yet, but the code is simpler to read; this should
542 Nothing major yet, but the code is simpler to read; this should
535 make it easier to do more serious modifications in the future.
543 make it easier to do more serious modifications in the future.
536
544
537 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
545 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
538 which broke in .15 (thanks to a report by Ville).
546 which broke in .15 (thanks to a report by Ville).
539
547
540 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
548 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
541 be quite correct, I know next to nothing about unicode). This
549 be quite correct, I know next to nothing about unicode). This
542 will allow unicode strings to be used in prompts, amongst other
550 will allow unicode strings to be used in prompts, amongst other
543 cases. It also will prevent ipython from crashing when unicode
551 cases. It also will prevent ipython from crashing when unicode
544 shows up unexpectedly in many places. If ascii encoding fails, we
552 shows up unexpectedly in many places. If ascii encoding fails, we
545 assume utf_8. Currently the encoding is not a user-visible
553 assume utf_8. Currently the encoding is not a user-visible
546 setting, though it could be made so if there is demand for it.
554 setting, though it could be made so if there is demand for it.
547
555
548 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
556 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
549
557
550 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
558 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
551
559
552 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
560 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
553
561
554 * IPython/genutils.py: Add 2.2 compatibility here, so all other
562 * IPython/genutils.py: Add 2.2 compatibility here, so all other
555 code can work transparently for 2.2/2.3.
563 code can work transparently for 2.2/2.3.
556
564
557 2005-07-16 Fernando Perez <fperez@colorado.edu>
565 2005-07-16 Fernando Perez <fperez@colorado.edu>
558
566
559 * IPython/ultraTB.py (ExceptionColors): Make a global variable
567 * IPython/ultraTB.py (ExceptionColors): Make a global variable
560 out of the color scheme table used for coloring exception
568 out of the color scheme table used for coloring exception
561 tracebacks. This allows user code to add new schemes at runtime.
569 tracebacks. This allows user code to add new schemes at runtime.
562 This is a minimally modified version of the patch at
570 This is a minimally modified version of the patch at
563 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
571 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
564 for the contribution.
572 for the contribution.
565
573
566 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
574 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
567 slightly modified version of the patch in
575 slightly modified version of the patch in
568 http://www.scipy.net/roundup/ipython/issue34, which also allows me
576 http://www.scipy.net/roundup/ipython/issue34, which also allows me
569 to remove the previous try/except solution (which was costlier).
577 to remove the previous try/except solution (which was costlier).
570 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
578 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
571
579
572 2005-06-08 Fernando Perez <fperez@colorado.edu>
580 2005-06-08 Fernando Perez <fperez@colorado.edu>
573
581
574 * IPython/iplib.py (write/write_err): Add methods to abstract all
582 * IPython/iplib.py (write/write_err): Add methods to abstract all
575 I/O a bit more.
583 I/O a bit more.
576
584
577 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
585 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
578 warning, reported by Aric Hagberg, fix by JD Hunter.
586 warning, reported by Aric Hagberg, fix by JD Hunter.
579
587
580 2005-06-02 *** Released version 0.6.15
588 2005-06-02 *** Released version 0.6.15
581
589
582 2005-06-01 Fernando Perez <fperez@colorado.edu>
590 2005-06-01 Fernando Perez <fperez@colorado.edu>
583
591
584 * IPython/iplib.py (MagicCompleter.file_matches): Fix
592 * IPython/iplib.py (MagicCompleter.file_matches): Fix
585 tab-completion of filenames within open-quoted strings. Note that
593 tab-completion of filenames within open-quoted strings. Note that
586 this requires that in ~/.ipython/ipythonrc, users change the
594 this requires that in ~/.ipython/ipythonrc, users change the
587 readline delimiters configuration to read:
595 readline delimiters configuration to read:
588
596
589 readline_remove_delims -/~
597 readline_remove_delims -/~
590
598
591
599
592 2005-05-31 *** Released version 0.6.14
600 2005-05-31 *** Released version 0.6.14
593
601
594 2005-05-29 Fernando Perez <fperez@colorado.edu>
602 2005-05-29 Fernando Perez <fperez@colorado.edu>
595
603
596 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
604 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
597 with files not on the filesystem. Reported by Eliyahu Sandler
605 with files not on the filesystem. Reported by Eliyahu Sandler
598 <eli@gondolin.net>
606 <eli@gondolin.net>
599
607
600 2005-05-22 Fernando Perez <fperez@colorado.edu>
608 2005-05-22 Fernando Perez <fperez@colorado.edu>
601
609
602 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
610 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
603 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
611 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
604
612
605 2005-05-19 Fernando Perez <fperez@colorado.edu>
613 2005-05-19 Fernando Perez <fperez@colorado.edu>
606
614
607 * IPython/iplib.py (safe_execfile): close a file which could be
615 * IPython/iplib.py (safe_execfile): close a file which could be
608 left open (causing problems in win32, which locks open files).
616 left open (causing problems in win32, which locks open files).
609 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
617 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
610
618
611 2005-05-18 Fernando Perez <fperez@colorado.edu>
619 2005-05-18 Fernando Perez <fperez@colorado.edu>
612
620
613 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
621 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
614 keyword arguments correctly to safe_execfile().
622 keyword arguments correctly to safe_execfile().
615
623
616 2005-05-13 Fernando Perez <fperez@colorado.edu>
624 2005-05-13 Fernando Perez <fperez@colorado.edu>
617
625
618 * ipython.1: Added info about Qt to manpage, and threads warning
626 * ipython.1: Added info about Qt to manpage, and threads warning
619 to usage page (invoked with --help).
627 to usage page (invoked with --help).
620
628
621 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
629 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
622 new matcher (it goes at the end of the priority list) to do
630 new matcher (it goes at the end of the priority list) to do
623 tab-completion on named function arguments. Submitted by George
631 tab-completion on named function arguments. Submitted by George
624 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
632 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
625 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
633 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
626 for more details.
634 for more details.
627
635
628 * IPython/Magic.py (magic_run): Added new -e flag to ignore
636 * IPython/Magic.py (magic_run): Added new -e flag to ignore
629 SystemExit exceptions in the script being run. Thanks to a report
637 SystemExit exceptions in the script being run. Thanks to a report
630 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
638 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
631 producing very annoying behavior when running unit tests.
639 producing very annoying behavior when running unit tests.
632
640
633 2005-05-12 Fernando Perez <fperez@colorado.edu>
641 2005-05-12 Fernando Perez <fperez@colorado.edu>
634
642
635 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
643 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
636 which I'd broken (again) due to a changed regexp. In the process,
644 which I'd broken (again) due to a changed regexp. In the process,
637 added ';' as an escape to auto-quote the whole line without
645 added ';' as an escape to auto-quote the whole line without
638 splitting its arguments. Thanks to a report by Jerry McRae
646 splitting its arguments. Thanks to a report by Jerry McRae
639 <qrs0xyc02-AT-sneakemail.com>.
647 <qrs0xyc02-AT-sneakemail.com>.
640
648
641 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
649 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
642 possible crashes caused by a TokenError. Reported by Ed Schofield
650 possible crashes caused by a TokenError. Reported by Ed Schofield
643 <schofield-AT-ftw.at>.
651 <schofield-AT-ftw.at>.
644
652
645 2005-05-06 Fernando Perez <fperez@colorado.edu>
653 2005-05-06 Fernando Perez <fperez@colorado.edu>
646
654
647 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
655 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
648
656
649 2005-04-29 Fernando Perez <fperez@colorado.edu>
657 2005-04-29 Fernando Perez <fperez@colorado.edu>
650
658
651 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
659 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
652 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
660 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
653 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
661 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
654 which provides support for Qt interactive usage (similar to the
662 which provides support for Qt interactive usage (similar to the
655 existing one for WX and GTK). This had been often requested.
663 existing one for WX and GTK). This had been often requested.
656
664
657 2005-04-14 *** Released version 0.6.13
665 2005-04-14 *** Released version 0.6.13
658
666
659 2005-04-08 Fernando Perez <fperez@colorado.edu>
667 2005-04-08 Fernando Perez <fperez@colorado.edu>
660
668
661 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
669 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
662 from _ofind, which gets called on almost every input line. Now,
670 from _ofind, which gets called on almost every input line. Now,
663 we only try to get docstrings if they are actually going to be
671 we only try to get docstrings if they are actually going to be
664 used (the overhead of fetching unnecessary docstrings can be
672 used (the overhead of fetching unnecessary docstrings can be
665 noticeable for certain objects, such as Pyro proxies).
673 noticeable for certain objects, such as Pyro proxies).
666
674
667 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
675 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
668 for completers. For some reason I had been passing them the state
676 for completers. For some reason I had been passing them the state
669 variable, which completers never actually need, and was in
677 variable, which completers never actually need, and was in
670 conflict with the rlcompleter API. Custom completers ONLY need to
678 conflict with the rlcompleter API. Custom completers ONLY need to
671 take the text parameter.
679 take the text parameter.
672
680
673 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
681 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
674 work correctly in pysh. I've also moved all the logic which used
682 work correctly in pysh. I've also moved all the logic which used
675 to be in pysh.py here, which will prevent problems with future
683 to be in pysh.py here, which will prevent problems with future
676 upgrades. However, this time I must warn users to update their
684 upgrades. However, this time I must warn users to update their
677 pysh profile to include the line
685 pysh profile to include the line
678
686
679 import_all IPython.Extensions.InterpreterExec
687 import_all IPython.Extensions.InterpreterExec
680
688
681 because otherwise things won't work for them. They MUST also
689 because otherwise things won't work for them. They MUST also
682 delete pysh.py and the line
690 delete pysh.py and the line
683
691
684 execfile pysh.py
692 execfile pysh.py
685
693
686 from their ipythonrc-pysh.
694 from their ipythonrc-pysh.
687
695
688 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
696 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
689 robust in the face of objects whose dir() returns non-strings
697 robust in the face of objects whose dir() returns non-strings
690 (which it shouldn't, but some broken libs like ITK do). Thanks to
698 (which it shouldn't, but some broken libs like ITK do). Thanks to
691 a patch by John Hunter (implemented differently, though). Also
699 a patch by John Hunter (implemented differently, though). Also
692 minor improvements by using .extend instead of + on lists.
700 minor improvements by using .extend instead of + on lists.
693
701
694 * pysh.py:
702 * pysh.py:
695
703
696 2005-04-06 Fernando Perez <fperez@colorado.edu>
704 2005-04-06 Fernando Perez <fperez@colorado.edu>
697
705
698 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
706 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
699 by default, so that all users benefit from it. Those who don't
707 by default, so that all users benefit from it. Those who don't
700 want it can still turn it off.
708 want it can still turn it off.
701
709
702 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
710 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
703 config file, I'd forgotten about this, so users were getting it
711 config file, I'd forgotten about this, so users were getting it
704 off by default.
712 off by default.
705
713
706 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
714 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
707 consistency. Now magics can be called in multiline statements,
715 consistency. Now magics can be called in multiline statements,
708 and python variables can be expanded in magic calls via $var.
716 and python variables can be expanded in magic calls via $var.
709 This makes the magic system behave just like aliases or !system
717 This makes the magic system behave just like aliases or !system
710 calls.
718 calls.
711
719
712 2005-03-28 Fernando Perez <fperez@colorado.edu>
720 2005-03-28 Fernando Perez <fperez@colorado.edu>
713
721
714 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
722 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
715 expensive string additions for building command. Add support for
723 expensive string additions for building command. Add support for
716 trailing ';' when autocall is used.
724 trailing ';' when autocall is used.
717
725
718 2005-03-26 Fernando Perez <fperez@colorado.edu>
726 2005-03-26 Fernando Perez <fperez@colorado.edu>
719
727
720 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
728 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
721 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
729 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
722 ipython.el robust against prompts with any number of spaces
730 ipython.el robust against prompts with any number of spaces
723 (including 0) after the ':' character.
731 (including 0) after the ':' character.
724
732
725 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
733 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
726 continuation prompt, which misled users to think the line was
734 continuation prompt, which misled users to think the line was
727 already indented. Closes debian Bug#300847, reported to me by
735 already indented. Closes debian Bug#300847, reported to me by
728 Norbert Tretkowski <tretkowski-AT-inittab.de>.
736 Norbert Tretkowski <tretkowski-AT-inittab.de>.
729
737
730 2005-03-23 Fernando Perez <fperez@colorado.edu>
738 2005-03-23 Fernando Perez <fperez@colorado.edu>
731
739
732 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
740 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
733 properly aligned if they have embedded newlines.
741 properly aligned if they have embedded newlines.
734
742
735 * IPython/iplib.py (runlines): Add a public method to expose
743 * IPython/iplib.py (runlines): Add a public method to expose
736 IPython's code execution machinery, so that users can run strings
744 IPython's code execution machinery, so that users can run strings
737 as if they had been typed at the prompt interactively.
745 as if they had been typed at the prompt interactively.
738 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
746 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
739 methods which can call the system shell, but with python variable
747 methods which can call the system shell, but with python variable
740 expansion. The three such methods are: __IPYTHON__.system,
748 expansion. The three such methods are: __IPYTHON__.system,
741 .getoutput and .getoutputerror. These need to be documented in a
749 .getoutput and .getoutputerror. These need to be documented in a
742 'public API' section (to be written) of the manual.
750 'public API' section (to be written) of the manual.
743
751
744 2005-03-20 Fernando Perez <fperez@colorado.edu>
752 2005-03-20 Fernando Perez <fperez@colorado.edu>
745
753
746 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
754 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
747 for custom exception handling. This is quite powerful, and it
755 for custom exception handling. This is quite powerful, and it
748 allows for user-installable exception handlers which can trap
756 allows for user-installable exception handlers which can trap
749 custom exceptions at runtime and treat them separately from
757 custom exceptions at runtime and treat them separately from
750 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
758 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
751 Mantegazza <mantegazza-AT-ill.fr>.
759 Mantegazza <mantegazza-AT-ill.fr>.
752 (InteractiveShell.set_custom_completer): public API function to
760 (InteractiveShell.set_custom_completer): public API function to
753 add new completers at runtime.
761 add new completers at runtime.
754
762
755 2005-03-19 Fernando Perez <fperez@colorado.edu>
763 2005-03-19 Fernando Perez <fperez@colorado.edu>
756
764
757 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
765 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
758 allow objects which provide their docstrings via non-standard
766 allow objects which provide their docstrings via non-standard
759 mechanisms (like Pyro proxies) to still be inspected by ipython's
767 mechanisms (like Pyro proxies) to still be inspected by ipython's
760 ? system.
768 ? system.
761
769
762 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
770 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
763 automatic capture system. I tried quite hard to make it work
771 automatic capture system. I tried quite hard to make it work
764 reliably, and simply failed. I tried many combinations with the
772 reliably, and simply failed. I tried many combinations with the
765 subprocess module, but eventually nothing worked in all needed
773 subprocess module, but eventually nothing worked in all needed
766 cases (not blocking stdin for the child, duplicating stdout
774 cases (not blocking stdin for the child, duplicating stdout
767 without blocking, etc). The new %sc/%sx still do capture to these
775 without blocking, etc). The new %sc/%sx still do capture to these
768 magical list/string objects which make shell use much more
776 magical list/string objects which make shell use much more
769 conveninent, so not all is lost.
777 conveninent, so not all is lost.
770
778
771 XXX - FIX MANUAL for the change above!
779 XXX - FIX MANUAL for the change above!
772
780
773 (runsource): I copied code.py's runsource() into ipython to modify
781 (runsource): I copied code.py's runsource() into ipython to modify
774 it a bit. Now the code object and source to be executed are
782 it a bit. Now the code object and source to be executed are
775 stored in ipython. This makes this info accessible to third-party
783 stored in ipython. This makes this info accessible to third-party
776 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
784 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
777 Mantegazza <mantegazza-AT-ill.fr>.
785 Mantegazza <mantegazza-AT-ill.fr>.
778
786
779 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
787 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
780 history-search via readline (like C-p/C-n). I'd wanted this for a
788 history-search via readline (like C-p/C-n). I'd wanted this for a
781 long time, but only recently found out how to do it. For users
789 long time, but only recently found out how to do it. For users
782 who already have their ipythonrc files made and want this, just
790 who already have their ipythonrc files made and want this, just
783 add:
791 add:
784
792
785 readline_parse_and_bind "\e[A": history-search-backward
793 readline_parse_and_bind "\e[A": history-search-backward
786 readline_parse_and_bind "\e[B": history-search-forward
794 readline_parse_and_bind "\e[B": history-search-forward
787
795
788 2005-03-18 Fernando Perez <fperez@colorado.edu>
796 2005-03-18 Fernando Perez <fperez@colorado.edu>
789
797
790 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
798 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
791 LSString and SList classes which allow transparent conversions
799 LSString and SList classes which allow transparent conversions
792 between list mode and whitespace-separated string.
800 between list mode and whitespace-separated string.
793 (magic_r): Fix recursion problem in %r.
801 (magic_r): Fix recursion problem in %r.
794
802
795 * IPython/genutils.py (LSString): New class to be used for
803 * IPython/genutils.py (LSString): New class to be used for
796 automatic storage of the results of all alias/system calls in _o
804 automatic storage of the results of all alias/system calls in _o
797 and _e (stdout/err). These provide a .l/.list attribute which
805 and _e (stdout/err). These provide a .l/.list attribute which
798 does automatic splitting on newlines. This means that for most
806 does automatic splitting on newlines. This means that for most
799 uses, you'll never need to do capturing of output with %sc/%sx
807 uses, you'll never need to do capturing of output with %sc/%sx
800 anymore, since ipython keeps this always done for you. Note that
808 anymore, since ipython keeps this always done for you. Note that
801 only the LAST results are stored, the _o/e variables are
809 only the LAST results are stored, the _o/e variables are
802 overwritten on each call. If you need to save their contents
810 overwritten on each call. If you need to save their contents
803 further, simply bind them to any other name.
811 further, simply bind them to any other name.
804
812
805 2005-03-17 Fernando Perez <fperez@colorado.edu>
813 2005-03-17 Fernando Perez <fperez@colorado.edu>
806
814
807 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
815 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
808 prompt namespace handling.
816 prompt namespace handling.
809
817
810 2005-03-16 Fernando Perez <fperez@colorado.edu>
818 2005-03-16 Fernando Perez <fperez@colorado.edu>
811
819
812 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
820 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
813 classic prompts to be '>>> ' (final space was missing, and it
821 classic prompts to be '>>> ' (final space was missing, and it
814 trips the emacs python mode).
822 trips the emacs python mode).
815 (BasePrompt.__str__): Added safe support for dynamic prompt
823 (BasePrompt.__str__): Added safe support for dynamic prompt
816 strings. Now you can set your prompt string to be '$x', and the
824 strings. Now you can set your prompt string to be '$x', and the
817 value of x will be printed from your interactive namespace. The
825 value of x will be printed from your interactive namespace. The
818 interpolation syntax includes the full Itpl support, so
826 interpolation syntax includes the full Itpl support, so
819 ${foo()+x+bar()} is a valid prompt string now, and the function
827 ${foo()+x+bar()} is a valid prompt string now, and the function
820 calls will be made at runtime.
828 calls will be made at runtime.
821
829
822 2005-03-15 Fernando Perez <fperez@colorado.edu>
830 2005-03-15 Fernando Perez <fperez@colorado.edu>
823
831
824 * IPython/Magic.py (magic_history): renamed %hist to %history, to
832 * IPython/Magic.py (magic_history): renamed %hist to %history, to
825 avoid name clashes in pylab. %hist still works, it just forwards
833 avoid name clashes in pylab. %hist still works, it just forwards
826 the call to %history.
834 the call to %history.
827
835
828 2005-03-02 *** Released version 0.6.12
836 2005-03-02 *** Released version 0.6.12
829
837
830 2005-03-02 Fernando Perez <fperez@colorado.edu>
838 2005-03-02 Fernando Perez <fperez@colorado.edu>
831
839
832 * IPython/iplib.py (handle_magic): log magic calls properly as
840 * IPython/iplib.py (handle_magic): log magic calls properly as
833 ipmagic() function calls.
841 ipmagic() function calls.
834
842
835 * IPython/Magic.py (magic_time): Improved %time to support
843 * IPython/Magic.py (magic_time): Improved %time to support
836 statements and provide wall-clock as well as CPU time.
844 statements and provide wall-clock as well as CPU time.
837
845
838 2005-02-27 Fernando Perez <fperez@colorado.edu>
846 2005-02-27 Fernando Perez <fperez@colorado.edu>
839
847
840 * IPython/hooks.py: New hooks module, to expose user-modifiable
848 * IPython/hooks.py: New hooks module, to expose user-modifiable
841 IPython functionality in a clean manner. For now only the editor
849 IPython functionality in a clean manner. For now only the editor
842 hook is actually written, and other thigns which I intend to turn
850 hook is actually written, and other thigns which I intend to turn
843 into proper hooks aren't yet there. The display and prefilter
851 into proper hooks aren't yet there. The display and prefilter
844 stuff, for example, should be hooks. But at least now the
852 stuff, for example, should be hooks. But at least now the
845 framework is in place, and the rest can be moved here with more
853 framework is in place, and the rest can be moved here with more
846 time later. IPython had had a .hooks variable for a long time for
854 time later. IPython had had a .hooks variable for a long time for
847 this purpose, but I'd never actually used it for anything.
855 this purpose, but I'd never actually used it for anything.
848
856
849 2005-02-26 Fernando Perez <fperez@colorado.edu>
857 2005-02-26 Fernando Perez <fperez@colorado.edu>
850
858
851 * IPython/ipmaker.py (make_IPython): make the default ipython
859 * IPython/ipmaker.py (make_IPython): make the default ipython
852 directory be called _ipython under win32, to follow more the
860 directory be called _ipython under win32, to follow more the
853 naming peculiarities of that platform (where buggy software like
861 naming peculiarities of that platform (where buggy software like
854 Visual Sourcesafe breaks with .named directories). Reported by
862 Visual Sourcesafe breaks with .named directories). Reported by
855 Ville Vainio.
863 Ville Vainio.
856
864
857 2005-02-23 Fernando Perez <fperez@colorado.edu>
865 2005-02-23 Fernando Perez <fperez@colorado.edu>
858
866
859 * IPython/iplib.py (InteractiveShell.__init__): removed a few
867 * IPython/iplib.py (InteractiveShell.__init__): removed a few
860 auto_aliases for win32 which were causing problems. Users can
868 auto_aliases for win32 which were causing problems. Users can
861 define the ones they personally like.
869 define the ones they personally like.
862
870
863 2005-02-21 Fernando Perez <fperez@colorado.edu>
871 2005-02-21 Fernando Perez <fperez@colorado.edu>
864
872
865 * IPython/Magic.py (magic_time): new magic to time execution of
873 * IPython/Magic.py (magic_time): new magic to time execution of
866 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
874 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
867
875
868 2005-02-19 Fernando Perez <fperez@colorado.edu>
876 2005-02-19 Fernando Perez <fperez@colorado.edu>
869
877
870 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
878 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
871 into keys (for prompts, for example).
879 into keys (for prompts, for example).
872
880
873 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
881 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
874 prompts in case users want them. This introduces a small behavior
882 prompts in case users want them. This introduces a small behavior
875 change: ipython does not automatically add a space to all prompts
883 change: ipython does not automatically add a space to all prompts
876 anymore. To get the old prompts with a space, users should add it
884 anymore. To get the old prompts with a space, users should add it
877 manually to their ipythonrc file, so for example prompt_in1 should
885 manually to their ipythonrc file, so for example prompt_in1 should
878 now read 'In [\#]: ' instead of 'In [\#]:'.
886 now read 'In [\#]: ' instead of 'In [\#]:'.
879 (BasePrompt.__init__): New option prompts_pad_left (only in rc
887 (BasePrompt.__init__): New option prompts_pad_left (only in rc
880 file) to control left-padding of secondary prompts.
888 file) to control left-padding of secondary prompts.
881
889
882 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
890 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
883 the profiler can't be imported. Fix for Debian, which removed
891 the profiler can't be imported. Fix for Debian, which removed
884 profile.py because of License issues. I applied a slightly
892 profile.py because of License issues. I applied a slightly
885 modified version of the original Debian patch at
893 modified version of the original Debian patch at
886 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
894 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
887
895
888 2005-02-17 Fernando Perez <fperez@colorado.edu>
896 2005-02-17 Fernando Perez <fperez@colorado.edu>
889
897
890 * IPython/genutils.py (native_line_ends): Fix bug which would
898 * IPython/genutils.py (native_line_ends): Fix bug which would
891 cause improper line-ends under win32 b/c I was not opening files
899 cause improper line-ends under win32 b/c I was not opening files
892 in binary mode. Bug report and fix thanks to Ville.
900 in binary mode. Bug report and fix thanks to Ville.
893
901
894 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
902 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
895 trying to catch spurious foo[1] autocalls. My fix actually broke
903 trying to catch spurious foo[1] autocalls. My fix actually broke
896 ',/' autoquote/call with explicit escape (bad regexp).
904 ',/' autoquote/call with explicit escape (bad regexp).
897
905
898 2005-02-15 *** Released version 0.6.11
906 2005-02-15 *** Released version 0.6.11
899
907
900 2005-02-14 Fernando Perez <fperez@colorado.edu>
908 2005-02-14 Fernando Perez <fperez@colorado.edu>
901
909
902 * IPython/background_jobs.py: New background job management
910 * IPython/background_jobs.py: New background job management
903 subsystem. This is implemented via a new set of classes, and
911 subsystem. This is implemented via a new set of classes, and
904 IPython now provides a builtin 'jobs' object for background job
912 IPython now provides a builtin 'jobs' object for background job
905 execution. A convenience %bg magic serves as a lightweight
913 execution. A convenience %bg magic serves as a lightweight
906 frontend for starting the more common type of calls. This was
914 frontend for starting the more common type of calls. This was
907 inspired by discussions with B. Granger and the BackgroundCommand
915 inspired by discussions with B. Granger and the BackgroundCommand
908 class described in the book Python Scripting for Computational
916 class described in the book Python Scripting for Computational
909 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
917 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
910 (although ultimately no code from this text was used, as IPython's
918 (although ultimately no code from this text was used, as IPython's
911 system is a separate implementation).
919 system is a separate implementation).
912
920
913 * IPython/iplib.py (MagicCompleter.python_matches): add new option
921 * IPython/iplib.py (MagicCompleter.python_matches): add new option
914 to control the completion of single/double underscore names
922 to control the completion of single/double underscore names
915 separately. As documented in the example ipytonrc file, the
923 separately. As documented in the example ipytonrc file, the
916 readline_omit__names variable can now be set to 2, to omit even
924 readline_omit__names variable can now be set to 2, to omit even
917 single underscore names. Thanks to a patch by Brian Wong
925 single underscore names. Thanks to a patch by Brian Wong
918 <BrianWong-AT-AirgoNetworks.Com>.
926 <BrianWong-AT-AirgoNetworks.Com>.
919 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
927 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
920 be autocalled as foo([1]) if foo were callable. A problem for
928 be autocalled as foo([1]) if foo were callable. A problem for
921 things which are both callable and implement __getitem__.
929 things which are both callable and implement __getitem__.
922 (init_readline): Fix autoindentation for win32. Thanks to a patch
930 (init_readline): Fix autoindentation for win32. Thanks to a patch
923 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
931 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
924
932
925 2005-02-12 Fernando Perez <fperez@colorado.edu>
933 2005-02-12 Fernando Perez <fperez@colorado.edu>
926
934
927 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
935 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
928 which I had written long ago to sort out user error messages which
936 which I had written long ago to sort out user error messages which
929 may occur during startup. This seemed like a good idea initially,
937 may occur during startup. This seemed like a good idea initially,
930 but it has proven a disaster in retrospect. I don't want to
938 but it has proven a disaster in retrospect. I don't want to
931 change much code for now, so my fix is to set the internal 'debug'
939 change much code for now, so my fix is to set the internal 'debug'
932 flag to true everywhere, whose only job was precisely to control
940 flag to true everywhere, whose only job was precisely to control
933 this subsystem. This closes issue 28 (as well as avoiding all
941 this subsystem. This closes issue 28 (as well as avoiding all
934 sorts of strange hangups which occur from time to time).
942 sorts of strange hangups which occur from time to time).
935
943
936 2005-02-07 Fernando Perez <fperez@colorado.edu>
944 2005-02-07 Fernando Perez <fperez@colorado.edu>
937
945
938 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
946 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
939 previous call produced a syntax error.
947 previous call produced a syntax error.
940
948
941 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
949 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
942 classes without constructor.
950 classes without constructor.
943
951
944 2005-02-06 Fernando Perez <fperez@colorado.edu>
952 2005-02-06 Fernando Perez <fperez@colorado.edu>
945
953
946 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
954 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
947 completions with the results of each matcher, so we return results
955 completions with the results of each matcher, so we return results
948 to the user from all namespaces. This breaks with ipython
956 to the user from all namespaces. This breaks with ipython
949 tradition, but I think it's a nicer behavior. Now you get all
957 tradition, but I think it's a nicer behavior. Now you get all
950 possible completions listed, from all possible namespaces (python,
958 possible completions listed, from all possible namespaces (python,
951 filesystem, magics...) After a request by John Hunter
959 filesystem, magics...) After a request by John Hunter
952 <jdhunter-AT-nitace.bsd.uchicago.edu>.
960 <jdhunter-AT-nitace.bsd.uchicago.edu>.
953
961
954 2005-02-05 Fernando Perez <fperez@colorado.edu>
962 2005-02-05 Fernando Perez <fperez@colorado.edu>
955
963
956 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
964 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
957 the call had quote characters in it (the quotes were stripped).
965 the call had quote characters in it (the quotes were stripped).
958
966
959 2005-01-31 Fernando Perez <fperez@colorado.edu>
967 2005-01-31 Fernando Perez <fperez@colorado.edu>
960
968
961 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
969 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
962 Itpl.itpl() to make the code more robust against psyco
970 Itpl.itpl() to make the code more robust against psyco
963 optimizations.
971 optimizations.
964
972
965 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
973 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
966 of causing an exception. Quicker, cleaner.
974 of causing an exception. Quicker, cleaner.
967
975
968 2005-01-28 Fernando Perez <fperez@colorado.edu>
976 2005-01-28 Fernando Perez <fperez@colorado.edu>
969
977
970 * scripts/ipython_win_post_install.py (install): hardcode
978 * scripts/ipython_win_post_install.py (install): hardcode
971 sys.prefix+'python.exe' as the executable path. It turns out that
979 sys.prefix+'python.exe' as the executable path. It turns out that
972 during the post-installation run, sys.executable resolves to the
980 during the post-installation run, sys.executable resolves to the
973 name of the binary installer! I should report this as a distutils
981 name of the binary installer! I should report this as a distutils
974 bug, I think. I updated the .10 release with this tiny fix, to
982 bug, I think. I updated the .10 release with this tiny fix, to
975 avoid annoying the lists further.
983 avoid annoying the lists further.
976
984
977 2005-01-27 *** Released version 0.6.10
985 2005-01-27 *** Released version 0.6.10
978
986
979 2005-01-27 Fernando Perez <fperez@colorado.edu>
987 2005-01-27 Fernando Perez <fperez@colorado.edu>
980
988
981 * IPython/numutils.py (norm): Added 'inf' as optional name for
989 * IPython/numutils.py (norm): Added 'inf' as optional name for
982 L-infinity norm, included references to mathworld.com for vector
990 L-infinity norm, included references to mathworld.com for vector
983 norm definitions.
991 norm definitions.
984 (amin/amax): added amin/amax for array min/max. Similar to what
992 (amin/amax): added amin/amax for array min/max. Similar to what
985 pylab ships with after the recent reorganization of names.
993 pylab ships with after the recent reorganization of names.
986 (spike/spike_odd): removed deprecated spike/spike_odd functions.
994 (spike/spike_odd): removed deprecated spike/spike_odd functions.
987
995
988 * ipython.el: committed Alex's recent fixes and improvements.
996 * ipython.el: committed Alex's recent fixes and improvements.
989 Tested with python-mode from CVS, and it looks excellent. Since
997 Tested with python-mode from CVS, and it looks excellent. Since
990 python-mode hasn't released anything in a while, I'm temporarily
998 python-mode hasn't released anything in a while, I'm temporarily
991 putting a copy of today's CVS (v 4.70) of python-mode in:
999 putting a copy of today's CVS (v 4.70) of python-mode in:
992 http://ipython.scipy.org/tmp/python-mode.el
1000 http://ipython.scipy.org/tmp/python-mode.el
993
1001
994 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1002 * scripts/ipython_win_post_install.py (install): Win32 fix to use
995 sys.executable for the executable name, instead of assuming it's
1003 sys.executable for the executable name, instead of assuming it's
996 called 'python.exe' (the post-installer would have produced broken
1004 called 'python.exe' (the post-installer would have produced broken
997 setups on systems with a differently named python binary).
1005 setups on systems with a differently named python binary).
998
1006
999 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1007 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1000 references to os.linesep, to make the code more
1008 references to os.linesep, to make the code more
1001 platform-independent. This is also part of the win32 coloring
1009 platform-independent. This is also part of the win32 coloring
1002 fixes.
1010 fixes.
1003
1011
1004 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1012 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1005 lines, which actually cause coloring bugs because the length of
1013 lines, which actually cause coloring bugs because the length of
1006 the line is very difficult to correctly compute with embedded
1014 the line is very difficult to correctly compute with embedded
1007 escapes. This was the source of all the coloring problems under
1015 escapes. This was the source of all the coloring problems under
1008 Win32. I think that _finally_, Win32 users have a properly
1016 Win32. I think that _finally_, Win32 users have a properly
1009 working ipython in all respects. This would never have happened
1017 working ipython in all respects. This would never have happened
1010 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1018 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1011
1019
1012 2005-01-26 *** Released version 0.6.9
1020 2005-01-26 *** Released version 0.6.9
1013
1021
1014 2005-01-25 Fernando Perez <fperez@colorado.edu>
1022 2005-01-25 Fernando Perez <fperez@colorado.edu>
1015
1023
1016 * setup.py: finally, we have a true Windows installer, thanks to
1024 * setup.py: finally, we have a true Windows installer, thanks to
1017 the excellent work of Viktor Ransmayr
1025 the excellent work of Viktor Ransmayr
1018 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1026 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1019 Windows users. The setup routine is quite a bit cleaner thanks to
1027 Windows users. The setup routine is quite a bit cleaner thanks to
1020 this, and the post-install script uses the proper functions to
1028 this, and the post-install script uses the proper functions to
1021 allow a clean de-installation using the standard Windows Control
1029 allow a clean de-installation using the standard Windows Control
1022 Panel.
1030 Panel.
1023
1031
1024 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1032 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1025 environment variable under all OSes (including win32) if
1033 environment variable under all OSes (including win32) if
1026 available. This will give consistency to win32 users who have set
1034 available. This will give consistency to win32 users who have set
1027 this variable for any reason. If os.environ['HOME'] fails, the
1035 this variable for any reason. If os.environ['HOME'] fails, the
1028 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1036 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1029
1037
1030 2005-01-24 Fernando Perez <fperez@colorado.edu>
1038 2005-01-24 Fernando Perez <fperez@colorado.edu>
1031
1039
1032 * IPython/numutils.py (empty_like): add empty_like(), similar to
1040 * IPython/numutils.py (empty_like): add empty_like(), similar to
1033 zeros_like() but taking advantage of the new empty() Numeric routine.
1041 zeros_like() but taking advantage of the new empty() Numeric routine.
1034
1042
1035 2005-01-23 *** Released version 0.6.8
1043 2005-01-23 *** Released version 0.6.8
1036
1044
1037 2005-01-22 Fernando Perez <fperez@colorado.edu>
1045 2005-01-22 Fernando Perez <fperez@colorado.edu>
1038
1046
1039 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1047 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1040 automatic show() calls. After discussing things with JDH, it
1048 automatic show() calls. After discussing things with JDH, it
1041 turns out there are too many corner cases where this can go wrong.
1049 turns out there are too many corner cases where this can go wrong.
1042 It's best not to try to be 'too smart', and simply have ipython
1050 It's best not to try to be 'too smart', and simply have ipython
1043 reproduce as much as possible the default behavior of a normal
1051 reproduce as much as possible the default behavior of a normal
1044 python shell.
1052 python shell.
1045
1053
1046 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1054 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1047 line-splitting regexp and _prefilter() to avoid calling getattr()
1055 line-splitting regexp and _prefilter() to avoid calling getattr()
1048 on assignments. This closes
1056 on assignments. This closes
1049 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1057 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1050 readline uses getattr(), so a simple <TAB> keypress is still
1058 readline uses getattr(), so a simple <TAB> keypress is still
1051 enough to trigger getattr() calls on an object.
1059 enough to trigger getattr() calls on an object.
1052
1060
1053 2005-01-21 Fernando Perez <fperez@colorado.edu>
1061 2005-01-21 Fernando Perez <fperez@colorado.edu>
1054
1062
1055 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1063 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1056 docstring under pylab so it doesn't mask the original.
1064 docstring under pylab so it doesn't mask the original.
1057
1065
1058 2005-01-21 *** Released version 0.6.7
1066 2005-01-21 *** Released version 0.6.7
1059
1067
1060 2005-01-21 Fernando Perez <fperez@colorado.edu>
1068 2005-01-21 Fernando Perez <fperez@colorado.edu>
1061
1069
1062 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1070 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1063 signal handling for win32 users in multithreaded mode.
1071 signal handling for win32 users in multithreaded mode.
1064
1072
1065 2005-01-17 Fernando Perez <fperez@colorado.edu>
1073 2005-01-17 Fernando Perez <fperez@colorado.edu>
1066
1074
1067 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1075 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1068 instances with no __init__. After a crash report by Norbert Nemec
1076 instances with no __init__. After a crash report by Norbert Nemec
1069 <Norbert-AT-nemec-online.de>.
1077 <Norbert-AT-nemec-online.de>.
1070
1078
1071 2005-01-14 Fernando Perez <fperez@colorado.edu>
1079 2005-01-14 Fernando Perez <fperez@colorado.edu>
1072
1080
1073 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1081 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1074 names for verbose exceptions, when multiple dotted names and the
1082 names for verbose exceptions, when multiple dotted names and the
1075 'parent' object were present on the same line.
1083 'parent' object were present on the same line.
1076
1084
1077 2005-01-11 Fernando Perez <fperez@colorado.edu>
1085 2005-01-11 Fernando Perez <fperez@colorado.edu>
1078
1086
1079 * IPython/genutils.py (flag_calls): new utility to trap and flag
1087 * IPython/genutils.py (flag_calls): new utility to trap and flag
1080 calls in functions. I need it to clean up matplotlib support.
1088 calls in functions. I need it to clean up matplotlib support.
1081 Also removed some deprecated code in genutils.
1089 Also removed some deprecated code in genutils.
1082
1090
1083 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1091 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1084 that matplotlib scripts called with %run, which don't call show()
1092 that matplotlib scripts called with %run, which don't call show()
1085 themselves, still have their plotting windows open.
1093 themselves, still have their plotting windows open.
1086
1094
1087 2005-01-05 Fernando Perez <fperez@colorado.edu>
1095 2005-01-05 Fernando Perez <fperez@colorado.edu>
1088
1096
1089 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1097 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1090 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1098 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1091
1099
1092 2004-12-19 Fernando Perez <fperez@colorado.edu>
1100 2004-12-19 Fernando Perez <fperez@colorado.edu>
1093
1101
1094 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1102 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1095 parent_runcode, which was an eyesore. The same result can be
1103 parent_runcode, which was an eyesore. The same result can be
1096 obtained with Python's regular superclass mechanisms.
1104 obtained with Python's regular superclass mechanisms.
1097
1105
1098 2004-12-17 Fernando Perez <fperez@colorado.edu>
1106 2004-12-17 Fernando Perez <fperez@colorado.edu>
1099
1107
1100 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1108 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1101 reported by Prabhu.
1109 reported by Prabhu.
1102 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1110 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1103 sys.stderr) instead of explicitly calling sys.stderr. This helps
1111 sys.stderr) instead of explicitly calling sys.stderr. This helps
1104 maintain our I/O abstractions clean, for future GUI embeddings.
1112 maintain our I/O abstractions clean, for future GUI embeddings.
1105
1113
1106 * IPython/genutils.py (info): added new utility for sys.stderr
1114 * IPython/genutils.py (info): added new utility for sys.stderr
1107 unified info message handling (thin wrapper around warn()).
1115 unified info message handling (thin wrapper around warn()).
1108
1116
1109 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1117 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1110 composite (dotted) names on verbose exceptions.
1118 composite (dotted) names on verbose exceptions.
1111 (VerboseTB.nullrepr): harden against another kind of errors which
1119 (VerboseTB.nullrepr): harden against another kind of errors which
1112 Python's inspect module can trigger, and which were crashing
1120 Python's inspect module can trigger, and which were crashing
1113 IPython. Thanks to a report by Marco Lombardi
1121 IPython. Thanks to a report by Marco Lombardi
1114 <mlombard-AT-ma010192.hq.eso.org>.
1122 <mlombard-AT-ma010192.hq.eso.org>.
1115
1123
1116 2004-12-13 *** Released version 0.6.6
1124 2004-12-13 *** Released version 0.6.6
1117
1125
1118 2004-12-12 Fernando Perez <fperez@colorado.edu>
1126 2004-12-12 Fernando Perez <fperez@colorado.edu>
1119
1127
1120 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1128 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1121 generated by pygtk upon initialization if it was built without
1129 generated by pygtk upon initialization if it was built without
1122 threads (for matplotlib users). After a crash reported by
1130 threads (for matplotlib users). After a crash reported by
1123 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1131 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1124
1132
1125 * IPython/ipmaker.py (make_IPython): fix small bug in the
1133 * IPython/ipmaker.py (make_IPython): fix small bug in the
1126 import_some parameter for multiple imports.
1134 import_some parameter for multiple imports.
1127
1135
1128 * IPython/iplib.py (ipmagic): simplified the interface of
1136 * IPython/iplib.py (ipmagic): simplified the interface of
1129 ipmagic() to take a single string argument, just as it would be
1137 ipmagic() to take a single string argument, just as it would be
1130 typed at the IPython cmd line.
1138 typed at the IPython cmd line.
1131 (ipalias): Added new ipalias() with an interface identical to
1139 (ipalias): Added new ipalias() with an interface identical to
1132 ipmagic(). This completes exposing a pure python interface to the
1140 ipmagic(). This completes exposing a pure python interface to the
1133 alias and magic system, which can be used in loops or more complex
1141 alias and magic system, which can be used in loops or more complex
1134 code where IPython's automatic line mangling is not active.
1142 code where IPython's automatic line mangling is not active.
1135
1143
1136 * IPython/genutils.py (timing): changed interface of timing to
1144 * IPython/genutils.py (timing): changed interface of timing to
1137 simply run code once, which is the most common case. timings()
1145 simply run code once, which is the most common case. timings()
1138 remains unchanged, for the cases where you want multiple runs.
1146 remains unchanged, for the cases where you want multiple runs.
1139
1147
1140 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1148 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1141 bug where Python2.2 crashes with exec'ing code which does not end
1149 bug where Python2.2 crashes with exec'ing code which does not end
1142 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1150 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1143 before.
1151 before.
1144
1152
1145 2004-12-10 Fernando Perez <fperez@colorado.edu>
1153 2004-12-10 Fernando Perez <fperez@colorado.edu>
1146
1154
1147 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1155 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1148 -t to -T, to accomodate the new -t flag in %run (the %run and
1156 -t to -T, to accomodate the new -t flag in %run (the %run and
1149 %prun options are kind of intermixed, and it's not easy to change
1157 %prun options are kind of intermixed, and it's not easy to change
1150 this with the limitations of python's getopt).
1158 this with the limitations of python's getopt).
1151
1159
1152 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1160 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1153 the execution of scripts. It's not as fine-tuned as timeit.py,
1161 the execution of scripts. It's not as fine-tuned as timeit.py,
1154 but it works from inside ipython (and under 2.2, which lacks
1162 but it works from inside ipython (and under 2.2, which lacks
1155 timeit.py). Optionally a number of runs > 1 can be given for
1163 timeit.py). Optionally a number of runs > 1 can be given for
1156 timing very short-running code.
1164 timing very short-running code.
1157
1165
1158 * IPython/genutils.py (uniq_stable): new routine which returns a
1166 * IPython/genutils.py (uniq_stable): new routine which returns a
1159 list of unique elements in any iterable, but in stable order of
1167 list of unique elements in any iterable, but in stable order of
1160 appearance. I needed this for the ultraTB fixes, and it's a handy
1168 appearance. I needed this for the ultraTB fixes, and it's a handy
1161 utility.
1169 utility.
1162
1170
1163 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1171 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1164 dotted names in Verbose exceptions. This had been broken since
1172 dotted names in Verbose exceptions. This had been broken since
1165 the very start, now x.y will properly be printed in a Verbose
1173 the very start, now x.y will properly be printed in a Verbose
1166 traceback, instead of x being shown and y appearing always as an
1174 traceback, instead of x being shown and y appearing always as an
1167 'undefined global'. Getting this to work was a bit tricky,
1175 'undefined global'. Getting this to work was a bit tricky,
1168 because by default python tokenizers are stateless. Saved by
1176 because by default python tokenizers are stateless. Saved by
1169 python's ability to easily add a bit of state to an arbitrary
1177 python's ability to easily add a bit of state to an arbitrary
1170 function (without needing to build a full-blown callable object).
1178 function (without needing to build a full-blown callable object).
1171
1179
1172 Also big cleanup of this code, which had horrendous runtime
1180 Also big cleanup of this code, which had horrendous runtime
1173 lookups of zillions of attributes for colorization. Moved all
1181 lookups of zillions of attributes for colorization. Moved all
1174 this code into a few templates, which make it cleaner and quicker.
1182 this code into a few templates, which make it cleaner and quicker.
1175
1183
1176 Printout quality was also improved for Verbose exceptions: one
1184 Printout quality was also improved for Verbose exceptions: one
1177 variable per line, and memory addresses are printed (this can be
1185 variable per line, and memory addresses are printed (this can be
1178 quite handy in nasty debugging situations, which is what Verbose
1186 quite handy in nasty debugging situations, which is what Verbose
1179 is for).
1187 is for).
1180
1188
1181 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1189 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1182 the command line as scripts to be loaded by embedded instances.
1190 the command line as scripts to be loaded by embedded instances.
1183 Doing so has the potential for an infinite recursion if there are
1191 Doing so has the potential for an infinite recursion if there are
1184 exceptions thrown in the process. This fixes a strange crash
1192 exceptions thrown in the process. This fixes a strange crash
1185 reported by Philippe MULLER <muller-AT-irit.fr>.
1193 reported by Philippe MULLER <muller-AT-irit.fr>.
1186
1194
1187 2004-12-09 Fernando Perez <fperez@colorado.edu>
1195 2004-12-09 Fernando Perez <fperez@colorado.edu>
1188
1196
1189 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1197 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1190 to reflect new names in matplotlib, which now expose the
1198 to reflect new names in matplotlib, which now expose the
1191 matlab-compatible interface via a pylab module instead of the
1199 matlab-compatible interface via a pylab module instead of the
1192 'matlab' name. The new code is backwards compatible, so users of
1200 'matlab' name. The new code is backwards compatible, so users of
1193 all matplotlib versions are OK. Patch by J. Hunter.
1201 all matplotlib versions are OK. Patch by J. Hunter.
1194
1202
1195 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1203 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1196 of __init__ docstrings for instances (class docstrings are already
1204 of __init__ docstrings for instances (class docstrings are already
1197 automatically printed). Instances with customized docstrings
1205 automatically printed). Instances with customized docstrings
1198 (indep. of the class) are also recognized and all 3 separate
1206 (indep. of the class) are also recognized and all 3 separate
1199 docstrings are printed (instance, class, constructor). After some
1207 docstrings are printed (instance, class, constructor). After some
1200 comments/suggestions by J. Hunter.
1208 comments/suggestions by J. Hunter.
1201
1209
1202 2004-12-05 Fernando Perez <fperez@colorado.edu>
1210 2004-12-05 Fernando Perez <fperez@colorado.edu>
1203
1211
1204 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1212 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1205 warnings when tab-completion fails and triggers an exception.
1213 warnings when tab-completion fails and triggers an exception.
1206
1214
1207 2004-12-03 Fernando Perez <fperez@colorado.edu>
1215 2004-12-03 Fernando Perez <fperez@colorado.edu>
1208
1216
1209 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1217 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1210 be triggered when using 'run -p'. An incorrect option flag was
1218 be triggered when using 'run -p'. An incorrect option flag was
1211 being set ('d' instead of 'D').
1219 being set ('d' instead of 'D').
1212 (manpage): fix missing escaped \- sign.
1220 (manpage): fix missing escaped \- sign.
1213
1221
1214 2004-11-30 *** Released version 0.6.5
1222 2004-11-30 *** Released version 0.6.5
1215
1223
1216 2004-11-30 Fernando Perez <fperez@colorado.edu>
1224 2004-11-30 Fernando Perez <fperez@colorado.edu>
1217
1225
1218 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1226 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1219 setting with -d option.
1227 setting with -d option.
1220
1228
1221 * setup.py (docfiles): Fix problem where the doc glob I was using
1229 * setup.py (docfiles): Fix problem where the doc glob I was using
1222 was COMPLETELY BROKEN. It was giving the right files by pure
1230 was COMPLETELY BROKEN. It was giving the right files by pure
1223 accident, but failed once I tried to include ipython.el. Note:
1231 accident, but failed once I tried to include ipython.el. Note:
1224 glob() does NOT allow you to do exclusion on multiple endings!
1232 glob() does NOT allow you to do exclusion on multiple endings!
1225
1233
1226 2004-11-29 Fernando Perez <fperez@colorado.edu>
1234 2004-11-29 Fernando Perez <fperez@colorado.edu>
1227
1235
1228 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1236 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1229 the manpage as the source. Better formatting & consistency.
1237 the manpage as the source. Better formatting & consistency.
1230
1238
1231 * IPython/Magic.py (magic_run): Added new -d option, to run
1239 * IPython/Magic.py (magic_run): Added new -d option, to run
1232 scripts under the control of the python pdb debugger. Note that
1240 scripts under the control of the python pdb debugger. Note that
1233 this required changing the %prun option -d to -D, to avoid a clash
1241 this required changing the %prun option -d to -D, to avoid a clash
1234 (since %run must pass options to %prun, and getopt is too dumb to
1242 (since %run must pass options to %prun, and getopt is too dumb to
1235 handle options with string values with embedded spaces). Thanks
1243 handle options with string values with embedded spaces). Thanks
1236 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1244 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1237 (magic_who_ls): added type matching to %who and %whos, so that one
1245 (magic_who_ls): added type matching to %who and %whos, so that one
1238 can filter their output to only include variables of certain
1246 can filter their output to only include variables of certain
1239 types. Another suggestion by Matthew.
1247 types. Another suggestion by Matthew.
1240 (magic_whos): Added memory summaries in kb and Mb for arrays.
1248 (magic_whos): Added memory summaries in kb and Mb for arrays.
1241 (magic_who): Improve formatting (break lines every 9 vars).
1249 (magic_who): Improve formatting (break lines every 9 vars).
1242
1250
1243 2004-11-28 Fernando Perez <fperez@colorado.edu>
1251 2004-11-28 Fernando Perez <fperez@colorado.edu>
1244
1252
1245 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1253 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1246 cache when empty lines were present.
1254 cache when empty lines were present.
1247
1255
1248 2004-11-24 Fernando Perez <fperez@colorado.edu>
1256 2004-11-24 Fernando Perez <fperez@colorado.edu>
1249
1257
1250 * IPython/usage.py (__doc__): document the re-activated threading
1258 * IPython/usage.py (__doc__): document the re-activated threading
1251 options for WX and GTK.
1259 options for WX and GTK.
1252
1260
1253 2004-11-23 Fernando Perez <fperez@colorado.edu>
1261 2004-11-23 Fernando Perez <fperez@colorado.edu>
1254
1262
1255 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1263 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1256 the -wthread and -gthread options, along with a new -tk one to try
1264 the -wthread and -gthread options, along with a new -tk one to try
1257 and coordinate Tk threading with wx/gtk. The tk support is very
1265 and coordinate Tk threading with wx/gtk. The tk support is very
1258 platform dependent, since it seems to require Tcl and Tk to be
1266 platform dependent, since it seems to require Tcl and Tk to be
1259 built with threads (Fedora1/2 appears NOT to have it, but in
1267 built with threads (Fedora1/2 appears NOT to have it, but in
1260 Prabhu's Debian boxes it works OK). But even with some Tk
1268 Prabhu's Debian boxes it works OK). But even with some Tk
1261 limitations, this is a great improvement.
1269 limitations, this is a great improvement.
1262
1270
1263 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1271 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1264 info in user prompts. Patch by Prabhu.
1272 info in user prompts. Patch by Prabhu.
1265
1273
1266 2004-11-18 Fernando Perez <fperez@colorado.edu>
1274 2004-11-18 Fernando Perez <fperez@colorado.edu>
1267
1275
1268 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1276 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1269 EOFErrors and bail, to avoid infinite loops if a non-terminating
1277 EOFErrors and bail, to avoid infinite loops if a non-terminating
1270 file is fed into ipython. Patch submitted in issue 19 by user,
1278 file is fed into ipython. Patch submitted in issue 19 by user,
1271 many thanks.
1279 many thanks.
1272
1280
1273 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1281 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1274 autoquote/parens in continuation prompts, which can cause lots of
1282 autoquote/parens in continuation prompts, which can cause lots of
1275 problems. Closes roundup issue 20.
1283 problems. Closes roundup issue 20.
1276
1284
1277 2004-11-17 Fernando Perez <fperez@colorado.edu>
1285 2004-11-17 Fernando Perez <fperez@colorado.edu>
1278
1286
1279 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1287 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1280 reported as debian bug #280505. I'm not sure my local changelog
1288 reported as debian bug #280505. I'm not sure my local changelog
1281 entry has the proper debian format (Jack?).
1289 entry has the proper debian format (Jack?).
1282
1290
1283 2004-11-08 *** Released version 0.6.4
1291 2004-11-08 *** Released version 0.6.4
1284
1292
1285 2004-11-08 Fernando Perez <fperez@colorado.edu>
1293 2004-11-08 Fernando Perez <fperez@colorado.edu>
1286
1294
1287 * IPython/iplib.py (init_readline): Fix exit message for Windows
1295 * IPython/iplib.py (init_readline): Fix exit message for Windows
1288 when readline is active. Thanks to a report by Eric Jones
1296 when readline is active. Thanks to a report by Eric Jones
1289 <eric-AT-enthought.com>.
1297 <eric-AT-enthought.com>.
1290
1298
1291 2004-11-07 Fernando Perez <fperez@colorado.edu>
1299 2004-11-07 Fernando Perez <fperez@colorado.edu>
1292
1300
1293 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1301 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1294 sometimes seen by win2k/cygwin users.
1302 sometimes seen by win2k/cygwin users.
1295
1303
1296 2004-11-06 Fernando Perez <fperez@colorado.edu>
1304 2004-11-06 Fernando Perez <fperez@colorado.edu>
1297
1305
1298 * IPython/iplib.py (interact): Change the handling of %Exit from
1306 * IPython/iplib.py (interact): Change the handling of %Exit from
1299 trying to propagate a SystemExit to an internal ipython flag.
1307 trying to propagate a SystemExit to an internal ipython flag.
1300 This is less elegant than using Python's exception mechanism, but
1308 This is less elegant than using Python's exception mechanism, but
1301 I can't get that to work reliably with threads, so under -pylab
1309 I can't get that to work reliably with threads, so under -pylab
1302 %Exit was hanging IPython. Cross-thread exception handling is
1310 %Exit was hanging IPython. Cross-thread exception handling is
1303 really a bitch. Thaks to a bug report by Stephen Walton
1311 really a bitch. Thaks to a bug report by Stephen Walton
1304 <stephen.walton-AT-csun.edu>.
1312 <stephen.walton-AT-csun.edu>.
1305
1313
1306 2004-11-04 Fernando Perez <fperez@colorado.edu>
1314 2004-11-04 Fernando Perez <fperez@colorado.edu>
1307
1315
1308 * IPython/iplib.py (raw_input_original): store a pointer to the
1316 * IPython/iplib.py (raw_input_original): store a pointer to the
1309 true raw_input to harden against code which can modify it
1317 true raw_input to harden against code which can modify it
1310 (wx.py.PyShell does this and would otherwise crash ipython).
1318 (wx.py.PyShell does this and would otherwise crash ipython).
1311 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1319 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1312
1320
1313 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1321 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1314 Ctrl-C problem, which does not mess up the input line.
1322 Ctrl-C problem, which does not mess up the input line.
1315
1323
1316 2004-11-03 Fernando Perez <fperez@colorado.edu>
1324 2004-11-03 Fernando Perez <fperez@colorado.edu>
1317
1325
1318 * IPython/Release.py: Changed licensing to BSD, in all files.
1326 * IPython/Release.py: Changed licensing to BSD, in all files.
1319 (name): lowercase name for tarball/RPM release.
1327 (name): lowercase name for tarball/RPM release.
1320
1328
1321 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1329 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1322 use throughout ipython.
1330 use throughout ipython.
1323
1331
1324 * IPython/Magic.py (Magic._ofind): Switch to using the new
1332 * IPython/Magic.py (Magic._ofind): Switch to using the new
1325 OInspect.getdoc() function.
1333 OInspect.getdoc() function.
1326
1334
1327 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1335 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1328 of the line currently being canceled via Ctrl-C. It's extremely
1336 of the line currently being canceled via Ctrl-C. It's extremely
1329 ugly, but I don't know how to do it better (the problem is one of
1337 ugly, but I don't know how to do it better (the problem is one of
1330 handling cross-thread exceptions).
1338 handling cross-thread exceptions).
1331
1339
1332 2004-10-28 Fernando Perez <fperez@colorado.edu>
1340 2004-10-28 Fernando Perez <fperez@colorado.edu>
1333
1341
1334 * IPython/Shell.py (signal_handler): add signal handlers to trap
1342 * IPython/Shell.py (signal_handler): add signal handlers to trap
1335 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1343 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1336 report by Francesc Alted.
1344 report by Francesc Alted.
1337
1345
1338 2004-10-21 Fernando Perez <fperez@colorado.edu>
1346 2004-10-21 Fernando Perez <fperez@colorado.edu>
1339
1347
1340 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1348 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1341 to % for pysh syntax extensions.
1349 to % for pysh syntax extensions.
1342
1350
1343 2004-10-09 Fernando Perez <fperez@colorado.edu>
1351 2004-10-09 Fernando Perez <fperez@colorado.edu>
1344
1352
1345 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1353 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1346 arrays to print a more useful summary, without calling str(arr).
1354 arrays to print a more useful summary, without calling str(arr).
1347 This avoids the problem of extremely lengthy computations which
1355 This avoids the problem of extremely lengthy computations which
1348 occur if arr is large, and appear to the user as a system lockup
1356 occur if arr is large, and appear to the user as a system lockup
1349 with 100% cpu activity. After a suggestion by Kristian Sandberg
1357 with 100% cpu activity. After a suggestion by Kristian Sandberg
1350 <Kristian.Sandberg@colorado.edu>.
1358 <Kristian.Sandberg@colorado.edu>.
1351 (Magic.__init__): fix bug in global magic escapes not being
1359 (Magic.__init__): fix bug in global magic escapes not being
1352 correctly set.
1360 correctly set.
1353
1361
1354 2004-10-08 Fernando Perez <fperez@colorado.edu>
1362 2004-10-08 Fernando Perez <fperez@colorado.edu>
1355
1363
1356 * IPython/Magic.py (__license__): change to absolute imports of
1364 * IPython/Magic.py (__license__): change to absolute imports of
1357 ipython's own internal packages, to start adapting to the absolute
1365 ipython's own internal packages, to start adapting to the absolute
1358 import requirement of PEP-328.
1366 import requirement of PEP-328.
1359
1367
1360 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1368 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1361 files, and standardize author/license marks through the Release
1369 files, and standardize author/license marks through the Release
1362 module instead of having per/file stuff (except for files with
1370 module instead of having per/file stuff (except for files with
1363 particular licenses, like the MIT/PSF-licensed codes).
1371 particular licenses, like the MIT/PSF-licensed codes).
1364
1372
1365 * IPython/Debugger.py: remove dead code for python 2.1
1373 * IPython/Debugger.py: remove dead code for python 2.1
1366
1374
1367 2004-10-04 Fernando Perez <fperez@colorado.edu>
1375 2004-10-04 Fernando Perez <fperez@colorado.edu>
1368
1376
1369 * IPython/iplib.py (ipmagic): New function for accessing magics
1377 * IPython/iplib.py (ipmagic): New function for accessing magics
1370 via a normal python function call.
1378 via a normal python function call.
1371
1379
1372 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1380 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1373 from '@' to '%', to accomodate the new @decorator syntax of python
1381 from '@' to '%', to accomodate the new @decorator syntax of python
1374 2.4.
1382 2.4.
1375
1383
1376 2004-09-29 Fernando Perez <fperez@colorado.edu>
1384 2004-09-29 Fernando Perez <fperez@colorado.edu>
1377
1385
1378 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1386 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1379 matplotlib.use to prevent running scripts which try to switch
1387 matplotlib.use to prevent running scripts which try to switch
1380 interactive backends from within ipython. This will just crash
1388 interactive backends from within ipython. This will just crash
1381 the python interpreter, so we can't allow it (but a detailed error
1389 the python interpreter, so we can't allow it (but a detailed error
1382 is given to the user).
1390 is given to the user).
1383
1391
1384 2004-09-28 Fernando Perez <fperez@colorado.edu>
1392 2004-09-28 Fernando Perez <fperez@colorado.edu>
1385
1393
1386 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1394 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1387 matplotlib-related fixes so that using @run with non-matplotlib
1395 matplotlib-related fixes so that using @run with non-matplotlib
1388 scripts doesn't pop up spurious plot windows. This requires
1396 scripts doesn't pop up spurious plot windows. This requires
1389 matplotlib >= 0.63, where I had to make some changes as well.
1397 matplotlib >= 0.63, where I had to make some changes as well.
1390
1398
1391 * IPython/ipmaker.py (make_IPython): update version requirement to
1399 * IPython/ipmaker.py (make_IPython): update version requirement to
1392 python 2.2.
1400 python 2.2.
1393
1401
1394 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1402 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1395 banner arg for embedded customization.
1403 banner arg for embedded customization.
1396
1404
1397 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1405 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1398 explicit uses of __IP as the IPython's instance name. Now things
1406 explicit uses of __IP as the IPython's instance name. Now things
1399 are properly handled via the shell.name value. The actual code
1407 are properly handled via the shell.name value. The actual code
1400 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1408 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1401 is much better than before. I'll clean things completely when the
1409 is much better than before. I'll clean things completely when the
1402 magic stuff gets a real overhaul.
1410 magic stuff gets a real overhaul.
1403
1411
1404 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1412 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1405 minor changes to debian dir.
1413 minor changes to debian dir.
1406
1414
1407 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1415 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1408 pointer to the shell itself in the interactive namespace even when
1416 pointer to the shell itself in the interactive namespace even when
1409 a user-supplied dict is provided. This is needed for embedding
1417 a user-supplied dict is provided. This is needed for embedding
1410 purposes (found by tests with Michel Sanner).
1418 purposes (found by tests with Michel Sanner).
1411
1419
1412 2004-09-27 Fernando Perez <fperez@colorado.edu>
1420 2004-09-27 Fernando Perez <fperez@colorado.edu>
1413
1421
1414 * IPython/UserConfig/ipythonrc: remove []{} from
1422 * IPython/UserConfig/ipythonrc: remove []{} from
1415 readline_remove_delims, so that things like [modname.<TAB> do
1423 readline_remove_delims, so that things like [modname.<TAB> do
1416 proper completion. This disables [].TAB, but that's a less common
1424 proper completion. This disables [].TAB, but that's a less common
1417 case than module names in list comprehensions, for example.
1425 case than module names in list comprehensions, for example.
1418 Thanks to a report by Andrea Riciputi.
1426 Thanks to a report by Andrea Riciputi.
1419
1427
1420 2004-09-09 Fernando Perez <fperez@colorado.edu>
1428 2004-09-09 Fernando Perez <fperez@colorado.edu>
1421
1429
1422 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1430 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1423 blocking problems in win32 and osx. Fix by John.
1431 blocking problems in win32 and osx. Fix by John.
1424
1432
1425 2004-09-08 Fernando Perez <fperez@colorado.edu>
1433 2004-09-08 Fernando Perez <fperez@colorado.edu>
1426
1434
1427 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1435 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1428 for Win32 and OSX. Fix by John Hunter.
1436 for Win32 and OSX. Fix by John Hunter.
1429
1437
1430 2004-08-30 *** Released version 0.6.3
1438 2004-08-30 *** Released version 0.6.3
1431
1439
1432 2004-08-30 Fernando Perez <fperez@colorado.edu>
1440 2004-08-30 Fernando Perez <fperez@colorado.edu>
1433
1441
1434 * setup.py (isfile): Add manpages to list of dependent files to be
1442 * setup.py (isfile): Add manpages to list of dependent files to be
1435 updated.
1443 updated.
1436
1444
1437 2004-08-27 Fernando Perez <fperez@colorado.edu>
1445 2004-08-27 Fernando Perez <fperez@colorado.edu>
1438
1446
1439 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1447 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1440 for now. They don't really work with standalone WX/GTK code
1448 for now. They don't really work with standalone WX/GTK code
1441 (though matplotlib IS working fine with both of those backends).
1449 (though matplotlib IS working fine with both of those backends).
1442 This will neeed much more testing. I disabled most things with
1450 This will neeed much more testing. I disabled most things with
1443 comments, so turning it back on later should be pretty easy.
1451 comments, so turning it back on later should be pretty easy.
1444
1452
1445 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1453 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1446 autocalling of expressions like r'foo', by modifying the line
1454 autocalling of expressions like r'foo', by modifying the line
1447 split regexp. Closes
1455 split regexp. Closes
1448 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1456 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1449 Riley <ipythonbugs-AT-sabi.net>.
1457 Riley <ipythonbugs-AT-sabi.net>.
1450 (InteractiveShell.mainloop): honor --nobanner with banner
1458 (InteractiveShell.mainloop): honor --nobanner with banner
1451 extensions.
1459 extensions.
1452
1460
1453 * IPython/Shell.py: Significant refactoring of all classes, so
1461 * IPython/Shell.py: Significant refactoring of all classes, so
1454 that we can really support ALL matplotlib backends and threading
1462 that we can really support ALL matplotlib backends and threading
1455 models (John spotted a bug with Tk which required this). Now we
1463 models (John spotted a bug with Tk which required this). Now we
1456 should support single-threaded, WX-threads and GTK-threads, both
1464 should support single-threaded, WX-threads and GTK-threads, both
1457 for generic code and for matplotlib.
1465 for generic code and for matplotlib.
1458
1466
1459 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1467 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1460 -pylab, to simplify things for users. Will also remove the pylab
1468 -pylab, to simplify things for users. Will also remove the pylab
1461 profile, since now all of matplotlib configuration is directly
1469 profile, since now all of matplotlib configuration is directly
1462 handled here. This also reduces startup time.
1470 handled here. This also reduces startup time.
1463
1471
1464 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1472 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1465 shell wasn't being correctly called. Also in IPShellWX.
1473 shell wasn't being correctly called. Also in IPShellWX.
1466
1474
1467 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1475 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1468 fine-tune banner.
1476 fine-tune banner.
1469
1477
1470 * IPython/numutils.py (spike): Deprecate these spike functions,
1478 * IPython/numutils.py (spike): Deprecate these spike functions,
1471 delete (long deprecated) gnuplot_exec handler.
1479 delete (long deprecated) gnuplot_exec handler.
1472
1480
1473 2004-08-26 Fernando Perez <fperez@colorado.edu>
1481 2004-08-26 Fernando Perez <fperez@colorado.edu>
1474
1482
1475 * ipython.1: Update for threading options, plus some others which
1483 * ipython.1: Update for threading options, plus some others which
1476 were missing.
1484 were missing.
1477
1485
1478 * IPython/ipmaker.py (__call__): Added -wthread option for
1486 * IPython/ipmaker.py (__call__): Added -wthread option for
1479 wxpython thread handling. Make sure threading options are only
1487 wxpython thread handling. Make sure threading options are only
1480 valid at the command line.
1488 valid at the command line.
1481
1489
1482 * scripts/ipython: moved shell selection into a factory function
1490 * scripts/ipython: moved shell selection into a factory function
1483 in Shell.py, to keep the starter script to a minimum.
1491 in Shell.py, to keep the starter script to a minimum.
1484
1492
1485 2004-08-25 Fernando Perez <fperez@colorado.edu>
1493 2004-08-25 Fernando Perez <fperez@colorado.edu>
1486
1494
1487 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1495 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1488 John. Along with some recent changes he made to matplotlib, the
1496 John. Along with some recent changes he made to matplotlib, the
1489 next versions of both systems should work very well together.
1497 next versions of both systems should work very well together.
1490
1498
1491 2004-08-24 Fernando Perez <fperez@colorado.edu>
1499 2004-08-24 Fernando Perez <fperez@colorado.edu>
1492
1500
1493 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1501 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1494 tried to switch the profiling to using hotshot, but I'm getting
1502 tried to switch the profiling to using hotshot, but I'm getting
1495 strange errors from prof.runctx() there. I may be misreading the
1503 strange errors from prof.runctx() there. I may be misreading the
1496 docs, but it looks weird. For now the profiling code will
1504 docs, but it looks weird. For now the profiling code will
1497 continue to use the standard profiler.
1505 continue to use the standard profiler.
1498
1506
1499 2004-08-23 Fernando Perez <fperez@colorado.edu>
1507 2004-08-23 Fernando Perez <fperez@colorado.edu>
1500
1508
1501 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1509 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1502 threaded shell, by John Hunter. It's not quite ready yet, but
1510 threaded shell, by John Hunter. It's not quite ready yet, but
1503 close.
1511 close.
1504
1512
1505 2004-08-22 Fernando Perez <fperez@colorado.edu>
1513 2004-08-22 Fernando Perez <fperez@colorado.edu>
1506
1514
1507 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1515 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1508 in Magic and ultraTB.
1516 in Magic and ultraTB.
1509
1517
1510 * ipython.1: document threading options in manpage.
1518 * ipython.1: document threading options in manpage.
1511
1519
1512 * scripts/ipython: Changed name of -thread option to -gthread,
1520 * scripts/ipython: Changed name of -thread option to -gthread,
1513 since this is GTK specific. I want to leave the door open for a
1521 since this is GTK specific. I want to leave the door open for a
1514 -wthread option for WX, which will most likely be necessary. This
1522 -wthread option for WX, which will most likely be necessary. This
1515 change affects usage and ipmaker as well.
1523 change affects usage and ipmaker as well.
1516
1524
1517 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1525 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1518 handle the matplotlib shell issues. Code by John Hunter
1526 handle the matplotlib shell issues. Code by John Hunter
1519 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1527 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1520 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1528 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1521 broken (and disabled for end users) for now, but it puts the
1529 broken (and disabled for end users) for now, but it puts the
1522 infrastructure in place.
1530 infrastructure in place.
1523
1531
1524 2004-08-21 Fernando Perez <fperez@colorado.edu>
1532 2004-08-21 Fernando Perez <fperez@colorado.edu>
1525
1533
1526 * ipythonrc-pylab: Add matplotlib support.
1534 * ipythonrc-pylab: Add matplotlib support.
1527
1535
1528 * matplotlib_config.py: new files for matplotlib support, part of
1536 * matplotlib_config.py: new files for matplotlib support, part of
1529 the pylab profile.
1537 the pylab profile.
1530
1538
1531 * IPython/usage.py (__doc__): documented the threading options.
1539 * IPython/usage.py (__doc__): documented the threading options.
1532
1540
1533 2004-08-20 Fernando Perez <fperez@colorado.edu>
1541 2004-08-20 Fernando Perez <fperez@colorado.edu>
1534
1542
1535 * ipython: Modified the main calling routine to handle the -thread
1543 * ipython: Modified the main calling routine to handle the -thread
1536 and -mpthread options. This needs to be done as a top-level hack,
1544 and -mpthread options. This needs to be done as a top-level hack,
1537 because it determines which class to instantiate for IPython
1545 because it determines which class to instantiate for IPython
1538 itself.
1546 itself.
1539
1547
1540 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1548 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1541 classes to support multithreaded GTK operation without blocking,
1549 classes to support multithreaded GTK operation without blocking,
1542 and matplotlib with all backends. This is a lot of still very
1550 and matplotlib with all backends. This is a lot of still very
1543 experimental code, and threads are tricky. So it may still have a
1551 experimental code, and threads are tricky. So it may still have a
1544 few rough edges... This code owes a lot to
1552 few rough edges... This code owes a lot to
1545 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1553 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1546 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1554 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1547 to John Hunter for all the matplotlib work.
1555 to John Hunter for all the matplotlib work.
1548
1556
1549 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1557 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1550 options for gtk thread and matplotlib support.
1558 options for gtk thread and matplotlib support.
1551
1559
1552 2004-08-16 Fernando Perez <fperez@colorado.edu>
1560 2004-08-16 Fernando Perez <fperez@colorado.edu>
1553
1561
1554 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1562 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1555 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1563 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1556 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1564 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1557
1565
1558 2004-08-11 Fernando Perez <fperez@colorado.edu>
1566 2004-08-11 Fernando Perez <fperez@colorado.edu>
1559
1567
1560 * setup.py (isfile): Fix build so documentation gets updated for
1568 * setup.py (isfile): Fix build so documentation gets updated for
1561 rpms (it was only done for .tgz builds).
1569 rpms (it was only done for .tgz builds).
1562
1570
1563 2004-08-10 Fernando Perez <fperez@colorado.edu>
1571 2004-08-10 Fernando Perez <fperez@colorado.edu>
1564
1572
1565 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1573 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1566
1574
1567 * iplib.py : Silence syntax error exceptions in tab-completion.
1575 * iplib.py : Silence syntax error exceptions in tab-completion.
1568
1576
1569 2004-08-05 Fernando Perez <fperez@colorado.edu>
1577 2004-08-05 Fernando Perez <fperez@colorado.edu>
1570
1578
1571 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1579 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1572 'color off' mark for continuation prompts. This was causing long
1580 'color off' mark for continuation prompts. This was causing long
1573 continuation lines to mis-wrap.
1581 continuation lines to mis-wrap.
1574
1582
1575 2004-08-01 Fernando Perez <fperez@colorado.edu>
1583 2004-08-01 Fernando Perez <fperez@colorado.edu>
1576
1584
1577 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1585 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1578 for building ipython to be a parameter. All this is necessary
1586 for building ipython to be a parameter. All this is necessary
1579 right now to have a multithreaded version, but this insane
1587 right now to have a multithreaded version, but this insane
1580 non-design will be cleaned up soon. For now, it's a hack that
1588 non-design will be cleaned up soon. For now, it's a hack that
1581 works.
1589 works.
1582
1590
1583 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1591 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1584 args in various places. No bugs so far, but it's a dangerous
1592 args in various places. No bugs so far, but it's a dangerous
1585 practice.
1593 practice.
1586
1594
1587 2004-07-31 Fernando Perez <fperez@colorado.edu>
1595 2004-07-31 Fernando Perez <fperez@colorado.edu>
1588
1596
1589 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1597 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1590 fix completion of files with dots in their names under most
1598 fix completion of files with dots in their names under most
1591 profiles (pysh was OK because the completion order is different).
1599 profiles (pysh was OK because the completion order is different).
1592
1600
1593 2004-07-27 Fernando Perez <fperez@colorado.edu>
1601 2004-07-27 Fernando Perez <fperez@colorado.edu>
1594
1602
1595 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1603 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1596 keywords manually, b/c the one in keyword.py was removed in python
1604 keywords manually, b/c the one in keyword.py was removed in python
1597 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1605 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1598 This is NOT a bug under python 2.3 and earlier.
1606 This is NOT a bug under python 2.3 and earlier.
1599
1607
1600 2004-07-26 Fernando Perez <fperez@colorado.edu>
1608 2004-07-26 Fernando Perez <fperez@colorado.edu>
1601
1609
1602 * IPython/ultraTB.py (VerboseTB.text): Add another
1610 * IPython/ultraTB.py (VerboseTB.text): Add another
1603 linecache.checkcache() call to try to prevent inspect.py from
1611 linecache.checkcache() call to try to prevent inspect.py from
1604 crashing under python 2.3. I think this fixes
1612 crashing under python 2.3. I think this fixes
1605 http://www.scipy.net/roundup/ipython/issue17.
1613 http://www.scipy.net/roundup/ipython/issue17.
1606
1614
1607 2004-07-26 *** Released version 0.6.2
1615 2004-07-26 *** Released version 0.6.2
1608
1616
1609 2004-07-26 Fernando Perez <fperez@colorado.edu>
1617 2004-07-26 Fernando Perez <fperez@colorado.edu>
1610
1618
1611 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1619 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1612 fail for any number.
1620 fail for any number.
1613 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1621 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1614 empty bookmarks.
1622 empty bookmarks.
1615
1623
1616 2004-07-26 *** Released version 0.6.1
1624 2004-07-26 *** Released version 0.6.1
1617
1625
1618 2004-07-26 Fernando Perez <fperez@colorado.edu>
1626 2004-07-26 Fernando Perez <fperez@colorado.edu>
1619
1627
1620 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1628 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1621
1629
1622 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1630 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1623 escaping '()[]{}' in filenames.
1631 escaping '()[]{}' in filenames.
1624
1632
1625 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1633 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1626 Python 2.2 users who lack a proper shlex.split.
1634 Python 2.2 users who lack a proper shlex.split.
1627
1635
1628 2004-07-19 Fernando Perez <fperez@colorado.edu>
1636 2004-07-19 Fernando Perez <fperez@colorado.edu>
1629
1637
1630 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1638 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1631 for reading readline's init file. I follow the normal chain:
1639 for reading readline's init file. I follow the normal chain:
1632 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1640 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1633 report by Mike Heeter. This closes
1641 report by Mike Heeter. This closes
1634 http://www.scipy.net/roundup/ipython/issue16.
1642 http://www.scipy.net/roundup/ipython/issue16.
1635
1643
1636 2004-07-18 Fernando Perez <fperez@colorado.edu>
1644 2004-07-18 Fernando Perez <fperez@colorado.edu>
1637
1645
1638 * IPython/iplib.py (__init__): Add better handling of '\' under
1646 * IPython/iplib.py (__init__): Add better handling of '\' under
1639 Win32 for filenames. After a patch by Ville.
1647 Win32 for filenames. After a patch by Ville.
1640
1648
1641 2004-07-17 Fernando Perez <fperez@colorado.edu>
1649 2004-07-17 Fernando Perez <fperez@colorado.edu>
1642
1650
1643 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1651 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1644 autocalling would be triggered for 'foo is bar' if foo is
1652 autocalling would be triggered for 'foo is bar' if foo is
1645 callable. I also cleaned up the autocall detection code to use a
1653 callable. I also cleaned up the autocall detection code to use a
1646 regexp, which is faster. Bug reported by Alexander Schmolck.
1654 regexp, which is faster. Bug reported by Alexander Schmolck.
1647
1655
1648 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1656 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1649 '?' in them would confuse the help system. Reported by Alex
1657 '?' in them would confuse the help system. Reported by Alex
1650 Schmolck.
1658 Schmolck.
1651
1659
1652 2004-07-16 Fernando Perez <fperez@colorado.edu>
1660 2004-07-16 Fernando Perez <fperez@colorado.edu>
1653
1661
1654 * IPython/GnuplotInteractive.py (__all__): added plot2.
1662 * IPython/GnuplotInteractive.py (__all__): added plot2.
1655
1663
1656 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1664 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1657 plotting dictionaries, lists or tuples of 1d arrays.
1665 plotting dictionaries, lists or tuples of 1d arrays.
1658
1666
1659 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1667 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1660 optimizations.
1668 optimizations.
1661
1669
1662 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1670 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1663 the information which was there from Janko's original IPP code:
1671 the information which was there from Janko's original IPP code:
1664
1672
1665 03.05.99 20:53 porto.ifm.uni-kiel.de
1673 03.05.99 20:53 porto.ifm.uni-kiel.de
1666 --Started changelog.
1674 --Started changelog.
1667 --make clear do what it say it does
1675 --make clear do what it say it does
1668 --added pretty output of lines from inputcache
1676 --added pretty output of lines from inputcache
1669 --Made Logger a mixin class, simplifies handling of switches
1677 --Made Logger a mixin class, simplifies handling of switches
1670 --Added own completer class. .string<TAB> expands to last history
1678 --Added own completer class. .string<TAB> expands to last history
1671 line which starts with string. The new expansion is also present
1679 line which starts with string. The new expansion is also present
1672 with Ctrl-r from the readline library. But this shows, who this
1680 with Ctrl-r from the readline library. But this shows, who this
1673 can be done for other cases.
1681 can be done for other cases.
1674 --Added convention that all shell functions should accept a
1682 --Added convention that all shell functions should accept a
1675 parameter_string This opens the door for different behaviour for
1683 parameter_string This opens the door for different behaviour for
1676 each function. @cd is a good example of this.
1684 each function. @cd is a good example of this.
1677
1685
1678 04.05.99 12:12 porto.ifm.uni-kiel.de
1686 04.05.99 12:12 porto.ifm.uni-kiel.de
1679 --added logfile rotation
1687 --added logfile rotation
1680 --added new mainloop method which freezes first the namespace
1688 --added new mainloop method which freezes first the namespace
1681
1689
1682 07.05.99 21:24 porto.ifm.uni-kiel.de
1690 07.05.99 21:24 porto.ifm.uni-kiel.de
1683 --added the docreader classes. Now there is a help system.
1691 --added the docreader classes. Now there is a help system.
1684 -This is only a first try. Currently it's not easy to put new
1692 -This is only a first try. Currently it's not easy to put new
1685 stuff in the indices. But this is the way to go. Info would be
1693 stuff in the indices. But this is the way to go. Info would be
1686 better, but HTML is every where and not everybody has an info
1694 better, but HTML is every where and not everybody has an info
1687 system installed and it's not so easy to change html-docs to info.
1695 system installed and it's not so easy to change html-docs to info.
1688 --added global logfile option
1696 --added global logfile option
1689 --there is now a hook for object inspection method pinfo needs to
1697 --there is now a hook for object inspection method pinfo needs to
1690 be provided for this. Can be reached by two '??'.
1698 be provided for this. Can be reached by two '??'.
1691
1699
1692 08.05.99 20:51 porto.ifm.uni-kiel.de
1700 08.05.99 20:51 porto.ifm.uni-kiel.de
1693 --added a README
1701 --added a README
1694 --bug in rc file. Something has changed so functions in the rc
1702 --bug in rc file. Something has changed so functions in the rc
1695 file need to reference the shell and not self. Not clear if it's a
1703 file need to reference the shell and not self. Not clear if it's a
1696 bug or feature.
1704 bug or feature.
1697 --changed rc file for new behavior
1705 --changed rc file for new behavior
1698
1706
1699 2004-07-15 Fernando Perez <fperez@colorado.edu>
1707 2004-07-15 Fernando Perez <fperez@colorado.edu>
1700
1708
1701 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1709 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1702 cache was falling out of sync in bizarre manners when multi-line
1710 cache was falling out of sync in bizarre manners when multi-line
1703 input was present. Minor optimizations and cleanup.
1711 input was present. Minor optimizations and cleanup.
1704
1712
1705 (Logger): Remove old Changelog info for cleanup. This is the
1713 (Logger): Remove old Changelog info for cleanup. This is the
1706 information which was there from Janko's original code:
1714 information which was there from Janko's original code:
1707
1715
1708 Changes to Logger: - made the default log filename a parameter
1716 Changes to Logger: - made the default log filename a parameter
1709
1717
1710 - put a check for lines beginning with !@? in log(). Needed
1718 - put a check for lines beginning with !@? in log(). Needed
1711 (even if the handlers properly log their lines) for mid-session
1719 (even if the handlers properly log their lines) for mid-session
1712 logging activation to work properly. Without this, lines logged
1720 logging activation to work properly. Without this, lines logged
1713 in mid session, which get read from the cache, would end up
1721 in mid session, which get read from the cache, would end up
1714 'bare' (with !@? in the open) in the log. Now they are caught
1722 'bare' (with !@? in the open) in the log. Now they are caught
1715 and prepended with a #.
1723 and prepended with a #.
1716
1724
1717 * IPython/iplib.py (InteractiveShell.init_readline): added check
1725 * IPython/iplib.py (InteractiveShell.init_readline): added check
1718 in case MagicCompleter fails to be defined, so we don't crash.
1726 in case MagicCompleter fails to be defined, so we don't crash.
1719
1727
1720 2004-07-13 Fernando Perez <fperez@colorado.edu>
1728 2004-07-13 Fernando Perez <fperez@colorado.edu>
1721
1729
1722 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1730 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1723 of EPS if the requested filename ends in '.eps'.
1731 of EPS if the requested filename ends in '.eps'.
1724
1732
1725 2004-07-04 Fernando Perez <fperez@colorado.edu>
1733 2004-07-04 Fernando Perez <fperez@colorado.edu>
1726
1734
1727 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1735 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1728 escaping of quotes when calling the shell.
1736 escaping of quotes when calling the shell.
1729
1737
1730 2004-07-02 Fernando Perez <fperez@colorado.edu>
1738 2004-07-02 Fernando Perez <fperez@colorado.edu>
1731
1739
1732 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1740 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1733 gettext not working because we were clobbering '_'. Fixes
1741 gettext not working because we were clobbering '_'. Fixes
1734 http://www.scipy.net/roundup/ipython/issue6.
1742 http://www.scipy.net/roundup/ipython/issue6.
1735
1743
1736 2004-07-01 Fernando Perez <fperez@colorado.edu>
1744 2004-07-01 Fernando Perez <fperez@colorado.edu>
1737
1745
1738 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1746 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1739 into @cd. Patch by Ville.
1747 into @cd. Patch by Ville.
1740
1748
1741 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1749 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1742 new function to store things after ipmaker runs. Patch by Ville.
1750 new function to store things after ipmaker runs. Patch by Ville.
1743 Eventually this will go away once ipmaker is removed and the class
1751 Eventually this will go away once ipmaker is removed and the class
1744 gets cleaned up, but for now it's ok. Key functionality here is
1752 gets cleaned up, but for now it's ok. Key functionality here is
1745 the addition of the persistent storage mechanism, a dict for
1753 the addition of the persistent storage mechanism, a dict for
1746 keeping data across sessions (for now just bookmarks, but more can
1754 keeping data across sessions (for now just bookmarks, but more can
1747 be implemented later).
1755 be implemented later).
1748
1756
1749 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1757 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1750 persistent across sections. Patch by Ville, I modified it
1758 persistent across sections. Patch by Ville, I modified it
1751 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1759 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1752 added a '-l' option to list all bookmarks.
1760 added a '-l' option to list all bookmarks.
1753
1761
1754 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1762 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1755 center for cleanup. Registered with atexit.register(). I moved
1763 center for cleanup. Registered with atexit.register(). I moved
1756 here the old exit_cleanup(). After a patch by Ville.
1764 here the old exit_cleanup(). After a patch by Ville.
1757
1765
1758 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1766 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1759 characters in the hacked shlex_split for python 2.2.
1767 characters in the hacked shlex_split for python 2.2.
1760
1768
1761 * IPython/iplib.py (file_matches): more fixes to filenames with
1769 * IPython/iplib.py (file_matches): more fixes to filenames with
1762 whitespace in them. It's not perfect, but limitations in python's
1770 whitespace in them. It's not perfect, but limitations in python's
1763 readline make it impossible to go further.
1771 readline make it impossible to go further.
1764
1772
1765 2004-06-29 Fernando Perez <fperez@colorado.edu>
1773 2004-06-29 Fernando Perez <fperez@colorado.edu>
1766
1774
1767 * IPython/iplib.py (file_matches): escape whitespace correctly in
1775 * IPython/iplib.py (file_matches): escape whitespace correctly in
1768 filename completions. Bug reported by Ville.
1776 filename completions. Bug reported by Ville.
1769
1777
1770 2004-06-28 Fernando Perez <fperez@colorado.edu>
1778 2004-06-28 Fernando Perez <fperez@colorado.edu>
1771
1779
1772 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1780 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1773 the history file will be called 'history-PROFNAME' (or just
1781 the history file will be called 'history-PROFNAME' (or just
1774 'history' if no profile is loaded). I was getting annoyed at
1782 'history' if no profile is loaded). I was getting annoyed at
1775 getting my Numerical work history clobbered by pysh sessions.
1783 getting my Numerical work history clobbered by pysh sessions.
1776
1784
1777 * IPython/iplib.py (InteractiveShell.__init__): Internal
1785 * IPython/iplib.py (InteractiveShell.__init__): Internal
1778 getoutputerror() function so that we can honor the system_verbose
1786 getoutputerror() function so that we can honor the system_verbose
1779 flag for _all_ system calls. I also added escaping of #
1787 flag for _all_ system calls. I also added escaping of #
1780 characters here to avoid confusing Itpl.
1788 characters here to avoid confusing Itpl.
1781
1789
1782 * IPython/Magic.py (shlex_split): removed call to shell in
1790 * IPython/Magic.py (shlex_split): removed call to shell in
1783 parse_options and replaced it with shlex.split(). The annoying
1791 parse_options and replaced it with shlex.split(). The annoying
1784 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1792 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1785 to backport it from 2.3, with several frail hacks (the shlex
1793 to backport it from 2.3, with several frail hacks (the shlex
1786 module is rather limited in 2.2). Thanks to a suggestion by Ville
1794 module is rather limited in 2.2). Thanks to a suggestion by Ville
1787 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1795 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1788 problem.
1796 problem.
1789
1797
1790 (Magic.magic_system_verbose): new toggle to print the actual
1798 (Magic.magic_system_verbose): new toggle to print the actual
1791 system calls made by ipython. Mainly for debugging purposes.
1799 system calls made by ipython. Mainly for debugging purposes.
1792
1800
1793 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1801 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1794 doesn't support persistence. Reported (and fix suggested) by
1802 doesn't support persistence. Reported (and fix suggested) by
1795 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1803 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1796
1804
1797 2004-06-26 Fernando Perez <fperez@colorado.edu>
1805 2004-06-26 Fernando Perez <fperez@colorado.edu>
1798
1806
1799 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1807 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1800 continue prompts.
1808 continue prompts.
1801
1809
1802 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1810 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1803 function (basically a big docstring) and a few more things here to
1811 function (basically a big docstring) and a few more things here to
1804 speedup startup. pysh.py is now very lightweight. We want because
1812 speedup startup. pysh.py is now very lightweight. We want because
1805 it gets execfile'd, while InterpreterExec gets imported, so
1813 it gets execfile'd, while InterpreterExec gets imported, so
1806 byte-compilation saves time.
1814 byte-compilation saves time.
1807
1815
1808 2004-06-25 Fernando Perez <fperez@colorado.edu>
1816 2004-06-25 Fernando Perez <fperez@colorado.edu>
1809
1817
1810 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1818 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1811 -NUM', which was recently broken.
1819 -NUM', which was recently broken.
1812
1820
1813 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1821 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1814 in multi-line input (but not !!, which doesn't make sense there).
1822 in multi-line input (but not !!, which doesn't make sense there).
1815
1823
1816 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1824 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1817 It's just too useful, and people can turn it off in the less
1825 It's just too useful, and people can turn it off in the less
1818 common cases where it's a problem.
1826 common cases where it's a problem.
1819
1827
1820 2004-06-24 Fernando Perez <fperez@colorado.edu>
1828 2004-06-24 Fernando Perez <fperez@colorado.edu>
1821
1829
1822 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1830 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1823 special syntaxes (like alias calling) is now allied in multi-line
1831 special syntaxes (like alias calling) is now allied in multi-line
1824 input. This is still _very_ experimental, but it's necessary for
1832 input. This is still _very_ experimental, but it's necessary for
1825 efficient shell usage combining python looping syntax with system
1833 efficient shell usage combining python looping syntax with system
1826 calls. For now it's restricted to aliases, I don't think it
1834 calls. For now it's restricted to aliases, I don't think it
1827 really even makes sense to have this for magics.
1835 really even makes sense to have this for magics.
1828
1836
1829 2004-06-23 Fernando Perez <fperez@colorado.edu>
1837 2004-06-23 Fernando Perez <fperez@colorado.edu>
1830
1838
1831 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1839 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1832 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1840 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1833
1841
1834 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1842 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1835 extensions under Windows (after code sent by Gary Bishop). The
1843 extensions under Windows (after code sent by Gary Bishop). The
1836 extensions considered 'executable' are stored in IPython's rc
1844 extensions considered 'executable' are stored in IPython's rc
1837 structure as win_exec_ext.
1845 structure as win_exec_ext.
1838
1846
1839 * IPython/genutils.py (shell): new function, like system() but
1847 * IPython/genutils.py (shell): new function, like system() but
1840 without return value. Very useful for interactive shell work.
1848 without return value. Very useful for interactive shell work.
1841
1849
1842 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1850 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1843 delete aliases.
1851 delete aliases.
1844
1852
1845 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1853 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1846 sure that the alias table doesn't contain python keywords.
1854 sure that the alias table doesn't contain python keywords.
1847
1855
1848 2004-06-21 Fernando Perez <fperez@colorado.edu>
1856 2004-06-21 Fernando Perez <fperez@colorado.edu>
1849
1857
1850 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1858 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1851 non-existent items are found in $PATH. Reported by Thorsten.
1859 non-existent items are found in $PATH. Reported by Thorsten.
1852
1860
1853 2004-06-20 Fernando Perez <fperez@colorado.edu>
1861 2004-06-20 Fernando Perez <fperez@colorado.edu>
1854
1862
1855 * IPython/iplib.py (complete): modified the completer so that the
1863 * IPython/iplib.py (complete): modified the completer so that the
1856 order of priorities can be easily changed at runtime.
1864 order of priorities can be easily changed at runtime.
1857
1865
1858 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1866 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1859 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1867 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1860
1868
1861 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1869 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1862 expand Python variables prepended with $ in all system calls. The
1870 expand Python variables prepended with $ in all system calls. The
1863 same was done to InteractiveShell.handle_shell_escape. Now all
1871 same was done to InteractiveShell.handle_shell_escape. Now all
1864 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1872 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1865 expansion of python variables and expressions according to the
1873 expansion of python variables and expressions according to the
1866 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1874 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1867
1875
1868 Though PEP-215 has been rejected, a similar (but simpler) one
1876 Though PEP-215 has been rejected, a similar (but simpler) one
1869 seems like it will go into Python 2.4, PEP-292 -
1877 seems like it will go into Python 2.4, PEP-292 -
1870 http://www.python.org/peps/pep-0292.html.
1878 http://www.python.org/peps/pep-0292.html.
1871
1879
1872 I'll keep the full syntax of PEP-215, since IPython has since the
1880 I'll keep the full syntax of PEP-215, since IPython has since the
1873 start used Ka-Ping Yee's reference implementation discussed there
1881 start used Ka-Ping Yee's reference implementation discussed there
1874 (Itpl), and I actually like the powerful semantics it offers.
1882 (Itpl), and I actually like the powerful semantics it offers.
1875
1883
1876 In order to access normal shell variables, the $ has to be escaped
1884 In order to access normal shell variables, the $ has to be escaped
1877 via an extra $. For example:
1885 via an extra $. For example:
1878
1886
1879 In [7]: PATH='a python variable'
1887 In [7]: PATH='a python variable'
1880
1888
1881 In [8]: !echo $PATH
1889 In [8]: !echo $PATH
1882 a python variable
1890 a python variable
1883
1891
1884 In [9]: !echo $$PATH
1892 In [9]: !echo $$PATH
1885 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1893 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1886
1894
1887 (Magic.parse_options): escape $ so the shell doesn't evaluate
1895 (Magic.parse_options): escape $ so the shell doesn't evaluate
1888 things prematurely.
1896 things prematurely.
1889
1897
1890 * IPython/iplib.py (InteractiveShell.call_alias): added the
1898 * IPython/iplib.py (InteractiveShell.call_alias): added the
1891 ability for aliases to expand python variables via $.
1899 ability for aliases to expand python variables via $.
1892
1900
1893 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1901 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1894 system, now there's a @rehash/@rehashx pair of magics. These work
1902 system, now there's a @rehash/@rehashx pair of magics. These work
1895 like the csh rehash command, and can be invoked at any time. They
1903 like the csh rehash command, and can be invoked at any time. They
1896 build a table of aliases to everything in the user's $PATH
1904 build a table of aliases to everything in the user's $PATH
1897 (@rehash uses everything, @rehashx is slower but only adds
1905 (@rehash uses everything, @rehashx is slower but only adds
1898 executable files). With this, the pysh.py-based shell profile can
1906 executable files). With this, the pysh.py-based shell profile can
1899 now simply call rehash upon startup, and full access to all
1907 now simply call rehash upon startup, and full access to all
1900 programs in the user's path is obtained.
1908 programs in the user's path is obtained.
1901
1909
1902 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1910 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1903 functionality is now fully in place. I removed the old dynamic
1911 functionality is now fully in place. I removed the old dynamic
1904 code generation based approach, in favor of a much lighter one
1912 code generation based approach, in favor of a much lighter one
1905 based on a simple dict. The advantage is that this allows me to
1913 based on a simple dict. The advantage is that this allows me to
1906 now have thousands of aliases with negligible cost (unthinkable
1914 now have thousands of aliases with negligible cost (unthinkable
1907 with the old system).
1915 with the old system).
1908
1916
1909 2004-06-19 Fernando Perez <fperez@colorado.edu>
1917 2004-06-19 Fernando Perez <fperez@colorado.edu>
1910
1918
1911 * IPython/iplib.py (__init__): extended MagicCompleter class to
1919 * IPython/iplib.py (__init__): extended MagicCompleter class to
1912 also complete (last in priority) on user aliases.
1920 also complete (last in priority) on user aliases.
1913
1921
1914 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1922 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1915 call to eval.
1923 call to eval.
1916 (ItplNS.__init__): Added a new class which functions like Itpl,
1924 (ItplNS.__init__): Added a new class which functions like Itpl,
1917 but allows configuring the namespace for the evaluation to occur
1925 but allows configuring the namespace for the evaluation to occur
1918 in.
1926 in.
1919
1927
1920 2004-06-18 Fernando Perez <fperez@colorado.edu>
1928 2004-06-18 Fernando Perez <fperez@colorado.edu>
1921
1929
1922 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1930 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1923 better message when 'exit' or 'quit' are typed (a common newbie
1931 better message when 'exit' or 'quit' are typed (a common newbie
1924 confusion).
1932 confusion).
1925
1933
1926 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1934 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1927 check for Windows users.
1935 check for Windows users.
1928
1936
1929 * IPython/iplib.py (InteractiveShell.user_setup): removed
1937 * IPython/iplib.py (InteractiveShell.user_setup): removed
1930 disabling of colors for Windows. I'll test at runtime and issue a
1938 disabling of colors for Windows. I'll test at runtime and issue a
1931 warning if Gary's readline isn't found, as to nudge users to
1939 warning if Gary's readline isn't found, as to nudge users to
1932 download it.
1940 download it.
1933
1941
1934 2004-06-16 Fernando Perez <fperez@colorado.edu>
1942 2004-06-16 Fernando Perez <fperez@colorado.edu>
1935
1943
1936 * IPython/genutils.py (Stream.__init__): changed to print errors
1944 * IPython/genutils.py (Stream.__init__): changed to print errors
1937 to sys.stderr. I had a circular dependency here. Now it's
1945 to sys.stderr. I had a circular dependency here. Now it's
1938 possible to run ipython as IDLE's shell (consider this pre-alpha,
1946 possible to run ipython as IDLE's shell (consider this pre-alpha,
1939 since true stdout things end up in the starting terminal instead
1947 since true stdout things end up in the starting terminal instead
1940 of IDLE's out).
1948 of IDLE's out).
1941
1949
1942 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1950 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1943 users who haven't # updated their prompt_in2 definitions. Remove
1951 users who haven't # updated their prompt_in2 definitions. Remove
1944 eventually.
1952 eventually.
1945 (multiple_replace): added credit to original ASPN recipe.
1953 (multiple_replace): added credit to original ASPN recipe.
1946
1954
1947 2004-06-15 Fernando Perez <fperez@colorado.edu>
1955 2004-06-15 Fernando Perez <fperez@colorado.edu>
1948
1956
1949 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1957 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1950 list of auto-defined aliases.
1958 list of auto-defined aliases.
1951
1959
1952 2004-06-13 Fernando Perez <fperez@colorado.edu>
1960 2004-06-13 Fernando Perez <fperez@colorado.edu>
1953
1961
1954 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1962 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1955 install was really requested (so setup.py can be used for other
1963 install was really requested (so setup.py can be used for other
1956 things under Windows).
1964 things under Windows).
1957
1965
1958 2004-06-10 Fernando Perez <fperez@colorado.edu>
1966 2004-06-10 Fernando Perez <fperez@colorado.edu>
1959
1967
1960 * IPython/Logger.py (Logger.create_log): Manually remove any old
1968 * IPython/Logger.py (Logger.create_log): Manually remove any old
1961 backup, since os.remove may fail under Windows. Fixes bug
1969 backup, since os.remove may fail under Windows. Fixes bug
1962 reported by Thorsten.
1970 reported by Thorsten.
1963
1971
1964 2004-06-09 Fernando Perez <fperez@colorado.edu>
1972 2004-06-09 Fernando Perez <fperez@colorado.edu>
1965
1973
1966 * examples/example-embed.py: fixed all references to %n (replaced
1974 * examples/example-embed.py: fixed all references to %n (replaced
1967 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1975 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1968 for all examples and the manual as well.
1976 for all examples and the manual as well.
1969
1977
1970 2004-06-08 Fernando Perez <fperez@colorado.edu>
1978 2004-06-08 Fernando Perez <fperez@colorado.edu>
1971
1979
1972 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1980 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1973 alignment and color management. All 3 prompt subsystems now
1981 alignment and color management. All 3 prompt subsystems now
1974 inherit from BasePrompt.
1982 inherit from BasePrompt.
1975
1983
1976 * tools/release: updates for windows installer build and tag rpms
1984 * tools/release: updates for windows installer build and tag rpms
1977 with python version (since paths are fixed).
1985 with python version (since paths are fixed).
1978
1986
1979 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1987 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1980 which will become eventually obsolete. Also fixed the default
1988 which will become eventually obsolete. Also fixed the default
1981 prompt_in2 to use \D, so at least new users start with the correct
1989 prompt_in2 to use \D, so at least new users start with the correct
1982 defaults.
1990 defaults.
1983 WARNING: Users with existing ipythonrc files will need to apply
1991 WARNING: Users with existing ipythonrc files will need to apply
1984 this fix manually!
1992 this fix manually!
1985
1993
1986 * setup.py: make windows installer (.exe). This is finally the
1994 * setup.py: make windows installer (.exe). This is finally the
1987 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1995 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1988 which I hadn't included because it required Python 2.3 (or recent
1996 which I hadn't included because it required Python 2.3 (or recent
1989 distutils).
1997 distutils).
1990
1998
1991 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1999 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1992 usage of new '\D' escape.
2000 usage of new '\D' escape.
1993
2001
1994 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2002 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1995 lacks os.getuid())
2003 lacks os.getuid())
1996 (CachedOutput.set_colors): Added the ability to turn coloring
2004 (CachedOutput.set_colors): Added the ability to turn coloring
1997 on/off with @colors even for manually defined prompt colors. It
2005 on/off with @colors even for manually defined prompt colors. It
1998 uses a nasty global, but it works safely and via the generic color
2006 uses a nasty global, but it works safely and via the generic color
1999 handling mechanism.
2007 handling mechanism.
2000 (Prompt2.__init__): Introduced new escape '\D' for continuation
2008 (Prompt2.__init__): Introduced new escape '\D' for continuation
2001 prompts. It represents the counter ('\#') as dots.
2009 prompts. It represents the counter ('\#') as dots.
2002 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2010 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2003 need to update their ipythonrc files and replace '%n' with '\D' in
2011 need to update their ipythonrc files and replace '%n' with '\D' in
2004 their prompt_in2 settings everywhere. Sorry, but there's
2012 their prompt_in2 settings everywhere. Sorry, but there's
2005 otherwise no clean way to get all prompts to properly align. The
2013 otherwise no clean way to get all prompts to properly align. The
2006 ipythonrc shipped with IPython has been updated.
2014 ipythonrc shipped with IPython has been updated.
2007
2015
2008 2004-06-07 Fernando Perez <fperez@colorado.edu>
2016 2004-06-07 Fernando Perez <fperez@colorado.edu>
2009
2017
2010 * setup.py (isfile): Pass local_icons option to latex2html, so the
2018 * setup.py (isfile): Pass local_icons option to latex2html, so the
2011 resulting HTML file is self-contained. Thanks to
2019 resulting HTML file is self-contained. Thanks to
2012 dryice-AT-liu.com.cn for the tip.
2020 dryice-AT-liu.com.cn for the tip.
2013
2021
2014 * pysh.py: I created a new profile 'shell', which implements a
2022 * pysh.py: I created a new profile 'shell', which implements a
2015 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2023 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2016 system shell, nor will it become one anytime soon. It's mainly
2024 system shell, nor will it become one anytime soon. It's mainly
2017 meant to illustrate the use of the new flexible bash-like prompts.
2025 meant to illustrate the use of the new flexible bash-like prompts.
2018 I guess it could be used by hardy souls for true shell management,
2026 I guess it could be used by hardy souls for true shell management,
2019 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2027 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2020 profile. This uses the InterpreterExec extension provided by
2028 profile. This uses the InterpreterExec extension provided by
2021 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2029 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2022
2030
2023 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2031 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2024 auto-align itself with the length of the previous input prompt
2032 auto-align itself with the length of the previous input prompt
2025 (taking into account the invisible color escapes).
2033 (taking into account the invisible color escapes).
2026 (CachedOutput.__init__): Large restructuring of this class. Now
2034 (CachedOutput.__init__): Large restructuring of this class. Now
2027 all three prompts (primary1, primary2, output) are proper objects,
2035 all three prompts (primary1, primary2, output) are proper objects,
2028 managed by the 'parent' CachedOutput class. The code is still a
2036 managed by the 'parent' CachedOutput class. The code is still a
2029 bit hackish (all prompts share state via a pointer to the cache),
2037 bit hackish (all prompts share state via a pointer to the cache),
2030 but it's overall far cleaner than before.
2038 but it's overall far cleaner than before.
2031
2039
2032 * IPython/genutils.py (getoutputerror): modified to add verbose,
2040 * IPython/genutils.py (getoutputerror): modified to add verbose,
2033 debug and header options. This makes the interface of all getout*
2041 debug and header options. This makes the interface of all getout*
2034 functions uniform.
2042 functions uniform.
2035 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2043 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2036
2044
2037 * IPython/Magic.py (Magic.default_option): added a function to
2045 * IPython/Magic.py (Magic.default_option): added a function to
2038 allow registering default options for any magic command. This
2046 allow registering default options for any magic command. This
2039 makes it easy to have profiles which customize the magics globally
2047 makes it easy to have profiles which customize the magics globally
2040 for a certain use. The values set through this function are
2048 for a certain use. The values set through this function are
2041 picked up by the parse_options() method, which all magics should
2049 picked up by the parse_options() method, which all magics should
2042 use to parse their options.
2050 use to parse their options.
2043
2051
2044 * IPython/genutils.py (warn): modified the warnings framework to
2052 * IPython/genutils.py (warn): modified the warnings framework to
2045 use the Term I/O class. I'm trying to slowly unify all of
2053 use the Term I/O class. I'm trying to slowly unify all of
2046 IPython's I/O operations to pass through Term.
2054 IPython's I/O operations to pass through Term.
2047
2055
2048 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2056 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2049 the secondary prompt to correctly match the length of the primary
2057 the secondary prompt to correctly match the length of the primary
2050 one for any prompt. Now multi-line code will properly line up
2058 one for any prompt. Now multi-line code will properly line up
2051 even for path dependent prompts, such as the new ones available
2059 even for path dependent prompts, such as the new ones available
2052 via the prompt_specials.
2060 via the prompt_specials.
2053
2061
2054 2004-06-06 Fernando Perez <fperez@colorado.edu>
2062 2004-06-06 Fernando Perez <fperez@colorado.edu>
2055
2063
2056 * IPython/Prompts.py (prompt_specials): Added the ability to have
2064 * IPython/Prompts.py (prompt_specials): Added the ability to have
2057 bash-like special sequences in the prompts, which get
2065 bash-like special sequences in the prompts, which get
2058 automatically expanded. Things like hostname, current working
2066 automatically expanded. Things like hostname, current working
2059 directory and username are implemented already, but it's easy to
2067 directory and username are implemented already, but it's easy to
2060 add more in the future. Thanks to a patch by W.J. van der Laan
2068 add more in the future. Thanks to a patch by W.J. van der Laan
2061 <gnufnork-AT-hetdigitalegat.nl>
2069 <gnufnork-AT-hetdigitalegat.nl>
2062 (prompt_specials): Added color support for prompt strings, so
2070 (prompt_specials): Added color support for prompt strings, so
2063 users can define arbitrary color setups for their prompts.
2071 users can define arbitrary color setups for their prompts.
2064
2072
2065 2004-06-05 Fernando Perez <fperez@colorado.edu>
2073 2004-06-05 Fernando Perez <fperez@colorado.edu>
2066
2074
2067 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2075 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2068 code to load Gary Bishop's readline and configure it
2076 code to load Gary Bishop's readline and configure it
2069 automatically. Thanks to Gary for help on this.
2077 automatically. Thanks to Gary for help on this.
2070
2078
2071 2004-06-01 Fernando Perez <fperez@colorado.edu>
2079 2004-06-01 Fernando Perez <fperez@colorado.edu>
2072
2080
2073 * IPython/Logger.py (Logger.create_log): fix bug for logging
2081 * IPython/Logger.py (Logger.create_log): fix bug for logging
2074 with no filename (previous fix was incomplete).
2082 with no filename (previous fix was incomplete).
2075
2083
2076 2004-05-25 Fernando Perez <fperez@colorado.edu>
2084 2004-05-25 Fernando Perez <fperez@colorado.edu>
2077
2085
2078 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2086 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2079 parens would get passed to the shell.
2087 parens would get passed to the shell.
2080
2088
2081 2004-05-20 Fernando Perez <fperez@colorado.edu>
2089 2004-05-20 Fernando Perez <fperez@colorado.edu>
2082
2090
2083 * IPython/Magic.py (Magic.magic_prun): changed default profile
2091 * IPython/Magic.py (Magic.magic_prun): changed default profile
2084 sort order to 'time' (the more common profiling need).
2092 sort order to 'time' (the more common profiling need).
2085
2093
2086 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2094 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2087 so that source code shown is guaranteed in sync with the file on
2095 so that source code shown is guaranteed in sync with the file on
2088 disk (also changed in psource). Similar fix to the one for
2096 disk (also changed in psource). Similar fix to the one for
2089 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2097 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2090 <yann.ledu-AT-noos.fr>.
2098 <yann.ledu-AT-noos.fr>.
2091
2099
2092 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2100 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2093 with a single option would not be correctly parsed. Closes
2101 with a single option would not be correctly parsed. Closes
2094 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2102 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2095 introduced in 0.6.0 (on 2004-05-06).
2103 introduced in 0.6.0 (on 2004-05-06).
2096
2104
2097 2004-05-13 *** Released version 0.6.0
2105 2004-05-13 *** Released version 0.6.0
2098
2106
2099 2004-05-13 Fernando Perez <fperez@colorado.edu>
2107 2004-05-13 Fernando Perez <fperez@colorado.edu>
2100
2108
2101 * debian/: Added debian/ directory to CVS, so that debian support
2109 * debian/: Added debian/ directory to CVS, so that debian support
2102 is publicly accessible. The debian package is maintained by Jack
2110 is publicly accessible. The debian package is maintained by Jack
2103 Moffit <jack-AT-xiph.org>.
2111 Moffit <jack-AT-xiph.org>.
2104
2112
2105 * Documentation: included the notes about an ipython-based system
2113 * Documentation: included the notes about an ipython-based system
2106 shell (the hypothetical 'pysh') into the new_design.pdf document,
2114 shell (the hypothetical 'pysh') into the new_design.pdf document,
2107 so that these ideas get distributed to users along with the
2115 so that these ideas get distributed to users along with the
2108 official documentation.
2116 official documentation.
2109
2117
2110 2004-05-10 Fernando Perez <fperez@colorado.edu>
2118 2004-05-10 Fernando Perez <fperez@colorado.edu>
2111
2119
2112 * IPython/Logger.py (Logger.create_log): fix recently introduced
2120 * IPython/Logger.py (Logger.create_log): fix recently introduced
2113 bug (misindented line) where logstart would fail when not given an
2121 bug (misindented line) where logstart would fail when not given an
2114 explicit filename.
2122 explicit filename.
2115
2123
2116 2004-05-09 Fernando Perez <fperez@colorado.edu>
2124 2004-05-09 Fernando Perez <fperez@colorado.edu>
2117
2125
2118 * IPython/Magic.py (Magic.parse_options): skip system call when
2126 * IPython/Magic.py (Magic.parse_options): skip system call when
2119 there are no options to look for. Faster, cleaner for the common
2127 there are no options to look for. Faster, cleaner for the common
2120 case.
2128 case.
2121
2129
2122 * Documentation: many updates to the manual: describing Windows
2130 * Documentation: many updates to the manual: describing Windows
2123 support better, Gnuplot updates, credits, misc small stuff. Also
2131 support better, Gnuplot updates, credits, misc small stuff. Also
2124 updated the new_design doc a bit.
2132 updated the new_design doc a bit.
2125
2133
2126 2004-05-06 *** Released version 0.6.0.rc1
2134 2004-05-06 *** Released version 0.6.0.rc1
2127
2135
2128 2004-05-06 Fernando Perez <fperez@colorado.edu>
2136 2004-05-06 Fernando Perez <fperez@colorado.edu>
2129
2137
2130 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2138 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2131 operations to use the vastly more efficient list/''.join() method.
2139 operations to use the vastly more efficient list/''.join() method.
2132 (FormattedTB.text): Fix
2140 (FormattedTB.text): Fix
2133 http://www.scipy.net/roundup/ipython/issue12 - exception source
2141 http://www.scipy.net/roundup/ipython/issue12 - exception source
2134 extract not updated after reload. Thanks to Mike Salib
2142 extract not updated after reload. Thanks to Mike Salib
2135 <msalib-AT-mit.edu> for pinning the source of the problem.
2143 <msalib-AT-mit.edu> for pinning the source of the problem.
2136 Fortunately, the solution works inside ipython and doesn't require
2144 Fortunately, the solution works inside ipython and doesn't require
2137 any changes to python proper.
2145 any changes to python proper.
2138
2146
2139 * IPython/Magic.py (Magic.parse_options): Improved to process the
2147 * IPython/Magic.py (Magic.parse_options): Improved to process the
2140 argument list as a true shell would (by actually using the
2148 argument list as a true shell would (by actually using the
2141 underlying system shell). This way, all @magics automatically get
2149 underlying system shell). This way, all @magics automatically get
2142 shell expansion for variables. Thanks to a comment by Alex
2150 shell expansion for variables. Thanks to a comment by Alex
2143 Schmolck.
2151 Schmolck.
2144
2152
2145 2004-04-04 Fernando Perez <fperez@colorado.edu>
2153 2004-04-04 Fernando Perez <fperez@colorado.edu>
2146
2154
2147 * IPython/iplib.py (InteractiveShell.interact): Added a special
2155 * IPython/iplib.py (InteractiveShell.interact): Added a special
2148 trap for a debugger quit exception, which is basically impossible
2156 trap for a debugger quit exception, which is basically impossible
2149 to handle by normal mechanisms, given what pdb does to the stack.
2157 to handle by normal mechanisms, given what pdb does to the stack.
2150 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2158 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2151
2159
2152 2004-04-03 Fernando Perez <fperez@colorado.edu>
2160 2004-04-03 Fernando Perez <fperez@colorado.edu>
2153
2161
2154 * IPython/genutils.py (Term): Standardized the names of the Term
2162 * IPython/genutils.py (Term): Standardized the names of the Term
2155 class streams to cin/cout/cerr, following C++ naming conventions
2163 class streams to cin/cout/cerr, following C++ naming conventions
2156 (I can't use in/out/err because 'in' is not a valid attribute
2164 (I can't use in/out/err because 'in' is not a valid attribute
2157 name).
2165 name).
2158
2166
2159 * IPython/iplib.py (InteractiveShell.interact): don't increment
2167 * IPython/iplib.py (InteractiveShell.interact): don't increment
2160 the prompt if there's no user input. By Daniel 'Dang' Griffith
2168 the prompt if there's no user input. By Daniel 'Dang' Griffith
2161 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2169 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2162 Francois Pinard.
2170 Francois Pinard.
2163
2171
2164 2004-04-02 Fernando Perez <fperez@colorado.edu>
2172 2004-04-02 Fernando Perez <fperez@colorado.edu>
2165
2173
2166 * IPython/genutils.py (Stream.__init__): Modified to survive at
2174 * IPython/genutils.py (Stream.__init__): Modified to survive at
2167 least importing in contexts where stdin/out/err aren't true file
2175 least importing in contexts where stdin/out/err aren't true file
2168 objects, such as PyCrust (they lack fileno() and mode). However,
2176 objects, such as PyCrust (they lack fileno() and mode). However,
2169 the recovery facilities which rely on these things existing will
2177 the recovery facilities which rely on these things existing will
2170 not work.
2178 not work.
2171
2179
2172 2004-04-01 Fernando Perez <fperez@colorado.edu>
2180 2004-04-01 Fernando Perez <fperez@colorado.edu>
2173
2181
2174 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2182 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2175 use the new getoutputerror() function, so it properly
2183 use the new getoutputerror() function, so it properly
2176 distinguishes stdout/err.
2184 distinguishes stdout/err.
2177
2185
2178 * IPython/genutils.py (getoutputerror): added a function to
2186 * IPython/genutils.py (getoutputerror): added a function to
2179 capture separately the standard output and error of a command.
2187 capture separately the standard output and error of a command.
2180 After a comment from dang on the mailing lists. This code is
2188 After a comment from dang on the mailing lists. This code is
2181 basically a modified version of commands.getstatusoutput(), from
2189 basically a modified version of commands.getstatusoutput(), from
2182 the standard library.
2190 the standard library.
2183
2191
2184 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2192 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2185 '!!' as a special syntax (shorthand) to access @sx.
2193 '!!' as a special syntax (shorthand) to access @sx.
2186
2194
2187 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2195 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2188 command and return its output as a list split on '\n'.
2196 command and return its output as a list split on '\n'.
2189
2197
2190 2004-03-31 Fernando Perez <fperez@colorado.edu>
2198 2004-03-31 Fernando Perez <fperez@colorado.edu>
2191
2199
2192 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2200 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2193 method to dictionaries used as FakeModule instances if they lack
2201 method to dictionaries used as FakeModule instances if they lack
2194 it. At least pydoc in python2.3 breaks for runtime-defined
2202 it. At least pydoc in python2.3 breaks for runtime-defined
2195 functions without this hack. At some point I need to _really_
2203 functions without this hack. At some point I need to _really_
2196 understand what FakeModule is doing, because it's a gross hack.
2204 understand what FakeModule is doing, because it's a gross hack.
2197 But it solves Arnd's problem for now...
2205 But it solves Arnd's problem for now...
2198
2206
2199 2004-02-27 Fernando Perez <fperez@colorado.edu>
2207 2004-02-27 Fernando Perez <fperez@colorado.edu>
2200
2208
2201 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2209 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2202 mode would behave erratically. Also increased the number of
2210 mode would behave erratically. Also increased the number of
2203 possible logs in rotate mod to 999. Thanks to Rod Holland
2211 possible logs in rotate mod to 999. Thanks to Rod Holland
2204 <rhh@StructureLABS.com> for the report and fixes.
2212 <rhh@StructureLABS.com> for the report and fixes.
2205
2213
2206 2004-02-26 Fernando Perez <fperez@colorado.edu>
2214 2004-02-26 Fernando Perez <fperez@colorado.edu>
2207
2215
2208 * IPython/genutils.py (page): Check that the curses module really
2216 * IPython/genutils.py (page): Check that the curses module really
2209 has the initscr attribute before trying to use it. For some
2217 has the initscr attribute before trying to use it. For some
2210 reason, the Solaris curses module is missing this. I think this
2218 reason, the Solaris curses module is missing this. I think this
2211 should be considered a Solaris python bug, but I'm not sure.
2219 should be considered a Solaris python bug, but I'm not sure.
2212
2220
2213 2004-01-17 Fernando Perez <fperez@colorado.edu>
2221 2004-01-17 Fernando Perez <fperez@colorado.edu>
2214
2222
2215 * IPython/genutils.py (Stream.__init__): Changes to try to make
2223 * IPython/genutils.py (Stream.__init__): Changes to try to make
2216 ipython robust against stdin/out/err being closed by the user.
2224 ipython robust against stdin/out/err being closed by the user.
2217 This is 'user error' (and blocks a normal python session, at least
2225 This is 'user error' (and blocks a normal python session, at least
2218 the stdout case). However, Ipython should be able to survive such
2226 the stdout case). However, Ipython should be able to survive such
2219 instances of abuse as gracefully as possible. To simplify the
2227 instances of abuse as gracefully as possible. To simplify the
2220 coding and maintain compatibility with Gary Bishop's Term
2228 coding and maintain compatibility with Gary Bishop's Term
2221 contributions, I've made use of classmethods for this. I think
2229 contributions, I've made use of classmethods for this. I think
2222 this introduces a dependency on python 2.2.
2230 this introduces a dependency on python 2.2.
2223
2231
2224 2004-01-13 Fernando Perez <fperez@colorado.edu>
2232 2004-01-13 Fernando Perez <fperez@colorado.edu>
2225
2233
2226 * IPython/numutils.py (exp_safe): simplified the code a bit and
2234 * IPython/numutils.py (exp_safe): simplified the code a bit and
2227 removed the need for importing the kinds module altogether.
2235 removed the need for importing the kinds module altogether.
2228
2236
2229 2004-01-06 Fernando Perez <fperez@colorado.edu>
2237 2004-01-06 Fernando Perez <fperez@colorado.edu>
2230
2238
2231 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2239 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2232 a magic function instead, after some community feedback. No
2240 a magic function instead, after some community feedback. No
2233 special syntax will exist for it, but its name is deliberately
2241 special syntax will exist for it, but its name is deliberately
2234 very short.
2242 very short.
2235
2243
2236 2003-12-20 Fernando Perez <fperez@colorado.edu>
2244 2003-12-20 Fernando Perez <fperez@colorado.edu>
2237
2245
2238 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2246 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2239 new functionality, to automagically assign the result of a shell
2247 new functionality, to automagically assign the result of a shell
2240 command to a variable. I'll solicit some community feedback on
2248 command to a variable. I'll solicit some community feedback on
2241 this before making it permanent.
2249 this before making it permanent.
2242
2250
2243 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2251 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2244 requested about callables for which inspect couldn't obtain a
2252 requested about callables for which inspect couldn't obtain a
2245 proper argspec. Thanks to a crash report sent by Etienne
2253 proper argspec. Thanks to a crash report sent by Etienne
2246 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2254 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2247
2255
2248 2003-12-09 Fernando Perez <fperez@colorado.edu>
2256 2003-12-09 Fernando Perez <fperez@colorado.edu>
2249
2257
2250 * IPython/genutils.py (page): patch for the pager to work across
2258 * IPython/genutils.py (page): patch for the pager to work across
2251 various versions of Windows. By Gary Bishop.
2259 various versions of Windows. By Gary Bishop.
2252
2260
2253 2003-12-04 Fernando Perez <fperez@colorado.edu>
2261 2003-12-04 Fernando Perez <fperez@colorado.edu>
2254
2262
2255 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2263 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2256 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2264 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2257 While I tested this and it looks ok, there may still be corner
2265 While I tested this and it looks ok, there may still be corner
2258 cases I've missed.
2266 cases I've missed.
2259
2267
2260 2003-12-01 Fernando Perez <fperez@colorado.edu>
2268 2003-12-01 Fernando Perez <fperez@colorado.edu>
2261
2269
2262 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2270 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2263 where a line like 'p,q=1,2' would fail because the automagic
2271 where a line like 'p,q=1,2' would fail because the automagic
2264 system would be triggered for @p.
2272 system would be triggered for @p.
2265
2273
2266 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2274 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2267 cleanups, code unmodified.
2275 cleanups, code unmodified.
2268
2276
2269 * IPython/genutils.py (Term): added a class for IPython to handle
2277 * IPython/genutils.py (Term): added a class for IPython to handle
2270 output. In most cases it will just be a proxy for stdout/err, but
2278 output. In most cases it will just be a proxy for stdout/err, but
2271 having this allows modifications to be made for some platforms,
2279 having this allows modifications to be made for some platforms,
2272 such as handling color escapes under Windows. All of this code
2280 such as handling color escapes under Windows. All of this code
2273 was contributed by Gary Bishop, with minor modifications by me.
2281 was contributed by Gary Bishop, with minor modifications by me.
2274 The actual changes affect many files.
2282 The actual changes affect many files.
2275
2283
2276 2003-11-30 Fernando Perez <fperez@colorado.edu>
2284 2003-11-30 Fernando Perez <fperez@colorado.edu>
2277
2285
2278 * IPython/iplib.py (file_matches): new completion code, courtesy
2286 * IPython/iplib.py (file_matches): new completion code, courtesy
2279 of Jeff Collins. This enables filename completion again under
2287 of Jeff Collins. This enables filename completion again under
2280 python 2.3, which disabled it at the C level.
2288 python 2.3, which disabled it at the C level.
2281
2289
2282 2003-11-11 Fernando Perez <fperez@colorado.edu>
2290 2003-11-11 Fernando Perez <fperez@colorado.edu>
2283
2291
2284 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2292 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2285 for Numeric.array(map(...)), but often convenient.
2293 for Numeric.array(map(...)), but often convenient.
2286
2294
2287 2003-11-05 Fernando Perez <fperez@colorado.edu>
2295 2003-11-05 Fernando Perez <fperez@colorado.edu>
2288
2296
2289 * IPython/numutils.py (frange): Changed a call from int() to
2297 * IPython/numutils.py (frange): Changed a call from int() to
2290 int(round()) to prevent a problem reported with arange() in the
2298 int(round()) to prevent a problem reported with arange() in the
2291 numpy list.
2299 numpy list.
2292
2300
2293 2003-10-06 Fernando Perez <fperez@colorado.edu>
2301 2003-10-06 Fernando Perez <fperez@colorado.edu>
2294
2302
2295 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2303 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2296 prevent crashes if sys lacks an argv attribute (it happens with
2304 prevent crashes if sys lacks an argv attribute (it happens with
2297 embedded interpreters which build a bare-bones sys module).
2305 embedded interpreters which build a bare-bones sys module).
2298 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2306 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2299
2307
2300 2003-09-24 Fernando Perez <fperez@colorado.edu>
2308 2003-09-24 Fernando Perez <fperez@colorado.edu>
2301
2309
2302 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2310 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2303 to protect against poorly written user objects where __getattr__
2311 to protect against poorly written user objects where __getattr__
2304 raises exceptions other than AttributeError. Thanks to a bug
2312 raises exceptions other than AttributeError. Thanks to a bug
2305 report by Oliver Sander <osander-AT-gmx.de>.
2313 report by Oliver Sander <osander-AT-gmx.de>.
2306
2314
2307 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2315 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2308 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2316 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2309
2317
2310 2003-09-09 Fernando Perez <fperez@colorado.edu>
2318 2003-09-09 Fernando Perez <fperez@colorado.edu>
2311
2319
2312 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2320 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2313 unpacking a list whith a callable as first element would
2321 unpacking a list whith a callable as first element would
2314 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2322 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2315 Collins.
2323 Collins.
2316
2324
2317 2003-08-25 *** Released version 0.5.0
2325 2003-08-25 *** Released version 0.5.0
2318
2326
2319 2003-08-22 Fernando Perez <fperez@colorado.edu>
2327 2003-08-22 Fernando Perez <fperez@colorado.edu>
2320
2328
2321 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2329 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2322 improperly defined user exceptions. Thanks to feedback from Mark
2330 improperly defined user exceptions. Thanks to feedback from Mark
2323 Russell <mrussell-AT-verio.net>.
2331 Russell <mrussell-AT-verio.net>.
2324
2332
2325 2003-08-20 Fernando Perez <fperez@colorado.edu>
2333 2003-08-20 Fernando Perez <fperez@colorado.edu>
2326
2334
2327 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2335 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2328 printing so that it would print multi-line string forms starting
2336 printing so that it would print multi-line string forms starting
2329 with a new line. This way the formatting is better respected for
2337 with a new line. This way the formatting is better respected for
2330 objects which work hard to make nice string forms.
2338 objects which work hard to make nice string forms.
2331
2339
2332 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2340 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2333 autocall would overtake data access for objects with both
2341 autocall would overtake data access for objects with both
2334 __getitem__ and __call__.
2342 __getitem__ and __call__.
2335
2343
2336 2003-08-19 *** Released version 0.5.0-rc1
2344 2003-08-19 *** Released version 0.5.0-rc1
2337
2345
2338 2003-08-19 Fernando Perez <fperez@colorado.edu>
2346 2003-08-19 Fernando Perez <fperez@colorado.edu>
2339
2347
2340 * IPython/deep_reload.py (load_tail): single tiny change here
2348 * IPython/deep_reload.py (load_tail): single tiny change here
2341 seems to fix the long-standing bug of dreload() failing to work
2349 seems to fix the long-standing bug of dreload() failing to work
2342 for dotted names. But this module is pretty tricky, so I may have
2350 for dotted names. But this module is pretty tricky, so I may have
2343 missed some subtlety. Needs more testing!.
2351 missed some subtlety. Needs more testing!.
2344
2352
2345 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2353 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2346 exceptions which have badly implemented __str__ methods.
2354 exceptions which have badly implemented __str__ methods.
2347 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2355 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2348 which I've been getting reports about from Python 2.3 users. I
2356 which I've been getting reports about from Python 2.3 users. I
2349 wish I had a simple test case to reproduce the problem, so I could
2357 wish I had a simple test case to reproduce the problem, so I could
2350 either write a cleaner workaround or file a bug report if
2358 either write a cleaner workaround or file a bug report if
2351 necessary.
2359 necessary.
2352
2360
2353 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2361 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2354 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2362 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2355 a bug report by Tjabo Kloppenburg.
2363 a bug report by Tjabo Kloppenburg.
2356
2364
2357 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2365 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2358 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2366 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2359 seems rather unstable. Thanks to a bug report by Tjabo
2367 seems rather unstable. Thanks to a bug report by Tjabo
2360 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2368 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2361
2369
2362 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2370 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2363 this out soon because of the critical fixes in the inner loop for
2371 this out soon because of the critical fixes in the inner loop for
2364 generators.
2372 generators.
2365
2373
2366 * IPython/Magic.py (Magic.getargspec): removed. This (and
2374 * IPython/Magic.py (Magic.getargspec): removed. This (and
2367 _get_def) have been obsoleted by OInspect for a long time, I
2375 _get_def) have been obsoleted by OInspect for a long time, I
2368 hadn't noticed that they were dead code.
2376 hadn't noticed that they were dead code.
2369 (Magic._ofind): restored _ofind functionality for a few literals
2377 (Magic._ofind): restored _ofind functionality for a few literals
2370 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2378 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2371 for things like "hello".capitalize?, since that would require a
2379 for things like "hello".capitalize?, since that would require a
2372 potentially dangerous eval() again.
2380 potentially dangerous eval() again.
2373
2381
2374 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2382 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2375 logic a bit more to clean up the escapes handling and minimize the
2383 logic a bit more to clean up the escapes handling and minimize the
2376 use of _ofind to only necessary cases. The interactive 'feel' of
2384 use of _ofind to only necessary cases. The interactive 'feel' of
2377 IPython should have improved quite a bit with the changes in
2385 IPython should have improved quite a bit with the changes in
2378 _prefilter and _ofind (besides being far safer than before).
2386 _prefilter and _ofind (besides being far safer than before).
2379
2387
2380 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2388 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2381 obscure, never reported). Edit would fail to find the object to
2389 obscure, never reported). Edit would fail to find the object to
2382 edit under some circumstances.
2390 edit under some circumstances.
2383 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2391 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2384 which were causing double-calling of generators. Those eval calls
2392 which were causing double-calling of generators. Those eval calls
2385 were _very_ dangerous, since code with side effects could be
2393 were _very_ dangerous, since code with side effects could be
2386 triggered. As they say, 'eval is evil'... These were the
2394 triggered. As they say, 'eval is evil'... These were the
2387 nastiest evals in IPython. Besides, _ofind is now far simpler,
2395 nastiest evals in IPython. Besides, _ofind is now far simpler,
2388 and it should also be quite a bit faster. Its use of inspect is
2396 and it should also be quite a bit faster. Its use of inspect is
2389 also safer, so perhaps some of the inspect-related crashes I've
2397 also safer, so perhaps some of the inspect-related crashes I've
2390 seen lately with Python 2.3 might be taken care of. That will
2398 seen lately with Python 2.3 might be taken care of. That will
2391 need more testing.
2399 need more testing.
2392
2400
2393 2003-08-17 Fernando Perez <fperez@colorado.edu>
2401 2003-08-17 Fernando Perez <fperez@colorado.edu>
2394
2402
2395 * IPython/iplib.py (InteractiveShell._prefilter): significant
2403 * IPython/iplib.py (InteractiveShell._prefilter): significant
2396 simplifications to the logic for handling user escapes. Faster
2404 simplifications to the logic for handling user escapes. Faster
2397 and simpler code.
2405 and simpler code.
2398
2406
2399 2003-08-14 Fernando Perez <fperez@colorado.edu>
2407 2003-08-14 Fernando Perez <fperez@colorado.edu>
2400
2408
2401 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2409 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2402 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2410 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2403 but it should be quite a bit faster. And the recursive version
2411 but it should be quite a bit faster. And the recursive version
2404 generated O(log N) intermediate storage for all rank>1 arrays,
2412 generated O(log N) intermediate storage for all rank>1 arrays,
2405 even if they were contiguous.
2413 even if they were contiguous.
2406 (l1norm): Added this function.
2414 (l1norm): Added this function.
2407 (norm): Added this function for arbitrary norms (including
2415 (norm): Added this function for arbitrary norms (including
2408 l-infinity). l1 and l2 are still special cases for convenience
2416 l-infinity). l1 and l2 are still special cases for convenience
2409 and speed.
2417 and speed.
2410
2418
2411 2003-08-03 Fernando Perez <fperez@colorado.edu>
2419 2003-08-03 Fernando Perez <fperez@colorado.edu>
2412
2420
2413 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2421 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2414 exceptions, which now raise PendingDeprecationWarnings in Python
2422 exceptions, which now raise PendingDeprecationWarnings in Python
2415 2.3. There were some in Magic and some in Gnuplot2.
2423 2.3. There were some in Magic and some in Gnuplot2.
2416
2424
2417 2003-06-30 Fernando Perez <fperez@colorado.edu>
2425 2003-06-30 Fernando Perez <fperez@colorado.edu>
2418
2426
2419 * IPython/genutils.py (page): modified to call curses only for
2427 * IPython/genutils.py (page): modified to call curses only for
2420 terminals where TERM=='xterm'. After problems under many other
2428 terminals where TERM=='xterm'. After problems under many other
2421 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2429 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2422
2430
2423 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2431 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2424 would be triggered when readline was absent. This was just an old
2432 would be triggered when readline was absent. This was just an old
2425 debugging statement I'd forgotten to take out.
2433 debugging statement I'd forgotten to take out.
2426
2434
2427 2003-06-20 Fernando Perez <fperez@colorado.edu>
2435 2003-06-20 Fernando Perez <fperez@colorado.edu>
2428
2436
2429 * IPython/genutils.py (clock): modified to return only user time
2437 * IPython/genutils.py (clock): modified to return only user time
2430 (not counting system time), after a discussion on scipy. While
2438 (not counting system time), after a discussion on scipy. While
2431 system time may be a useful quantity occasionally, it may much
2439 system time may be a useful quantity occasionally, it may much
2432 more easily be skewed by occasional swapping or other similar
2440 more easily be skewed by occasional swapping or other similar
2433 activity.
2441 activity.
2434
2442
2435 2003-06-05 Fernando Perez <fperez@colorado.edu>
2443 2003-06-05 Fernando Perez <fperez@colorado.edu>
2436
2444
2437 * IPython/numutils.py (identity): new function, for building
2445 * IPython/numutils.py (identity): new function, for building
2438 arbitrary rank Kronecker deltas (mostly backwards compatible with
2446 arbitrary rank Kronecker deltas (mostly backwards compatible with
2439 Numeric.identity)
2447 Numeric.identity)
2440
2448
2441 2003-06-03 Fernando Perez <fperez@colorado.edu>
2449 2003-06-03 Fernando Perez <fperez@colorado.edu>
2442
2450
2443 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2451 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2444 arguments passed to magics with spaces, to allow trailing '\' to
2452 arguments passed to magics with spaces, to allow trailing '\' to
2445 work normally (mainly for Windows users).
2453 work normally (mainly for Windows users).
2446
2454
2447 2003-05-29 Fernando Perez <fperez@colorado.edu>
2455 2003-05-29 Fernando Perez <fperez@colorado.edu>
2448
2456
2449 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2457 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2450 instead of pydoc.help. This fixes a bizarre behavior where
2458 instead of pydoc.help. This fixes a bizarre behavior where
2451 printing '%s' % locals() would trigger the help system. Now
2459 printing '%s' % locals() would trigger the help system. Now
2452 ipython behaves like normal python does.
2460 ipython behaves like normal python does.
2453
2461
2454 Note that if one does 'from pydoc import help', the bizarre
2462 Note that if one does 'from pydoc import help', the bizarre
2455 behavior returns, but this will also happen in normal python, so
2463 behavior returns, but this will also happen in normal python, so
2456 it's not an ipython bug anymore (it has to do with how pydoc.help
2464 it's not an ipython bug anymore (it has to do with how pydoc.help
2457 is implemented).
2465 is implemented).
2458
2466
2459 2003-05-22 Fernando Perez <fperez@colorado.edu>
2467 2003-05-22 Fernando Perez <fperez@colorado.edu>
2460
2468
2461 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2469 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2462 return [] instead of None when nothing matches, also match to end
2470 return [] instead of None when nothing matches, also match to end
2463 of line. Patch by Gary Bishop.
2471 of line. Patch by Gary Bishop.
2464
2472
2465 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2473 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2466 protection as before, for files passed on the command line. This
2474 protection as before, for files passed on the command line. This
2467 prevents the CrashHandler from kicking in if user files call into
2475 prevents the CrashHandler from kicking in if user files call into
2468 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2476 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2469 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2477 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2470
2478
2471 2003-05-20 *** Released version 0.4.0
2479 2003-05-20 *** Released version 0.4.0
2472
2480
2473 2003-05-20 Fernando Perez <fperez@colorado.edu>
2481 2003-05-20 Fernando Perez <fperez@colorado.edu>
2474
2482
2475 * setup.py: added support for manpages. It's a bit hackish b/c of
2483 * setup.py: added support for manpages. It's a bit hackish b/c of
2476 a bug in the way the bdist_rpm distutils target handles gzipped
2484 a bug in the way the bdist_rpm distutils target handles gzipped
2477 manpages, but it works. After a patch by Jack.
2485 manpages, but it works. After a patch by Jack.
2478
2486
2479 2003-05-19 Fernando Perez <fperez@colorado.edu>
2487 2003-05-19 Fernando Perez <fperez@colorado.edu>
2480
2488
2481 * IPython/numutils.py: added a mockup of the kinds module, since
2489 * IPython/numutils.py: added a mockup of the kinds module, since
2482 it was recently removed from Numeric. This way, numutils will
2490 it was recently removed from Numeric. This way, numutils will
2483 work for all users even if they are missing kinds.
2491 work for all users even if they are missing kinds.
2484
2492
2485 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2493 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2486 failure, which can occur with SWIG-wrapped extensions. After a
2494 failure, which can occur with SWIG-wrapped extensions. After a
2487 crash report from Prabhu.
2495 crash report from Prabhu.
2488
2496
2489 2003-05-16 Fernando Perez <fperez@colorado.edu>
2497 2003-05-16 Fernando Perez <fperez@colorado.edu>
2490
2498
2491 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2499 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2492 protect ipython from user code which may call directly
2500 protect ipython from user code which may call directly
2493 sys.excepthook (this looks like an ipython crash to the user, even
2501 sys.excepthook (this looks like an ipython crash to the user, even
2494 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2502 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2495 This is especially important to help users of WxWindows, but may
2503 This is especially important to help users of WxWindows, but may
2496 also be useful in other cases.
2504 also be useful in other cases.
2497
2505
2498 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2506 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2499 an optional tb_offset to be specified, and to preserve exception
2507 an optional tb_offset to be specified, and to preserve exception
2500 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2508 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2501
2509
2502 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2510 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2503
2511
2504 2003-05-15 Fernando Perez <fperez@colorado.edu>
2512 2003-05-15 Fernando Perez <fperez@colorado.edu>
2505
2513
2506 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2514 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2507 installing for a new user under Windows.
2515 installing for a new user under Windows.
2508
2516
2509 2003-05-12 Fernando Perez <fperez@colorado.edu>
2517 2003-05-12 Fernando Perez <fperez@colorado.edu>
2510
2518
2511 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2519 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2512 handler for Emacs comint-based lines. Currently it doesn't do
2520 handler for Emacs comint-based lines. Currently it doesn't do
2513 much (but importantly, it doesn't update the history cache). In
2521 much (but importantly, it doesn't update the history cache). In
2514 the future it may be expanded if Alex needs more functionality
2522 the future it may be expanded if Alex needs more functionality
2515 there.
2523 there.
2516
2524
2517 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2525 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2518 info to crash reports.
2526 info to crash reports.
2519
2527
2520 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2528 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2521 just like Python's -c. Also fixed crash with invalid -color
2529 just like Python's -c. Also fixed crash with invalid -color
2522 option value at startup. Thanks to Will French
2530 option value at startup. Thanks to Will French
2523 <wfrench-AT-bestweb.net> for the bug report.
2531 <wfrench-AT-bestweb.net> for the bug report.
2524
2532
2525 2003-05-09 Fernando Perez <fperez@colorado.edu>
2533 2003-05-09 Fernando Perez <fperez@colorado.edu>
2526
2534
2527 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2535 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2528 to EvalDict (it's a mapping, after all) and simplified its code
2536 to EvalDict (it's a mapping, after all) and simplified its code
2529 quite a bit, after a nice discussion on c.l.py where Gustavo
2537 quite a bit, after a nice discussion on c.l.py where Gustavo
2530 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2538 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2531
2539
2532 2003-04-30 Fernando Perez <fperez@colorado.edu>
2540 2003-04-30 Fernando Perez <fperez@colorado.edu>
2533
2541
2534 * IPython/genutils.py (timings_out): modified it to reduce its
2542 * IPython/genutils.py (timings_out): modified it to reduce its
2535 overhead in the common reps==1 case.
2543 overhead in the common reps==1 case.
2536
2544
2537 2003-04-29 Fernando Perez <fperez@colorado.edu>
2545 2003-04-29 Fernando Perez <fperez@colorado.edu>
2538
2546
2539 * IPython/genutils.py (timings_out): Modified to use the resource
2547 * IPython/genutils.py (timings_out): Modified to use the resource
2540 module, which avoids the wraparound problems of time.clock().
2548 module, which avoids the wraparound problems of time.clock().
2541
2549
2542 2003-04-17 *** Released version 0.2.15pre4
2550 2003-04-17 *** Released version 0.2.15pre4
2543
2551
2544 2003-04-17 Fernando Perez <fperez@colorado.edu>
2552 2003-04-17 Fernando Perez <fperez@colorado.edu>
2545
2553
2546 * setup.py (scriptfiles): Split windows-specific stuff over to a
2554 * setup.py (scriptfiles): Split windows-specific stuff over to a
2547 separate file, in an attempt to have a Windows GUI installer.
2555 separate file, in an attempt to have a Windows GUI installer.
2548 That didn't work, but part of the groundwork is done.
2556 That didn't work, but part of the groundwork is done.
2549
2557
2550 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2558 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2551 indent/unindent with 4 spaces. Particularly useful in combination
2559 indent/unindent with 4 spaces. Particularly useful in combination
2552 with the new auto-indent option.
2560 with the new auto-indent option.
2553
2561
2554 2003-04-16 Fernando Perez <fperez@colorado.edu>
2562 2003-04-16 Fernando Perez <fperez@colorado.edu>
2555
2563
2556 * IPython/Magic.py: various replacements of self.rc for
2564 * IPython/Magic.py: various replacements of self.rc for
2557 self.shell.rc. A lot more remains to be done to fully disentangle
2565 self.shell.rc. A lot more remains to be done to fully disentangle
2558 this class from the main Shell class.
2566 this class from the main Shell class.
2559
2567
2560 * IPython/GnuplotRuntime.py: added checks for mouse support so
2568 * IPython/GnuplotRuntime.py: added checks for mouse support so
2561 that we don't try to enable it if the current gnuplot doesn't
2569 that we don't try to enable it if the current gnuplot doesn't
2562 really support it. Also added checks so that we don't try to
2570 really support it. Also added checks so that we don't try to
2563 enable persist under Windows (where Gnuplot doesn't recognize the
2571 enable persist under Windows (where Gnuplot doesn't recognize the
2564 option).
2572 option).
2565
2573
2566 * IPython/iplib.py (InteractiveShell.interact): Added optional
2574 * IPython/iplib.py (InteractiveShell.interact): Added optional
2567 auto-indenting code, after a patch by King C. Shu
2575 auto-indenting code, after a patch by King C. Shu
2568 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2576 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2569 get along well with pasting indented code. If I ever figure out
2577 get along well with pasting indented code. If I ever figure out
2570 how to make that part go well, it will become on by default.
2578 how to make that part go well, it will become on by default.
2571
2579
2572 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2580 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2573 crash ipython if there was an unmatched '%' in the user's prompt
2581 crash ipython if there was an unmatched '%' in the user's prompt
2574 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2582 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2575
2583
2576 * IPython/iplib.py (InteractiveShell.interact): removed the
2584 * IPython/iplib.py (InteractiveShell.interact): removed the
2577 ability to ask the user whether he wants to crash or not at the
2585 ability to ask the user whether he wants to crash or not at the
2578 'last line' exception handler. Calling functions at that point
2586 'last line' exception handler. Calling functions at that point
2579 changes the stack, and the error reports would have incorrect
2587 changes the stack, and the error reports would have incorrect
2580 tracebacks.
2588 tracebacks.
2581
2589
2582 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2590 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2583 pass through a peger a pretty-printed form of any object. After a
2591 pass through a peger a pretty-printed form of any object. After a
2584 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2592 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2585
2593
2586 2003-04-14 Fernando Perez <fperez@colorado.edu>
2594 2003-04-14 Fernando Perez <fperez@colorado.edu>
2587
2595
2588 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2596 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2589 all files in ~ would be modified at first install (instead of
2597 all files in ~ would be modified at first install (instead of
2590 ~/.ipython). This could be potentially disastrous, as the
2598 ~/.ipython). This could be potentially disastrous, as the
2591 modification (make line-endings native) could damage binary files.
2599 modification (make line-endings native) could damage binary files.
2592
2600
2593 2003-04-10 Fernando Perez <fperez@colorado.edu>
2601 2003-04-10 Fernando Perez <fperez@colorado.edu>
2594
2602
2595 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2603 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2596 handle only lines which are invalid python. This now means that
2604 handle only lines which are invalid python. This now means that
2597 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2605 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2598 for the bug report.
2606 for the bug report.
2599
2607
2600 2003-04-01 Fernando Perez <fperez@colorado.edu>
2608 2003-04-01 Fernando Perez <fperez@colorado.edu>
2601
2609
2602 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2610 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2603 where failing to set sys.last_traceback would crash pdb.pm().
2611 where failing to set sys.last_traceback would crash pdb.pm().
2604 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2612 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2605 report.
2613 report.
2606
2614
2607 2003-03-25 Fernando Perez <fperez@colorado.edu>
2615 2003-03-25 Fernando Perez <fperez@colorado.edu>
2608
2616
2609 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2617 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2610 before printing it (it had a lot of spurious blank lines at the
2618 before printing it (it had a lot of spurious blank lines at the
2611 end).
2619 end).
2612
2620
2613 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2621 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2614 output would be sent 21 times! Obviously people don't use this
2622 output would be sent 21 times! Obviously people don't use this
2615 too often, or I would have heard about it.
2623 too often, or I would have heard about it.
2616
2624
2617 2003-03-24 Fernando Perez <fperez@colorado.edu>
2625 2003-03-24 Fernando Perez <fperez@colorado.edu>
2618
2626
2619 * setup.py (scriptfiles): renamed the data_files parameter from
2627 * setup.py (scriptfiles): renamed the data_files parameter from
2620 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2628 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2621 for the patch.
2629 for the patch.
2622
2630
2623 2003-03-20 Fernando Perez <fperez@colorado.edu>
2631 2003-03-20 Fernando Perez <fperez@colorado.edu>
2624
2632
2625 * IPython/genutils.py (error): added error() and fatal()
2633 * IPython/genutils.py (error): added error() and fatal()
2626 functions.
2634 functions.
2627
2635
2628 2003-03-18 *** Released version 0.2.15pre3
2636 2003-03-18 *** Released version 0.2.15pre3
2629
2637
2630 2003-03-18 Fernando Perez <fperez@colorado.edu>
2638 2003-03-18 Fernando Perez <fperez@colorado.edu>
2631
2639
2632 * setupext/install_data_ext.py
2640 * setupext/install_data_ext.py
2633 (install_data_ext.initialize_options): Class contributed by Jack
2641 (install_data_ext.initialize_options): Class contributed by Jack
2634 Moffit for fixing the old distutils hack. He is sending this to
2642 Moffit for fixing the old distutils hack. He is sending this to
2635 the distutils folks so in the future we may not need it as a
2643 the distutils folks so in the future we may not need it as a
2636 private fix.
2644 private fix.
2637
2645
2638 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2646 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2639 changes for Debian packaging. See his patch for full details.
2647 changes for Debian packaging. See his patch for full details.
2640 The old distutils hack of making the ipythonrc* files carry a
2648 The old distutils hack of making the ipythonrc* files carry a
2641 bogus .py extension is gone, at last. Examples were moved to a
2649 bogus .py extension is gone, at last. Examples were moved to a
2642 separate subdir under doc/, and the separate executable scripts
2650 separate subdir under doc/, and the separate executable scripts
2643 now live in their own directory. Overall a great cleanup. The
2651 now live in their own directory. Overall a great cleanup. The
2644 manual was updated to use the new files, and setup.py has been
2652 manual was updated to use the new files, and setup.py has been
2645 fixed for this setup.
2653 fixed for this setup.
2646
2654
2647 * IPython/PyColorize.py (Parser.usage): made non-executable and
2655 * IPython/PyColorize.py (Parser.usage): made non-executable and
2648 created a pycolor wrapper around it to be included as a script.
2656 created a pycolor wrapper around it to be included as a script.
2649
2657
2650 2003-03-12 *** Released version 0.2.15pre2
2658 2003-03-12 *** Released version 0.2.15pre2
2651
2659
2652 2003-03-12 Fernando Perez <fperez@colorado.edu>
2660 2003-03-12 Fernando Perez <fperez@colorado.edu>
2653
2661
2654 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2662 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2655 long-standing problem with garbage characters in some terminals.
2663 long-standing problem with garbage characters in some terminals.
2656 The issue was really that the \001 and \002 escapes must _only_ be
2664 The issue was really that the \001 and \002 escapes must _only_ be
2657 passed to input prompts (which call readline), but _never_ to
2665 passed to input prompts (which call readline), but _never_ to
2658 normal text to be printed on screen. I changed ColorANSI to have
2666 normal text to be printed on screen. I changed ColorANSI to have
2659 two classes: TermColors and InputTermColors, each with the
2667 two classes: TermColors and InputTermColors, each with the
2660 appropriate escapes for input prompts or normal text. The code in
2668 appropriate escapes for input prompts or normal text. The code in
2661 Prompts.py got slightly more complicated, but this very old and
2669 Prompts.py got slightly more complicated, but this very old and
2662 annoying bug is finally fixed.
2670 annoying bug is finally fixed.
2663
2671
2664 All the credit for nailing down the real origin of this problem
2672 All the credit for nailing down the real origin of this problem
2665 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2673 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2666 *Many* thanks to him for spending quite a bit of effort on this.
2674 *Many* thanks to him for spending quite a bit of effort on this.
2667
2675
2668 2003-03-05 *** Released version 0.2.15pre1
2676 2003-03-05 *** Released version 0.2.15pre1
2669
2677
2670 2003-03-03 Fernando Perez <fperez@colorado.edu>
2678 2003-03-03 Fernando Perez <fperez@colorado.edu>
2671
2679
2672 * IPython/FakeModule.py: Moved the former _FakeModule to a
2680 * IPython/FakeModule.py: Moved the former _FakeModule to a
2673 separate file, because it's also needed by Magic (to fix a similar
2681 separate file, because it's also needed by Magic (to fix a similar
2674 pickle-related issue in @run).
2682 pickle-related issue in @run).
2675
2683
2676 2003-03-02 Fernando Perez <fperez@colorado.edu>
2684 2003-03-02 Fernando Perez <fperez@colorado.edu>
2677
2685
2678 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2686 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2679 the autocall option at runtime.
2687 the autocall option at runtime.
2680 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2688 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2681 across Magic.py to start separating Magic from InteractiveShell.
2689 across Magic.py to start separating Magic from InteractiveShell.
2682 (Magic._ofind): Fixed to return proper namespace for dotted
2690 (Magic._ofind): Fixed to return proper namespace for dotted
2683 names. Before, a dotted name would always return 'not currently
2691 names. Before, a dotted name would always return 'not currently
2684 defined', because it would find the 'parent'. s.x would be found,
2692 defined', because it would find the 'parent'. s.x would be found,
2685 but since 'x' isn't defined by itself, it would get confused.
2693 but since 'x' isn't defined by itself, it would get confused.
2686 (Magic.magic_run): Fixed pickling problems reported by Ralf
2694 (Magic.magic_run): Fixed pickling problems reported by Ralf
2687 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2695 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2688 that I'd used when Mike Heeter reported similar issues at the
2696 that I'd used when Mike Heeter reported similar issues at the
2689 top-level, but now for @run. It boils down to injecting the
2697 top-level, but now for @run. It boils down to injecting the
2690 namespace where code is being executed with something that looks
2698 namespace where code is being executed with something that looks
2691 enough like a module to fool pickle.dump(). Since a pickle stores
2699 enough like a module to fool pickle.dump(). Since a pickle stores
2692 a named reference to the importing module, we need this for
2700 a named reference to the importing module, we need this for
2693 pickles to save something sensible.
2701 pickles to save something sensible.
2694
2702
2695 * IPython/ipmaker.py (make_IPython): added an autocall option.
2703 * IPython/ipmaker.py (make_IPython): added an autocall option.
2696
2704
2697 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2705 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2698 the auto-eval code. Now autocalling is an option, and the code is
2706 the auto-eval code. Now autocalling is an option, and the code is
2699 also vastly safer. There is no more eval() involved at all.
2707 also vastly safer. There is no more eval() involved at all.
2700
2708
2701 2003-03-01 Fernando Perez <fperez@colorado.edu>
2709 2003-03-01 Fernando Perez <fperez@colorado.edu>
2702
2710
2703 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2711 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2704 dict with named keys instead of a tuple.
2712 dict with named keys instead of a tuple.
2705
2713
2706 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2714 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2707
2715
2708 * setup.py (make_shortcut): Fixed message about directories
2716 * setup.py (make_shortcut): Fixed message about directories
2709 created during Windows installation (the directories were ok, just
2717 created during Windows installation (the directories were ok, just
2710 the printed message was misleading). Thanks to Chris Liechti
2718 the printed message was misleading). Thanks to Chris Liechti
2711 <cliechti-AT-gmx.net> for the heads up.
2719 <cliechti-AT-gmx.net> for the heads up.
2712
2720
2713 2003-02-21 Fernando Perez <fperez@colorado.edu>
2721 2003-02-21 Fernando Perez <fperez@colorado.edu>
2714
2722
2715 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2723 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2716 of ValueError exception when checking for auto-execution. This
2724 of ValueError exception when checking for auto-execution. This
2717 one is raised by things like Numeric arrays arr.flat when the
2725 one is raised by things like Numeric arrays arr.flat when the
2718 array is non-contiguous.
2726 array is non-contiguous.
2719
2727
2720 2003-01-31 Fernando Perez <fperez@colorado.edu>
2728 2003-01-31 Fernando Perez <fperez@colorado.edu>
2721
2729
2722 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2730 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2723 not return any value at all (even though the command would get
2731 not return any value at all (even though the command would get
2724 executed).
2732 executed).
2725 (xsys): Flush stdout right after printing the command to ensure
2733 (xsys): Flush stdout right after printing the command to ensure
2726 proper ordering of commands and command output in the total
2734 proper ordering of commands and command output in the total
2727 output.
2735 output.
2728 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2736 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2729 system/getoutput as defaults. The old ones are kept for
2737 system/getoutput as defaults. The old ones are kept for
2730 compatibility reasons, so no code which uses this library needs
2738 compatibility reasons, so no code which uses this library needs
2731 changing.
2739 changing.
2732
2740
2733 2003-01-27 *** Released version 0.2.14
2741 2003-01-27 *** Released version 0.2.14
2734
2742
2735 2003-01-25 Fernando Perez <fperez@colorado.edu>
2743 2003-01-25 Fernando Perez <fperez@colorado.edu>
2736
2744
2737 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2745 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2738 functions defined in previous edit sessions could not be re-edited
2746 functions defined in previous edit sessions could not be re-edited
2739 (because the temp files were immediately removed). Now temp files
2747 (because the temp files were immediately removed). Now temp files
2740 are removed only at IPython's exit.
2748 are removed only at IPython's exit.
2741 (Magic.magic_run): Improved @run to perform shell-like expansions
2749 (Magic.magic_run): Improved @run to perform shell-like expansions
2742 on its arguments (~users and $VARS). With this, @run becomes more
2750 on its arguments (~users and $VARS). With this, @run becomes more
2743 like a normal command-line.
2751 like a normal command-line.
2744
2752
2745 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2753 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2746 bugs related to embedding and cleaned up that code. A fairly
2754 bugs related to embedding and cleaned up that code. A fairly
2747 important one was the impossibility to access the global namespace
2755 important one was the impossibility to access the global namespace
2748 through the embedded IPython (only local variables were visible).
2756 through the embedded IPython (only local variables were visible).
2749
2757
2750 2003-01-14 Fernando Perez <fperez@colorado.edu>
2758 2003-01-14 Fernando Perez <fperez@colorado.edu>
2751
2759
2752 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2760 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2753 auto-calling to be a bit more conservative. Now it doesn't get
2761 auto-calling to be a bit more conservative. Now it doesn't get
2754 triggered if any of '!=()<>' are in the rest of the input line, to
2762 triggered if any of '!=()<>' are in the rest of the input line, to
2755 allow comparing callables. Thanks to Alex for the heads up.
2763 allow comparing callables. Thanks to Alex for the heads up.
2756
2764
2757 2003-01-07 Fernando Perez <fperez@colorado.edu>
2765 2003-01-07 Fernando Perez <fperez@colorado.edu>
2758
2766
2759 * IPython/genutils.py (page): fixed estimation of the number of
2767 * IPython/genutils.py (page): fixed estimation of the number of
2760 lines in a string to be paged to simply count newlines. This
2768 lines in a string to be paged to simply count newlines. This
2761 prevents over-guessing due to embedded escape sequences. A better
2769 prevents over-guessing due to embedded escape sequences. A better
2762 long-term solution would involve stripping out the control chars
2770 long-term solution would involve stripping out the control chars
2763 for the count, but it's potentially so expensive I just don't
2771 for the count, but it's potentially so expensive I just don't
2764 think it's worth doing.
2772 think it's worth doing.
2765
2773
2766 2002-12-19 *** Released version 0.2.14pre50
2774 2002-12-19 *** Released version 0.2.14pre50
2767
2775
2768 2002-12-19 Fernando Perez <fperez@colorado.edu>
2776 2002-12-19 Fernando Perez <fperez@colorado.edu>
2769
2777
2770 * tools/release (version): Changed release scripts to inform
2778 * tools/release (version): Changed release scripts to inform
2771 Andrea and build a NEWS file with a list of recent changes.
2779 Andrea and build a NEWS file with a list of recent changes.
2772
2780
2773 * IPython/ColorANSI.py (__all__): changed terminal detection
2781 * IPython/ColorANSI.py (__all__): changed terminal detection
2774 code. Seems to work better for xterms without breaking
2782 code. Seems to work better for xterms without breaking
2775 konsole. Will need more testing to determine if WinXP and Mac OSX
2783 konsole. Will need more testing to determine if WinXP and Mac OSX
2776 also work ok.
2784 also work ok.
2777
2785
2778 2002-12-18 *** Released version 0.2.14pre49
2786 2002-12-18 *** Released version 0.2.14pre49
2779
2787
2780 2002-12-18 Fernando Perez <fperez@colorado.edu>
2788 2002-12-18 Fernando Perez <fperez@colorado.edu>
2781
2789
2782 * Docs: added new info about Mac OSX, from Andrea.
2790 * Docs: added new info about Mac OSX, from Andrea.
2783
2791
2784 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2792 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2785 allow direct plotting of python strings whose format is the same
2793 allow direct plotting of python strings whose format is the same
2786 of gnuplot data files.
2794 of gnuplot data files.
2787
2795
2788 2002-12-16 Fernando Perez <fperez@colorado.edu>
2796 2002-12-16 Fernando Perez <fperez@colorado.edu>
2789
2797
2790 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2798 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2791 value of exit question to be acknowledged.
2799 value of exit question to be acknowledged.
2792
2800
2793 2002-12-03 Fernando Perez <fperez@colorado.edu>
2801 2002-12-03 Fernando Perez <fperez@colorado.edu>
2794
2802
2795 * IPython/ipmaker.py: removed generators, which had been added
2803 * IPython/ipmaker.py: removed generators, which had been added
2796 by mistake in an earlier debugging run. This was causing trouble
2804 by mistake in an earlier debugging run. This was causing trouble
2797 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2805 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2798 for pointing this out.
2806 for pointing this out.
2799
2807
2800 2002-11-17 Fernando Perez <fperez@colorado.edu>
2808 2002-11-17 Fernando Perez <fperez@colorado.edu>
2801
2809
2802 * Manual: updated the Gnuplot section.
2810 * Manual: updated the Gnuplot section.
2803
2811
2804 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2812 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2805 a much better split of what goes in Runtime and what goes in
2813 a much better split of what goes in Runtime and what goes in
2806 Interactive.
2814 Interactive.
2807
2815
2808 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2816 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2809 being imported from iplib.
2817 being imported from iplib.
2810
2818
2811 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2819 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2812 for command-passing. Now the global Gnuplot instance is called
2820 for command-passing. Now the global Gnuplot instance is called
2813 'gp' instead of 'g', which was really a far too fragile and
2821 'gp' instead of 'g', which was really a far too fragile and
2814 common name.
2822 common name.
2815
2823
2816 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2824 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2817 bounding boxes generated by Gnuplot for square plots.
2825 bounding boxes generated by Gnuplot for square plots.
2818
2826
2819 * IPython/genutils.py (popkey): new function added. I should
2827 * IPython/genutils.py (popkey): new function added. I should
2820 suggest this on c.l.py as a dict method, it seems useful.
2828 suggest this on c.l.py as a dict method, it seems useful.
2821
2829
2822 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2830 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2823 to transparently handle PostScript generation. MUCH better than
2831 to transparently handle PostScript generation. MUCH better than
2824 the previous plot_eps/replot_eps (which I removed now). The code
2832 the previous plot_eps/replot_eps (which I removed now). The code
2825 is also fairly clean and well documented now (including
2833 is also fairly clean and well documented now (including
2826 docstrings).
2834 docstrings).
2827
2835
2828 2002-11-13 Fernando Perez <fperez@colorado.edu>
2836 2002-11-13 Fernando Perez <fperez@colorado.edu>
2829
2837
2830 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2838 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2831 (inconsistent with options).
2839 (inconsistent with options).
2832
2840
2833 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2841 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2834 manually disabled, I don't know why. Fixed it.
2842 manually disabled, I don't know why. Fixed it.
2835 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2843 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2836 eps output.
2844 eps output.
2837
2845
2838 2002-11-12 Fernando Perez <fperez@colorado.edu>
2846 2002-11-12 Fernando Perez <fperez@colorado.edu>
2839
2847
2840 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2848 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2841 don't propagate up to caller. Fixes crash reported by François
2849 don't propagate up to caller. Fixes crash reported by François
2842 Pinard.
2850 Pinard.
2843
2851
2844 2002-11-09 Fernando Perez <fperez@colorado.edu>
2852 2002-11-09 Fernando Perez <fperez@colorado.edu>
2845
2853
2846 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2854 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2847 history file for new users.
2855 history file for new users.
2848 (make_IPython): fixed bug where initial install would leave the
2856 (make_IPython): fixed bug where initial install would leave the
2849 user running in the .ipython dir.
2857 user running in the .ipython dir.
2850 (make_IPython): fixed bug where config dir .ipython would be
2858 (make_IPython): fixed bug where config dir .ipython would be
2851 created regardless of the given -ipythondir option. Thanks to Cory
2859 created regardless of the given -ipythondir option. Thanks to Cory
2852 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2860 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2853
2861
2854 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2862 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2855 type confirmations. Will need to use it in all of IPython's code
2863 type confirmations. Will need to use it in all of IPython's code
2856 consistently.
2864 consistently.
2857
2865
2858 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2866 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2859 context to print 31 lines instead of the default 5. This will make
2867 context to print 31 lines instead of the default 5. This will make
2860 the crash reports extremely detailed in case the problem is in
2868 the crash reports extremely detailed in case the problem is in
2861 libraries I don't have access to.
2869 libraries I don't have access to.
2862
2870
2863 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2871 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2864 line of defense' code to still crash, but giving users fair
2872 line of defense' code to still crash, but giving users fair
2865 warning. I don't want internal errors to go unreported: if there's
2873 warning. I don't want internal errors to go unreported: if there's
2866 an internal problem, IPython should crash and generate a full
2874 an internal problem, IPython should crash and generate a full
2867 report.
2875 report.
2868
2876
2869 2002-11-08 Fernando Perez <fperez@colorado.edu>
2877 2002-11-08 Fernando Perez <fperez@colorado.edu>
2870
2878
2871 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2879 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2872 otherwise uncaught exceptions which can appear if people set
2880 otherwise uncaught exceptions which can appear if people set
2873 sys.stdout to something badly broken. Thanks to a crash report
2881 sys.stdout to something badly broken. Thanks to a crash report
2874 from henni-AT-mail.brainbot.com.
2882 from henni-AT-mail.brainbot.com.
2875
2883
2876 2002-11-04 Fernando Perez <fperez@colorado.edu>
2884 2002-11-04 Fernando Perez <fperez@colorado.edu>
2877
2885
2878 * IPython/iplib.py (InteractiveShell.interact): added
2886 * IPython/iplib.py (InteractiveShell.interact): added
2879 __IPYTHON__active to the builtins. It's a flag which goes on when
2887 __IPYTHON__active to the builtins. It's a flag which goes on when
2880 the interaction starts and goes off again when it stops. This
2888 the interaction starts and goes off again when it stops. This
2881 allows embedding code to detect being inside IPython. Before this
2889 allows embedding code to detect being inside IPython. Before this
2882 was done via __IPYTHON__, but that only shows that an IPython
2890 was done via __IPYTHON__, but that only shows that an IPython
2883 instance has been created.
2891 instance has been created.
2884
2892
2885 * IPython/Magic.py (Magic.magic_env): I realized that in a
2893 * IPython/Magic.py (Magic.magic_env): I realized that in a
2886 UserDict, instance.data holds the data as a normal dict. So I
2894 UserDict, instance.data holds the data as a normal dict. So I
2887 modified @env to return os.environ.data instead of rebuilding a
2895 modified @env to return os.environ.data instead of rebuilding a
2888 dict by hand.
2896 dict by hand.
2889
2897
2890 2002-11-02 Fernando Perez <fperez@colorado.edu>
2898 2002-11-02 Fernando Perez <fperez@colorado.edu>
2891
2899
2892 * IPython/genutils.py (warn): changed so that level 1 prints no
2900 * IPython/genutils.py (warn): changed so that level 1 prints no
2893 header. Level 2 is now the default (with 'WARNING' header, as
2901 header. Level 2 is now the default (with 'WARNING' header, as
2894 before). I think I tracked all places where changes were needed in
2902 before). I think I tracked all places where changes were needed in
2895 IPython, but outside code using the old level numbering may have
2903 IPython, but outside code using the old level numbering may have
2896 broken.
2904 broken.
2897
2905
2898 * IPython/iplib.py (InteractiveShell.runcode): added this to
2906 * IPython/iplib.py (InteractiveShell.runcode): added this to
2899 handle the tracebacks in SystemExit traps correctly. The previous
2907 handle the tracebacks in SystemExit traps correctly. The previous
2900 code (through interact) was printing more of the stack than
2908 code (through interact) was printing more of the stack than
2901 necessary, showing IPython internal code to the user.
2909 necessary, showing IPython internal code to the user.
2902
2910
2903 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2911 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2904 default. Now that the default at the confirmation prompt is yes,
2912 default. Now that the default at the confirmation prompt is yes,
2905 it's not so intrusive. François' argument that ipython sessions
2913 it's not so intrusive. François' argument that ipython sessions
2906 tend to be complex enough not to lose them from an accidental C-d,
2914 tend to be complex enough not to lose them from an accidental C-d,
2907 is a valid one.
2915 is a valid one.
2908
2916
2909 * IPython/iplib.py (InteractiveShell.interact): added a
2917 * IPython/iplib.py (InteractiveShell.interact): added a
2910 showtraceback() call to the SystemExit trap, and modified the exit
2918 showtraceback() call to the SystemExit trap, and modified the exit
2911 confirmation to have yes as the default.
2919 confirmation to have yes as the default.
2912
2920
2913 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2921 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2914 this file. It's been gone from the code for a long time, this was
2922 this file. It's been gone from the code for a long time, this was
2915 simply leftover junk.
2923 simply leftover junk.
2916
2924
2917 2002-11-01 Fernando Perez <fperez@colorado.edu>
2925 2002-11-01 Fernando Perez <fperez@colorado.edu>
2918
2926
2919 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2927 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2920 added. If set, IPython now traps EOF and asks for
2928 added. If set, IPython now traps EOF and asks for
2921 confirmation. After a request by François Pinard.
2929 confirmation. After a request by François Pinard.
2922
2930
2923 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2931 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2924 of @abort, and with a new (better) mechanism for handling the
2932 of @abort, and with a new (better) mechanism for handling the
2925 exceptions.
2933 exceptions.
2926
2934
2927 2002-10-27 Fernando Perez <fperez@colorado.edu>
2935 2002-10-27 Fernando Perez <fperez@colorado.edu>
2928
2936
2929 * IPython/usage.py (__doc__): updated the --help information and
2937 * IPython/usage.py (__doc__): updated the --help information and
2930 the ipythonrc file to indicate that -log generates
2938 the ipythonrc file to indicate that -log generates
2931 ./ipython.log. Also fixed the corresponding info in @logstart.
2939 ./ipython.log. Also fixed the corresponding info in @logstart.
2932 This and several other fixes in the manuals thanks to reports by
2940 This and several other fixes in the manuals thanks to reports by
2933 François Pinard <pinard-AT-iro.umontreal.ca>.
2941 François Pinard <pinard-AT-iro.umontreal.ca>.
2934
2942
2935 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2943 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2936 refer to @logstart (instead of @log, which doesn't exist).
2944 refer to @logstart (instead of @log, which doesn't exist).
2937
2945
2938 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2946 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2939 AttributeError crash. Thanks to Christopher Armstrong
2947 AttributeError crash. Thanks to Christopher Armstrong
2940 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2948 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2941 introduced recently (in 0.2.14pre37) with the fix to the eval
2949 introduced recently (in 0.2.14pre37) with the fix to the eval
2942 problem mentioned below.
2950 problem mentioned below.
2943
2951
2944 2002-10-17 Fernando Perez <fperez@colorado.edu>
2952 2002-10-17 Fernando Perez <fperez@colorado.edu>
2945
2953
2946 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2954 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2947 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2955 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2948
2956
2949 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2957 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2950 this function to fix a problem reported by Alex Schmolck. He saw
2958 this function to fix a problem reported by Alex Schmolck. He saw
2951 it with list comprehensions and generators, which were getting
2959 it with list comprehensions and generators, which were getting
2952 called twice. The real problem was an 'eval' call in testing for
2960 called twice. The real problem was an 'eval' call in testing for
2953 automagic which was evaluating the input line silently.
2961 automagic which was evaluating the input line silently.
2954
2962
2955 This is a potentially very nasty bug, if the input has side
2963 This is a potentially very nasty bug, if the input has side
2956 effects which must not be repeated. The code is much cleaner now,
2964 effects which must not be repeated. The code is much cleaner now,
2957 without any blanket 'except' left and with a regexp test for
2965 without any blanket 'except' left and with a regexp test for
2958 actual function names.
2966 actual function names.
2959
2967
2960 But an eval remains, which I'm not fully comfortable with. I just
2968 But an eval remains, which I'm not fully comfortable with. I just
2961 don't know how to find out if an expression could be a callable in
2969 don't know how to find out if an expression could be a callable in
2962 the user's namespace without doing an eval on the string. However
2970 the user's namespace without doing an eval on the string. However
2963 that string is now much more strictly checked so that no code
2971 that string is now much more strictly checked so that no code
2964 slips by, so the eval should only happen for things that can
2972 slips by, so the eval should only happen for things that can
2965 really be only function/method names.
2973 really be only function/method names.
2966
2974
2967 2002-10-15 Fernando Perez <fperez@colorado.edu>
2975 2002-10-15 Fernando Perez <fperez@colorado.edu>
2968
2976
2969 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2977 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2970 OSX information to main manual, removed README_Mac_OSX file from
2978 OSX information to main manual, removed README_Mac_OSX file from
2971 distribution. Also updated credits for recent additions.
2979 distribution. Also updated credits for recent additions.
2972
2980
2973 2002-10-10 Fernando Perez <fperez@colorado.edu>
2981 2002-10-10 Fernando Perez <fperez@colorado.edu>
2974
2982
2975 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2983 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2976 terminal-related issues. Many thanks to Andrea Riciputi
2984 terminal-related issues. Many thanks to Andrea Riciputi
2977 <andrea.riciputi-AT-libero.it> for writing it.
2985 <andrea.riciputi-AT-libero.it> for writing it.
2978
2986
2979 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2987 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2980 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2988 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2981
2989
2982 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2990 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2983 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2991 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2984 <syver-en-AT-online.no> who both submitted patches for this problem.
2992 <syver-en-AT-online.no> who both submitted patches for this problem.
2985
2993
2986 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2994 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2987 global embedding to make sure that things don't overwrite user
2995 global embedding to make sure that things don't overwrite user
2988 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2996 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2989
2997
2990 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2998 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2991 compatibility. Thanks to Hayden Callow
2999 compatibility. Thanks to Hayden Callow
2992 <h.callow-AT-elec.canterbury.ac.nz>
3000 <h.callow-AT-elec.canterbury.ac.nz>
2993
3001
2994 2002-10-04 Fernando Perez <fperez@colorado.edu>
3002 2002-10-04 Fernando Perez <fperez@colorado.edu>
2995
3003
2996 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3004 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2997 Gnuplot.File objects.
3005 Gnuplot.File objects.
2998
3006
2999 2002-07-23 Fernando Perez <fperez@colorado.edu>
3007 2002-07-23 Fernando Perez <fperez@colorado.edu>
3000
3008
3001 * IPython/genutils.py (timing): Added timings() and timing() for
3009 * IPython/genutils.py (timing): Added timings() and timing() for
3002 quick access to the most commonly needed data, the execution
3010 quick access to the most commonly needed data, the execution
3003 times. Old timing() renamed to timings_out().
3011 times. Old timing() renamed to timings_out().
3004
3012
3005 2002-07-18 Fernando Perez <fperez@colorado.edu>
3013 2002-07-18 Fernando Perez <fperez@colorado.edu>
3006
3014
3007 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3015 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3008 bug with nested instances disrupting the parent's tab completion.
3016 bug with nested instances disrupting the parent's tab completion.
3009
3017
3010 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3018 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3011 all_completions code to begin the emacs integration.
3019 all_completions code to begin the emacs integration.
3012
3020
3013 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3021 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3014 argument to allow titling individual arrays when plotting.
3022 argument to allow titling individual arrays when plotting.
3015
3023
3016 2002-07-15 Fernando Perez <fperez@colorado.edu>
3024 2002-07-15 Fernando Perez <fperez@colorado.edu>
3017
3025
3018 * setup.py (make_shortcut): changed to retrieve the value of
3026 * setup.py (make_shortcut): changed to retrieve the value of
3019 'Program Files' directory from the registry (this value changes in
3027 'Program Files' directory from the registry (this value changes in
3020 non-english versions of Windows). Thanks to Thomas Fanslau
3028 non-english versions of Windows). Thanks to Thomas Fanslau
3021 <tfanslau-AT-gmx.de> for the report.
3029 <tfanslau-AT-gmx.de> for the report.
3022
3030
3023 2002-07-10 Fernando Perez <fperez@colorado.edu>
3031 2002-07-10 Fernando Perez <fperez@colorado.edu>
3024
3032
3025 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3033 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3026 a bug in pdb, which crashes if a line with only whitespace is
3034 a bug in pdb, which crashes if a line with only whitespace is
3027 entered. Bug report submitted to sourceforge.
3035 entered. Bug report submitted to sourceforge.
3028
3036
3029 2002-07-09 Fernando Perez <fperez@colorado.edu>
3037 2002-07-09 Fernando Perez <fperez@colorado.edu>
3030
3038
3031 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3039 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3032 reporting exceptions (it's a bug in inspect.py, I just set a
3040 reporting exceptions (it's a bug in inspect.py, I just set a
3033 workaround).
3041 workaround).
3034
3042
3035 2002-07-08 Fernando Perez <fperez@colorado.edu>
3043 2002-07-08 Fernando Perez <fperez@colorado.edu>
3036
3044
3037 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3045 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3038 __IPYTHON__ in __builtins__ to show up in user_ns.
3046 __IPYTHON__ in __builtins__ to show up in user_ns.
3039
3047
3040 2002-07-03 Fernando Perez <fperez@colorado.edu>
3048 2002-07-03 Fernando Perez <fperez@colorado.edu>
3041
3049
3042 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3050 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3043 name from @gp_set_instance to @gp_set_default.
3051 name from @gp_set_instance to @gp_set_default.
3044
3052
3045 * IPython/ipmaker.py (make_IPython): default editor value set to
3053 * IPython/ipmaker.py (make_IPython): default editor value set to
3046 '0' (a string), to match the rc file. Otherwise will crash when
3054 '0' (a string), to match the rc file. Otherwise will crash when
3047 .strip() is called on it.
3055 .strip() is called on it.
3048
3056
3049
3057
3050 2002-06-28 Fernando Perez <fperez@colorado.edu>
3058 2002-06-28 Fernando Perez <fperez@colorado.edu>
3051
3059
3052 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3060 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3053 of files in current directory when a file is executed via
3061 of files in current directory when a file is executed via
3054 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3062 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3055
3063
3056 * setup.py (manfiles): fix for rpm builds, submitted by RA
3064 * setup.py (manfiles): fix for rpm builds, submitted by RA
3057 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3065 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3058
3066
3059 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3067 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3060 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3068 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3061 string!). A. Schmolck caught this one.
3069 string!). A. Schmolck caught this one.
3062
3070
3063 2002-06-27 Fernando Perez <fperez@colorado.edu>
3071 2002-06-27 Fernando Perez <fperez@colorado.edu>
3064
3072
3065 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3073 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3066 defined files at the cmd line. __name__ wasn't being set to
3074 defined files at the cmd line. __name__ wasn't being set to
3067 __main__.
3075 __main__.
3068
3076
3069 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3077 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3070 regular lists and tuples besides Numeric arrays.
3078 regular lists and tuples besides Numeric arrays.
3071
3079
3072 * IPython/Prompts.py (CachedOutput.__call__): Added output
3080 * IPython/Prompts.py (CachedOutput.__call__): Added output
3073 supression for input ending with ';'. Similar to Mathematica and
3081 supression for input ending with ';'. Similar to Mathematica and
3074 Matlab. The _* vars and Out[] list are still updated, just like
3082 Matlab. The _* vars and Out[] list are still updated, just like
3075 Mathematica behaves.
3083 Mathematica behaves.
3076
3084
3077 2002-06-25 Fernando Perez <fperez@colorado.edu>
3085 2002-06-25 Fernando Perez <fperez@colorado.edu>
3078
3086
3079 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3087 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3080 .ini extensions for profiels under Windows.
3088 .ini extensions for profiels under Windows.
3081
3089
3082 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3090 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3083 string form. Fix contributed by Alexander Schmolck
3091 string form. Fix contributed by Alexander Schmolck
3084 <a.schmolck-AT-gmx.net>
3092 <a.schmolck-AT-gmx.net>
3085
3093
3086 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3094 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3087 pre-configured Gnuplot instance.
3095 pre-configured Gnuplot instance.
3088
3096
3089 2002-06-21 Fernando Perez <fperez@colorado.edu>
3097 2002-06-21 Fernando Perez <fperez@colorado.edu>
3090
3098
3091 * IPython/numutils.py (exp_safe): new function, works around the
3099 * IPython/numutils.py (exp_safe): new function, works around the
3092 underflow problems in Numeric.
3100 underflow problems in Numeric.
3093 (log2): New fn. Safe log in base 2: returns exact integer answer
3101 (log2): New fn. Safe log in base 2: returns exact integer answer
3094 for exact integer powers of 2.
3102 for exact integer powers of 2.
3095
3103
3096 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3104 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3097 properly.
3105 properly.
3098
3106
3099 2002-06-20 Fernando Perez <fperez@colorado.edu>
3107 2002-06-20 Fernando Perez <fperez@colorado.edu>
3100
3108
3101 * IPython/genutils.py (timing): new function like
3109 * IPython/genutils.py (timing): new function like
3102 Mathematica's. Similar to time_test, but returns more info.
3110 Mathematica's. Similar to time_test, but returns more info.
3103
3111
3104 2002-06-18 Fernando Perez <fperez@colorado.edu>
3112 2002-06-18 Fernando Perez <fperez@colorado.edu>
3105
3113
3106 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3114 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3107 according to Mike Heeter's suggestions.
3115 according to Mike Heeter's suggestions.
3108
3116
3109 2002-06-16 Fernando Perez <fperez@colorado.edu>
3117 2002-06-16 Fernando Perez <fperez@colorado.edu>
3110
3118
3111 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3119 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3112 system. GnuplotMagic is gone as a user-directory option. New files
3120 system. GnuplotMagic is gone as a user-directory option. New files
3113 make it easier to use all the gnuplot stuff both from external
3121 make it easier to use all the gnuplot stuff both from external
3114 programs as well as from IPython. Had to rewrite part of
3122 programs as well as from IPython. Had to rewrite part of
3115 hardcopy() b/c of a strange bug: often the ps files simply don't
3123 hardcopy() b/c of a strange bug: often the ps files simply don't
3116 get created, and require a repeat of the command (often several
3124 get created, and require a repeat of the command (often several
3117 times).
3125 times).
3118
3126
3119 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3127 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3120 resolve output channel at call time, so that if sys.stderr has
3128 resolve output channel at call time, so that if sys.stderr has
3121 been redirected by user this gets honored.
3129 been redirected by user this gets honored.
3122
3130
3123 2002-06-13 Fernando Perez <fperez@colorado.edu>
3131 2002-06-13 Fernando Perez <fperez@colorado.edu>
3124
3132
3125 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3133 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3126 IPShell. Kept a copy with the old names to avoid breaking people's
3134 IPShell. Kept a copy with the old names to avoid breaking people's
3127 embedded code.
3135 embedded code.
3128
3136
3129 * IPython/ipython: simplified it to the bare minimum after
3137 * IPython/ipython: simplified it to the bare minimum after
3130 Holger's suggestions. Added info about how to use it in
3138 Holger's suggestions. Added info about how to use it in
3131 PYTHONSTARTUP.
3139 PYTHONSTARTUP.
3132
3140
3133 * IPython/Shell.py (IPythonShell): changed the options passing
3141 * IPython/Shell.py (IPythonShell): changed the options passing
3134 from a string with funky %s replacements to a straight list. Maybe
3142 from a string with funky %s replacements to a straight list. Maybe
3135 a bit more typing, but it follows sys.argv conventions, so there's
3143 a bit more typing, but it follows sys.argv conventions, so there's
3136 less special-casing to remember.
3144 less special-casing to remember.
3137
3145
3138 2002-06-12 Fernando Perez <fperez@colorado.edu>
3146 2002-06-12 Fernando Perez <fperez@colorado.edu>
3139
3147
3140 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3148 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3141 command. Thanks to a suggestion by Mike Heeter.
3149 command. Thanks to a suggestion by Mike Heeter.
3142 (Magic.magic_pfile): added behavior to look at filenames if given
3150 (Magic.magic_pfile): added behavior to look at filenames if given
3143 arg is not a defined object.
3151 arg is not a defined object.
3144 (Magic.magic_save): New @save function to save code snippets. Also
3152 (Magic.magic_save): New @save function to save code snippets. Also
3145 a Mike Heeter idea.
3153 a Mike Heeter idea.
3146
3154
3147 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3155 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3148 plot() and replot(). Much more convenient now, especially for
3156 plot() and replot(). Much more convenient now, especially for
3149 interactive use.
3157 interactive use.
3150
3158
3151 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3159 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3152 filenames.
3160 filenames.
3153
3161
3154 2002-06-02 Fernando Perez <fperez@colorado.edu>
3162 2002-06-02 Fernando Perez <fperez@colorado.edu>
3155
3163
3156 * IPython/Struct.py (Struct.__init__): modified to admit
3164 * IPython/Struct.py (Struct.__init__): modified to admit
3157 initialization via another struct.
3165 initialization via another struct.
3158
3166
3159 * IPython/genutils.py (SystemExec.__init__): New stateful
3167 * IPython/genutils.py (SystemExec.__init__): New stateful
3160 interface to xsys and bq. Useful for writing system scripts.
3168 interface to xsys and bq. Useful for writing system scripts.
3161
3169
3162 2002-05-30 Fernando Perez <fperez@colorado.edu>
3170 2002-05-30 Fernando Perez <fperez@colorado.edu>
3163
3171
3164 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3172 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3165 documents. This will make the user download smaller (it's getting
3173 documents. This will make the user download smaller (it's getting
3166 too big).
3174 too big).
3167
3175
3168 2002-05-29 Fernando Perez <fperez@colorado.edu>
3176 2002-05-29 Fernando Perez <fperez@colorado.edu>
3169
3177
3170 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3178 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3171 fix problems with shelve and pickle. Seems to work, but I don't
3179 fix problems with shelve and pickle. Seems to work, but I don't
3172 know if corner cases break it. Thanks to Mike Heeter
3180 know if corner cases break it. Thanks to Mike Heeter
3173 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3181 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3174
3182
3175 2002-05-24 Fernando Perez <fperez@colorado.edu>
3183 2002-05-24 Fernando Perez <fperez@colorado.edu>
3176
3184
3177 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3185 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3178 macros having broken.
3186 macros having broken.
3179
3187
3180 2002-05-21 Fernando Perez <fperez@colorado.edu>
3188 2002-05-21 Fernando Perez <fperez@colorado.edu>
3181
3189
3182 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3190 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3183 introduced logging bug: all history before logging started was
3191 introduced logging bug: all history before logging started was
3184 being written one character per line! This came from the redesign
3192 being written one character per line! This came from the redesign
3185 of the input history as a special list which slices to strings,
3193 of the input history as a special list which slices to strings,
3186 not to lists.
3194 not to lists.
3187
3195
3188 2002-05-20 Fernando Perez <fperez@colorado.edu>
3196 2002-05-20 Fernando Perez <fperez@colorado.edu>
3189
3197
3190 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3198 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3191 be an attribute of all classes in this module. The design of these
3199 be an attribute of all classes in this module. The design of these
3192 classes needs some serious overhauling.
3200 classes needs some serious overhauling.
3193
3201
3194 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3202 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3195 which was ignoring '_' in option names.
3203 which was ignoring '_' in option names.
3196
3204
3197 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3205 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3198 'Verbose_novars' to 'Context' and made it the new default. It's a
3206 'Verbose_novars' to 'Context' and made it the new default. It's a
3199 bit more readable and also safer than verbose.
3207 bit more readable and also safer than verbose.
3200
3208
3201 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3209 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3202 triple-quoted strings.
3210 triple-quoted strings.
3203
3211
3204 * IPython/OInspect.py (__all__): new module exposing the object
3212 * IPython/OInspect.py (__all__): new module exposing the object
3205 introspection facilities. Now the corresponding magics are dummy
3213 introspection facilities. Now the corresponding magics are dummy
3206 wrappers around this. Having this module will make it much easier
3214 wrappers around this. Having this module will make it much easier
3207 to put these functions into our modified pdb.
3215 to put these functions into our modified pdb.
3208 This new object inspector system uses the new colorizing module,
3216 This new object inspector system uses the new colorizing module,
3209 so source code and other things are nicely syntax highlighted.
3217 so source code and other things are nicely syntax highlighted.
3210
3218
3211 2002-05-18 Fernando Perez <fperez@colorado.edu>
3219 2002-05-18 Fernando Perez <fperez@colorado.edu>
3212
3220
3213 * IPython/ColorANSI.py: Split the coloring tools into a separate
3221 * IPython/ColorANSI.py: Split the coloring tools into a separate
3214 module so I can use them in other code easier (they were part of
3222 module so I can use them in other code easier (they were part of
3215 ultraTB).
3223 ultraTB).
3216
3224
3217 2002-05-17 Fernando Perez <fperez@colorado.edu>
3225 2002-05-17 Fernando Perez <fperez@colorado.edu>
3218
3226
3219 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3227 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3220 fixed it to set the global 'g' also to the called instance, as
3228 fixed it to set the global 'g' also to the called instance, as
3221 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3229 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3222 user's 'g' variables).
3230 user's 'g' variables).
3223
3231
3224 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3232 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3225 global variables (aliases to _ih,_oh) so that users which expect
3233 global variables (aliases to _ih,_oh) so that users which expect
3226 In[5] or Out[7] to work aren't unpleasantly surprised.
3234 In[5] or Out[7] to work aren't unpleasantly surprised.
3227 (InputList.__getslice__): new class to allow executing slices of
3235 (InputList.__getslice__): new class to allow executing slices of
3228 input history directly. Very simple class, complements the use of
3236 input history directly. Very simple class, complements the use of
3229 macros.
3237 macros.
3230
3238
3231 2002-05-16 Fernando Perez <fperez@colorado.edu>
3239 2002-05-16 Fernando Perez <fperez@colorado.edu>
3232
3240
3233 * setup.py (docdirbase): make doc directory be just doc/IPython
3241 * setup.py (docdirbase): make doc directory be just doc/IPython
3234 without version numbers, it will reduce clutter for users.
3242 without version numbers, it will reduce clutter for users.
3235
3243
3236 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3244 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3237 execfile call to prevent possible memory leak. See for details:
3245 execfile call to prevent possible memory leak. See for details:
3238 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3246 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3239
3247
3240 2002-05-15 Fernando Perez <fperez@colorado.edu>
3248 2002-05-15 Fernando Perez <fperez@colorado.edu>
3241
3249
3242 * IPython/Magic.py (Magic.magic_psource): made the object
3250 * IPython/Magic.py (Magic.magic_psource): made the object
3243 introspection names be more standard: pdoc, pdef, pfile and
3251 introspection names be more standard: pdoc, pdef, pfile and
3244 psource. They all print/page their output, and it makes
3252 psource. They all print/page their output, and it makes
3245 remembering them easier. Kept old names for compatibility as
3253 remembering them easier. Kept old names for compatibility as
3246 aliases.
3254 aliases.
3247
3255
3248 2002-05-14 Fernando Perez <fperez@colorado.edu>
3256 2002-05-14 Fernando Perez <fperez@colorado.edu>
3249
3257
3250 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3258 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3251 what the mouse problem was. The trick is to use gnuplot with temp
3259 what the mouse problem was. The trick is to use gnuplot with temp
3252 files and NOT with pipes (for data communication), because having
3260 files and NOT with pipes (for data communication), because having
3253 both pipes and the mouse on is bad news.
3261 both pipes and the mouse on is bad news.
3254
3262
3255 2002-05-13 Fernando Perez <fperez@colorado.edu>
3263 2002-05-13 Fernando Perez <fperez@colorado.edu>
3256
3264
3257 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3265 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3258 bug. Information would be reported about builtins even when
3266 bug. Information would be reported about builtins even when
3259 user-defined functions overrode them.
3267 user-defined functions overrode them.
3260
3268
3261 2002-05-11 Fernando Perez <fperez@colorado.edu>
3269 2002-05-11 Fernando Perez <fperez@colorado.edu>
3262
3270
3263 * IPython/__init__.py (__all__): removed FlexCompleter from
3271 * IPython/__init__.py (__all__): removed FlexCompleter from
3264 __all__ so that things don't fail in platforms without readline.
3272 __all__ so that things don't fail in platforms without readline.
3265
3273
3266 2002-05-10 Fernando Perez <fperez@colorado.edu>
3274 2002-05-10 Fernando Perez <fperez@colorado.edu>
3267
3275
3268 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3276 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3269 it requires Numeric, effectively making Numeric a dependency for
3277 it requires Numeric, effectively making Numeric a dependency for
3270 IPython.
3278 IPython.
3271
3279
3272 * Released 0.2.13
3280 * Released 0.2.13
3273
3281
3274 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3282 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3275 profiler interface. Now all the major options from the profiler
3283 profiler interface. Now all the major options from the profiler
3276 module are directly supported in IPython, both for single
3284 module are directly supported in IPython, both for single
3277 expressions (@prun) and for full programs (@run -p).
3285 expressions (@prun) and for full programs (@run -p).
3278
3286
3279 2002-05-09 Fernando Perez <fperez@colorado.edu>
3287 2002-05-09 Fernando Perez <fperez@colorado.edu>
3280
3288
3281 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3289 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3282 magic properly formatted for screen.
3290 magic properly formatted for screen.
3283
3291
3284 * setup.py (make_shortcut): Changed things to put pdf version in
3292 * setup.py (make_shortcut): Changed things to put pdf version in
3285 doc/ instead of doc/manual (had to change lyxport a bit).
3293 doc/ instead of doc/manual (had to change lyxport a bit).
3286
3294
3287 * IPython/Magic.py (Profile.string_stats): made profile runs go
3295 * IPython/Magic.py (Profile.string_stats): made profile runs go
3288 through pager (they are long and a pager allows searching, saving,
3296 through pager (they are long and a pager allows searching, saving,
3289 etc.)
3297 etc.)
3290
3298
3291 2002-05-08 Fernando Perez <fperez@colorado.edu>
3299 2002-05-08 Fernando Perez <fperez@colorado.edu>
3292
3300
3293 * Released 0.2.12
3301 * Released 0.2.12
3294
3302
3295 2002-05-06 Fernando Perez <fperez@colorado.edu>
3303 2002-05-06 Fernando Perez <fperez@colorado.edu>
3296
3304
3297 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3305 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3298 introduced); 'hist n1 n2' was broken.
3306 introduced); 'hist n1 n2' was broken.
3299 (Magic.magic_pdb): added optional on/off arguments to @pdb
3307 (Magic.magic_pdb): added optional on/off arguments to @pdb
3300 (Magic.magic_run): added option -i to @run, which executes code in
3308 (Magic.magic_run): added option -i to @run, which executes code in
3301 the IPython namespace instead of a clean one. Also added @irun as
3309 the IPython namespace instead of a clean one. Also added @irun as
3302 an alias to @run -i.
3310 an alias to @run -i.
3303
3311
3304 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3312 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3305 fixed (it didn't really do anything, the namespaces were wrong).
3313 fixed (it didn't really do anything, the namespaces were wrong).
3306
3314
3307 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3315 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3308
3316
3309 * IPython/__init__.py (__all__): Fixed package namespace, now
3317 * IPython/__init__.py (__all__): Fixed package namespace, now
3310 'import IPython' does give access to IPython.<all> as
3318 'import IPython' does give access to IPython.<all> as
3311 expected. Also renamed __release__ to Release.
3319 expected. Also renamed __release__ to Release.
3312
3320
3313 * IPython/Debugger.py (__license__): created new Pdb class which
3321 * IPython/Debugger.py (__license__): created new Pdb class which
3314 functions like a drop-in for the normal pdb.Pdb but does NOT
3322 functions like a drop-in for the normal pdb.Pdb but does NOT
3315 import readline by default. This way it doesn't muck up IPython's
3323 import readline by default. This way it doesn't muck up IPython's
3316 readline handling, and now tab-completion finally works in the
3324 readline handling, and now tab-completion finally works in the
3317 debugger -- sort of. It completes things globally visible, but the
3325 debugger -- sort of. It completes things globally visible, but the
3318 completer doesn't track the stack as pdb walks it. That's a bit
3326 completer doesn't track the stack as pdb walks it. That's a bit
3319 tricky, and I'll have to implement it later.
3327 tricky, and I'll have to implement it later.
3320
3328
3321 2002-05-05 Fernando Perez <fperez@colorado.edu>
3329 2002-05-05 Fernando Perez <fperez@colorado.edu>
3322
3330
3323 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3331 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3324 magic docstrings when printed via ? (explicit \'s were being
3332 magic docstrings when printed via ? (explicit \'s were being
3325 printed).
3333 printed).
3326
3334
3327 * IPython/ipmaker.py (make_IPython): fixed namespace
3335 * IPython/ipmaker.py (make_IPython): fixed namespace
3328 identification bug. Now variables loaded via logs or command-line
3336 identification bug. Now variables loaded via logs or command-line
3329 files are recognized in the interactive namespace by @who.
3337 files are recognized in the interactive namespace by @who.
3330
3338
3331 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3339 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3332 log replay system stemming from the string form of Structs.
3340 log replay system stemming from the string form of Structs.
3333
3341
3334 * IPython/Magic.py (Macro.__init__): improved macros to properly
3342 * IPython/Magic.py (Macro.__init__): improved macros to properly
3335 handle magic commands in them.
3343 handle magic commands in them.
3336 (Magic.magic_logstart): usernames are now expanded so 'logstart
3344 (Magic.magic_logstart): usernames are now expanded so 'logstart
3337 ~/mylog' now works.
3345 ~/mylog' now works.
3338
3346
3339 * IPython/iplib.py (complete): fixed bug where paths starting with
3347 * IPython/iplib.py (complete): fixed bug where paths starting with
3340 '/' would be completed as magic names.
3348 '/' would be completed as magic names.
3341
3349
3342 2002-05-04 Fernando Perez <fperez@colorado.edu>
3350 2002-05-04 Fernando Perez <fperez@colorado.edu>
3343
3351
3344 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3352 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3345 allow running full programs under the profiler's control.
3353 allow running full programs under the profiler's control.
3346
3354
3347 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3355 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3348 mode to report exceptions verbosely but without formatting
3356 mode to report exceptions verbosely but without formatting
3349 variables. This addresses the issue of ipython 'freezing' (it's
3357 variables. This addresses the issue of ipython 'freezing' (it's
3350 not frozen, but caught in an expensive formatting loop) when huge
3358 not frozen, but caught in an expensive formatting loop) when huge
3351 variables are in the context of an exception.
3359 variables are in the context of an exception.
3352 (VerboseTB.text): Added '--->' markers at line where exception was
3360 (VerboseTB.text): Added '--->' markers at line where exception was
3353 triggered. Much clearer to read, especially in NoColor modes.
3361 triggered. Much clearer to read, especially in NoColor modes.
3354
3362
3355 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3363 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3356 implemented in reverse when changing to the new parse_options().
3364 implemented in reverse when changing to the new parse_options().
3357
3365
3358 2002-05-03 Fernando Perez <fperez@colorado.edu>
3366 2002-05-03 Fernando Perez <fperez@colorado.edu>
3359
3367
3360 * IPython/Magic.py (Magic.parse_options): new function so that
3368 * IPython/Magic.py (Magic.parse_options): new function so that
3361 magics can parse options easier.
3369 magics can parse options easier.
3362 (Magic.magic_prun): new function similar to profile.run(),
3370 (Magic.magic_prun): new function similar to profile.run(),
3363 suggested by Chris Hart.
3371 suggested by Chris Hart.
3364 (Magic.magic_cd): fixed behavior so that it only changes if
3372 (Magic.magic_cd): fixed behavior so that it only changes if
3365 directory actually is in history.
3373 directory actually is in history.
3366
3374
3367 * IPython/usage.py (__doc__): added information about potential
3375 * IPython/usage.py (__doc__): added information about potential
3368 slowness of Verbose exception mode when there are huge data
3376 slowness of Verbose exception mode when there are huge data
3369 structures to be formatted (thanks to Archie Paulson).
3377 structures to be formatted (thanks to Archie Paulson).
3370
3378
3371 * IPython/ipmaker.py (make_IPython): Changed default logging
3379 * IPython/ipmaker.py (make_IPython): Changed default logging
3372 (when simply called with -log) to use curr_dir/ipython.log in
3380 (when simply called with -log) to use curr_dir/ipython.log in
3373 rotate mode. Fixed crash which was occuring with -log before
3381 rotate mode. Fixed crash which was occuring with -log before
3374 (thanks to Jim Boyle).
3382 (thanks to Jim Boyle).
3375
3383
3376 2002-05-01 Fernando Perez <fperez@colorado.edu>
3384 2002-05-01 Fernando Perez <fperez@colorado.edu>
3377
3385
3378 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3386 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3379 was nasty -- though somewhat of a corner case).
3387 was nasty -- though somewhat of a corner case).
3380
3388
3381 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3389 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3382 text (was a bug).
3390 text (was a bug).
3383
3391
3384 2002-04-30 Fernando Perez <fperez@colorado.edu>
3392 2002-04-30 Fernando Perez <fperez@colorado.edu>
3385
3393
3386 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3394 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3387 a print after ^D or ^C from the user so that the In[] prompt
3395 a print after ^D or ^C from the user so that the In[] prompt
3388 doesn't over-run the gnuplot one.
3396 doesn't over-run the gnuplot one.
3389
3397
3390 2002-04-29 Fernando Perez <fperez@colorado.edu>
3398 2002-04-29 Fernando Perez <fperez@colorado.edu>
3391
3399
3392 * Released 0.2.10
3400 * Released 0.2.10
3393
3401
3394 * IPython/__release__.py (version): get date dynamically.
3402 * IPython/__release__.py (version): get date dynamically.
3395
3403
3396 * Misc. documentation updates thanks to Arnd's comments. Also ran
3404 * Misc. documentation updates thanks to Arnd's comments. Also ran
3397 a full spellcheck on the manual (hadn't been done in a while).
3405 a full spellcheck on the manual (hadn't been done in a while).
3398
3406
3399 2002-04-27 Fernando Perez <fperez@colorado.edu>
3407 2002-04-27 Fernando Perez <fperez@colorado.edu>
3400
3408
3401 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3409 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3402 starting a log in mid-session would reset the input history list.
3410 starting a log in mid-session would reset the input history list.
3403
3411
3404 2002-04-26 Fernando Perez <fperez@colorado.edu>
3412 2002-04-26 Fernando Perez <fperez@colorado.edu>
3405
3413
3406 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3414 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3407 all files were being included in an update. Now anything in
3415 all files were being included in an update. Now anything in
3408 UserConfig that matches [A-Za-z]*.py will go (this excludes
3416 UserConfig that matches [A-Za-z]*.py will go (this excludes
3409 __init__.py)
3417 __init__.py)
3410
3418
3411 2002-04-25 Fernando Perez <fperez@colorado.edu>
3419 2002-04-25 Fernando Perez <fperez@colorado.edu>
3412
3420
3413 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3421 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3414 to __builtins__ so that any form of embedded or imported code can
3422 to __builtins__ so that any form of embedded or imported code can
3415 test for being inside IPython.
3423 test for being inside IPython.
3416
3424
3417 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3425 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3418 changed to GnuplotMagic because it's now an importable module,
3426 changed to GnuplotMagic because it's now an importable module,
3419 this makes the name follow that of the standard Gnuplot module.
3427 this makes the name follow that of the standard Gnuplot module.
3420 GnuplotMagic can now be loaded at any time in mid-session.
3428 GnuplotMagic can now be loaded at any time in mid-session.
3421
3429
3422 2002-04-24 Fernando Perez <fperez@colorado.edu>
3430 2002-04-24 Fernando Perez <fperez@colorado.edu>
3423
3431
3424 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3432 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3425 the globals (IPython has its own namespace) and the
3433 the globals (IPython has its own namespace) and the
3426 PhysicalQuantity stuff is much better anyway.
3434 PhysicalQuantity stuff is much better anyway.
3427
3435
3428 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3436 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3429 embedding example to standard user directory for
3437 embedding example to standard user directory for
3430 distribution. Also put it in the manual.
3438 distribution. Also put it in the manual.
3431
3439
3432 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3440 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3433 instance as first argument (so it doesn't rely on some obscure
3441 instance as first argument (so it doesn't rely on some obscure
3434 hidden global).
3442 hidden global).
3435
3443
3436 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3444 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3437 delimiters. While it prevents ().TAB from working, it allows
3445 delimiters. While it prevents ().TAB from working, it allows
3438 completions in open (... expressions. This is by far a more common
3446 completions in open (... expressions. This is by far a more common
3439 case.
3447 case.
3440
3448
3441 2002-04-23 Fernando Perez <fperez@colorado.edu>
3449 2002-04-23 Fernando Perez <fperez@colorado.edu>
3442
3450
3443 * IPython/Extensions/InterpreterPasteInput.py: new
3451 * IPython/Extensions/InterpreterPasteInput.py: new
3444 syntax-processing module for pasting lines with >>> or ... at the
3452 syntax-processing module for pasting lines with >>> or ... at the
3445 start.
3453 start.
3446
3454
3447 * IPython/Extensions/PhysicalQ_Interactive.py
3455 * IPython/Extensions/PhysicalQ_Interactive.py
3448 (PhysicalQuantityInteractive.__int__): fixed to work with either
3456 (PhysicalQuantityInteractive.__int__): fixed to work with either
3449 Numeric or math.
3457 Numeric or math.
3450
3458
3451 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3459 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3452 provided profiles. Now we have:
3460 provided profiles. Now we have:
3453 -math -> math module as * and cmath with its own namespace.
3461 -math -> math module as * and cmath with its own namespace.
3454 -numeric -> Numeric as *, plus gnuplot & grace
3462 -numeric -> Numeric as *, plus gnuplot & grace
3455 -physics -> same as before
3463 -physics -> same as before
3456
3464
3457 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3465 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3458 user-defined magics wouldn't be found by @magic if they were
3466 user-defined magics wouldn't be found by @magic if they were
3459 defined as class methods. Also cleaned up the namespace search
3467 defined as class methods. Also cleaned up the namespace search
3460 logic and the string building (to use %s instead of many repeated
3468 logic and the string building (to use %s instead of many repeated
3461 string adds).
3469 string adds).
3462
3470
3463 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3471 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3464 of user-defined magics to operate with class methods (cleaner, in
3472 of user-defined magics to operate with class methods (cleaner, in
3465 line with the gnuplot code).
3473 line with the gnuplot code).
3466
3474
3467 2002-04-22 Fernando Perez <fperez@colorado.edu>
3475 2002-04-22 Fernando Perez <fperez@colorado.edu>
3468
3476
3469 * setup.py: updated dependency list so that manual is updated when
3477 * setup.py: updated dependency list so that manual is updated when
3470 all included files change.
3478 all included files change.
3471
3479
3472 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3480 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3473 the delimiter removal option (the fix is ugly right now).
3481 the delimiter removal option (the fix is ugly right now).
3474
3482
3475 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3483 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3476 all of the math profile (quicker loading, no conflict between
3484 all of the math profile (quicker loading, no conflict between
3477 g-9.8 and g-gnuplot).
3485 g-9.8 and g-gnuplot).
3478
3486
3479 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3487 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3480 name of post-mortem files to IPython_crash_report.txt.
3488 name of post-mortem files to IPython_crash_report.txt.
3481
3489
3482 * Cleanup/update of the docs. Added all the new readline info and
3490 * Cleanup/update of the docs. Added all the new readline info and
3483 formatted all lists as 'real lists'.
3491 formatted all lists as 'real lists'.
3484
3492
3485 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3493 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3486 tab-completion options, since the full readline parse_and_bind is
3494 tab-completion options, since the full readline parse_and_bind is
3487 now accessible.
3495 now accessible.
3488
3496
3489 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3497 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3490 handling of readline options. Now users can specify any string to
3498 handling of readline options. Now users can specify any string to
3491 be passed to parse_and_bind(), as well as the delimiters to be
3499 be passed to parse_and_bind(), as well as the delimiters to be
3492 removed.
3500 removed.
3493 (InteractiveShell.__init__): Added __name__ to the global
3501 (InteractiveShell.__init__): Added __name__ to the global
3494 namespace so that things like Itpl which rely on its existence
3502 namespace so that things like Itpl which rely on its existence
3495 don't crash.
3503 don't crash.
3496 (InteractiveShell._prefilter): Defined the default with a _ so
3504 (InteractiveShell._prefilter): Defined the default with a _ so
3497 that prefilter() is easier to override, while the default one
3505 that prefilter() is easier to override, while the default one
3498 remains available.
3506 remains available.
3499
3507
3500 2002-04-18 Fernando Perez <fperez@colorado.edu>
3508 2002-04-18 Fernando Perez <fperez@colorado.edu>
3501
3509
3502 * Added information about pdb in the docs.
3510 * Added information about pdb in the docs.
3503
3511
3504 2002-04-17 Fernando Perez <fperez@colorado.edu>
3512 2002-04-17 Fernando Perez <fperez@colorado.edu>
3505
3513
3506 * IPython/ipmaker.py (make_IPython): added rc_override option to
3514 * IPython/ipmaker.py (make_IPython): added rc_override option to
3507 allow passing config options at creation time which may override
3515 allow passing config options at creation time which may override
3508 anything set in the config files or command line. This is
3516 anything set in the config files or command line. This is
3509 particularly useful for configuring embedded instances.
3517 particularly useful for configuring embedded instances.
3510
3518
3511 2002-04-15 Fernando Perez <fperez@colorado.edu>
3519 2002-04-15 Fernando Perez <fperez@colorado.edu>
3512
3520
3513 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3521 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3514 crash embedded instances because of the input cache falling out of
3522 crash embedded instances because of the input cache falling out of
3515 sync with the output counter.
3523 sync with the output counter.
3516
3524
3517 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3525 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3518 mode which calls pdb after an uncaught exception in IPython itself.
3526 mode which calls pdb after an uncaught exception in IPython itself.
3519
3527
3520 2002-04-14 Fernando Perez <fperez@colorado.edu>
3528 2002-04-14 Fernando Perez <fperez@colorado.edu>
3521
3529
3522 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3530 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3523 readline, fix it back after each call.
3531 readline, fix it back after each call.
3524
3532
3525 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3533 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3526 method to force all access via __call__(), which guarantees that
3534 method to force all access via __call__(), which guarantees that
3527 traceback references are properly deleted.
3535 traceback references are properly deleted.
3528
3536
3529 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3537 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3530 improve printing when pprint is in use.
3538 improve printing when pprint is in use.
3531
3539
3532 2002-04-13 Fernando Perez <fperez@colorado.edu>
3540 2002-04-13 Fernando Perez <fperez@colorado.edu>
3533
3541
3534 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3542 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3535 exceptions aren't caught anymore. If the user triggers one, he
3543 exceptions aren't caught anymore. If the user triggers one, he
3536 should know why he's doing it and it should go all the way up,
3544 should know why he's doing it and it should go all the way up,
3537 just like any other exception. So now @abort will fully kill the
3545 just like any other exception. So now @abort will fully kill the
3538 embedded interpreter and the embedding code (unless that happens
3546 embedded interpreter and the embedding code (unless that happens
3539 to catch SystemExit).
3547 to catch SystemExit).
3540
3548
3541 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3549 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3542 and a debugger() method to invoke the interactive pdb debugger
3550 and a debugger() method to invoke the interactive pdb debugger
3543 after printing exception information. Also added the corresponding
3551 after printing exception information. Also added the corresponding
3544 -pdb option and @pdb magic to control this feature, and updated
3552 -pdb option and @pdb magic to control this feature, and updated
3545 the docs. After a suggestion from Christopher Hart
3553 the docs. After a suggestion from Christopher Hart
3546 (hart-AT-caltech.edu).
3554 (hart-AT-caltech.edu).
3547
3555
3548 2002-04-12 Fernando Perez <fperez@colorado.edu>
3556 2002-04-12 Fernando Perez <fperez@colorado.edu>
3549
3557
3550 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3558 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3551 the exception handlers defined by the user (not the CrashHandler)
3559 the exception handlers defined by the user (not the CrashHandler)
3552 so that user exceptions don't trigger an ipython bug report.
3560 so that user exceptions don't trigger an ipython bug report.
3553
3561
3554 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3562 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3555 configurable (it should have always been so).
3563 configurable (it should have always been so).
3556
3564
3557 2002-03-26 Fernando Perez <fperez@colorado.edu>
3565 2002-03-26 Fernando Perez <fperez@colorado.edu>
3558
3566
3559 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3567 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3560 and there to fix embedding namespace issues. This should all be
3568 and there to fix embedding namespace issues. This should all be
3561 done in a more elegant way.
3569 done in a more elegant way.
3562
3570
3563 2002-03-25 Fernando Perez <fperez@colorado.edu>
3571 2002-03-25 Fernando Perez <fperez@colorado.edu>
3564
3572
3565 * IPython/genutils.py (get_home_dir): Try to make it work under
3573 * IPython/genutils.py (get_home_dir): Try to make it work under
3566 win9x also.
3574 win9x also.
3567
3575
3568 2002-03-20 Fernando Perez <fperez@colorado.edu>
3576 2002-03-20 Fernando Perez <fperez@colorado.edu>
3569
3577
3570 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3578 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3571 sys.displayhook untouched upon __init__.
3579 sys.displayhook untouched upon __init__.
3572
3580
3573 2002-03-19 Fernando Perez <fperez@colorado.edu>
3581 2002-03-19 Fernando Perez <fperez@colorado.edu>
3574
3582
3575 * Released 0.2.9 (for embedding bug, basically).
3583 * Released 0.2.9 (for embedding bug, basically).
3576
3584
3577 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3585 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3578 exceptions so that enclosing shell's state can be restored.
3586 exceptions so that enclosing shell's state can be restored.
3579
3587
3580 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3588 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3581 naming conventions in the .ipython/ dir.
3589 naming conventions in the .ipython/ dir.
3582
3590
3583 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3591 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3584 from delimiters list so filenames with - in them get expanded.
3592 from delimiters list so filenames with - in them get expanded.
3585
3593
3586 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3594 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3587 sys.displayhook not being properly restored after an embedded call.
3595 sys.displayhook not being properly restored after an embedded call.
3588
3596
3589 2002-03-18 Fernando Perez <fperez@colorado.edu>
3597 2002-03-18 Fernando Perez <fperez@colorado.edu>
3590
3598
3591 * Released 0.2.8
3599 * Released 0.2.8
3592
3600
3593 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3601 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3594 some files weren't being included in a -upgrade.
3602 some files weren't being included in a -upgrade.
3595 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3603 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3596 on' so that the first tab completes.
3604 on' so that the first tab completes.
3597 (InteractiveShell.handle_magic): fixed bug with spaces around
3605 (InteractiveShell.handle_magic): fixed bug with spaces around
3598 quotes breaking many magic commands.
3606 quotes breaking many magic commands.
3599
3607
3600 * setup.py: added note about ignoring the syntax error messages at
3608 * setup.py: added note about ignoring the syntax error messages at
3601 installation.
3609 installation.
3602
3610
3603 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3611 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3604 streamlining the gnuplot interface, now there's only one magic @gp.
3612 streamlining the gnuplot interface, now there's only one magic @gp.
3605
3613
3606 2002-03-17 Fernando Perez <fperez@colorado.edu>
3614 2002-03-17 Fernando Perez <fperez@colorado.edu>
3607
3615
3608 * IPython/UserConfig/magic_gnuplot.py: new name for the
3616 * IPython/UserConfig/magic_gnuplot.py: new name for the
3609 example-magic_pm.py file. Much enhanced system, now with a shell
3617 example-magic_pm.py file. Much enhanced system, now with a shell
3610 for communicating directly with gnuplot, one command at a time.
3618 for communicating directly with gnuplot, one command at a time.
3611
3619
3612 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3620 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3613 setting __name__=='__main__'.
3621 setting __name__=='__main__'.
3614
3622
3615 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3623 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3616 mini-shell for accessing gnuplot from inside ipython. Should
3624 mini-shell for accessing gnuplot from inside ipython. Should
3617 extend it later for grace access too. Inspired by Arnd's
3625 extend it later for grace access too. Inspired by Arnd's
3618 suggestion.
3626 suggestion.
3619
3627
3620 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3628 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3621 calling magic functions with () in their arguments. Thanks to Arnd
3629 calling magic functions with () in their arguments. Thanks to Arnd
3622 Baecker for pointing this to me.
3630 Baecker for pointing this to me.
3623
3631
3624 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3632 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3625 infinitely for integer or complex arrays (only worked with floats).
3633 infinitely for integer or complex arrays (only worked with floats).
3626
3634
3627 2002-03-16 Fernando Perez <fperez@colorado.edu>
3635 2002-03-16 Fernando Perez <fperez@colorado.edu>
3628
3636
3629 * setup.py: Merged setup and setup_windows into a single script
3637 * setup.py: Merged setup and setup_windows into a single script
3630 which properly handles things for windows users.
3638 which properly handles things for windows users.
3631
3639
3632 2002-03-15 Fernando Perez <fperez@colorado.edu>
3640 2002-03-15 Fernando Perez <fperez@colorado.edu>
3633
3641
3634 * Big change to the manual: now the magics are all automatically
3642 * Big change to the manual: now the magics are all automatically
3635 documented. This information is generated from their docstrings
3643 documented. This information is generated from their docstrings
3636 and put in a latex file included by the manual lyx file. This way
3644 and put in a latex file included by the manual lyx file. This way
3637 we get always up to date information for the magics. The manual
3645 we get always up to date information for the magics. The manual
3638 now also has proper version information, also auto-synced.
3646 now also has proper version information, also auto-synced.
3639
3647
3640 For this to work, an undocumented --magic_docstrings option was added.
3648 For this to work, an undocumented --magic_docstrings option was added.
3641
3649
3642 2002-03-13 Fernando Perez <fperez@colorado.edu>
3650 2002-03-13 Fernando Perez <fperez@colorado.edu>
3643
3651
3644 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3652 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3645 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3653 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3646
3654
3647 2002-03-12 Fernando Perez <fperez@colorado.edu>
3655 2002-03-12 Fernando Perez <fperez@colorado.edu>
3648
3656
3649 * IPython/ultraTB.py (TermColors): changed color escapes again to
3657 * IPython/ultraTB.py (TermColors): changed color escapes again to
3650 fix the (old, reintroduced) line-wrapping bug. Basically, if
3658 fix the (old, reintroduced) line-wrapping bug. Basically, if
3651 \001..\002 aren't given in the color escapes, lines get wrapped
3659 \001..\002 aren't given in the color escapes, lines get wrapped
3652 weirdly. But giving those screws up old xterms and emacs terms. So
3660 weirdly. But giving those screws up old xterms and emacs terms. So
3653 I added some logic for emacs terms to be ok, but I can't identify old
3661 I added some logic for emacs terms to be ok, but I can't identify old
3654 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3662 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3655
3663
3656 2002-03-10 Fernando Perez <fperez@colorado.edu>
3664 2002-03-10 Fernando Perez <fperez@colorado.edu>
3657
3665
3658 * IPython/usage.py (__doc__): Various documentation cleanups and
3666 * IPython/usage.py (__doc__): Various documentation cleanups and
3659 updates, both in usage docstrings and in the manual.
3667 updates, both in usage docstrings and in the manual.
3660
3668
3661 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3669 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3662 handling of caching. Set minimum acceptabe value for having a
3670 handling of caching. Set minimum acceptabe value for having a
3663 cache at 20 values.
3671 cache at 20 values.
3664
3672
3665 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3673 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3666 install_first_time function to a method, renamed it and added an
3674 install_first_time function to a method, renamed it and added an
3667 'upgrade' mode. Now people can update their config directory with
3675 'upgrade' mode. Now people can update their config directory with
3668 a simple command line switch (-upgrade, also new).
3676 a simple command line switch (-upgrade, also new).
3669
3677
3670 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3678 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3671 @file (convenient for automagic users under Python >= 2.2).
3679 @file (convenient for automagic users under Python >= 2.2).
3672 Removed @files (it seemed more like a plural than an abbrev. of
3680 Removed @files (it seemed more like a plural than an abbrev. of
3673 'file show').
3681 'file show').
3674
3682
3675 * IPython/iplib.py (install_first_time): Fixed crash if there were
3683 * IPython/iplib.py (install_first_time): Fixed crash if there were
3676 backup files ('~') in .ipython/ install directory.
3684 backup files ('~') in .ipython/ install directory.
3677
3685
3678 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3686 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3679 system. Things look fine, but these changes are fairly
3687 system. Things look fine, but these changes are fairly
3680 intrusive. Test them for a few days.
3688 intrusive. Test them for a few days.
3681
3689
3682 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3690 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3683 the prompts system. Now all in/out prompt strings are user
3691 the prompts system. Now all in/out prompt strings are user
3684 controllable. This is particularly useful for embedding, as one
3692 controllable. This is particularly useful for embedding, as one
3685 can tag embedded instances with particular prompts.
3693 can tag embedded instances with particular prompts.
3686
3694
3687 Also removed global use of sys.ps1/2, which now allows nested
3695 Also removed global use of sys.ps1/2, which now allows nested
3688 embeddings without any problems. Added command-line options for
3696 embeddings without any problems. Added command-line options for
3689 the prompt strings.
3697 the prompt strings.
3690
3698
3691 2002-03-08 Fernando Perez <fperez@colorado.edu>
3699 2002-03-08 Fernando Perez <fperez@colorado.edu>
3692
3700
3693 * IPython/UserConfig/example-embed-short.py (ipshell): added
3701 * IPython/UserConfig/example-embed-short.py (ipshell): added
3694 example file with the bare minimum code for embedding.
3702 example file with the bare minimum code for embedding.
3695
3703
3696 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3704 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3697 functionality for the embeddable shell to be activated/deactivated
3705 functionality for the embeddable shell to be activated/deactivated
3698 either globally or at each call.
3706 either globally or at each call.
3699
3707
3700 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3708 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3701 rewriting the prompt with '--->' for auto-inputs with proper
3709 rewriting the prompt with '--->' for auto-inputs with proper
3702 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3710 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3703 this is handled by the prompts class itself, as it should.
3711 this is handled by the prompts class itself, as it should.
3704
3712
3705 2002-03-05 Fernando Perez <fperez@colorado.edu>
3713 2002-03-05 Fernando Perez <fperez@colorado.edu>
3706
3714
3707 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3715 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3708 @logstart to avoid name clashes with the math log function.
3716 @logstart to avoid name clashes with the math log function.
3709
3717
3710 * Big updates to X/Emacs section of the manual.
3718 * Big updates to X/Emacs section of the manual.
3711
3719
3712 * Removed ipython_emacs. Milan explained to me how to pass
3720 * Removed ipython_emacs. Milan explained to me how to pass
3713 arguments to ipython through Emacs. Some day I'm going to end up
3721 arguments to ipython through Emacs. Some day I'm going to end up
3714 learning some lisp...
3722 learning some lisp...
3715
3723
3716 2002-03-04 Fernando Perez <fperez@colorado.edu>
3724 2002-03-04 Fernando Perez <fperez@colorado.edu>
3717
3725
3718 * IPython/ipython_emacs: Created script to be used as the
3726 * IPython/ipython_emacs: Created script to be used as the
3719 py-python-command Emacs variable so we can pass IPython
3727 py-python-command Emacs variable so we can pass IPython
3720 parameters. I can't figure out how to tell Emacs directly to pass
3728 parameters. I can't figure out how to tell Emacs directly to pass
3721 parameters to IPython, so a dummy shell script will do it.
3729 parameters to IPython, so a dummy shell script will do it.
3722
3730
3723 Other enhancements made for things to work better under Emacs'
3731 Other enhancements made for things to work better under Emacs'
3724 various types of terminals. Many thanks to Milan Zamazal
3732 various types of terminals. Many thanks to Milan Zamazal
3725 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3733 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3726
3734
3727 2002-03-01 Fernando Perez <fperez@colorado.edu>
3735 2002-03-01 Fernando Perez <fperez@colorado.edu>
3728
3736
3729 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3737 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3730 that loading of readline is now optional. This gives better
3738 that loading of readline is now optional. This gives better
3731 control to emacs users.
3739 control to emacs users.
3732
3740
3733 * IPython/ultraTB.py (__date__): Modified color escape sequences
3741 * IPython/ultraTB.py (__date__): Modified color escape sequences
3734 and now things work fine under xterm and in Emacs' term buffers
3742 and now things work fine under xterm and in Emacs' term buffers
3735 (though not shell ones). Well, in emacs you get colors, but all
3743 (though not shell ones). Well, in emacs you get colors, but all
3736 seem to be 'light' colors (no difference between dark and light
3744 seem to be 'light' colors (no difference between dark and light
3737 ones). But the garbage chars are gone, and also in xterms. It
3745 ones). But the garbage chars are gone, and also in xterms. It
3738 seems that now I'm using 'cleaner' ansi sequences.
3746 seems that now I'm using 'cleaner' ansi sequences.
3739
3747
3740 2002-02-21 Fernando Perez <fperez@colorado.edu>
3748 2002-02-21 Fernando Perez <fperez@colorado.edu>
3741
3749
3742 * Released 0.2.7 (mainly to publish the scoping fix).
3750 * Released 0.2.7 (mainly to publish the scoping fix).
3743
3751
3744 * IPython/Logger.py (Logger.logstate): added. A corresponding
3752 * IPython/Logger.py (Logger.logstate): added. A corresponding
3745 @logstate magic was created.
3753 @logstate magic was created.
3746
3754
3747 * IPython/Magic.py: fixed nested scoping problem under Python
3755 * IPython/Magic.py: fixed nested scoping problem under Python
3748 2.1.x (automagic wasn't working).
3756 2.1.x (automagic wasn't working).
3749
3757
3750 2002-02-20 Fernando Perez <fperez@colorado.edu>
3758 2002-02-20 Fernando Perez <fperez@colorado.edu>
3751
3759
3752 * Released 0.2.6.
3760 * Released 0.2.6.
3753
3761
3754 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3762 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3755 option so that logs can come out without any headers at all.
3763 option so that logs can come out without any headers at all.
3756
3764
3757 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3765 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3758 SciPy.
3766 SciPy.
3759
3767
3760 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3768 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3761 that embedded IPython calls don't require vars() to be explicitly
3769 that embedded IPython calls don't require vars() to be explicitly
3762 passed. Now they are extracted from the caller's frame (code
3770 passed. Now they are extracted from the caller's frame (code
3763 snatched from Eric Jones' weave). Added better documentation to
3771 snatched from Eric Jones' weave). Added better documentation to
3764 the section on embedding and the example file.
3772 the section on embedding and the example file.
3765
3773
3766 * IPython/genutils.py (page): Changed so that under emacs, it just
3774 * IPython/genutils.py (page): Changed so that under emacs, it just
3767 prints the string. You can then page up and down in the emacs
3775 prints the string. You can then page up and down in the emacs
3768 buffer itself. This is how the builtin help() works.
3776 buffer itself. This is how the builtin help() works.
3769
3777
3770 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3778 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3771 macro scoping: macros need to be executed in the user's namespace
3779 macro scoping: macros need to be executed in the user's namespace
3772 to work as if they had been typed by the user.
3780 to work as if they had been typed by the user.
3773
3781
3774 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3782 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3775 execute automatically (no need to type 'exec...'). They then
3783 execute automatically (no need to type 'exec...'). They then
3776 behave like 'true macros'. The printing system was also modified
3784 behave like 'true macros'. The printing system was also modified
3777 for this to work.
3785 for this to work.
3778
3786
3779 2002-02-19 Fernando Perez <fperez@colorado.edu>
3787 2002-02-19 Fernando Perez <fperez@colorado.edu>
3780
3788
3781 * IPython/genutils.py (page_file): new function for paging files
3789 * IPython/genutils.py (page_file): new function for paging files
3782 in an OS-independent way. Also necessary for file viewing to work
3790 in an OS-independent way. Also necessary for file viewing to work
3783 well inside Emacs buffers.
3791 well inside Emacs buffers.
3784 (page): Added checks for being in an emacs buffer.
3792 (page): Added checks for being in an emacs buffer.
3785 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3793 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3786 same bug in iplib.
3794 same bug in iplib.
3787
3795
3788 2002-02-18 Fernando Perez <fperez@colorado.edu>
3796 2002-02-18 Fernando Perez <fperez@colorado.edu>
3789
3797
3790 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3798 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3791 of readline so that IPython can work inside an Emacs buffer.
3799 of readline so that IPython can work inside an Emacs buffer.
3792
3800
3793 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3801 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3794 method signatures (they weren't really bugs, but it looks cleaner
3802 method signatures (they weren't really bugs, but it looks cleaner
3795 and keeps PyChecker happy).
3803 and keeps PyChecker happy).
3796
3804
3797 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3805 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3798 for implementing various user-defined hooks. Currently only
3806 for implementing various user-defined hooks. Currently only
3799 display is done.
3807 display is done.
3800
3808
3801 * IPython/Prompts.py (CachedOutput._display): changed display
3809 * IPython/Prompts.py (CachedOutput._display): changed display
3802 functions so that they can be dynamically changed by users easily.
3810 functions so that they can be dynamically changed by users easily.
3803
3811
3804 * IPython/Extensions/numeric_formats.py (num_display): added an
3812 * IPython/Extensions/numeric_formats.py (num_display): added an
3805 extension for printing NumPy arrays in flexible manners. It
3813 extension for printing NumPy arrays in flexible manners. It
3806 doesn't do anything yet, but all the structure is in
3814 doesn't do anything yet, but all the structure is in
3807 place. Ultimately the plan is to implement output format control
3815 place. Ultimately the plan is to implement output format control
3808 like in Octave.
3816 like in Octave.
3809
3817
3810 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3818 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3811 methods are found at run-time by all the automatic machinery.
3819 methods are found at run-time by all the automatic machinery.
3812
3820
3813 2002-02-17 Fernando Perez <fperez@colorado.edu>
3821 2002-02-17 Fernando Perez <fperez@colorado.edu>
3814
3822
3815 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3823 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3816 whole file a little.
3824 whole file a little.
3817
3825
3818 * ToDo: closed this document. Now there's a new_design.lyx
3826 * ToDo: closed this document. Now there's a new_design.lyx
3819 document for all new ideas. Added making a pdf of it for the
3827 document for all new ideas. Added making a pdf of it for the
3820 end-user distro.
3828 end-user distro.
3821
3829
3822 * IPython/Logger.py (Logger.switch_log): Created this to replace
3830 * IPython/Logger.py (Logger.switch_log): Created this to replace
3823 logon() and logoff(). It also fixes a nasty crash reported by
3831 logon() and logoff(). It also fixes a nasty crash reported by
3824 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3832 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3825
3833
3826 * IPython/iplib.py (complete): got auto-completion to work with
3834 * IPython/iplib.py (complete): got auto-completion to work with
3827 automagic (I had wanted this for a long time).
3835 automagic (I had wanted this for a long time).
3828
3836
3829 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3837 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3830 to @file, since file() is now a builtin and clashes with automagic
3838 to @file, since file() is now a builtin and clashes with automagic
3831 for @file.
3839 for @file.
3832
3840
3833 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3841 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3834 of this was previously in iplib, which had grown to more than 2000
3842 of this was previously in iplib, which had grown to more than 2000
3835 lines, way too long. No new functionality, but it makes managing
3843 lines, way too long. No new functionality, but it makes managing
3836 the code a bit easier.
3844 the code a bit easier.
3837
3845
3838 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3846 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3839 information to crash reports.
3847 information to crash reports.
3840
3848
3841 2002-02-12 Fernando Perez <fperez@colorado.edu>
3849 2002-02-12 Fernando Perez <fperez@colorado.edu>
3842
3850
3843 * Released 0.2.5.
3851 * Released 0.2.5.
3844
3852
3845 2002-02-11 Fernando Perez <fperez@colorado.edu>
3853 2002-02-11 Fernando Perez <fperez@colorado.edu>
3846
3854
3847 * Wrote a relatively complete Windows installer. It puts
3855 * Wrote a relatively complete Windows installer. It puts
3848 everything in place, creates Start Menu entries and fixes the
3856 everything in place, creates Start Menu entries and fixes the
3849 color issues. Nothing fancy, but it works.
3857 color issues. Nothing fancy, but it works.
3850
3858
3851 2002-02-10 Fernando Perez <fperez@colorado.edu>
3859 2002-02-10 Fernando Perez <fperez@colorado.edu>
3852
3860
3853 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3861 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3854 os.path.expanduser() call so that we can type @run ~/myfile.py and
3862 os.path.expanduser() call so that we can type @run ~/myfile.py and
3855 have thigs work as expected.
3863 have thigs work as expected.
3856
3864
3857 * IPython/genutils.py (page): fixed exception handling so things
3865 * IPython/genutils.py (page): fixed exception handling so things
3858 work both in Unix and Windows correctly. Quitting a pager triggers
3866 work both in Unix and Windows correctly. Quitting a pager triggers
3859 an IOError/broken pipe in Unix, and in windows not finding a pager
3867 an IOError/broken pipe in Unix, and in windows not finding a pager
3860 is also an IOError, so I had to actually look at the return value
3868 is also an IOError, so I had to actually look at the return value
3861 of the exception, not just the exception itself. Should be ok now.
3869 of the exception, not just the exception itself. Should be ok now.
3862
3870
3863 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3871 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3864 modified to allow case-insensitive color scheme changes.
3872 modified to allow case-insensitive color scheme changes.
3865
3873
3866 2002-02-09 Fernando Perez <fperez@colorado.edu>
3874 2002-02-09 Fernando Perez <fperez@colorado.edu>
3867
3875
3868 * IPython/genutils.py (native_line_ends): new function to leave
3876 * IPython/genutils.py (native_line_ends): new function to leave
3869 user config files with os-native line-endings.
3877 user config files with os-native line-endings.
3870
3878
3871 * README and manual updates.
3879 * README and manual updates.
3872
3880
3873 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3881 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3874 instead of StringType to catch Unicode strings.
3882 instead of StringType to catch Unicode strings.
3875
3883
3876 * IPython/genutils.py (filefind): fixed bug for paths with
3884 * IPython/genutils.py (filefind): fixed bug for paths with
3877 embedded spaces (very common in Windows).
3885 embedded spaces (very common in Windows).
3878
3886
3879 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3887 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3880 files under Windows, so that they get automatically associated
3888 files under Windows, so that they get automatically associated
3881 with a text editor. Windows makes it a pain to handle
3889 with a text editor. Windows makes it a pain to handle
3882 extension-less files.
3890 extension-less files.
3883
3891
3884 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3892 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3885 warning about readline only occur for Posix. In Windows there's no
3893 warning about readline only occur for Posix. In Windows there's no
3886 way to get readline, so why bother with the warning.
3894 way to get readline, so why bother with the warning.
3887
3895
3888 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3896 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3889 for __str__ instead of dir(self), since dir() changed in 2.2.
3897 for __str__ instead of dir(self), since dir() changed in 2.2.
3890
3898
3891 * Ported to Windows! Tested on XP, I suspect it should work fine
3899 * Ported to Windows! Tested on XP, I suspect it should work fine
3892 on NT/2000, but I don't think it will work on 98 et al. That
3900 on NT/2000, but I don't think it will work on 98 et al. That
3893 series of Windows is such a piece of junk anyway that I won't try
3901 series of Windows is such a piece of junk anyway that I won't try
3894 porting it there. The XP port was straightforward, showed a few
3902 porting it there. The XP port was straightforward, showed a few
3895 bugs here and there (fixed all), in particular some string
3903 bugs here and there (fixed all), in particular some string
3896 handling stuff which required considering Unicode strings (which
3904 handling stuff which required considering Unicode strings (which
3897 Windows uses). This is good, but hasn't been too tested :) No
3905 Windows uses). This is good, but hasn't been too tested :) No
3898 fancy installer yet, I'll put a note in the manual so people at
3906 fancy installer yet, I'll put a note in the manual so people at
3899 least make manually a shortcut.
3907 least make manually a shortcut.
3900
3908
3901 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3909 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3902 into a single one, "colors". This now controls both prompt and
3910 into a single one, "colors". This now controls both prompt and
3903 exception color schemes, and can be changed both at startup
3911 exception color schemes, and can be changed both at startup
3904 (either via command-line switches or via ipythonrc files) and at
3912 (either via command-line switches or via ipythonrc files) and at
3905 runtime, with @colors.
3913 runtime, with @colors.
3906 (Magic.magic_run): renamed @prun to @run and removed the old
3914 (Magic.magic_run): renamed @prun to @run and removed the old
3907 @run. The two were too similar to warrant keeping both.
3915 @run. The two were too similar to warrant keeping both.
3908
3916
3909 2002-02-03 Fernando Perez <fperez@colorado.edu>
3917 2002-02-03 Fernando Perez <fperez@colorado.edu>
3910
3918
3911 * IPython/iplib.py (install_first_time): Added comment on how to
3919 * IPython/iplib.py (install_first_time): Added comment on how to
3912 configure the color options for first-time users. Put a <return>
3920 configure the color options for first-time users. Put a <return>
3913 request at the end so that small-terminal users get a chance to
3921 request at the end so that small-terminal users get a chance to
3914 read the startup info.
3922 read the startup info.
3915
3923
3916 2002-01-23 Fernando Perez <fperez@colorado.edu>
3924 2002-01-23 Fernando Perez <fperez@colorado.edu>
3917
3925
3918 * IPython/iplib.py (CachedOutput.update): Changed output memory
3926 * IPython/iplib.py (CachedOutput.update): Changed output memory
3919 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3927 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3920 input history we still use _i. Did this b/c these variable are
3928 input history we still use _i. Did this b/c these variable are
3921 very commonly used in interactive work, so the less we need to
3929 very commonly used in interactive work, so the less we need to
3922 type the better off we are.
3930 type the better off we are.
3923 (Magic.magic_prun): updated @prun to better handle the namespaces
3931 (Magic.magic_prun): updated @prun to better handle the namespaces
3924 the file will run in, including a fix for __name__ not being set
3932 the file will run in, including a fix for __name__ not being set
3925 before.
3933 before.
3926
3934
3927 2002-01-20 Fernando Perez <fperez@colorado.edu>
3935 2002-01-20 Fernando Perez <fperez@colorado.edu>
3928
3936
3929 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3937 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3930 extra garbage for Python 2.2. Need to look more carefully into
3938 extra garbage for Python 2.2. Need to look more carefully into
3931 this later.
3939 this later.
3932
3940
3933 2002-01-19 Fernando Perez <fperez@colorado.edu>
3941 2002-01-19 Fernando Perez <fperez@colorado.edu>
3934
3942
3935 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3943 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3936 display SyntaxError exceptions properly formatted when they occur
3944 display SyntaxError exceptions properly formatted when they occur
3937 (they can be triggered by imported code).
3945 (they can be triggered by imported code).
3938
3946
3939 2002-01-18 Fernando Perez <fperez@colorado.edu>
3947 2002-01-18 Fernando Perez <fperez@colorado.edu>
3940
3948
3941 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3949 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3942 SyntaxError exceptions are reported nicely formatted, instead of
3950 SyntaxError exceptions are reported nicely formatted, instead of
3943 spitting out only offset information as before.
3951 spitting out only offset information as before.
3944 (Magic.magic_prun): Added the @prun function for executing
3952 (Magic.magic_prun): Added the @prun function for executing
3945 programs with command line args inside IPython.
3953 programs with command line args inside IPython.
3946
3954
3947 2002-01-16 Fernando Perez <fperez@colorado.edu>
3955 2002-01-16 Fernando Perez <fperez@colorado.edu>
3948
3956
3949 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3957 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3950 to *not* include the last item given in a range. This brings their
3958 to *not* include the last item given in a range. This brings their
3951 behavior in line with Python's slicing:
3959 behavior in line with Python's slicing:
3952 a[n1:n2] -> a[n1]...a[n2-1]
3960 a[n1:n2] -> a[n1]...a[n2-1]
3953 It may be a bit less convenient, but I prefer to stick to Python's
3961 It may be a bit less convenient, but I prefer to stick to Python's
3954 conventions *everywhere*, so users never have to wonder.
3962 conventions *everywhere*, so users never have to wonder.
3955 (Magic.magic_macro): Added @macro function to ease the creation of
3963 (Magic.magic_macro): Added @macro function to ease the creation of
3956 macros.
3964 macros.
3957
3965
3958 2002-01-05 Fernando Perez <fperez@colorado.edu>
3966 2002-01-05 Fernando Perez <fperez@colorado.edu>
3959
3967
3960 * Released 0.2.4.
3968 * Released 0.2.4.
3961
3969
3962 * IPython/iplib.py (Magic.magic_pdef):
3970 * IPython/iplib.py (Magic.magic_pdef):
3963 (InteractiveShell.safe_execfile): report magic lines and error
3971 (InteractiveShell.safe_execfile): report magic lines and error
3964 lines without line numbers so one can easily copy/paste them for
3972 lines without line numbers so one can easily copy/paste them for
3965 re-execution.
3973 re-execution.
3966
3974
3967 * Updated manual with recent changes.
3975 * Updated manual with recent changes.
3968
3976
3969 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3977 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3970 docstring printing when class? is called. Very handy for knowing
3978 docstring printing when class? is called. Very handy for knowing
3971 how to create class instances (as long as __init__ is well
3979 how to create class instances (as long as __init__ is well
3972 documented, of course :)
3980 documented, of course :)
3973 (Magic.magic_doc): print both class and constructor docstrings.
3981 (Magic.magic_doc): print both class and constructor docstrings.
3974 (Magic.magic_pdef): give constructor info if passed a class and
3982 (Magic.magic_pdef): give constructor info if passed a class and
3975 __call__ info for callable object instances.
3983 __call__ info for callable object instances.
3976
3984
3977 2002-01-04 Fernando Perez <fperez@colorado.edu>
3985 2002-01-04 Fernando Perez <fperez@colorado.edu>
3978
3986
3979 * Made deep_reload() off by default. It doesn't always work
3987 * Made deep_reload() off by default. It doesn't always work
3980 exactly as intended, so it's probably safer to have it off. It's
3988 exactly as intended, so it's probably safer to have it off. It's
3981 still available as dreload() anyway, so nothing is lost.
3989 still available as dreload() anyway, so nothing is lost.
3982
3990
3983 2002-01-02 Fernando Perez <fperez@colorado.edu>
3991 2002-01-02 Fernando Perez <fperez@colorado.edu>
3984
3992
3985 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3993 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3986 so I wanted an updated release).
3994 so I wanted an updated release).
3987
3995
3988 2001-12-27 Fernando Perez <fperez@colorado.edu>
3996 2001-12-27 Fernando Perez <fperez@colorado.edu>
3989
3997
3990 * IPython/iplib.py (InteractiveShell.interact): Added the original
3998 * IPython/iplib.py (InteractiveShell.interact): Added the original
3991 code from 'code.py' for this module in order to change the
3999 code from 'code.py' for this module in order to change the
3992 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4000 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3993 the history cache would break when the user hit Ctrl-C, and
4001 the history cache would break when the user hit Ctrl-C, and
3994 interact() offers no way to add any hooks to it.
4002 interact() offers no way to add any hooks to it.
3995
4003
3996 2001-12-23 Fernando Perez <fperez@colorado.edu>
4004 2001-12-23 Fernando Perez <fperez@colorado.edu>
3997
4005
3998 * setup.py: added check for 'MANIFEST' before trying to remove
4006 * setup.py: added check for 'MANIFEST' before trying to remove
3999 it. Thanks to Sean Reifschneider.
4007 it. Thanks to Sean Reifschneider.
4000
4008
4001 2001-12-22 Fernando Perez <fperez@colorado.edu>
4009 2001-12-22 Fernando Perez <fperez@colorado.edu>
4002
4010
4003 * Released 0.2.2.
4011 * Released 0.2.2.
4004
4012
4005 * Finished (reasonably) writing the manual. Later will add the
4013 * Finished (reasonably) writing the manual. Later will add the
4006 python-standard navigation stylesheets, but for the time being
4014 python-standard navigation stylesheets, but for the time being
4007 it's fairly complete. Distribution will include html and pdf
4015 it's fairly complete. Distribution will include html and pdf
4008 versions.
4016 versions.
4009
4017
4010 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4018 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4011 (MayaVi author).
4019 (MayaVi author).
4012
4020
4013 2001-12-21 Fernando Perez <fperez@colorado.edu>
4021 2001-12-21 Fernando Perez <fperez@colorado.edu>
4014
4022
4015 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4023 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4016 good public release, I think (with the manual and the distutils
4024 good public release, I think (with the manual and the distutils
4017 installer). The manual can use some work, but that can go
4025 installer). The manual can use some work, but that can go
4018 slowly. Otherwise I think it's quite nice for end users. Next
4026 slowly. Otherwise I think it's quite nice for end users. Next
4019 summer, rewrite the guts of it...
4027 summer, rewrite the guts of it...
4020
4028
4021 * Changed format of ipythonrc files to use whitespace as the
4029 * Changed format of ipythonrc files to use whitespace as the
4022 separator instead of an explicit '='. Cleaner.
4030 separator instead of an explicit '='. Cleaner.
4023
4031
4024 2001-12-20 Fernando Perez <fperez@colorado.edu>
4032 2001-12-20 Fernando Perez <fperez@colorado.edu>
4025
4033
4026 * Started a manual in LyX. For now it's just a quick merge of the
4034 * Started a manual in LyX. For now it's just a quick merge of the
4027 various internal docstrings and READMEs. Later it may grow into a
4035 various internal docstrings and READMEs. Later it may grow into a
4028 nice, full-blown manual.
4036 nice, full-blown manual.
4029
4037
4030 * Set up a distutils based installer. Installation should now be
4038 * Set up a distutils based installer. Installation should now be
4031 trivially simple for end-users.
4039 trivially simple for end-users.
4032
4040
4033 2001-12-11 Fernando Perez <fperez@colorado.edu>
4041 2001-12-11 Fernando Perez <fperez@colorado.edu>
4034
4042
4035 * Released 0.2.0. First public release, announced it at
4043 * Released 0.2.0. First public release, announced it at
4036 comp.lang.python. From now on, just bugfixes...
4044 comp.lang.python. From now on, just bugfixes...
4037
4045
4038 * Went through all the files, set copyright/license notices and
4046 * Went through all the files, set copyright/license notices and
4039 cleaned up things. Ready for release.
4047 cleaned up things. Ready for release.
4040
4048
4041 2001-12-10 Fernando Perez <fperez@colorado.edu>
4049 2001-12-10 Fernando Perez <fperez@colorado.edu>
4042
4050
4043 * Changed the first-time installer not to use tarfiles. It's more
4051 * Changed the first-time installer not to use tarfiles. It's more
4044 robust now and less unix-dependent. Also makes it easier for
4052 robust now and less unix-dependent. Also makes it easier for
4045 people to later upgrade versions.
4053 people to later upgrade versions.
4046
4054
4047 * Changed @exit to @abort to reflect the fact that it's pretty
4055 * Changed @exit to @abort to reflect the fact that it's pretty
4048 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4056 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4049 becomes significant only when IPyhton is embedded: in that case,
4057 becomes significant only when IPyhton is embedded: in that case,
4050 C-D closes IPython only, but @abort kills the enclosing program
4058 C-D closes IPython only, but @abort kills the enclosing program
4051 too (unless it had called IPython inside a try catching
4059 too (unless it had called IPython inside a try catching
4052 SystemExit).
4060 SystemExit).
4053
4061
4054 * Created Shell module which exposes the actuall IPython Shell
4062 * Created Shell module which exposes the actuall IPython Shell
4055 classes, currently the normal and the embeddable one. This at
4063 classes, currently the normal and the embeddable one. This at
4056 least offers a stable interface we won't need to change when
4064 least offers a stable interface we won't need to change when
4057 (later) the internals are rewritten. That rewrite will be confined
4065 (later) the internals are rewritten. That rewrite will be confined
4058 to iplib and ipmaker, but the Shell interface should remain as is.
4066 to iplib and ipmaker, but the Shell interface should remain as is.
4059
4067
4060 * Added embed module which offers an embeddable IPShell object,
4068 * Added embed module which offers an embeddable IPShell object,
4061 useful to fire up IPython *inside* a running program. Great for
4069 useful to fire up IPython *inside* a running program. Great for
4062 debugging or dynamical data analysis.
4070 debugging or dynamical data analysis.
4063
4071
4064 2001-12-08 Fernando Perez <fperez@colorado.edu>
4072 2001-12-08 Fernando Perez <fperez@colorado.edu>
4065
4073
4066 * Fixed small bug preventing seeing info from methods of defined
4074 * Fixed small bug preventing seeing info from methods of defined
4067 objects (incorrect namespace in _ofind()).
4075 objects (incorrect namespace in _ofind()).
4068
4076
4069 * Documentation cleanup. Moved the main usage docstrings to a
4077 * Documentation cleanup. Moved the main usage docstrings to a
4070 separate file, usage.py (cleaner to maintain, and hopefully in the
4078 separate file, usage.py (cleaner to maintain, and hopefully in the
4071 future some perlpod-like way of producing interactive, man and
4079 future some perlpod-like way of producing interactive, man and
4072 html docs out of it will be found).
4080 html docs out of it will be found).
4073
4081
4074 * Added @profile to see your profile at any time.
4082 * Added @profile to see your profile at any time.
4075
4083
4076 * Added @p as an alias for 'print'. It's especially convenient if
4084 * Added @p as an alias for 'print'. It's especially convenient if
4077 using automagic ('p x' prints x).
4085 using automagic ('p x' prints x).
4078
4086
4079 * Small cleanups and fixes after a pychecker run.
4087 * Small cleanups and fixes after a pychecker run.
4080
4088
4081 * Changed the @cd command to handle @cd - and @cd -<n> for
4089 * Changed the @cd command to handle @cd - and @cd -<n> for
4082 visiting any directory in _dh.
4090 visiting any directory in _dh.
4083
4091
4084 * Introduced _dh, a history of visited directories. @dhist prints
4092 * Introduced _dh, a history of visited directories. @dhist prints
4085 it out with numbers.
4093 it out with numbers.
4086
4094
4087 2001-12-07 Fernando Perez <fperez@colorado.edu>
4095 2001-12-07 Fernando Perez <fperez@colorado.edu>
4088
4096
4089 * Released 0.1.22
4097 * Released 0.1.22
4090
4098
4091 * Made initialization a bit more robust against invalid color
4099 * Made initialization a bit more robust against invalid color
4092 options in user input (exit, not traceback-crash).
4100 options in user input (exit, not traceback-crash).
4093
4101
4094 * Changed the bug crash reporter to write the report only in the
4102 * Changed the bug crash reporter to write the report only in the
4095 user's .ipython directory. That way IPython won't litter people's
4103 user's .ipython directory. That way IPython won't litter people's
4096 hard disks with crash files all over the place. Also print on
4104 hard disks with crash files all over the place. Also print on
4097 screen the necessary mail command.
4105 screen the necessary mail command.
4098
4106
4099 * With the new ultraTB, implemented LightBG color scheme for light
4107 * With the new ultraTB, implemented LightBG color scheme for light
4100 background terminals. A lot of people like white backgrounds, so I
4108 background terminals. A lot of people like white backgrounds, so I
4101 guess we should at least give them something readable.
4109 guess we should at least give them something readable.
4102
4110
4103 2001-12-06 Fernando Perez <fperez@colorado.edu>
4111 2001-12-06 Fernando Perez <fperez@colorado.edu>
4104
4112
4105 * Modified the structure of ultraTB. Now there's a proper class
4113 * Modified the structure of ultraTB. Now there's a proper class
4106 for tables of color schemes which allow adding schemes easily and
4114 for tables of color schemes which allow adding schemes easily and
4107 switching the active scheme without creating a new instance every
4115 switching the active scheme without creating a new instance every
4108 time (which was ridiculous). The syntax for creating new schemes
4116 time (which was ridiculous). The syntax for creating new schemes
4109 is also cleaner. I think ultraTB is finally done, with a clean
4117 is also cleaner. I think ultraTB is finally done, with a clean
4110 class structure. Names are also much cleaner (now there's proper
4118 class structure. Names are also much cleaner (now there's proper
4111 color tables, no need for every variable to also have 'color' in
4119 color tables, no need for every variable to also have 'color' in
4112 its name).
4120 its name).
4113
4121
4114 * Broke down genutils into separate files. Now genutils only
4122 * Broke down genutils into separate files. Now genutils only
4115 contains utility functions, and classes have been moved to their
4123 contains utility functions, and classes have been moved to their
4116 own files (they had enough independent functionality to warrant
4124 own files (they had enough independent functionality to warrant
4117 it): ConfigLoader, OutputTrap, Struct.
4125 it): ConfigLoader, OutputTrap, Struct.
4118
4126
4119 2001-12-05 Fernando Perez <fperez@colorado.edu>
4127 2001-12-05 Fernando Perez <fperez@colorado.edu>
4120
4128
4121 * IPython turns 21! Released version 0.1.21, as a candidate for
4129 * IPython turns 21! Released version 0.1.21, as a candidate for
4122 public consumption. If all goes well, release in a few days.
4130 public consumption. If all goes well, release in a few days.
4123
4131
4124 * Fixed path bug (files in Extensions/ directory wouldn't be found
4132 * Fixed path bug (files in Extensions/ directory wouldn't be found
4125 unless IPython/ was explicitly in sys.path).
4133 unless IPython/ was explicitly in sys.path).
4126
4134
4127 * Extended the FlexCompleter class as MagicCompleter to allow
4135 * Extended the FlexCompleter class as MagicCompleter to allow
4128 completion of @-starting lines.
4136 completion of @-starting lines.
4129
4137
4130 * Created __release__.py file as a central repository for release
4138 * Created __release__.py file as a central repository for release
4131 info that other files can read from.
4139 info that other files can read from.
4132
4140
4133 * Fixed small bug in logging: when logging was turned on in
4141 * Fixed small bug in logging: when logging was turned on in
4134 mid-session, old lines with special meanings (!@?) were being
4142 mid-session, old lines with special meanings (!@?) were being
4135 logged without the prepended comment, which is necessary since
4143 logged without the prepended comment, which is necessary since
4136 they are not truly valid python syntax. This should make session
4144 they are not truly valid python syntax. This should make session
4137 restores produce less errors.
4145 restores produce less errors.
4138
4146
4139 * The namespace cleanup forced me to make a FlexCompleter class
4147 * The namespace cleanup forced me to make a FlexCompleter class
4140 which is nothing but a ripoff of rlcompleter, but with selectable
4148 which is nothing but a ripoff of rlcompleter, but with selectable
4141 namespace (rlcompleter only works in __main__.__dict__). I'll try
4149 namespace (rlcompleter only works in __main__.__dict__). I'll try
4142 to submit a note to the authors to see if this change can be
4150 to submit a note to the authors to see if this change can be
4143 incorporated in future rlcompleter releases (Dec.6: done)
4151 incorporated in future rlcompleter releases (Dec.6: done)
4144
4152
4145 * More fixes to namespace handling. It was a mess! Now all
4153 * More fixes to namespace handling. It was a mess! Now all
4146 explicit references to __main__.__dict__ are gone (except when
4154 explicit references to __main__.__dict__ are gone (except when
4147 really needed) and everything is handled through the namespace
4155 really needed) and everything is handled through the namespace
4148 dicts in the IPython instance. We seem to be getting somewhere
4156 dicts in the IPython instance. We seem to be getting somewhere
4149 with this, finally...
4157 with this, finally...
4150
4158
4151 * Small documentation updates.
4159 * Small documentation updates.
4152
4160
4153 * Created the Extensions directory under IPython (with an
4161 * Created the Extensions directory under IPython (with an
4154 __init__.py). Put the PhysicalQ stuff there. This directory should
4162 __init__.py). Put the PhysicalQ stuff there. This directory should
4155 be used for all special-purpose extensions.
4163 be used for all special-purpose extensions.
4156
4164
4157 * File renaming:
4165 * File renaming:
4158 ipythonlib --> ipmaker
4166 ipythonlib --> ipmaker
4159 ipplib --> iplib
4167 ipplib --> iplib
4160 This makes a bit more sense in terms of what these files actually do.
4168 This makes a bit more sense in terms of what these files actually do.
4161
4169
4162 * Moved all the classes and functions in ipythonlib to ipplib, so
4170 * Moved all the classes and functions in ipythonlib to ipplib, so
4163 now ipythonlib only has make_IPython(). This will ease up its
4171 now ipythonlib only has make_IPython(). This will ease up its
4164 splitting in smaller functional chunks later.
4172 splitting in smaller functional chunks later.
4165
4173
4166 * Cleaned up (done, I think) output of @whos. Better column
4174 * Cleaned up (done, I think) output of @whos. Better column
4167 formatting, and now shows str(var) for as much as it can, which is
4175 formatting, and now shows str(var) for as much as it can, which is
4168 typically what one gets with a 'print var'.
4176 typically what one gets with a 'print var'.
4169
4177
4170 2001-12-04 Fernando Perez <fperez@colorado.edu>
4178 2001-12-04 Fernando Perez <fperez@colorado.edu>
4171
4179
4172 * Fixed namespace problems. Now builtin/IPyhton/user names get
4180 * Fixed namespace problems. Now builtin/IPyhton/user names get
4173 properly reported in their namespace. Internal namespace handling
4181 properly reported in their namespace. Internal namespace handling
4174 is finally getting decent (not perfect yet, but much better than
4182 is finally getting decent (not perfect yet, but much better than
4175 the ad-hoc mess we had).
4183 the ad-hoc mess we had).
4176
4184
4177 * Removed -exit option. If people just want to run a python
4185 * Removed -exit option. If people just want to run a python
4178 script, that's what the normal interpreter is for. Less
4186 script, that's what the normal interpreter is for. Less
4179 unnecessary options, less chances for bugs.
4187 unnecessary options, less chances for bugs.
4180
4188
4181 * Added a crash handler which generates a complete post-mortem if
4189 * Added a crash handler which generates a complete post-mortem if
4182 IPython crashes. This will help a lot in tracking bugs down the
4190 IPython crashes. This will help a lot in tracking bugs down the
4183 road.
4191 road.
4184
4192
4185 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4193 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4186 which were boud to functions being reassigned would bypass the
4194 which were boud to functions being reassigned would bypass the
4187 logger, breaking the sync of _il with the prompt counter. This
4195 logger, breaking the sync of _il with the prompt counter. This
4188 would then crash IPython later when a new line was logged.
4196 would then crash IPython later when a new line was logged.
4189
4197
4190 2001-12-02 Fernando Perez <fperez@colorado.edu>
4198 2001-12-02 Fernando Perez <fperez@colorado.edu>
4191
4199
4192 * Made IPython a package. This means people don't have to clutter
4200 * Made IPython a package. This means people don't have to clutter
4193 their sys.path with yet another directory. Changed the INSTALL
4201 their sys.path with yet another directory. Changed the INSTALL
4194 file accordingly.
4202 file accordingly.
4195
4203
4196 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4204 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4197 sorts its output (so @who shows it sorted) and @whos formats the
4205 sorts its output (so @who shows it sorted) and @whos formats the
4198 table according to the width of the first column. Nicer, easier to
4206 table according to the width of the first column. Nicer, easier to
4199 read. Todo: write a generic table_format() which takes a list of
4207 read. Todo: write a generic table_format() which takes a list of
4200 lists and prints it nicely formatted, with optional row/column
4208 lists and prints it nicely formatted, with optional row/column
4201 separators and proper padding and justification.
4209 separators and proper padding and justification.
4202
4210
4203 * Released 0.1.20
4211 * Released 0.1.20
4204
4212
4205 * Fixed bug in @log which would reverse the inputcache list (a
4213 * Fixed bug in @log which would reverse the inputcache list (a
4206 copy operation was missing).
4214 copy operation was missing).
4207
4215
4208 * Code cleanup. @config was changed to use page(). Better, since
4216 * Code cleanup. @config was changed to use page(). Better, since
4209 its output is always quite long.
4217 its output is always quite long.
4210
4218
4211 * Itpl is back as a dependency. I was having too many problems
4219 * Itpl is back as a dependency. I was having too many problems
4212 getting the parametric aliases to work reliably, and it's just
4220 getting the parametric aliases to work reliably, and it's just
4213 easier to code weird string operations with it than playing %()s
4221 easier to code weird string operations with it than playing %()s
4214 games. It's only ~6k, so I don't think it's too big a deal.
4222 games. It's only ~6k, so I don't think it's too big a deal.
4215
4223
4216 * Found (and fixed) a very nasty bug with history. !lines weren't
4224 * Found (and fixed) a very nasty bug with history. !lines weren't
4217 getting cached, and the out of sync caches would crash
4225 getting cached, and the out of sync caches would crash
4218 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4226 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4219 division of labor a bit better. Bug fixed, cleaner structure.
4227 division of labor a bit better. Bug fixed, cleaner structure.
4220
4228
4221 2001-12-01 Fernando Perez <fperez@colorado.edu>
4229 2001-12-01 Fernando Perez <fperez@colorado.edu>
4222
4230
4223 * Released 0.1.19
4231 * Released 0.1.19
4224
4232
4225 * Added option -n to @hist to prevent line number printing. Much
4233 * Added option -n to @hist to prevent line number printing. Much
4226 easier to copy/paste code this way.
4234 easier to copy/paste code this way.
4227
4235
4228 * Created global _il to hold the input list. Allows easy
4236 * Created global _il to hold the input list. Allows easy
4229 re-execution of blocks of code by slicing it (inspired by Janko's
4237 re-execution of blocks of code by slicing it (inspired by Janko's
4230 comment on 'macros').
4238 comment on 'macros').
4231
4239
4232 * Small fixes and doc updates.
4240 * Small fixes and doc updates.
4233
4241
4234 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4242 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4235 much too fragile with automagic. Handles properly multi-line
4243 much too fragile with automagic. Handles properly multi-line
4236 statements and takes parameters.
4244 statements and takes parameters.
4237
4245
4238 2001-11-30 Fernando Perez <fperez@colorado.edu>
4246 2001-11-30 Fernando Perez <fperez@colorado.edu>
4239
4247
4240 * Version 0.1.18 released.
4248 * Version 0.1.18 released.
4241
4249
4242 * Fixed nasty namespace bug in initial module imports.
4250 * Fixed nasty namespace bug in initial module imports.
4243
4251
4244 * Added copyright/license notes to all code files (except
4252 * Added copyright/license notes to all code files (except
4245 DPyGetOpt). For the time being, LGPL. That could change.
4253 DPyGetOpt). For the time being, LGPL. That could change.
4246
4254
4247 * Rewrote a much nicer README, updated INSTALL, cleaned up
4255 * Rewrote a much nicer README, updated INSTALL, cleaned up
4248 ipythonrc-* samples.
4256 ipythonrc-* samples.
4249
4257
4250 * Overall code/documentation cleanup. Basically ready for
4258 * Overall code/documentation cleanup. Basically ready for
4251 release. Only remaining thing: licence decision (LGPL?).
4259 release. Only remaining thing: licence decision (LGPL?).
4252
4260
4253 * Converted load_config to a class, ConfigLoader. Now recursion
4261 * Converted load_config to a class, ConfigLoader. Now recursion
4254 control is better organized. Doesn't include the same file twice.
4262 control is better organized. Doesn't include the same file twice.
4255
4263
4256 2001-11-29 Fernando Perez <fperez@colorado.edu>
4264 2001-11-29 Fernando Perez <fperez@colorado.edu>
4257
4265
4258 * Got input history working. Changed output history variables from
4266 * Got input history working. Changed output history variables from
4259 _p to _o so that _i is for input and _o for output. Just cleaner
4267 _p to _o so that _i is for input and _o for output. Just cleaner
4260 convention.
4268 convention.
4261
4269
4262 * Implemented parametric aliases. This pretty much allows the
4270 * Implemented parametric aliases. This pretty much allows the
4263 alias system to offer full-blown shell convenience, I think.
4271 alias system to offer full-blown shell convenience, I think.
4264
4272
4265 * Version 0.1.17 released, 0.1.18 opened.
4273 * Version 0.1.17 released, 0.1.18 opened.
4266
4274
4267 * dot_ipython/ipythonrc (alias): added documentation.
4275 * dot_ipython/ipythonrc (alias): added documentation.
4268 (xcolor): Fixed small bug (xcolors -> xcolor)
4276 (xcolor): Fixed small bug (xcolors -> xcolor)
4269
4277
4270 * Changed the alias system. Now alias is a magic command to define
4278 * Changed the alias system. Now alias is a magic command to define
4271 aliases just like the shell. Rationale: the builtin magics should
4279 aliases just like the shell. Rationale: the builtin magics should
4272 be there for things deeply connected to IPython's
4280 be there for things deeply connected to IPython's
4273 architecture. And this is a much lighter system for what I think
4281 architecture. And this is a much lighter system for what I think
4274 is the really important feature: allowing users to define quickly
4282 is the really important feature: allowing users to define quickly
4275 magics that will do shell things for them, so they can customize
4283 magics that will do shell things for them, so they can customize
4276 IPython easily to match their work habits. If someone is really
4284 IPython easily to match their work habits. If someone is really
4277 desperate to have another name for a builtin alias, they can
4285 desperate to have another name for a builtin alias, they can
4278 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4286 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4279 works.
4287 works.
4280
4288
4281 2001-11-28 Fernando Perez <fperez@colorado.edu>
4289 2001-11-28 Fernando Perez <fperez@colorado.edu>
4282
4290
4283 * Changed @file so that it opens the source file at the proper
4291 * Changed @file so that it opens the source file at the proper
4284 line. Since it uses less, if your EDITOR environment is
4292 line. Since it uses less, if your EDITOR environment is
4285 configured, typing v will immediately open your editor of choice
4293 configured, typing v will immediately open your editor of choice
4286 right at the line where the object is defined. Not as quick as
4294 right at the line where the object is defined. Not as quick as
4287 having a direct @edit command, but for all intents and purposes it
4295 having a direct @edit command, but for all intents and purposes it
4288 works. And I don't have to worry about writing @edit to deal with
4296 works. And I don't have to worry about writing @edit to deal with
4289 all the editors, less does that.
4297 all the editors, less does that.
4290
4298
4291 * Version 0.1.16 released, 0.1.17 opened.
4299 * Version 0.1.16 released, 0.1.17 opened.
4292
4300
4293 * Fixed some nasty bugs in the page/page_dumb combo that could
4301 * Fixed some nasty bugs in the page/page_dumb combo that could
4294 crash IPython.
4302 crash IPython.
4295
4303
4296 2001-11-27 Fernando Perez <fperez@colorado.edu>
4304 2001-11-27 Fernando Perez <fperez@colorado.edu>
4297
4305
4298 * Version 0.1.15 released, 0.1.16 opened.
4306 * Version 0.1.15 released, 0.1.16 opened.
4299
4307
4300 * Finally got ? and ?? to work for undefined things: now it's
4308 * Finally got ? and ?? to work for undefined things: now it's
4301 possible to type {}.get? and get information about the get method
4309 possible to type {}.get? and get information about the get method
4302 of dicts, or os.path? even if only os is defined (so technically
4310 of dicts, or os.path? even if only os is defined (so technically
4303 os.path isn't). Works at any level. For example, after import os,
4311 os.path isn't). Works at any level. For example, after import os,
4304 os?, os.path?, os.path.abspath? all work. This is great, took some
4312 os?, os.path?, os.path.abspath? all work. This is great, took some
4305 work in _ofind.
4313 work in _ofind.
4306
4314
4307 * Fixed more bugs with logging. The sanest way to do it was to add
4315 * Fixed more bugs with logging. The sanest way to do it was to add
4308 to @log a 'mode' parameter. Killed two in one shot (this mode
4316 to @log a 'mode' parameter. Killed two in one shot (this mode
4309 option was a request of Janko's). I think it's finally clean
4317 option was a request of Janko's). I think it's finally clean
4310 (famous last words).
4318 (famous last words).
4311
4319
4312 * Added a page_dumb() pager which does a decent job of paging on
4320 * Added a page_dumb() pager which does a decent job of paging on
4313 screen, if better things (like less) aren't available. One less
4321 screen, if better things (like less) aren't available. One less
4314 unix dependency (someday maybe somebody will port this to
4322 unix dependency (someday maybe somebody will port this to
4315 windows).
4323 windows).
4316
4324
4317 * Fixed problem in magic_log: would lock of logging out if log
4325 * Fixed problem in magic_log: would lock of logging out if log
4318 creation failed (because it would still think it had succeeded).
4326 creation failed (because it would still think it had succeeded).
4319
4327
4320 * Improved the page() function using curses to auto-detect screen
4328 * Improved the page() function using curses to auto-detect screen
4321 size. Now it can make a much better decision on whether to print
4329 size. Now it can make a much better decision on whether to print
4322 or page a string. Option screen_length was modified: a value 0
4330 or page a string. Option screen_length was modified: a value 0
4323 means auto-detect, and that's the default now.
4331 means auto-detect, and that's the default now.
4324
4332
4325 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4333 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4326 go out. I'll test it for a few days, then talk to Janko about
4334 go out. I'll test it for a few days, then talk to Janko about
4327 licences and announce it.
4335 licences and announce it.
4328
4336
4329 * Fixed the length of the auto-generated ---> prompt which appears
4337 * Fixed the length of the auto-generated ---> prompt which appears
4330 for auto-parens and auto-quotes. Getting this right isn't trivial,
4338 for auto-parens and auto-quotes. Getting this right isn't trivial,
4331 with all the color escapes, different prompt types and optional
4339 with all the color escapes, different prompt types and optional
4332 separators. But it seems to be working in all the combinations.
4340 separators. But it seems to be working in all the combinations.
4333
4341
4334 2001-11-26 Fernando Perez <fperez@colorado.edu>
4342 2001-11-26 Fernando Perez <fperez@colorado.edu>
4335
4343
4336 * Wrote a regexp filter to get option types from the option names
4344 * Wrote a regexp filter to get option types from the option names
4337 string. This eliminates the need to manually keep two duplicate
4345 string. This eliminates the need to manually keep two duplicate
4338 lists.
4346 lists.
4339
4347
4340 * Removed the unneeded check_option_names. Now options are handled
4348 * Removed the unneeded check_option_names. Now options are handled
4341 in a much saner manner and it's easy to visually check that things
4349 in a much saner manner and it's easy to visually check that things
4342 are ok.
4350 are ok.
4343
4351
4344 * Updated version numbers on all files I modified to carry a
4352 * Updated version numbers on all files I modified to carry a
4345 notice so Janko and Nathan have clear version markers.
4353 notice so Janko and Nathan have clear version markers.
4346
4354
4347 * Updated docstring for ultraTB with my changes. I should send
4355 * Updated docstring for ultraTB with my changes. I should send
4348 this to Nathan.
4356 this to Nathan.
4349
4357
4350 * Lots of small fixes. Ran everything through pychecker again.
4358 * Lots of small fixes. Ran everything through pychecker again.
4351
4359
4352 * Made loading of deep_reload an cmd line option. If it's not too
4360 * Made loading of deep_reload an cmd line option. If it's not too
4353 kosher, now people can just disable it. With -nodeep_reload it's
4361 kosher, now people can just disable it. With -nodeep_reload it's
4354 still available as dreload(), it just won't overwrite reload().
4362 still available as dreload(), it just won't overwrite reload().
4355
4363
4356 * Moved many options to the no| form (-opt and -noopt
4364 * Moved many options to the no| form (-opt and -noopt
4357 accepted). Cleaner.
4365 accepted). Cleaner.
4358
4366
4359 * Changed magic_log so that if called with no parameters, it uses
4367 * Changed magic_log so that if called with no parameters, it uses
4360 'rotate' mode. That way auto-generated logs aren't automatically
4368 'rotate' mode. That way auto-generated logs aren't automatically
4361 over-written. For normal logs, now a backup is made if it exists
4369 over-written. For normal logs, now a backup is made if it exists
4362 (only 1 level of backups). A new 'backup' mode was added to the
4370 (only 1 level of backups). A new 'backup' mode was added to the
4363 Logger class to support this. This was a request by Janko.
4371 Logger class to support this. This was a request by Janko.
4364
4372
4365 * Added @logoff/@logon to stop/restart an active log.
4373 * Added @logoff/@logon to stop/restart an active log.
4366
4374
4367 * Fixed a lot of bugs in log saving/replay. It was pretty
4375 * Fixed a lot of bugs in log saving/replay. It was pretty
4368 broken. Now special lines (!@,/) appear properly in the command
4376 broken. Now special lines (!@,/) appear properly in the command
4369 history after a log replay.
4377 history after a log replay.
4370
4378
4371 * Tried and failed to implement full session saving via pickle. My
4379 * Tried and failed to implement full session saving via pickle. My
4372 idea was to pickle __main__.__dict__, but modules can't be
4380 idea was to pickle __main__.__dict__, but modules can't be
4373 pickled. This would be a better alternative to replaying logs, but
4381 pickled. This would be a better alternative to replaying logs, but
4374 seems quite tricky to get to work. Changed -session to be called
4382 seems quite tricky to get to work. Changed -session to be called
4375 -logplay, which more accurately reflects what it does. And if we
4383 -logplay, which more accurately reflects what it does. And if we
4376 ever get real session saving working, -session is now available.
4384 ever get real session saving working, -session is now available.
4377
4385
4378 * Implemented color schemes for prompts also. As for tracebacks,
4386 * Implemented color schemes for prompts also. As for tracebacks,
4379 currently only NoColor and Linux are supported. But now the
4387 currently only NoColor and Linux are supported. But now the
4380 infrastructure is in place, based on a generic ColorScheme
4388 infrastructure is in place, based on a generic ColorScheme
4381 class. So writing and activating new schemes both for the prompts
4389 class. So writing and activating new schemes both for the prompts
4382 and the tracebacks should be straightforward.
4390 and the tracebacks should be straightforward.
4383
4391
4384 * Version 0.1.13 released, 0.1.14 opened.
4392 * Version 0.1.13 released, 0.1.14 opened.
4385
4393
4386 * Changed handling of options for output cache. Now counter is
4394 * Changed handling of options for output cache. Now counter is
4387 hardwired starting at 1 and one specifies the maximum number of
4395 hardwired starting at 1 and one specifies the maximum number of
4388 entries *in the outcache* (not the max prompt counter). This is
4396 entries *in the outcache* (not the max prompt counter). This is
4389 much better, since many statements won't increase the cache
4397 much better, since many statements won't increase the cache
4390 count. It also eliminated some confusing options, now there's only
4398 count. It also eliminated some confusing options, now there's only
4391 one: cache_size.
4399 one: cache_size.
4392
4400
4393 * Added 'alias' magic function and magic_alias option in the
4401 * Added 'alias' magic function and magic_alias option in the
4394 ipythonrc file. Now the user can easily define whatever names he
4402 ipythonrc file. Now the user can easily define whatever names he
4395 wants for the magic functions without having to play weird
4403 wants for the magic functions without having to play weird
4396 namespace games. This gives IPython a real shell-like feel.
4404 namespace games. This gives IPython a real shell-like feel.
4397
4405
4398 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4406 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4399 @ or not).
4407 @ or not).
4400
4408
4401 This was one of the last remaining 'visible' bugs (that I know
4409 This was one of the last remaining 'visible' bugs (that I know
4402 of). I think if I can clean up the session loading so it works
4410 of). I think if I can clean up the session loading so it works
4403 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4411 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4404 about licensing).
4412 about licensing).
4405
4413
4406 2001-11-25 Fernando Perez <fperez@colorado.edu>
4414 2001-11-25 Fernando Perez <fperez@colorado.edu>
4407
4415
4408 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4416 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4409 there's a cleaner distinction between what ? and ?? show.
4417 there's a cleaner distinction between what ? and ?? show.
4410
4418
4411 * Added screen_length option. Now the user can define his own
4419 * Added screen_length option. Now the user can define his own
4412 screen size for page() operations.
4420 screen size for page() operations.
4413
4421
4414 * Implemented magic shell-like functions with automatic code
4422 * Implemented magic shell-like functions with automatic code
4415 generation. Now adding another function is just a matter of adding
4423 generation. Now adding another function is just a matter of adding
4416 an entry to a dict, and the function is dynamically generated at
4424 an entry to a dict, and the function is dynamically generated at
4417 run-time. Python has some really cool features!
4425 run-time. Python has some really cool features!
4418
4426
4419 * Renamed many options to cleanup conventions a little. Now all
4427 * Renamed many options to cleanup conventions a little. Now all
4420 are lowercase, and only underscores where needed. Also in the code
4428 are lowercase, and only underscores where needed. Also in the code
4421 option name tables are clearer.
4429 option name tables are clearer.
4422
4430
4423 * Changed prompts a little. Now input is 'In [n]:' instead of
4431 * Changed prompts a little. Now input is 'In [n]:' instead of
4424 'In[n]:='. This allows it the numbers to be aligned with the
4432 'In[n]:='. This allows it the numbers to be aligned with the
4425 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4433 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4426 Python (it was a Mathematica thing). The '...' continuation prompt
4434 Python (it was a Mathematica thing). The '...' continuation prompt
4427 was also changed a little to align better.
4435 was also changed a little to align better.
4428
4436
4429 * Fixed bug when flushing output cache. Not all _p<n> variables
4437 * Fixed bug when flushing output cache. Not all _p<n> variables
4430 exist, so their deletion needs to be wrapped in a try:
4438 exist, so their deletion needs to be wrapped in a try:
4431
4439
4432 * Figured out how to properly use inspect.formatargspec() (it
4440 * Figured out how to properly use inspect.formatargspec() (it
4433 requires the args preceded by *). So I removed all the code from
4441 requires the args preceded by *). So I removed all the code from
4434 _get_pdef in Magic, which was just replicating that.
4442 _get_pdef in Magic, which was just replicating that.
4435
4443
4436 * Added test to prefilter to allow redefining magic function names
4444 * Added test to prefilter to allow redefining magic function names
4437 as variables. This is ok, since the @ form is always available,
4445 as variables. This is ok, since the @ form is always available,
4438 but whe should allow the user to define a variable called 'ls' if
4446 but whe should allow the user to define a variable called 'ls' if
4439 he needs it.
4447 he needs it.
4440
4448
4441 * Moved the ToDo information from README into a separate ToDo.
4449 * Moved the ToDo information from README into a separate ToDo.
4442
4450
4443 * General code cleanup and small bugfixes. I think it's close to a
4451 * General code cleanup and small bugfixes. I think it's close to a
4444 state where it can be released, obviously with a big 'beta'
4452 state where it can be released, obviously with a big 'beta'
4445 warning on it.
4453 warning on it.
4446
4454
4447 * Got the magic function split to work. Now all magics are defined
4455 * Got the magic function split to work. Now all magics are defined
4448 in a separate class. It just organizes things a bit, and now
4456 in a separate class. It just organizes things a bit, and now
4449 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4457 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4450 was too long).
4458 was too long).
4451
4459
4452 * Changed @clear to @reset to avoid potential confusions with
4460 * Changed @clear to @reset to avoid potential confusions with
4453 the shell command clear. Also renamed @cl to @clear, which does
4461 the shell command clear. Also renamed @cl to @clear, which does
4454 exactly what people expect it to from their shell experience.
4462 exactly what people expect it to from their shell experience.
4455
4463
4456 Added a check to the @reset command (since it's so
4464 Added a check to the @reset command (since it's so
4457 destructive, it's probably a good idea to ask for confirmation).
4465 destructive, it's probably a good idea to ask for confirmation).
4458 But now reset only works for full namespace resetting. Since the
4466 But now reset only works for full namespace resetting. Since the
4459 del keyword is already there for deleting a few specific
4467 del keyword is already there for deleting a few specific
4460 variables, I don't see the point of having a redundant magic
4468 variables, I don't see the point of having a redundant magic
4461 function for the same task.
4469 function for the same task.
4462
4470
4463 2001-11-24 Fernando Perez <fperez@colorado.edu>
4471 2001-11-24 Fernando Perez <fperez@colorado.edu>
4464
4472
4465 * Updated the builtin docs (esp. the ? ones).
4473 * Updated the builtin docs (esp. the ? ones).
4466
4474
4467 * Ran all the code through pychecker. Not terribly impressed with
4475 * Ran all the code through pychecker. Not terribly impressed with
4468 it: lots of spurious warnings and didn't really find anything of
4476 it: lots of spurious warnings and didn't really find anything of
4469 substance (just a few modules being imported and not used).
4477 substance (just a few modules being imported and not used).
4470
4478
4471 * Implemented the new ultraTB functionality into IPython. New
4479 * Implemented the new ultraTB functionality into IPython. New
4472 option: xcolors. This chooses color scheme. xmode now only selects
4480 option: xcolors. This chooses color scheme. xmode now only selects
4473 between Plain and Verbose. Better orthogonality.
4481 between Plain and Verbose. Better orthogonality.
4474
4482
4475 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4483 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4476 mode and color scheme for the exception handlers. Now it's
4484 mode and color scheme for the exception handlers. Now it's
4477 possible to have the verbose traceback with no coloring.
4485 possible to have the verbose traceback with no coloring.
4478
4486
4479 2001-11-23 Fernando Perez <fperez@colorado.edu>
4487 2001-11-23 Fernando Perez <fperez@colorado.edu>
4480
4488
4481 * Version 0.1.12 released, 0.1.13 opened.
4489 * Version 0.1.12 released, 0.1.13 opened.
4482
4490
4483 * Removed option to set auto-quote and auto-paren escapes by
4491 * Removed option to set auto-quote and auto-paren escapes by
4484 user. The chances of breaking valid syntax are just too high. If
4492 user. The chances of breaking valid syntax are just too high. If
4485 someone *really* wants, they can always dig into the code.
4493 someone *really* wants, they can always dig into the code.
4486
4494
4487 * Made prompt separators configurable.
4495 * Made prompt separators configurable.
4488
4496
4489 2001-11-22 Fernando Perez <fperez@colorado.edu>
4497 2001-11-22 Fernando Perez <fperez@colorado.edu>
4490
4498
4491 * Small bugfixes in many places.
4499 * Small bugfixes in many places.
4492
4500
4493 * Removed the MyCompleter class from ipplib. It seemed redundant
4501 * Removed the MyCompleter class from ipplib. It seemed redundant
4494 with the C-p,C-n history search functionality. Less code to
4502 with the C-p,C-n history search functionality. Less code to
4495 maintain.
4503 maintain.
4496
4504
4497 * Moved all the original ipython.py code into ipythonlib.py. Right
4505 * Moved all the original ipython.py code into ipythonlib.py. Right
4498 now it's just one big dump into a function called make_IPython, so
4506 now it's just one big dump into a function called make_IPython, so
4499 no real modularity has been gained. But at least it makes the
4507 no real modularity has been gained. But at least it makes the
4500 wrapper script tiny, and since ipythonlib is a module, it gets
4508 wrapper script tiny, and since ipythonlib is a module, it gets
4501 compiled and startup is much faster.
4509 compiled and startup is much faster.
4502
4510
4503 This is a reasobably 'deep' change, so we should test it for a
4511 This is a reasobably 'deep' change, so we should test it for a
4504 while without messing too much more with the code.
4512 while without messing too much more with the code.
4505
4513
4506 2001-11-21 Fernando Perez <fperez@colorado.edu>
4514 2001-11-21 Fernando Perez <fperez@colorado.edu>
4507
4515
4508 * Version 0.1.11 released, 0.1.12 opened for further work.
4516 * Version 0.1.11 released, 0.1.12 opened for further work.
4509
4517
4510 * Removed dependency on Itpl. It was only needed in one place. It
4518 * Removed dependency on Itpl. It was only needed in one place. It
4511 would be nice if this became part of python, though. It makes life
4519 would be nice if this became part of python, though. It makes life
4512 *a lot* easier in some cases.
4520 *a lot* easier in some cases.
4513
4521
4514 * Simplified the prefilter code a bit. Now all handlers are
4522 * Simplified the prefilter code a bit. Now all handlers are
4515 expected to explicitly return a value (at least a blank string).
4523 expected to explicitly return a value (at least a blank string).
4516
4524
4517 * Heavy edits in ipplib. Removed the help system altogether. Now
4525 * Heavy edits in ipplib. Removed the help system altogether. Now
4518 obj?/?? is used for inspecting objects, a magic @doc prints
4526 obj?/?? is used for inspecting objects, a magic @doc prints
4519 docstrings, and full-blown Python help is accessed via the 'help'
4527 docstrings, and full-blown Python help is accessed via the 'help'
4520 keyword. This cleans up a lot of code (less to maintain) and does
4528 keyword. This cleans up a lot of code (less to maintain) and does
4521 the job. Since 'help' is now a standard Python component, might as
4529 the job. Since 'help' is now a standard Python component, might as
4522 well use it and remove duplicate functionality.
4530 well use it and remove duplicate functionality.
4523
4531
4524 Also removed the option to use ipplib as a standalone program. By
4532 Also removed the option to use ipplib as a standalone program. By
4525 now it's too dependent on other parts of IPython to function alone.
4533 now it's too dependent on other parts of IPython to function alone.
4526
4534
4527 * Fixed bug in genutils.pager. It would crash if the pager was
4535 * Fixed bug in genutils.pager. It would crash if the pager was
4528 exited immediately after opening (broken pipe).
4536 exited immediately after opening (broken pipe).
4529
4537
4530 * Trimmed down the VerboseTB reporting a little. The header is
4538 * Trimmed down the VerboseTB reporting a little. The header is
4531 much shorter now and the repeated exception arguments at the end
4539 much shorter now and the repeated exception arguments at the end
4532 have been removed. For interactive use the old header seemed a bit
4540 have been removed. For interactive use the old header seemed a bit
4533 excessive.
4541 excessive.
4534
4542
4535 * Fixed small bug in output of @whos for variables with multi-word
4543 * Fixed small bug in output of @whos for variables with multi-word
4536 types (only first word was displayed).
4544 types (only first word was displayed).
4537
4545
4538 2001-11-17 Fernando Perez <fperez@colorado.edu>
4546 2001-11-17 Fernando Perez <fperez@colorado.edu>
4539
4547
4540 * Version 0.1.10 released, 0.1.11 opened for further work.
4548 * Version 0.1.10 released, 0.1.11 opened for further work.
4541
4549
4542 * Modified dirs and friends. dirs now *returns* the stack (not
4550 * Modified dirs and friends. dirs now *returns* the stack (not
4543 prints), so one can manipulate it as a variable. Convenient to
4551 prints), so one can manipulate it as a variable. Convenient to
4544 travel along many directories.
4552 travel along many directories.
4545
4553
4546 * Fixed bug in magic_pdef: would only work with functions with
4554 * Fixed bug in magic_pdef: would only work with functions with
4547 arguments with default values.
4555 arguments with default values.
4548
4556
4549 2001-11-14 Fernando Perez <fperez@colorado.edu>
4557 2001-11-14 Fernando Perez <fperez@colorado.edu>
4550
4558
4551 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4559 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4552 example with IPython. Various other minor fixes and cleanups.
4560 example with IPython. Various other minor fixes and cleanups.
4553
4561
4554 * Version 0.1.9 released, 0.1.10 opened for further work.
4562 * Version 0.1.9 released, 0.1.10 opened for further work.
4555
4563
4556 * Added sys.path to the list of directories searched in the
4564 * Added sys.path to the list of directories searched in the
4557 execfile= option. It used to be the current directory and the
4565 execfile= option. It used to be the current directory and the
4558 user's IPYTHONDIR only.
4566 user's IPYTHONDIR only.
4559
4567
4560 2001-11-13 Fernando Perez <fperez@colorado.edu>
4568 2001-11-13 Fernando Perez <fperez@colorado.edu>
4561
4569
4562 * Reinstated the raw_input/prefilter separation that Janko had
4570 * Reinstated the raw_input/prefilter separation that Janko had
4563 initially. This gives a more convenient setup for extending the
4571 initially. This gives a more convenient setup for extending the
4564 pre-processor from the outside: raw_input always gets a string,
4572 pre-processor from the outside: raw_input always gets a string,
4565 and prefilter has to process it. We can then redefine prefilter
4573 and prefilter has to process it. We can then redefine prefilter
4566 from the outside and implement extensions for special
4574 from the outside and implement extensions for special
4567 purposes.
4575 purposes.
4568
4576
4569 Today I got one for inputting PhysicalQuantity objects
4577 Today I got one for inputting PhysicalQuantity objects
4570 (from Scientific) without needing any function calls at
4578 (from Scientific) without needing any function calls at
4571 all. Extremely convenient, and it's all done as a user-level
4579 all. Extremely convenient, and it's all done as a user-level
4572 extension (no IPython code was touched). Now instead of:
4580 extension (no IPython code was touched). Now instead of:
4573 a = PhysicalQuantity(4.2,'m/s**2')
4581 a = PhysicalQuantity(4.2,'m/s**2')
4574 one can simply say
4582 one can simply say
4575 a = 4.2 m/s**2
4583 a = 4.2 m/s**2
4576 or even
4584 or even
4577 a = 4.2 m/s^2
4585 a = 4.2 m/s^2
4578
4586
4579 I use this, but it's also a proof of concept: IPython really is
4587 I use this, but it's also a proof of concept: IPython really is
4580 fully user-extensible, even at the level of the parsing of the
4588 fully user-extensible, even at the level of the parsing of the
4581 command line. It's not trivial, but it's perfectly doable.
4589 command line. It's not trivial, but it's perfectly doable.
4582
4590
4583 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4591 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4584 the problem of modules being loaded in the inverse order in which
4592 the problem of modules being loaded in the inverse order in which
4585 they were defined in
4593 they were defined in
4586
4594
4587 * Version 0.1.8 released, 0.1.9 opened for further work.
4595 * Version 0.1.8 released, 0.1.9 opened for further work.
4588
4596
4589 * Added magics pdef, source and file. They respectively show the
4597 * Added magics pdef, source and file. They respectively show the
4590 definition line ('prototype' in C), source code and full python
4598 definition line ('prototype' in C), source code and full python
4591 file for any callable object. The object inspector oinfo uses
4599 file for any callable object. The object inspector oinfo uses
4592 these to show the same information.
4600 these to show the same information.
4593
4601
4594 * Version 0.1.7 released, 0.1.8 opened for further work.
4602 * Version 0.1.7 released, 0.1.8 opened for further work.
4595
4603
4596 * Separated all the magic functions into a class called Magic. The
4604 * Separated all the magic functions into a class called Magic. The
4597 InteractiveShell class was becoming too big for Xemacs to handle
4605 InteractiveShell class was becoming too big for Xemacs to handle
4598 (de-indenting a line would lock it up for 10 seconds while it
4606 (de-indenting a line would lock it up for 10 seconds while it
4599 backtracked on the whole class!)
4607 backtracked on the whole class!)
4600
4608
4601 FIXME: didn't work. It can be done, but right now namespaces are
4609 FIXME: didn't work. It can be done, but right now namespaces are
4602 all messed up. Do it later (reverted it for now, so at least
4610 all messed up. Do it later (reverted it for now, so at least
4603 everything works as before).
4611 everything works as before).
4604
4612
4605 * Got the object introspection system (magic_oinfo) working! I
4613 * Got the object introspection system (magic_oinfo) working! I
4606 think this is pretty much ready for release to Janko, so he can
4614 think this is pretty much ready for release to Janko, so he can
4607 test it for a while and then announce it. Pretty much 100% of what
4615 test it for a while and then announce it. Pretty much 100% of what
4608 I wanted for the 'phase 1' release is ready. Happy, tired.
4616 I wanted for the 'phase 1' release is ready. Happy, tired.
4609
4617
4610 2001-11-12 Fernando Perez <fperez@colorado.edu>
4618 2001-11-12 Fernando Perez <fperez@colorado.edu>
4611
4619
4612 * Version 0.1.6 released, 0.1.7 opened for further work.
4620 * Version 0.1.6 released, 0.1.7 opened for further work.
4613
4621
4614 * Fixed bug in printing: it used to test for truth before
4622 * Fixed bug in printing: it used to test for truth before
4615 printing, so 0 wouldn't print. Now checks for None.
4623 printing, so 0 wouldn't print. Now checks for None.
4616
4624
4617 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4625 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4618 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4626 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4619 reaches by hand into the outputcache. Think of a better way to do
4627 reaches by hand into the outputcache. Think of a better way to do
4620 this later.
4628 this later.
4621
4629
4622 * Various small fixes thanks to Nathan's comments.
4630 * Various small fixes thanks to Nathan's comments.
4623
4631
4624 * Changed magic_pprint to magic_Pprint. This way it doesn't
4632 * Changed magic_pprint to magic_Pprint. This way it doesn't
4625 collide with pprint() and the name is consistent with the command
4633 collide with pprint() and the name is consistent with the command
4626 line option.
4634 line option.
4627
4635
4628 * Changed prompt counter behavior to be fully like
4636 * Changed prompt counter behavior to be fully like
4629 Mathematica's. That is, even input that doesn't return a result
4637 Mathematica's. That is, even input that doesn't return a result
4630 raises the prompt counter. The old behavior was kind of confusing
4638 raises the prompt counter. The old behavior was kind of confusing
4631 (getting the same prompt number several times if the operation
4639 (getting the same prompt number several times if the operation
4632 didn't return a result).
4640 didn't return a result).
4633
4641
4634 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4642 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4635
4643
4636 * Fixed -Classic mode (wasn't working anymore).
4644 * Fixed -Classic mode (wasn't working anymore).
4637
4645
4638 * Added colored prompts using Nathan's new code. Colors are
4646 * Added colored prompts using Nathan's new code. Colors are
4639 currently hardwired, they can be user-configurable. For
4647 currently hardwired, they can be user-configurable. For
4640 developers, they can be chosen in file ipythonlib.py, at the
4648 developers, they can be chosen in file ipythonlib.py, at the
4641 beginning of the CachedOutput class def.
4649 beginning of the CachedOutput class def.
4642
4650
4643 2001-11-11 Fernando Perez <fperez@colorado.edu>
4651 2001-11-11 Fernando Perez <fperez@colorado.edu>
4644
4652
4645 * Version 0.1.5 released, 0.1.6 opened for further work.
4653 * Version 0.1.5 released, 0.1.6 opened for further work.
4646
4654
4647 * Changed magic_env to *return* the environment as a dict (not to
4655 * Changed magic_env to *return* the environment as a dict (not to
4648 print it). This way it prints, but it can also be processed.
4656 print it). This way it prints, but it can also be processed.
4649
4657
4650 * Added Verbose exception reporting to interactive
4658 * Added Verbose exception reporting to interactive
4651 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4659 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4652 traceback. Had to make some changes to the ultraTB file. This is
4660 traceback. Had to make some changes to the ultraTB file. This is
4653 probably the last 'big' thing in my mental todo list. This ties
4661 probably the last 'big' thing in my mental todo list. This ties
4654 in with the next entry:
4662 in with the next entry:
4655
4663
4656 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4664 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4657 has to specify is Plain, Color or Verbose for all exception
4665 has to specify is Plain, Color or Verbose for all exception
4658 handling.
4666 handling.
4659
4667
4660 * Removed ShellServices option. All this can really be done via
4668 * Removed ShellServices option. All this can really be done via
4661 the magic system. It's easier to extend, cleaner and has automatic
4669 the magic system. It's easier to extend, cleaner and has automatic
4662 namespace protection and documentation.
4670 namespace protection and documentation.
4663
4671
4664 2001-11-09 Fernando Perez <fperez@colorado.edu>
4672 2001-11-09 Fernando Perez <fperez@colorado.edu>
4665
4673
4666 * Fixed bug in output cache flushing (missing parameter to
4674 * Fixed bug in output cache flushing (missing parameter to
4667 __init__). Other small bugs fixed (found using pychecker).
4675 __init__). Other small bugs fixed (found using pychecker).
4668
4676
4669 * Version 0.1.4 opened for bugfixing.
4677 * Version 0.1.4 opened for bugfixing.
4670
4678
4671 2001-11-07 Fernando Perez <fperez@colorado.edu>
4679 2001-11-07 Fernando Perez <fperez@colorado.edu>
4672
4680
4673 * Version 0.1.3 released, mainly because of the raw_input bug.
4681 * Version 0.1.3 released, mainly because of the raw_input bug.
4674
4682
4675 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4683 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4676 and when testing for whether things were callable, a call could
4684 and when testing for whether things were callable, a call could
4677 actually be made to certain functions. They would get called again
4685 actually be made to certain functions. They would get called again
4678 once 'really' executed, with a resulting double call. A disaster
4686 once 'really' executed, with a resulting double call. A disaster
4679 in many cases (list.reverse() would never work!).
4687 in many cases (list.reverse() would never work!).
4680
4688
4681 * Removed prefilter() function, moved its code to raw_input (which
4689 * Removed prefilter() function, moved its code to raw_input (which
4682 after all was just a near-empty caller for prefilter). This saves
4690 after all was just a near-empty caller for prefilter). This saves
4683 a function call on every prompt, and simplifies the class a tiny bit.
4691 a function call on every prompt, and simplifies the class a tiny bit.
4684
4692
4685 * Fix _ip to __ip name in magic example file.
4693 * Fix _ip to __ip name in magic example file.
4686
4694
4687 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4695 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4688 work with non-gnu versions of tar.
4696 work with non-gnu versions of tar.
4689
4697
4690 2001-11-06 Fernando Perez <fperez@colorado.edu>
4698 2001-11-06 Fernando Perez <fperez@colorado.edu>
4691
4699
4692 * Version 0.1.2. Just to keep track of the recent changes.
4700 * Version 0.1.2. Just to keep track of the recent changes.
4693
4701
4694 * Fixed nasty bug in output prompt routine. It used to check 'if
4702 * Fixed nasty bug in output prompt routine. It used to check 'if
4695 arg != None...'. Problem is, this fails if arg implements a
4703 arg != None...'. Problem is, this fails if arg implements a
4696 special comparison (__cmp__) which disallows comparing to
4704 special comparison (__cmp__) which disallows comparing to
4697 None. Found it when trying to use the PhysicalQuantity module from
4705 None. Found it when trying to use the PhysicalQuantity module from
4698 ScientificPython.
4706 ScientificPython.
4699
4707
4700 2001-11-05 Fernando Perez <fperez@colorado.edu>
4708 2001-11-05 Fernando Perez <fperez@colorado.edu>
4701
4709
4702 * Also added dirs. Now the pushd/popd/dirs family functions
4710 * Also added dirs. Now the pushd/popd/dirs family functions
4703 basically like the shell, with the added convenience of going home
4711 basically like the shell, with the added convenience of going home
4704 when called with no args.
4712 when called with no args.
4705
4713
4706 * pushd/popd slightly modified to mimic shell behavior more
4714 * pushd/popd slightly modified to mimic shell behavior more
4707 closely.
4715 closely.
4708
4716
4709 * Added env,pushd,popd from ShellServices as magic functions. I
4717 * Added env,pushd,popd from ShellServices as magic functions. I
4710 think the cleanest will be to port all desired functions from
4718 think the cleanest will be to port all desired functions from
4711 ShellServices as magics and remove ShellServices altogether. This
4719 ShellServices as magics and remove ShellServices altogether. This
4712 will provide a single, clean way of adding functionality
4720 will provide a single, clean way of adding functionality
4713 (shell-type or otherwise) to IP.
4721 (shell-type or otherwise) to IP.
4714
4722
4715 2001-11-04 Fernando Perez <fperez@colorado.edu>
4723 2001-11-04 Fernando Perez <fperez@colorado.edu>
4716
4724
4717 * Added .ipython/ directory to sys.path. This way users can keep
4725 * Added .ipython/ directory to sys.path. This way users can keep
4718 customizations there and access them via import.
4726 customizations there and access them via import.
4719
4727
4720 2001-11-03 Fernando Perez <fperez@colorado.edu>
4728 2001-11-03 Fernando Perez <fperez@colorado.edu>
4721
4729
4722 * Opened version 0.1.1 for new changes.
4730 * Opened version 0.1.1 for new changes.
4723
4731
4724 * Changed version number to 0.1.0: first 'public' release, sent to
4732 * Changed version number to 0.1.0: first 'public' release, sent to
4725 Nathan and Janko.
4733 Nathan and Janko.
4726
4734
4727 * Lots of small fixes and tweaks.
4735 * Lots of small fixes and tweaks.
4728
4736
4729 * Minor changes to whos format. Now strings are shown, snipped if
4737 * Minor changes to whos format. Now strings are shown, snipped if
4730 too long.
4738 too long.
4731
4739
4732 * Changed ShellServices to work on __main__ so they show up in @who
4740 * Changed ShellServices to work on __main__ so they show up in @who
4733
4741
4734 * Help also works with ? at the end of a line:
4742 * Help also works with ? at the end of a line:
4735 ?sin and sin?
4743 ?sin and sin?
4736 both produce the same effect. This is nice, as often I use the
4744 both produce the same effect. This is nice, as often I use the
4737 tab-complete to find the name of a method, but I used to then have
4745 tab-complete to find the name of a method, but I used to then have
4738 to go to the beginning of the line to put a ? if I wanted more
4746 to go to the beginning of the line to put a ? if I wanted more
4739 info. Now I can just add the ? and hit return. Convenient.
4747 info. Now I can just add the ? and hit return. Convenient.
4740
4748
4741 2001-11-02 Fernando Perez <fperez@colorado.edu>
4749 2001-11-02 Fernando Perez <fperez@colorado.edu>
4742
4750
4743 * Python version check (>=2.1) added.
4751 * Python version check (>=2.1) added.
4744
4752
4745 * Added LazyPython documentation. At this point the docs are quite
4753 * Added LazyPython documentation. At this point the docs are quite
4746 a mess. A cleanup is in order.
4754 a mess. A cleanup is in order.
4747
4755
4748 * Auto-installer created. For some bizarre reason, the zipfiles
4756 * Auto-installer created. For some bizarre reason, the zipfiles
4749 module isn't working on my system. So I made a tar version
4757 module isn't working on my system. So I made a tar version
4750 (hopefully the command line options in various systems won't kill
4758 (hopefully the command line options in various systems won't kill
4751 me).
4759 me).
4752
4760
4753 * Fixes to Struct in genutils. Now all dictionary-like methods are
4761 * Fixes to Struct in genutils. Now all dictionary-like methods are
4754 protected (reasonably).
4762 protected (reasonably).
4755
4763
4756 * Added pager function to genutils and changed ? to print usage
4764 * Added pager function to genutils and changed ? to print usage
4757 note through it (it was too long).
4765 note through it (it was too long).
4758
4766
4759 * Added the LazyPython functionality. Works great! I changed the
4767 * Added the LazyPython functionality. Works great! I changed the
4760 auto-quote escape to ';', it's on home row and next to '. But
4768 auto-quote escape to ';', it's on home row and next to '. But
4761 both auto-quote and auto-paren (still /) escapes are command-line
4769 both auto-quote and auto-paren (still /) escapes are command-line
4762 parameters.
4770 parameters.
4763
4771
4764
4772
4765 2001-11-01 Fernando Perez <fperez@colorado.edu>
4773 2001-11-01 Fernando Perez <fperez@colorado.edu>
4766
4774
4767 * Version changed to 0.0.7. Fairly large change: configuration now
4775 * Version changed to 0.0.7. Fairly large change: configuration now
4768 is all stored in a directory, by default .ipython. There, all
4776 is all stored in a directory, by default .ipython. There, all
4769 config files have normal looking names (not .names)
4777 config files have normal looking names (not .names)
4770
4778
4771 * Version 0.0.6 Released first to Lucas and Archie as a test
4779 * Version 0.0.6 Released first to Lucas and Archie as a test
4772 run. Since it's the first 'semi-public' release, change version to
4780 run. Since it's the first 'semi-public' release, change version to
4773 > 0.0.6 for any changes now.
4781 > 0.0.6 for any changes now.
4774
4782
4775 * Stuff I had put in the ipplib.py changelog:
4783 * Stuff I had put in the ipplib.py changelog:
4776
4784
4777 Changes to InteractiveShell:
4785 Changes to InteractiveShell:
4778
4786
4779 - Made the usage message a parameter.
4787 - Made the usage message a parameter.
4780
4788
4781 - Require the name of the shell variable to be given. It's a bit
4789 - Require the name of the shell variable to be given. It's a bit
4782 of a hack, but allows the name 'shell' not to be hardwire in the
4790 of a hack, but allows the name 'shell' not to be hardwire in the
4783 magic (@) handler, which is problematic b/c it requires
4791 magic (@) handler, which is problematic b/c it requires
4784 polluting the global namespace with 'shell'. This in turn is
4792 polluting the global namespace with 'shell'. This in turn is
4785 fragile: if a user redefines a variable called shell, things
4793 fragile: if a user redefines a variable called shell, things
4786 break.
4794 break.
4787
4795
4788 - magic @: all functions available through @ need to be defined
4796 - magic @: all functions available through @ need to be defined
4789 as magic_<name>, even though they can be called simply as
4797 as magic_<name>, even though they can be called simply as
4790 @<name>. This allows the special command @magic to gather
4798 @<name>. This allows the special command @magic to gather
4791 information automatically about all existing magic functions,
4799 information automatically about all existing magic functions,
4792 even if they are run-time user extensions, by parsing the shell
4800 even if they are run-time user extensions, by parsing the shell
4793 instance __dict__ looking for special magic_ names.
4801 instance __dict__ looking for special magic_ names.
4794
4802
4795 - mainloop: added *two* local namespace parameters. This allows
4803 - mainloop: added *two* local namespace parameters. This allows
4796 the class to differentiate between parameters which were there
4804 the class to differentiate between parameters which were there
4797 before and after command line initialization was processed. This
4805 before and after command line initialization was processed. This
4798 way, later @who can show things loaded at startup by the
4806 way, later @who can show things loaded at startup by the
4799 user. This trick was necessary to make session saving/reloading
4807 user. This trick was necessary to make session saving/reloading
4800 really work: ideally after saving/exiting/reloading a session,
4808 really work: ideally after saving/exiting/reloading a session,
4801 *everythin* should look the same, including the output of @who. I
4809 *everythin* should look the same, including the output of @who. I
4802 was only able to make this work with this double namespace
4810 was only able to make this work with this double namespace
4803 trick.
4811 trick.
4804
4812
4805 - added a header to the logfile which allows (almost) full
4813 - added a header to the logfile which allows (almost) full
4806 session restoring.
4814 session restoring.
4807
4815
4808 - prepend lines beginning with @ or !, with a and log
4816 - prepend lines beginning with @ or !, with a and log
4809 them. Why? !lines: may be useful to know what you did @lines:
4817 them. Why? !lines: may be useful to know what you did @lines:
4810 they may affect session state. So when restoring a session, at
4818 they may affect session state. So when restoring a session, at
4811 least inform the user of their presence. I couldn't quite get
4819 least inform the user of their presence. I couldn't quite get
4812 them to properly re-execute, but at least the user is warned.
4820 them to properly re-execute, but at least the user is warned.
4813
4821
4814 * Started ChangeLog.
4822 * Started ChangeLog.
@@ -1,9376 +1,9373 b''
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 221
2 \lyxformat 221
3 \textclass article
3 \textclass article
4 \begin_preamble
4 \begin_preamble
5 %\usepackage{ae,aecompl}
5 %\usepackage{ae,aecompl}
6 \usepackage{color}
6 \usepackage{color}
7
7
8 % A few colors to replace the defaults for certain link types
8 % A few colors to replace the defaults for certain link types
9 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
9 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
10 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
10 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
11 \definecolor{darkred}{rgb}{.52,0.08,0.01}
11 \definecolor{darkred}{rgb}{.52,0.08,0.01}
12 \definecolor{darkgreen}{rgb}{.12,.54,.11}
12 \definecolor{darkgreen}{rgb}{.12,.54,.11}
13
13
14 % Use and configure listings package for nicely formatted code
14 % Use and configure listings package for nicely formatted code
15 \usepackage{listings}
15 \usepackage{listings}
16 \lstset{
16 \lstset{
17 language=Python,
17 language=Python,
18 basicstyle=\small\ttfamily,
18 basicstyle=\small\ttfamily,
19 commentstyle=\ttfamily\color{blue},
19 commentstyle=\ttfamily\color{blue},
20 stringstyle=\ttfamily\color{darkorange},
20 stringstyle=\ttfamily\color{darkorange},
21 showstringspaces=false,
21 showstringspaces=false,
22 breaklines=true,
22 breaklines=true,
23 postbreak = \space\dots
23 postbreak = \space\dots
24 }
24 }
25
25
26 \usepackage[%pdftex, % needed for pdflatex
26 \usepackage[%pdftex, % needed for pdflatex
27 breaklinks=true, % so long urls are correctly broken across lines
27 breaklinks=true, % so long urls are correctly broken across lines
28 colorlinks=true,
28 colorlinks=true,
29 urlcolor=blue,
29 urlcolor=blue,
30 linkcolor=darkred,
30 linkcolor=darkred,
31 citecolor=darkgreen,
31 citecolor=darkgreen,
32 ]{hyperref}
32 ]{hyperref}
33
33
34 \usepackage{html}
34 \usepackage{html}
35
35
36 % This helps prevent overly long lines that stretch beyond the margins
36 % This helps prevent overly long lines that stretch beyond the margins
37 \sloppy
37 \sloppy
38
38
39 % Define a \codelist command which either uses listings for latex, or
39 % Define a \codelist command which either uses listings for latex, or
40 % plain verbatim for html (since latex2html doesn't understand the
40 % plain verbatim for html (since latex2html doesn't understand the
41 % listings package).
41 % listings package).
42 \usepackage{verbatim}
42 \usepackage{verbatim}
43 \newcommand{\codelist}[1] {
43 \newcommand{\codelist}[1] {
44 \latex{\lstinputlisting{#1}}
44 \latex{\lstinputlisting{#1}}
45 \html{\verbatiminput{#1}}
45 \html{\verbatiminput{#1}}
46 }
46 }
47 \end_preamble
47 \end_preamble
48 \language english
48 \language english
49 \inputencoding latin1
49 \inputencoding latin1
50 \fontscheme palatino
50 \fontscheme palatino
51 \graphics default
51 \graphics default
52 \paperfontsize 11
52 \paperfontsize 11
53 \spacing single
53 \spacing single
54 \papersize Default
54 \papersize Default
55 \paperpackage a4
55 \paperpackage a4
56 \use_geometry 1
56 \use_geometry 1
57 \use_amsmath 0
57 \use_amsmath 0
58 \use_natbib 0
58 \use_natbib 0
59 \use_numerical_citations 0
59 \use_numerical_citations 0
60 \paperorientation portrait
60 \paperorientation portrait
61 \leftmargin 1in
61 \leftmargin 1in
62 \topmargin 1in
62 \topmargin 1in
63 \rightmargin 1in
63 \rightmargin 1in
64 \bottommargin 1in
64 \bottommargin 1in
65 \secnumdepth 3
65 \secnumdepth 3
66 \tocdepth 3
66 \tocdepth 3
67 \paragraph_separation skip
67 \paragraph_separation skip
68 \defskip medskip
68 \defskip medskip
69 \quotes_language english
69 \quotes_language english
70 \quotes_times 2
70 \quotes_times 2
71 \papercolumns 1
71 \papercolumns 1
72 \papersides 1
72 \papersides 1
73 \paperpagestyle fancy
73 \paperpagestyle fancy
74
74
75 \layout Title
75 \layout Title
76
76
77 IPython
77 IPython
78 \newline
78 \newline
79
79
80 \size larger
80 \size larger
81 An enhanced Interactive Python
81 An enhanced Interactive Python
82 \size large
82 \size large
83
83
84 \newline
84 \newline
85 User Manual, v.
85 User Manual, v.
86 __version__
86 __version__
87 \layout Author
87 \layout Author
88
88
89 Fernando PοΏ½rez
89 Fernando PοΏ½rez
90 \layout Standard
90 \layout Standard
91
91
92
92
93 \begin_inset ERT
93 \begin_inset ERT
94 status Collapsed
94 status Collapsed
95
95
96 \layout Standard
96 \layout Standard
97
97
98 \backslash
98 \backslash
99 latex{
99 latex{
100 \end_inset
100 \end_inset
101
101
102
102
103 \begin_inset LatexCommand \tableofcontents{}
103 \begin_inset LatexCommand \tableofcontents{}
104
104
105 \end_inset
105 \end_inset
106
106
107
107
108 \begin_inset ERT
108 \begin_inset ERT
109 status Collapsed
109 status Collapsed
110
110
111 \layout Standard
111 \layout Standard
112 }
112 }
113 \end_inset
113 \end_inset
114
114
115
115
116 \layout Standard
116 \layout Standard
117
117
118
118
119 \begin_inset ERT
119 \begin_inset ERT
120 status Open
120 status Open
121
121
122 \layout Standard
122 \layout Standard
123
123
124 \backslash
124 \backslash
125 html{
125 html{
126 \backslash
126 \backslash
127 bodytext{bgcolor=#ffffff}}
127 bodytext{bgcolor=#ffffff}}
128 \end_inset
128 \end_inset
129
129
130
130
131 \layout Section
131 \layout Section
132 \pagebreak_top
132 \pagebreak_top
133 Overview
133 Overview
134 \layout Standard
134 \layout Standard
135
135
136 One of Python's most useful features is its interactive interpreter.
136 One of Python's most useful features is its interactive interpreter.
137 This system allows very fast testing of ideas without the overhead of creating
137 This system allows very fast testing of ideas without the overhead of creating
138 test files as is typical in most programming languages.
138 test files as is typical in most programming languages.
139 However, the interpreter supplied with the standard Python distribution
139 However, the interpreter supplied with the standard Python distribution
140 is somewhat limited for extended interactive use.
140 is somewhat limited for extended interactive use.
141 \layout Standard
141 \layout Standard
142
142
143 IPython is a free software project (released under the BSD license) which
143 IPython is a free software project (released under the BSD license) which
144 tries to:
144 tries to:
145 \layout Enumerate
145 \layout Enumerate
146
146
147 Provide an interactive shell superior to Python's default.
147 Provide an interactive shell superior to Python's default.
148 IPython has many features for object introspection, system shell access,
148 IPython has many features for object introspection, system shell access,
149 and its own special command system for adding functionality when working
149 and its own special command system for adding functionality when working
150 interactively.
150 interactively.
151 It tries to be a very efficient environment both for Python code development
151 It tries to be a very efficient environment both for Python code development
152 and for exploration of problems using Python objects (in situations like
152 and for exploration of problems using Python objects (in situations like
153 data analysis).
153 data analysis).
154 \layout Enumerate
154 \layout Enumerate
155
155
156 Serve as an embeddable, ready to use interpreter for your own programs.
156 Serve as an embeddable, ready to use interpreter for your own programs.
157 IPython can be started with a single call from inside another program,
157 IPython can be started with a single call from inside another program,
158 providing access to the current namespace.
158 providing access to the current namespace.
159 This can be very useful both for debugging purposes and for situations
159 This can be very useful both for debugging purposes and for situations
160 where a blend of batch-processing and interactive exploration are needed.
160 where a blend of batch-processing and interactive exploration are needed.
161 \layout Enumerate
161 \layout Enumerate
162
162
163 Offer a flexible framework which can be used as the base environment for
163 Offer a flexible framework which can be used as the base environment for
164 other systems with Python as the underlying language.
164 other systems with Python as the underlying language.
165 Specifically scientific environments like Mathematica, IDL and Matlab inspired
165 Specifically scientific environments like Mathematica, IDL and Matlab inspired
166 its design, but similar ideas can be useful in many fields.
166 its design, but similar ideas can be useful in many fields.
167 \layout Enumerate
167 \layout Enumerate
168
168
169 Allow interactive testing of threaded graphical toolkits.
169 Allow interactive testing of threaded graphical toolkits.
170 IPython has support for interactive, non-blocking control of GTK, Qt and
170 IPython has support for interactive, non-blocking control of GTK, Qt and
171 WX applications via special threading flags.
171 WX applications via special threading flags.
172 The normal Python shell can only do this for Tkinter applications.
172 The normal Python shell can only do this for Tkinter applications.
173 \layout Subsection
173 \layout Subsection
174
174
175 Main features
175 Main features
176 \layout Itemize
176 \layout Itemize
177
177
178 Dynamic object introspection.
178 Dynamic object introspection.
179 One can access docstrings, function definition prototypes, source code,
179 One can access docstrings, function definition prototypes, source code,
180 source files and other details of any object accessible to the interpreter
180 source files and other details of any object accessible to the interpreter
181 with a single keystroke (`
181 with a single keystroke (`
182 \family typewriter
182 \family typewriter
183 ?
183 ?
184 \family default
184 \family default
185 ', and using `
185 ', and using `
186 \family typewriter
186 \family typewriter
187 ??
187 ??
188 \family default
188 \family default
189 ' provides additional detail).
189 ' provides additional detail).
190 \layout Itemize
190 \layout Itemize
191
191
192 Searching through modules and namespaces with `
192 Searching through modules and namespaces with `
193 \family typewriter
193 \family typewriter
194 *
194 *
195 \family default
195 \family default
196 ' wildcards, both when using the `
196 ' wildcards, both when using the `
197 \family typewriter
197 \family typewriter
198 ?
198 ?
199 \family default
199 \family default
200 ' system and via the
200 ' system and via the
201 \family typewriter
201 \family typewriter
202 %psearch
202 %psearch
203 \family default
203 \family default
204 command.
204 command.
205 \layout Itemize
205 \layout Itemize
206
206
207 Completion in the local namespace, by typing TAB at the prompt.
207 Completion in the local namespace, by typing TAB at the prompt.
208 This works for keywords, methods, variables and files in the current directory.
208 This works for keywords, methods, variables and files in the current directory.
209 This is supported via the readline library, and full access to configuring
209 This is supported via the readline library, and full access to configuring
210 readline's behavior is provided.
210 readline's behavior is provided.
211 \layout Itemize
211 \layout Itemize
212
212
213 Numbered input/output prompts with command history (persistent across sessions
213 Numbered input/output prompts with command history (persistent across sessions
214 and tied to each profile), full searching in this history and caching of
214 and tied to each profile), full searching in this history and caching of
215 all input and output.
215 all input and output.
216 \layout Itemize
216 \layout Itemize
217
217
218 User-extensible `magic' commands.
218 User-extensible `magic' commands.
219 A set of commands prefixed with
219 A set of commands prefixed with
220 \family typewriter
220 \family typewriter
221 %
221 %
222 \family default
222 \family default
223 is available for controlling IPython itself and provides directory control,
223 is available for controlling IPython itself and provides directory control,
224 namespace information and many aliases to common system shell commands.
224 namespace information and many aliases to common system shell commands.
225 \layout Itemize
225 \layout Itemize
226
226
227 Alias facility for defining your own system aliases.
227 Alias facility for defining your own system aliases.
228 \layout Itemize
228 \layout Itemize
229
229
230 Complete system shell access.
230 Complete system shell access.
231 Lines starting with ! are passed directly to the system shell, and using
231 Lines starting with ! are passed directly to the system shell, and using
232 !! captures shell output into python variables for further use.
232 !! captures shell output into python variables for further use.
233 \layout Itemize
233 \layout Itemize
234
234
235 Background execution of Python commands in a separate thread.
235 Background execution of Python commands in a separate thread.
236 IPython has an internal job manager called
236 IPython has an internal job manager called
237 \family typewriter
237 \family typewriter
238 jobs
238 jobs
239 \family default
239 \family default
240 , and a conveninence backgrounding magic function called
240 , and a conveninence backgrounding magic function called
241 \family typewriter
241 \family typewriter
242 %bg
242 %bg
243 \family default
243 \family default
244 .
244 .
245 \layout Itemize
245 \layout Itemize
246
246
247 The ability to expand python variables when calling the system shell.
247 The ability to expand python variables when calling the system shell.
248 In a shell command, any python variable prefixed with
248 In a shell command, any python variable prefixed with
249 \family typewriter
249 \family typewriter
250 $
250 $
251 \family default
251 \family default
252 is expanded.
252 is expanded.
253 A double
253 A double
254 \family typewriter
254 \family typewriter
255 $$
255 $$
256 \family default
256 \family default
257 allows passing a literal
257 allows passing a literal
258 \family typewriter
258 \family typewriter
259 $
259 $
260 \family default
260 \family default
261 to the shell (for access to shell and environment variables like
261 to the shell (for access to shell and environment variables like
262 \family typewriter
262 \family typewriter
263 $PATH
263 $PATH
264 \family default
264 \family default
265 ).
265 ).
266 \layout Itemize
266 \layout Itemize
267
267
268 Filesystem navigation, via a magic
268 Filesystem navigation, via a magic
269 \family typewriter
269 \family typewriter
270 %cd
270 %cd
271 \family default
271 \family default
272 command, along with a persistent bookmark system (using
272 command, along with a persistent bookmark system (using
273 \family typewriter
273 \family typewriter
274 %bookmark
274 %bookmark
275 \family default
275 \family default
276 ) for fast access to frequently visited directories.
276 ) for fast access to frequently visited directories.
277 \layout Itemize
277 \layout Itemize
278
278
279 A lightweight persistence framework via the
279 A lightweight persistence framework via the
280 \family typewriter
280 \family typewriter
281 %store
281 %store
282 \family default
282 \family default
283 command, which allows you to save arbitrary Python variables.
283 command, which allows you to save arbitrary Python variables.
284 These get restored automatically when your session restarts.
284 These get restored automatically when your session restarts.
285 \layout Itemize
285 \layout Itemize
286
286
287 Automatic indentation (optional) of code as you type (through the readline
287 Automatic indentation (optional) of code as you type (through the readline
288 library).
288 library).
289 \layout Itemize
289 \layout Itemize
290
290
291 Macro system for quickly re-executing multiple lines of previous input with
291 Macro system for quickly re-executing multiple lines of previous input with
292 a single name.
292 a single name.
293 Macros can be stored persistently via
293 Macros can be stored persistently via
294 \family typewriter
294 \family typewriter
295 %store
295 %store
296 \family default
296 \family default
297 and edited via
297 and edited via
298 \family typewriter
298 \family typewriter
299 %edit
299 %edit
300 \family default
300 \family default
301 .
301 .
302
302
303 \layout Itemize
303 \layout Itemize
304
304
305 Session logging (you can then later use these logs as code in your programs).
305 Session logging (you can then later use these logs as code in your programs).
306 Logs can optionally timestamp all input, and also store session output
306 Logs can optionally timestamp all input, and also store session output
307 (marked as comments, so the log remains valid Python source code).
307 (marked as comments, so the log remains valid Python source code).
308 \layout Itemize
308 \layout Itemize
309
309
310 Session restoring: logs can be replayed to restore a previous session to
310 Session restoring: logs can be replayed to restore a previous session to
311 the state where you left it.
311 the state where you left it.
312 \layout Itemize
312 \layout Itemize
313
313
314 Verbose and colored exception traceback printouts.
314 Verbose and colored exception traceback printouts.
315 Easier to parse visually, and in verbose mode they produce a lot of useful
315 Easier to parse visually, and in verbose mode they produce a lot of useful
316 debugging information (basically a terminal version of the cgitb module).
316 debugging information (basically a terminal version of the cgitb module).
317 \layout Itemize
317 \layout Itemize
318
318
319 Auto-parentheses: callable objects can be executed without parentheses:
319 Auto-parentheses: callable objects can be executed without parentheses:
320
320
321 \family typewriter
321 \family typewriter
322 `sin 3'
322 `sin 3'
323 \family default
323 \family default
324 is automatically converted to
324 is automatically converted to
325 \family typewriter
325 \family typewriter
326 `sin(3)
326 `sin(3)
327 \family default
327 \family default
328 '.
328 '.
329 \layout Itemize
329 \layout Itemize
330
330
331 Auto-quoting: using `
331 Auto-quoting: using `
332 \family typewriter
332 \family typewriter
333 ,
333 ,
334 \family default
334 \family default
335 ' or `
335 ' or `
336 \family typewriter
336 \family typewriter
337 ;
337 ;
338 \family default
338 \family default
339 ' as the first character forces auto-quoting of the rest of the line:
339 ' as the first character forces auto-quoting of the rest of the line:
340 \family typewriter
340 \family typewriter
341 `,my_function a\SpecialChar ~
341 `,my_function a\SpecialChar ~
342 b'
342 b'
343 \family default
343 \family default
344 becomes automatically
344 becomes automatically
345 \family typewriter
345 \family typewriter
346 `my_function("a","b")'
346 `my_function("a","b")'
347 \family default
347 \family default
348 , while
348 , while
349 \family typewriter
349 \family typewriter
350 `;my_function a\SpecialChar ~
350 `;my_function a\SpecialChar ~
351 b'
351 b'
352 \family default
352 \family default
353 becomes
353 becomes
354 \family typewriter
354 \family typewriter
355 `my_function("a b")'
355 `my_function("a b")'
356 \family default
356 \family default
357 .
357 .
358 \layout Itemize
358 \layout Itemize
359
359
360 Extensible input syntax.
360 Extensible input syntax.
361 You can define filters that pre-process user input to simplify input in
361 You can define filters that pre-process user input to simplify input in
362 special situations.
362 special situations.
363 This allows for example pasting multi-line code fragments which start with
363 This allows for example pasting multi-line code fragments which start with
364
364
365 \family typewriter
365 \family typewriter
366 `>>>'
366 `>>>'
367 \family default
367 \family default
368 or
368 or
369 \family typewriter
369 \family typewriter
370 `...'
370 `...'
371 \family default
371 \family default
372 such as those from other python sessions or the standard Python documentation.
372 such as those from other python sessions or the standard Python documentation.
373 \layout Itemize
373 \layout Itemize
374
374
375 Flexible configuration system.
375 Flexible configuration system.
376 It uses a configuration file which allows permanent setting of all command-line
376 It uses a configuration file which allows permanent setting of all command-line
377 options, module loading, code and file execution.
377 options, module loading, code and file execution.
378 The system allows recursive file inclusion, so you can have a base file
378 The system allows recursive file inclusion, so you can have a base file
379 with defaults and layers which load other customizations for particular
379 with defaults and layers which load other customizations for particular
380 projects.
380 projects.
381 \layout Itemize
381 \layout Itemize
382
382
383 Embeddable.
383 Embeddable.
384 You can call IPython as a python shell inside your own python programs.
384 You can call IPython as a python shell inside your own python programs.
385 This can be used both for debugging code or for providing interactive abilities
385 This can be used both for debugging code or for providing interactive abilities
386 to your programs with knowledge about the local namespaces (very useful
386 to your programs with knowledge about the local namespaces (very useful
387 in debugging and data analysis situations).
387 in debugging and data analysis situations).
388 \layout Itemize
388 \layout Itemize
389
389
390 Easy debugger access.
390 Easy debugger access.
391 You can set IPython to call up an enhanced version of the Python debugger
391 You can set IPython to call up an enhanced version of the Python debugger
392 (
392 (
393 \family typewriter
393 \family typewriter
394 pdb
394 pdb
395 \family default
395 \family default
396 ) every time there is an uncaught exception.
396 ) every time there is an uncaught exception.
397 This drops you inside the code which triggered the exception with all the
397 This drops you inside the code which triggered the exception with all the
398 data live and it is possible to navigate the stack to rapidly isolate the
398 data live and it is possible to navigate the stack to rapidly isolate the
399 source of a bug.
399 source of a bug.
400 The
400 The
401 \family typewriter
401 \family typewriter
402 %run
402 %run
403 \family default
403 \family default
404 magic command --with the
404 magic command --with the
405 \family typewriter
405 \family typewriter
406 -d
406 -d
407 \family default
407 \family default
408 option-- can run any script under
408 option-- can run any script under
409 \family typewriter
409 \family typewriter
410 pdb
410 pdb
411 \family default
411 \family default
412 's control, automatically setting initial breakpoints for you.
412 's control, automatically setting initial breakpoints for you.
413 This version of
413 This version of
414 \family typewriter
414 \family typewriter
415 pdb
415 pdb
416 \family default
416 \family default
417 has IPython-specific improvements, including tab-completion and traceback
417 has IPython-specific improvements, including tab-completion and traceback
418 coloring support.
418 coloring support.
419 \layout Itemize
419 \layout Itemize
420
420
421 Profiler support.
421 Profiler support.
422 You can run single statements (similar to
422 You can run single statements (similar to
423 \family typewriter
423 \family typewriter
424 profile.run()
424 profile.run()
425 \family default
425 \family default
426 ) or complete programs under the profiler's control.
426 ) or complete programs under the profiler's control.
427 While this is possible with the standard
427 While this is possible with the standard
428 \family typewriter
428 \family typewriter
429 profile
429 profile
430 \family default
430 \family default
431 module, IPython wraps this functionality with magic commands (see
431 module, IPython wraps this functionality with magic commands (see
432 \family typewriter
432 \family typewriter
433 `%prun'
433 `%prun'
434 \family default
434 \family default
435 and
435 and
436 \family typewriter
436 \family typewriter
437 `%run -p
437 `%run -p
438 \family default
438 \family default
439 ') convenient for rapid interactive work.
439 ') convenient for rapid interactive work.
440 \layout Subsection
440 \layout Subsection
441
441
442 Portability and Python requirements
442 Portability and Python requirements
443 \layout Standard
443 \layout Standard
444
444
445
445
446 \series bold
446 \series bold
447 Python requirements:
447 Python requirements:
448 \series default
448 \series default
449 IPython requires with Python version 2.3 or newer.
449 IPython requires with Python version 2.3 or newer.
450 If you are still using Python 2.2 and can not upgrade, the last version
450 If you are still using Python 2.2 and can not upgrade, the last version
451 of IPython which worked with Python 2.2 was 0.6.15, so you will have to use
451 of IPython which worked with Python 2.2 was 0.6.15, so you will have to use
452 that.
452 that.
453 \layout Standard
453 \layout Standard
454
454
455 IPython is developed under
455 IPython is developed under
456 \series bold
456 \series bold
457 Linux
457 Linux
458 \series default
458 \series default
459 , but it should work in any reasonable Unix-type system (tested OK under
459 , but it should work in any reasonable Unix-type system (tested OK under
460 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
460 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
461 \layout Standard
461 \layout Standard
462
462
463
463
464 \series bold
464 \series bold
465 Mac OS X
465 Mac OS X
466 \series default
466 \series default
467 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
467 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
468 Livermore for the information).
468 Livermore for the information).
469 Thanks to Andrea Riciputi, Fink support is available.
469 Thanks to Andrea Riciputi, Fink support is available.
470 \layout Standard
470 \layout Standard
471
471
472
472
473 \series bold
473 \series bold
474 CygWin
474 CygWin
475 \series default
475 \series default
476 : it works mostly OK, though some users have reported problems with prompt
476 : it works mostly OK, though some users have reported problems with prompt
477 coloring.
477 coloring.
478 No satisfactory solution to this has been found so far, you may want to
478 No satisfactory solution to this has been found so far, you may want to
479 disable colors permanently in the
479 disable colors permanently in the
480 \family typewriter
480 \family typewriter
481 ipythonrc
481 ipythonrc
482 \family default
482 \family default
483 configuration file if you experience problems.
483 configuration file if you experience problems.
484 If you have proper color support under cygwin, please post to the IPython
484 If you have proper color support under cygwin, please post to the IPython
485 mailing list so this issue can be resolved for all users.
485 mailing list so this issue can be resolved for all users.
486 \layout Standard
486 \layout Standard
487
487
488
488
489 \series bold
489 \series bold
490 Windows
490 Windows
491 \series default
491 \series default
492 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
492 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
493 Section\SpecialChar ~
493 Section\SpecialChar ~
494
494
495 \begin_inset LatexCommand \ref{sub:Under-Windows}
495 \begin_inset LatexCommand \ref{sub:Under-Windows}
496
496
497 \end_inset
497 \end_inset
498
498
499 describes installation details for Windows, including some additional tools
499 describes installation details for Windows, including some additional tools
500 needed on this platform.
500 needed on this platform.
501 \layout Standard
501 \layout Standard
502
502
503 Windows 9x support is present, and has been reported to work fine (at least
503 Windows 9x support is present, and has been reported to work fine (at least
504 on WinME).
504 on WinME).
505 \layout Standard
505 \layout Standard
506
506
507 Note, that I have very little access to and experience with Windows development.
507 Note, that I have very little access to and experience with Windows development.
508 However, an excellent group of Win32 users (led by Ville Vainio), consistenly
508 However, an excellent group of Win32 users (led by Ville Vainio), consistenly
509 contribute bugfixes and platform-specific enhancements, so they more than
509 contribute bugfixes and platform-specific enhancements, so they more than
510 make up for my deficiencies on that front.
510 make up for my deficiencies on that front.
511 In fact, Win32 users report using IPython as a system shell (see Sec.\SpecialChar ~
511 In fact, Win32 users report using IPython as a system shell (see Sec.\SpecialChar ~
512
512
513 \begin_inset LatexCommand \ref{sec:IPython-as-shell}
513 \begin_inset LatexCommand \ref{sec:IPython-as-shell}
514
514
515 \end_inset
515 \end_inset
516
516
517 for details), as it offers a level of control and features which the default
517 for details), as it offers a level of control and features which the default
518
518
519 \family typewriter
519 \family typewriter
520 cmd.exe
520 cmd.exe
521 \family default
521 \family default
522 doesn't provide.
522 doesn't provide.
523 \layout Subsection
523 \layout Subsection
524
524
525 Location
525 Location
526 \layout Standard
526 \layout Standard
527
527
528 IPython is generously hosted at
528 IPython is generously hosted at
529 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
529 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
530
530
531 \end_inset
531 \end_inset
532
532
533 by the Enthought, Inc and the SciPy project.
533 by the Enthought, Inc and the SciPy project.
534 This site offers downloads, subversion access, mailing lists and a bug
534 This site offers downloads, subversion access, mailing lists and a bug
535 tracking system.
535 tracking system.
536 I am very grateful to Enthought (
536 I am very grateful to Enthought (
537 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
537 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
538
538
539 \end_inset
539 \end_inset
540
540
541 ) and all of the SciPy team for their contribution.
541 ) and all of the SciPy team for their contribution.
542 \layout Section
542 \layout Section
543
543
544
544
545 \begin_inset LatexCommand \label{sec:install}
545 \begin_inset LatexCommand \label{sec:install}
546
546
547 \end_inset
547 \end_inset
548
548
549 Installation
549 Installation
550 \layout Subsection
550 \layout Subsection
551
551
552 Instant instructions
552 Instant instructions
553 \layout Standard
553 \layout Standard
554
554
555 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
555 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
556 download, then install with
556 download, then install with
557 \family typewriter
557 \family typewriter
558 `python setup.py install'
558 `python setup.py install'
559 \family default
559 \family default
560 .
560 .
561 Under Windows, double-click on the provided
561 Under Windows, double-click on the provided
562 \family typewriter
562 \family typewriter
563 .exe
563 .exe
564 \family default
564 \family default
565 binary installer.
565 binary installer.
566 \layout Standard
566 \layout Standard
567
567
568 Then, take a look at Sections
568 Then, take a look at Sections
569 \begin_inset LatexCommand \ref{sec:good_config}
569 \begin_inset LatexCommand \ref{sec:good_config}
570
570
571 \end_inset
571 \end_inset
572
572
573 for configuring things optimally and
573 for configuring things optimally and
574 \begin_inset LatexCommand \ref{sec:quick_tips}
574 \begin_inset LatexCommand \ref{sec:quick_tips}
575
575
576 \end_inset
576 \end_inset
577
577
578 for quick tips on efficient use of IPython.
578 for quick tips on efficient use of IPython.
579 You can later refer to the rest of the manual for all the gory details.
579 You can later refer to the rest of the manual for all the gory details.
580 \layout Standard
580 \layout Standard
581
581
582 See the notes in sec.
582 See the notes in sec.
583
583
584 \begin_inset LatexCommand \ref{sec:upgrade}
584 \begin_inset LatexCommand \ref{sec:upgrade}
585
585
586 \end_inset
586 \end_inset
587
587
588 for upgrading IPython versions.
588 for upgrading IPython versions.
589 \layout Subsection
589 \layout Subsection
590
590
591 Detailed Unix instructions (Linux, Mac OS X, etc.)
591 Detailed Unix instructions (Linux, Mac OS X, etc.)
592 \layout Standard
592 \layout Standard
593
593
594 For RPM based systems, simply install the supplied package in the usual
594 For RPM based systems, simply install the supplied package in the usual
595 manner.
595 manner.
596 If you download the tar archive, the process is:
596 If you download the tar archive, the process is:
597 \layout Enumerate
597 \layout Enumerate
598
598
599 Unzip/untar the
599 Unzip/untar the
600 \family typewriter
600 \family typewriter
601 ipython-XXX.tar.gz
601 ipython-XXX.tar.gz
602 \family default
602 \family default
603 file wherever you want (
603 file wherever you want (
604 \family typewriter
604 \family typewriter
605 XXX
605 XXX
606 \family default
606 \family default
607 is the version number).
607 is the version number).
608 It will make a directory called
608 It will make a directory called
609 \family typewriter
609 \family typewriter
610 ipython-XXX.
610 ipython-XXX.
611
611
612 \family default
612 \family default
613 Change into that directory where you will find the files
613 Change into that directory where you will find the files
614 \family typewriter
614 \family typewriter
615 README
615 README
616 \family default
616 \family default
617 and
617 and
618 \family typewriter
618 \family typewriter
619 setup.py
619 setup.py
620 \family default
620 \family default
621 .
621 .
622
622
623 \family typewriter
623 \family typewriter
624 O
624 O
625 \family default
625 \family default
626 nce you've completed the installation, you can safely remove this directory.
626 nce you've completed the installation, you can safely remove this directory.
627
627
628 \layout Enumerate
628 \layout Enumerate
629
629
630 If you are installing over a previous installation of version 0.2.0 or earlier,
630 If you are installing over a previous installation of version 0.2.0 or earlier,
631 first remove your
631 first remove your
632 \family typewriter
632 \family typewriter
633 $HOME/.ipython
633 $HOME/.ipython
634 \family default
634 \family default
635 directory, since the configuration file format has changed somewhat (the
635 directory, since the configuration file format has changed somewhat (the
636 '=' were removed from all option specifications).
636 '=' were removed from all option specifications).
637 Or you can call ipython with the
637 Or you can call ipython with the
638 \family typewriter
638 \family typewriter
639 -upgrade
639 -upgrade
640 \family default
640 \family default
641 option and it will do this automatically for you.
641 option and it will do this automatically for you.
642 \layout Enumerate
642 \layout Enumerate
643
643
644 IPython uses distutils, so you can install it by simply typing at the system
644 IPython uses distutils, so you can install it by simply typing at the system
645 prompt (don't type the
645 prompt (don't type the
646 \family typewriter
646 \family typewriter
647 $
647 $
648 \family default
648 \family default
649 )
649 )
650 \newline
650 \newline
651
651
652 \family typewriter
652 \family typewriter
653 $ python setup.py install
653 $ python setup.py install
654 \family default
654 \family default
655
655
656 \newline
656 \newline
657 Note that this assumes you have root access to your machine.
657 Note that this assumes you have root access to your machine.
658 If you don't have root access or don't want IPython to go in the default
658 If you don't have root access or don't want IPython to go in the default
659 python directories, you'll need to use the
659 python directories, you'll need to use the
660 \begin_inset ERT
660 \begin_inset ERT
661 status Collapsed
661 status Collapsed
662
662
663 \layout Standard
663 \layout Standard
664
664
665 \backslash
665 \backslash
666 verb|--home|
666 verb|--home|
667 \end_inset
667 \end_inset
668
668
669 option (or
669 option (or
670 \begin_inset ERT
670 \begin_inset ERT
671 status Collapsed
671 status Collapsed
672
672
673 \layout Standard
673 \layout Standard
674
674
675 \backslash
675 \backslash
676 verb|--prefix|
676 verb|--prefix|
677 \end_inset
677 \end_inset
678
678
679 ).
679 ).
680 For example:
680 For example:
681 \newline
681 \newline
682
682
683 \begin_inset ERT
683 \begin_inset ERT
684 status Collapsed
684 status Collapsed
685
685
686 \layout Standard
686 \layout Standard
687
687
688 \backslash
688 \backslash
689 verb|$ python setup.py install --home $HOME/local|
689 verb|$ python setup.py install --home $HOME/local|
690 \end_inset
690 \end_inset
691
691
692
692
693 \newline
693 \newline
694 will install IPython into
694 will install IPython into
695 \family typewriter
695 \family typewriter
696 $HOME/local
696 $HOME/local
697 \family default
697 \family default
698 and its subdirectories (creating them if necessary).
698 and its subdirectories (creating them if necessary).
699 \newline
699 \newline
700 You can type
700 You can type
701 \newline
701 \newline
702
702
703 \begin_inset ERT
703 \begin_inset ERT
704 status Collapsed
704 status Collapsed
705
705
706 \layout Standard
706 \layout Standard
707
707
708 \backslash
708 \backslash
709 verb|$ python setup.py --help|
709 verb|$ python setup.py --help|
710 \end_inset
710 \end_inset
711
711
712
712
713 \newline
713 \newline
714 for more details.
714 for more details.
715 \newline
715 \newline
716 Note that if you change the default location for
716 Note that if you change the default location for
717 \begin_inset ERT
717 \begin_inset ERT
718 status Collapsed
718 status Collapsed
719
719
720 \layout Standard
720 \layout Standard
721
721
722 \backslash
722 \backslash
723 verb|--home|
723 verb|--home|
724 \end_inset
724 \end_inset
725
725
726 at installation, IPython may end up installed at a location which is not
726 at installation, IPython may end up installed at a location which is not
727 part of your
727 part of your
728 \family typewriter
728 \family typewriter
729 $PYTHONPATH
729 $PYTHONPATH
730 \family default
730 \family default
731 environment variable.
731 environment variable.
732 In this case, you'll need to configure this variable to include the actual
732 In this case, you'll need to configure this variable to include the actual
733 directory where the
733 directory where the
734 \family typewriter
734 \family typewriter
735 IPython/
735 IPython/
736 \family default
736 \family default
737 directory ended (typically the value you give to
737 directory ended (typically the value you give to
738 \begin_inset ERT
738 \begin_inset ERT
739 status Collapsed
739 status Collapsed
740
740
741 \layout Standard
741 \layout Standard
742
742
743 \backslash
743 \backslash
744 verb|--home|
744 verb|--home|
745 \end_inset
745 \end_inset
746
746
747 plus
747 plus
748 \family typewriter
748 \family typewriter
749 /lib/python
749 /lib/python
750 \family default
750 \family default
751 ).
751 ).
752 \layout Subsubsection
752 \layout Subsubsection
753
753
754 Mac OSX information
754 Mac OSX information
755 \layout Standard
755 \layout Standard
756
756
757 Under OSX, there is a choice you need to make.
757 Under OSX, there is a choice you need to make.
758 Apple ships its own build of Python, which lives in the core OSX filesystem
758 Apple ships its own build of Python, which lives in the core OSX filesystem
759 hierarchy.
759 hierarchy.
760 You can also manually install a separate Python, either purely by hand
760 You can also manually install a separate Python, either purely by hand
761 (typically in
761 (typically in
762 \family typewriter
762 \family typewriter
763 /usr/local
763 /usr/local
764 \family default
764 \family default
765 ) or by using Fink, which puts everything under
765 ) or by using Fink, which puts everything under
766 \family typewriter
766 \family typewriter
767 /sw
767 /sw
768 \family default
768 \family default
769 .
769 .
770 Which route to follow is a matter of personal preference, as I've seen
770 Which route to follow is a matter of personal preference, as I've seen
771 users who favor each of the approaches.
771 users who favor each of the approaches.
772 Here I will simply list the known installation issues under OSX, along
772 Here I will simply list the known installation issues under OSX, along
773 with their solutions.
773 with their solutions.
774 \layout Standard
774 \layout Standard
775
775
776 This page:
776 This page:
777 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
777 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
778
778
779 \end_inset
779 \end_inset
780
780
781 contains information on this topic, with additional details on how to make
781 contains information on this topic, with additional details on how to make
782 IPython and matplotlib play nicely under OSX.
782 IPython and matplotlib play nicely under OSX.
783 \layout Subsubsection*
783 \layout Subsubsection*
784
784
785 GUI problems
785 GUI problems
786 \layout Standard
786 \layout Standard
787
787
788 The following instructions apply to an install of IPython under OSX from
788 The following instructions apply to an install of IPython under OSX from
789 unpacking the
789 unpacking the
790 \family typewriter
790 \family typewriter
791 .tar.gz
791 .tar.gz
792 \family default
792 \family default
793 distribution and installing it for the default Python interpreter shipped
793 distribution and installing it for the default Python interpreter shipped
794 by Apple.
794 by Apple.
795 If you are using a fink install, fink will take care of these details for
795 If you are using a fink install, fink will take care of these details for
796 you, by installing IPython against fink's Python.
796 you, by installing IPython against fink's Python.
797 \layout Standard
797 \layout Standard
798
798
799 IPython offers various forms of support for interacting with graphical applicati
799 IPython offers various forms of support for interacting with graphical applicati
800 ons from the command line, from simple Tk apps (which are in principle always
800 ons from the command line, from simple Tk apps (which are in principle always
801 supported by Python) to interactive control of WX, Qt and GTK apps.
801 supported by Python) to interactive control of WX, Qt and GTK apps.
802 Under OSX, however, this requires that ipython is installed by calling
802 Under OSX, however, this requires that ipython is installed by calling
803 the special
803 the special
804 \family typewriter
804 \family typewriter
805 pythonw
805 pythonw
806 \family default
806 \family default
807 script at installation time, which takes care of coordinating things with
807 script at installation time, which takes care of coordinating things with
808 Apple's graphical environment.
808 Apple's graphical environment.
809 \layout Standard
809 \layout Standard
810
810
811 So when installing under OSX, it is best to use the following command:
811 So when installing under OSX, it is best to use the following command:
812 \family typewriter
812 \family typewriter
813
813
814 \newline
814 \newline
815
815
816 \family default
816 \family default
817
817
818 \begin_inset ERT
818 \begin_inset ERT
819 status Collapsed
819 status Collapsed
820
820
821 \layout Standard
821 \layout Standard
822
822
823 \backslash
823 \backslash
824 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
824 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
825 \end_inset
825 \end_inset
826
826
827
827
828 \newline
828 \newline
829 or
829 or
830 \newline
830 \newline
831
831
832 \begin_inset ERT
832 \begin_inset ERT
833 status Collapsed
833 status Collapsed
834
834
835 \layout Standard
835 \layout Standard
836
836
837 \backslash
837 \backslash
838 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
838 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
839 \end_inset
839 \end_inset
840
840
841
841
842 \newline
842 \newline
843 depending on where you like to keep hand-installed executables.
843 depending on where you like to keep hand-installed executables.
844 \layout Standard
844 \layout Standard
845
845
846 The resulting script will have an appropriate shebang line (the first line
846 The resulting script will have an appropriate shebang line (the first line
847 in the script whic begins with
847 in the script whic begins with
848 \family typewriter
848 \family typewriter
849 #!...
849 #!...
850 \family default
850 \family default
851 ) such that the ipython interpreter can interact with the OS X GUI.
851 ) such that the ipython interpreter can interact with the OS X GUI.
852 If the installed version does not work and has a shebang line that points
852 If the installed version does not work and has a shebang line that points
853 to, for example, just
853 to, for example, just
854 \family typewriter
854 \family typewriter
855 /usr/bin/python
855 /usr/bin/python
856 \family default
856 \family default
857 , then you might have a stale, cached version in your
857 , then you might have a stale, cached version in your
858 \family typewriter
858 \family typewriter
859 build/scripts-<python-version>
859 build/scripts-<python-version>
860 \family default
860 \family default
861 directory.
861 directory.
862 Delete that directory and rerun the
862 Delete that directory and rerun the
863 \family typewriter
863 \family typewriter
864 setup.py
864 setup.py
865 \family default
865 \family default
866 .
866 .
867
867
868 \layout Standard
868 \layout Standard
869
869
870 It is also a good idea to use the special flag
870 It is also a good idea to use the special flag
871 \begin_inset ERT
871 \begin_inset ERT
872 status Collapsed
872 status Collapsed
873
873
874 \layout Standard
874 \layout Standard
875
875
876 \backslash
876 \backslash
877 verb|--install-scripts|
877 verb|--install-scripts|
878 \end_inset
878 \end_inset
879
879
880 as indicated above, to ensure that the ipython scripts end up in a location
880 as indicated above, to ensure that the ipython scripts end up in a location
881 which is part of your
881 which is part of your
882 \family typewriter
882 \family typewriter
883 $PATH
883 $PATH
884 \family default
884 \family default
885 .
885 .
886 Otherwise Apple's Python will put the scripts in an internal directory
886 Otherwise Apple's Python will put the scripts in an internal directory
887 not available by default at the command line (if you use
887 not available by default at the command line (if you use
888 \family typewriter
888 \family typewriter
889 /usr/local/bin
889 /usr/local/bin
890 \family default
890 \family default
891 , you need to make sure this is in your
891 , you need to make sure this is in your
892 \family typewriter
892 \family typewriter
893 $PATH
893 $PATH
894 \family default
894 \family default
895 , which may not be true by default).
895 , which may not be true by default).
896 \layout Subsubsection*
896 \layout Subsubsection*
897
897
898 Readline problems
898 Readline problems
899 \layout Standard
899 \layout Standard
900
900
901 By default, the Python version shipped by Apple does
901 By default, the Python version shipped by Apple does
902 \emph on
902 \emph on
903 not
903 not
904 \emph default
904 \emph default
905 include the readline library, so central to IPython's behavior.
905 include the readline library, so central to IPython's behavior.
906 If you install IPython against Apple's Python, you will not have arrow
906 If you install IPython against Apple's Python, you will not have arrow
907 keys, tab completion, etc.
907 keys, tab completion, etc.
908 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
908 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
909 \newline
909 \newline
910
910
911 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
911 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
912
912
913 \end_inset
913 \end_inset
914
914
915
915
916 \layout Standard
916 \layout Standard
917
917
918 If you are using OSX 10.4 (Tiger), after installing this package you need
918 If you are using OSX 10.4 (Tiger), after installing this package you need
919 to either:
919 to either:
920 \layout Enumerate
920 \layout Enumerate
921
921
922 move
922 move
923 \family typewriter
923 \family typewriter
924 readline.so
924 readline.so
925 \family default
925 \family default
926 from
926 from
927 \family typewriter
927 \family typewriter
928 /Library/Python/2.3
928 /Library/Python/2.3
929 \family default
929 \family default
930 to
930 to
931 \family typewriter
931 \family typewriter
932 /Library/Python/2.3/site-packages
932 /Library/Python/2.3/site-packages
933 \family default
933 \family default
934 , or
934 , or
935 \layout Enumerate
935 \layout Enumerate
936
936
937 install
937 install
938 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
938 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
939
939
940 \end_inset
940 \end_inset
941
941
942
942
943 \layout Standard
943 \layout Standard
944
944
945 Users installing against Fink's Python or a properly hand-built one should
945 Users installing against Fink's Python or a properly hand-built one should
946 not have this problem.
946 not have this problem.
947 \layout Subsubsection*
947 \layout Subsubsection*
948
948
949 DarwinPorts
949 DarwinPorts
950 \layout Standard
950 \layout Standard
951
951
952 I report here a message from an OSX user, who suggests an alternative means
952 I report here a message from an OSX user, who suggests an alternative means
953 of using IPython under this operating system with good results.
953 of using IPython under this operating system with good results.
954 Please let me know of any updates that may be useful for this section.
954 Please let me know of any updates that may be useful for this section.
955 His message is reproduced verbatim below:
955 His message is reproduced verbatim below:
956 \layout Quote
956 \layout Quote
957
957
958 From: Markus Banfi
958 From: Markus Banfi
959 \family typewriter
959 \family typewriter
960 <markus.banfi-AT-mospheira.net>
960 <markus.banfi-AT-mospheira.net>
961 \layout Quote
961 \layout Quote
962
962
963 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
963 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
964 of Fink.
964 of Fink.
965 I had no problems installing ipython with DarwinPorts.
965 I had no problems installing ipython with DarwinPorts.
966 It's just:
966 It's just:
967 \layout Quote
967 \layout Quote
968
968
969
969
970 \family typewriter
970 \family typewriter
971 sudo port install py-ipython
971 sudo port install py-ipython
972 \layout Quote
972 \layout Quote
973
973
974 It automatically resolved all dependencies (python24, readline, py-readline).
974 It automatically resolved all dependencies (python24, readline, py-readline).
975 So far I did not encounter any problems with the DarwinPorts port of ipython.
975 So far I did not encounter any problems with the DarwinPorts port of ipython.
976
976
977 \layout Subsection
977 \layout Subsection
978
978
979
979
980 \begin_inset LatexCommand \label{sub:Under-Windows}
980 \begin_inset LatexCommand \label{sub:Under-Windows}
981
981
982 \end_inset
982 \end_inset
983
983
984 Windows instructions
984 Windows instructions
985 \layout Standard
985 \layout Standard
986
986
987 Some of IPython's very useful features are:
987 Some of IPython's very useful features are:
988 \layout Itemize
988 \layout Itemize
989
989
990 Integrated readline support (Tab-based file, object and attribute completion,
990 Integrated readline support (Tab-based file, object and attribute completion,
991 input history across sessions, editable command line, etc.)
991 input history across sessions, editable command line, etc.)
992 \layout Itemize
992 \layout Itemize
993
993
994 Coloring of prompts, code and tracebacks.
994 Coloring of prompts, code and tracebacks.
995 \layout Standard
995 \layout Standard
996
996
997 These, by default, are only available under Unix-like operating systems.
997 These, by default, are only available under Unix-like operating systems.
998 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
998 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
999 from them.
999 from them.
1000 His readline library implements both GNU readline functionality and color
1000 His readline library implements both GNU readline functionality and color
1001 support, so that IPython under Windows XP/2k can be as friendly and powerful
1001 support, so that IPython under Windows XP/2k can be as friendly and powerful
1002 as under Unix-like environments.
1002 as under Unix-like environments.
1003 \layout Standard
1003 \layout Standard
1004
1004
1005 The
1005 The
1006 \family typewriter
1006 \family typewriter
1007 readline
1007 readline
1008 \family default
1008 \family default
1009 extension needs two other libraries to work, so in all you need:
1009 extension needs two other libraries to work, so in all you need:
1010 \layout Enumerate
1010 \layout Enumerate
1011
1011
1012
1012
1013 \family typewriter
1013 \family typewriter
1014 PyWin32
1014 PyWin32
1015 \family default
1015 \family default
1016 from
1016 from
1017 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
1017 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
1018
1018
1019 \end_inset
1019 \end_inset
1020
1020
1021 .
1021 .
1022 \layout Enumerate
1022 \layout Enumerate
1023
1023
1024
1024
1025 \family typewriter
1025 \family typewriter
1026 CTypes
1026 CTypes
1027 \family default
1027 \family default
1028 from
1028 from
1029 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1029 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1030
1030
1031 \end_inset
1031 \end_inset
1032
1032
1033 (you
1033 (you
1034 \emph on
1034 \emph on
1035 must
1035 must
1036 \emph default
1036 \emph default
1037 use version 0.9.1 or newer).
1037 use version 0.9.1 or newer).
1038 \layout Enumerate
1038 \layout Enumerate
1039
1039
1040
1040
1041 \family typewriter
1041 \family typewriter
1042 Readline
1042 Readline
1043 \family default
1043 \family default
1044 for Windows from
1044 for Windows from
1045 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
1045 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
1046
1046
1047 \end_inset
1047 \end_inset
1048
1048
1049 .
1049 .
1050 \layout Standard
1050 \layout Standard
1051
1051
1052
1052
1053 \series bold
1053 \series bold
1054 Warning about a broken readline-like library:
1054 Warning about a broken readline-like library:
1055 \series default
1055 \series default
1056 several users have reported problems stemming from using the pseudo-readline
1056 several users have reported problems stemming from using the pseudo-readline
1057 library at
1057 library at
1058 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1058 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1059
1059
1060 \end_inset
1060 \end_inset
1061
1061
1062 .
1062 .
1063 This is a broken library which, while called readline, only implements
1063 This is a broken library which, while called readline, only implements
1064 an incomplete subset of the readline API.
1064 an incomplete subset of the readline API.
1065 Since it is still called readline, it fools IPython's detection mechanisms
1065 Since it is still called readline, it fools IPython's detection mechanisms
1066 and causes unpredictable crashes later.
1066 and causes unpredictable crashes later.
1067 If you wish to use IPython under Windows, you must NOT use this library,
1067 If you wish to use IPython under Windows, you must NOT use this library,
1068 which for all purposes is (at least as of version 1.6) terminally broken.
1068 which for all purposes is (at least as of version 1.6) terminally broken.
1069 \layout Subsubsection
1069 \layout Subsubsection
1070
1070
1071 Installation procedure
1071 Installation procedure
1072 \layout Standard
1072 \layout Standard
1073
1073
1074 Once you have the above installed, from the IPython download directory grab
1074 Once you have the above installed, from the IPython download directory grab
1075 the
1075 the
1076 \family typewriter
1076 \family typewriter
1077 ipython-XXX.win32.exe
1077 ipython-XXX.win32.exe
1078 \family default
1078 \family default
1079 file, where
1079 file, where
1080 \family typewriter
1080 \family typewriter
1081 XXX
1081 XXX
1082 \family default
1082 \family default
1083 represents the version number.
1083 represents the version number.
1084 This is a regular windows executable installer, which you can simply double-cli
1084 This is a regular windows executable installer, which you can simply double-cli
1085 ck to install.
1085 ck to install.
1086 It will add an entry for IPython to your Start Menu, as well as registering
1086 It will add an entry for IPython to your Start Menu, as well as registering
1087 IPython in the Windows list of applications, so you can later uninstall
1087 IPython in the Windows list of applications, so you can later uninstall
1088 it from the Control Panel.
1088 it from the Control Panel.
1089
1089
1090 \layout Standard
1090 \layout Standard
1091
1091
1092 IPython tries to install the configuration information in a directory named
1092 IPython tries to install the configuration information in a directory named
1093
1093
1094 \family typewriter
1094 \family typewriter
1095 .ipython
1095 .ipython
1096 \family default
1096 \family default
1097 (
1097 (
1098 \family typewriter
1098 \family typewriter
1099 _ipython
1099 _ipython
1100 \family default
1100 \family default
1101 under Windows) located in your `home' directory.
1101 under Windows) located in your `home' directory.
1102 IPython sets this directory by looking for a
1102 IPython sets this directory by looking for a
1103 \family typewriter
1103 \family typewriter
1104 HOME
1104 HOME
1105 \family default
1105 \family default
1106 environment variable; if such a variable does not exist, it uses
1106 environment variable; if such a variable does not exist, it uses
1107 \family typewriter
1107 \family typewriter
1108 HOMEDRIVE
1108 HOMEDRIVE
1109 \backslash
1109 \backslash
1110 HOMEPATH
1110 HOMEPATH
1111 \family default
1111 \family default
1112 (these are always defined by Windows).
1112 (these are always defined by Windows).
1113 This typically gives something like
1113 This typically gives something like
1114 \family typewriter
1114 \family typewriter
1115 C:
1115 C:
1116 \backslash
1116 \backslash
1117 Documents and Settings
1117 Documents and Settings
1118 \backslash
1118 \backslash
1119 YourUserName
1119 YourUserName
1120 \family default
1120 \family default
1121 , but your local details may vary.
1121 , but your local details may vary.
1122 In this directory you will find all the files that configure IPython's
1122 In this directory you will find all the files that configure IPython's
1123 defaults, and you can put there your profiles and extensions.
1123 defaults, and you can put there your profiles and extensions.
1124 This directory is automatically added by IPython to
1124 This directory is automatically added by IPython to
1125 \family typewriter
1125 \family typewriter
1126 sys.path
1126 sys.path
1127 \family default
1127 \family default
1128 , so anything you place there can be found by
1128 , so anything you place there can be found by
1129 \family typewriter
1129 \family typewriter
1130 import
1130 import
1131 \family default
1131 \family default
1132 statements.
1132 statements.
1133 \layout Paragraph
1133 \layout Paragraph
1134
1134
1135 Upgrading
1135 Upgrading
1136 \layout Standard
1136 \layout Standard
1137
1137
1138 For an IPython upgrade, you should first uninstall the previous version.
1138 For an IPython upgrade, you should first uninstall the previous version.
1139 This will ensure that all files and directories (such as the documentation)
1139 This will ensure that all files and directories (such as the documentation)
1140 which carry embedded version strings in their names are properly removed.
1140 which carry embedded version strings in their names are properly removed.
1141 \layout Paragraph
1141 \layout Paragraph
1142
1142
1143 Manual installation under Win32
1143 Manual installation under Win32
1144 \layout Standard
1144 \layout Standard
1145
1145
1146 In case the automatic installer does not work for some reason, you can download
1146 In case the automatic installer does not work for some reason, you can download
1147 the
1147 the
1148 \family typewriter
1148 \family typewriter
1149 ipython-XXX.tar.gz
1149 ipython-XXX.tar.gz
1150 \family default
1150 \family default
1151 file, which contains the full IPython source distribution (the popular
1151 file, which contains the full IPython source distribution (the popular
1152 WinZip can read
1152 WinZip can read
1153 \family typewriter
1153 \family typewriter
1154 .tar.gz
1154 .tar.gz
1155 \family default
1155 \family default
1156 files).
1156 files).
1157 After uncompressing the archive, you can install it at a command terminal
1157 After uncompressing the archive, you can install it at a command terminal
1158 just like any other Python module, by using
1158 just like any other Python module, by using
1159 \family typewriter
1159 \family typewriter
1160 `python setup.py install'
1160 `python setup.py install'
1161 \family default
1161 \family default
1162 .
1162 .
1163
1163
1164 \layout Standard
1164 \layout Standard
1165
1165
1166 After the installation, run the supplied
1166 After the installation, run the supplied
1167 \family typewriter
1167 \family typewriter
1168 win32_manual_post_install.py
1168 win32_manual_post_install.py
1169 \family default
1169 \family default
1170 script, which creates the necessary Start Menu shortcuts for you.
1170 script, which creates the necessary Start Menu shortcuts for you.
1171 \layout Subsection
1171 \layout Subsection
1172
1172
1173
1173
1174 \begin_inset LatexCommand \label{sec:upgrade}
1174 \begin_inset LatexCommand \label{sec:upgrade}
1175
1175
1176 \end_inset
1176 \end_inset
1177
1177
1178 Upgrading from a previous version
1178 Upgrading from a previous version
1179 \layout Standard
1179 \layout Standard
1180
1180
1181 If you are upgrading from a previous version of IPython, after doing the
1181 If you are upgrading from a previous version of IPython, after doing the
1182 routine installation described above, you should call IPython with the
1182 routine installation described above, you should call IPython with the
1183
1183
1184 \family typewriter
1184 \family typewriter
1185 -upgrade
1185 -upgrade
1186 \family default
1186 \family default
1187 option the first time you run your new copy.
1187 option the first time you run your new copy.
1188 This will automatically update your configuration directory while preserving
1188 This will automatically update your configuration directory while preserving
1189 copies of your old files.
1189 copies of your old files.
1190 You can then later merge back any personal customizations you may have
1190 You can then later merge back any personal customizations you may have
1191 made into the new files.
1191 made into the new files.
1192 It is a good idea to do this as there may be new options available in the
1192 It is a good idea to do this as there may be new options available in the
1193 new configuration files which you will not have.
1193 new configuration files which you will not have.
1194 \layout Standard
1194 \layout Standard
1195
1195
1196 Under Windows, if you don't know how to call python scripts with arguments
1196 Under Windows, if you don't know how to call python scripts with arguments
1197 from a command line, simply delete the old config directory and IPython
1197 from a command line, simply delete the old config directory and IPython
1198 will make a new one.
1198 will make a new one.
1199 Win2k and WinXP users will find it in
1199 Win2k and WinXP users will find it in
1200 \family typewriter
1200 \family typewriter
1201 C:
1201 C:
1202 \backslash
1202 \backslash
1203 Documents and Settings
1203 Documents and Settings
1204 \backslash
1204 \backslash
1205 YourUserName
1205 YourUserName
1206 \backslash
1206 \backslash
1207 _ipython
1207 _ipython
1208 \family default
1208 \family default
1209 , and Win 9x users under
1209 , and Win 9x users under
1210 \family typewriter
1210 \family typewriter
1211 C:
1211 C:
1212 \backslash
1212 \backslash
1213 Program Files
1213 Program Files
1214 \backslash
1214 \backslash
1215 IPython
1215 IPython
1216 \backslash
1216 \backslash
1217 _ipython.
1217 _ipython.
1218 \layout Section
1218 \layout Section
1219
1219
1220
1220
1221 \begin_inset LatexCommand \label{sec:good_config}
1221 \begin_inset LatexCommand \label{sec:good_config}
1222
1222
1223 \end_inset
1223 \end_inset
1224
1224
1225
1225
1226 \begin_inset OptArg
1226 \begin_inset OptArg
1227 collapsed true
1227 collapsed true
1228
1228
1229 \layout Standard
1229 \layout Standard
1230
1230
1231 Initial configuration
1231 Initial configuration
1232 \begin_inset ERT
1232 \begin_inset ERT
1233 status Collapsed
1233 status Collapsed
1234
1234
1235 \layout Standard
1235 \layout Standard
1236
1236
1237 \backslash
1237 \backslash
1238 ldots
1238 ldots
1239 \end_inset
1239 \end_inset
1240
1240
1241
1241
1242 \end_inset
1242 \end_inset
1243
1243
1244 Initial configuration of your environment
1244 Initial configuration of your environment
1245 \layout Standard
1245 \layout Standard
1246
1246
1247 This section will help you set various things in your environment for your
1247 This section will help you set various things in your environment for your
1248 IPython sessions to be as efficient as possible.
1248 IPython sessions to be as efficient as possible.
1249 All of IPython's configuration information, along with several example
1249 All of IPython's configuration information, along with several example
1250 files, is stored in a directory named by default
1250 files, is stored in a directory named by default
1251 \family typewriter
1251 \family typewriter
1252 $HOME/.ipython
1252 $HOME/.ipython
1253 \family default
1253 \family default
1254 .
1254 .
1255 You can change this by defining the environment variable
1255 You can change this by defining the environment variable
1256 \family typewriter
1256 \family typewriter
1257 IPYTHONDIR
1257 IPYTHONDIR
1258 \family default
1258 \family default
1259 , or at runtime with the command line option
1259 , or at runtime with the command line option
1260 \family typewriter
1260 \family typewriter
1261 -ipythondir
1261 -ipythondir
1262 \family default
1262 \family default
1263 .
1263 .
1264 \layout Standard
1264 \layout Standard
1265
1265
1266 If all goes well, the first time you run IPython it should automatically
1266 If all goes well, the first time you run IPython it should automatically
1267 create a user copy of the config directory for you, based on its builtin
1267 create a user copy of the config directory for you, based on its builtin
1268 defaults.
1268 defaults.
1269 You can look at the files it creates to learn more about configuring the
1269 You can look at the files it creates to learn more about configuring the
1270 system.
1270 system.
1271 The main file you will modify to configure IPython's behavior is called
1271 The main file you will modify to configure IPython's behavior is called
1272
1272
1273 \family typewriter
1273 \family typewriter
1274 ipythonrc
1274 ipythonrc
1275 \family default
1275 \family default
1276 (with a
1276 (with a
1277 \family typewriter
1277 \family typewriter
1278 .ini
1278 .ini
1279 \family default
1279 \family default
1280 extension under Windows), included for reference in Sec.
1280 extension under Windows), included for reference in Sec.
1281
1281
1282 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1282 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1283
1283
1284 \end_inset
1284 \end_inset
1285
1285
1286 .
1286 .
1287 This file is very commented and has many variables you can change to suit
1287 This file is very commented and has many variables you can change to suit
1288 your taste, you can find more details in Sec.
1288 your taste, you can find more details in Sec.
1289
1289
1290 \begin_inset LatexCommand \ref{sec:customization}
1290 \begin_inset LatexCommand \ref{sec:customization}
1291
1291
1292 \end_inset
1292 \end_inset
1293
1293
1294 .
1294 .
1295 Here we discuss the basic things you will want to make sure things are
1295 Here we discuss the basic things you will want to make sure things are
1296 working properly from the beginning.
1296 working properly from the beginning.
1297 \layout Subsection
1297 \layout Subsection
1298
1298
1299
1299
1300 \begin_inset LatexCommand \label{sec:help-access}
1300 \begin_inset LatexCommand \label{sec:help-access}
1301
1301
1302 \end_inset
1302 \end_inset
1303
1303
1304 Access to the Python help system
1304 Access to the Python help system
1305 \layout Standard
1305 \layout Standard
1306
1306
1307 This is true for Python in general (not just for IPython): you should have
1307 This is true for Python in general (not just for IPython): you should have
1308 an environment variable called
1308 an environment variable called
1309 \family typewriter
1309 \family typewriter
1310 PYTHONDOCS
1310 PYTHONDOCS
1311 \family default
1311 \family default
1312 pointing to the directory where your HTML Python documentation lives.
1312 pointing to the directory where your HTML Python documentation lives.
1313 In my system it's
1313 In my system it's
1314 \family typewriter
1314 \family typewriter
1315 /usr/share/doc/python-docs-2.3.4/html
1315 /usr/share/doc/python-docs-2.3.4/html
1316 \family default
1316 \family default
1317 , check your local details or ask your systems administrator.
1317 , check your local details or ask your systems administrator.
1318
1318
1319 \layout Standard
1319 \layout Standard
1320
1320
1321 This is the directory which holds the HTML version of the Python manuals.
1321 This is the directory which holds the HTML version of the Python manuals.
1322 Unfortunately it seems that different Linux distributions package these
1322 Unfortunately it seems that different Linux distributions package these
1323 files differently, so you may have to look around a bit.
1323 files differently, so you may have to look around a bit.
1324 Below I show the contents of this directory on my system for reference:
1324 Below I show the contents of this directory on my system for reference:
1325 \layout Standard
1325 \layout Standard
1326
1326
1327
1327
1328 \family typewriter
1328 \family typewriter
1329 [html]> ls
1329 [html]> ls
1330 \newline
1330 \newline
1331 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1331 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1332 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1332 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1333 \layout Standard
1333 \layout Standard
1334
1334
1335 You should really make sure this variable is correctly set so that Python's
1335 You should really make sure this variable is correctly set so that Python's
1336 pydoc-based help system works.
1336 pydoc-based help system works.
1337 It is a powerful and convenient system with full access to the Python manuals
1337 It is a powerful and convenient system with full access to the Python manuals
1338 and all modules accessible to you.
1338 and all modules accessible to you.
1339 \layout Standard
1339 \layout Standard
1340
1340
1341 Under Windows it seems that pydoc finds the documentation automatically,
1341 Under Windows it seems that pydoc finds the documentation automatically,
1342 so no extra setup appears necessary.
1342 so no extra setup appears necessary.
1343 \layout Subsection
1343 \layout Subsection
1344
1344
1345 Editor
1345 Editor
1346 \layout Standard
1346 \layout Standard
1347
1347
1348 The
1348 The
1349 \family typewriter
1349 \family typewriter
1350 %edit
1350 %edit
1351 \family default
1351 \family default
1352 command (and its alias
1352 command (and its alias
1353 \family typewriter
1353 \family typewriter
1354 %ed
1354 %ed
1355 \family default
1355 \family default
1356 ) will invoke the editor set in your environment as
1356 ) will invoke the editor set in your environment as
1357 \family typewriter
1357 \family typewriter
1358 EDITOR
1358 EDITOR
1359 \family default
1359 \family default
1360 .
1360 .
1361 If this variable is not set, it will default to
1361 If this variable is not set, it will default to
1362 \family typewriter
1362 \family typewriter
1363 vi
1363 vi
1364 \family default
1364 \family default
1365 under Linux/Unix and to
1365 under Linux/Unix and to
1366 \family typewriter
1366 \family typewriter
1367 notepad
1367 notepad
1368 \family default
1368 \family default
1369 under Windows.
1369 under Windows.
1370 You may want to set this variable properly and to a lightweight editor
1370 You may want to set this variable properly and to a lightweight editor
1371 which doesn't take too long to start (that is, something other than a new
1371 which doesn't take too long to start (that is, something other than a new
1372 instance of
1372 instance of
1373 \family typewriter
1373 \family typewriter
1374 Emacs
1374 Emacs
1375 \family default
1375 \family default
1376 ).
1376 ).
1377 This way you can edit multi-line code quickly and with the power of a real
1377 This way you can edit multi-line code quickly and with the power of a real
1378 editor right inside IPython.
1378 editor right inside IPython.
1379
1379
1380 \layout Standard
1380 \layout Standard
1381
1381
1382 If you are a dedicated
1382 If you are a dedicated
1383 \family typewriter
1383 \family typewriter
1384 Emacs
1384 Emacs
1385 \family default
1385 \family default
1386 user, you should set up the
1386 user, you should set up the
1387 \family typewriter
1387 \family typewriter
1388 Emacs
1388 Emacs
1389 \family default
1389 \family default
1390 server so that new requests are handled by the original process.
1390 server so that new requests are handled by the original process.
1391 This means that almost no time is spent in handling the request (assuming
1391 This means that almost no time is spent in handling the request (assuming
1392 an
1392 an
1393 \family typewriter
1393 \family typewriter
1394 Emacs
1394 Emacs
1395 \family default
1395 \family default
1396 process is already running).
1396 process is already running).
1397 For this to work, you need to set your
1397 For this to work, you need to set your
1398 \family typewriter
1398 \family typewriter
1399 EDITOR
1399 EDITOR
1400 \family default
1400 \family default
1401 environment variable to
1401 environment variable to
1402 \family typewriter
1402 \family typewriter
1403 'emacsclient'
1403 'emacsclient'
1404 \family default
1404 \family default
1405 .
1405 .
1406
1406
1407 \family typewriter
1407 \family typewriter
1408
1408
1409 \family default
1409 \family default
1410 The code below, supplied by Francois Pinard, can then be used in your
1410 The code below, supplied by Francois Pinard, can then be used in your
1411 \family typewriter
1411 \family typewriter
1412 .emacs
1412 .emacs
1413 \family default
1413 \family default
1414 file to enable the server:
1414 file to enable the server:
1415 \layout Standard
1415 \layout Standard
1416
1416
1417
1417
1418 \family typewriter
1418 \family typewriter
1419 (defvar server-buffer-clients)
1419 (defvar server-buffer-clients)
1420 \newline
1420 \newline
1421 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1421 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1422 \newline
1422 \newline
1423
1423
1424 \begin_inset ERT
1424 \begin_inset ERT
1425 status Collapsed
1425 status Collapsed
1426
1426
1427 \layout Standard
1427 \layout Standard
1428
1428
1429 \backslash
1429 \backslash
1430 hspace*{0mm}
1430 hspace*{0mm}
1431 \end_inset
1431 \end_inset
1432
1432
1433 \SpecialChar ~
1433 \SpecialChar ~
1434 \SpecialChar ~
1434 \SpecialChar ~
1435 (server-start)
1435 (server-start)
1436 \newline
1436 \newline
1437
1437
1438 \begin_inset ERT
1438 \begin_inset ERT
1439 status Collapsed
1439 status Collapsed
1440
1440
1441 \layout Standard
1441 \layout Standard
1442
1442
1443 \backslash
1443 \backslash
1444 hspace*{0mm}
1444 hspace*{0mm}
1445 \end_inset
1445 \end_inset
1446
1446
1447 \SpecialChar ~
1447 \SpecialChar ~
1448 \SpecialChar ~
1448 \SpecialChar ~
1449 (defun fp-kill-server-with-buffer-routine ()
1449 (defun fp-kill-server-with-buffer-routine ()
1450 \newline
1450 \newline
1451
1451
1452 \begin_inset ERT
1452 \begin_inset ERT
1453 status Collapsed
1453 status Collapsed
1454
1454
1455 \layout Standard
1455 \layout Standard
1456
1456
1457 \backslash
1457 \backslash
1458 hspace*{0mm}
1458 hspace*{0mm}
1459 \end_inset
1459 \end_inset
1460
1460
1461 \SpecialChar ~
1461 \SpecialChar ~
1462 \SpecialChar ~
1462 \SpecialChar ~
1463 \SpecialChar ~
1463 \SpecialChar ~
1464 \SpecialChar ~
1464 \SpecialChar ~
1465 (and server-buffer-clients (server-done)))
1465 (and server-buffer-clients (server-done)))
1466 \newline
1466 \newline
1467
1467
1468 \begin_inset ERT
1468 \begin_inset ERT
1469 status Collapsed
1469 status Collapsed
1470
1470
1471 \layout Standard
1471 \layout Standard
1472
1472
1473 \backslash
1473 \backslash
1474 hspace*{0mm}
1474 hspace*{0mm}
1475 \end_inset
1475 \end_inset
1476
1476
1477 \SpecialChar ~
1477 \SpecialChar ~
1478 \SpecialChar ~
1478 \SpecialChar ~
1479 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1479 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1480 \layout Standard
1480 \layout Standard
1481
1481
1482 You can also set the value of this editor via the commmand-line option '-
1482 You can also set the value of this editor via the commmand-line option '-
1483 \family typewriter
1483 \family typewriter
1484 editor'
1484 editor'
1485 \family default
1485 \family default
1486 or in your
1486 or in your
1487 \family typewriter
1487 \family typewriter
1488 ipythonrc
1488 ipythonrc
1489 \family default
1489 \family default
1490 file.
1490 file.
1491 This is useful if you wish to use specifically for IPython an editor different
1491 This is useful if you wish to use specifically for IPython an editor different
1492 from your typical default (and for Windows users who tend to use fewer
1492 from your typical default (and for Windows users who tend to use fewer
1493 environment variables).
1493 environment variables).
1494 \layout Subsection
1494 \layout Subsection
1495
1495
1496 Color
1496 Color
1497 \layout Standard
1497 \layout Standard
1498
1498
1499 The default IPython configuration has most bells and whistles turned on
1499 The default IPython configuration has most bells and whistles turned on
1500 (they're pretty safe).
1500 (they're pretty safe).
1501 But there's one that
1501 But there's one that
1502 \emph on
1502 \emph on
1503 may
1503 may
1504 \emph default
1504 \emph default
1505 cause problems on some systems: the use of color on screen for displaying
1505 cause problems on some systems: the use of color on screen for displaying
1506 information.
1506 information.
1507 This is very useful, since IPython can show prompts and exception tracebacks
1507 This is very useful, since IPython can show prompts and exception tracebacks
1508 with various colors, display syntax-highlighted source code, and in general
1508 with various colors, display syntax-highlighted source code, and in general
1509 make it easier to visually parse information.
1509 make it easier to visually parse information.
1510 \layout Standard
1510 \layout Standard
1511
1511
1512 The following terminals seem to handle the color sequences fine:
1512 The following terminals seem to handle the color sequences fine:
1513 \layout Itemize
1513 \layout Itemize
1514
1514
1515 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1515 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1516 \layout Itemize
1516 \layout Itemize
1517
1517
1518 CDE terminal (tested under Solaris).
1518 CDE terminal (tested under Solaris).
1519 This one boldfaces light colors.
1519 This one boldfaces light colors.
1520 \layout Itemize
1520 \layout Itemize
1521
1521
1522 (X)Emacs buffers.
1522 (X)Emacs buffers.
1523 See sec.
1523 See sec.
1524 \begin_inset LatexCommand \ref{sec:emacs}
1524 \begin_inset LatexCommand \ref{sec:emacs}
1525
1525
1526 \end_inset
1526 \end_inset
1527
1527
1528 for more details on using IPython with (X)Emacs.
1528 for more details on using IPython with (X)Emacs.
1529 \layout Itemize
1529 \layout Itemize
1530
1530
1531 A Windows (XP/2k) command prompt
1531 A Windows (XP/2k) command prompt
1532 \emph on
1532 \emph on
1533 with Gary Bishop's support extensions
1533 with Gary Bishop's support extensions
1534 \emph default
1534 \emph default
1535 .
1535 .
1536 Gary's extensions are discussed in Sec.\SpecialChar ~
1536 Gary's extensions are discussed in Sec.\SpecialChar ~
1537
1537
1538 \begin_inset LatexCommand \ref{sub:Under-Windows}
1538 \begin_inset LatexCommand \ref{sub:Under-Windows}
1539
1539
1540 \end_inset
1540 \end_inset
1541
1541
1542 .
1542 .
1543 \layout Itemize
1543 \layout Itemize
1544
1544
1545 A Windows (XP/2k) CygWin shell.
1545 A Windows (XP/2k) CygWin shell.
1546 Although some users have reported problems; it is not clear whether there
1546 Although some users have reported problems; it is not clear whether there
1547 is an issue for everyone or only under specific configurations.
1547 is an issue for everyone or only under specific configurations.
1548 If you have full color support under cygwin, please post to the IPython
1548 If you have full color support under cygwin, please post to the IPython
1549 mailing list so this issue can be resolved for all users.
1549 mailing list so this issue can be resolved for all users.
1550 \layout Standard
1550 \layout Standard
1551
1551
1552 These have shown problems:
1552 These have shown problems:
1553 \layout Itemize
1553 \layout Itemize
1554
1554
1555 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1555 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1556 or ssh.
1556 or ssh.
1557 \layout Itemize
1557 \layout Itemize
1558
1558
1559 Windows native command prompt in WinXP/2k,
1559 Windows native command prompt in WinXP/2k,
1560 \emph on
1560 \emph on
1561 without
1561 without
1562 \emph default
1562 \emph default
1563 Gary Bishop's extensions.
1563 Gary Bishop's extensions.
1564 Once Gary's readline library is installed, the normal WinXP/2k command
1564 Once Gary's readline library is installed, the normal WinXP/2k command
1565 prompt works perfectly.
1565 prompt works perfectly.
1566 \layout Standard
1566 \layout Standard
1567
1567
1568 Currently the following color schemes are available:
1568 Currently the following color schemes are available:
1569 \layout Itemize
1569 \layout Itemize
1570
1570
1571
1571
1572 \family typewriter
1572 \family typewriter
1573 NoColor
1573 NoColor
1574 \family default
1574 \family default
1575 : uses no color escapes at all (all escapes are empty
1575 : uses no color escapes at all (all escapes are empty
1576 \begin_inset Quotes eld
1576 \begin_inset Quotes eld
1577 \end_inset
1577 \end_inset
1578
1578
1579
1579
1580 \begin_inset Quotes eld
1580 \begin_inset Quotes eld
1581 \end_inset
1581 \end_inset
1582
1582
1583 strings).
1583 strings).
1584 This 'scheme' is thus fully safe to use in any terminal.
1584 This 'scheme' is thus fully safe to use in any terminal.
1585 \layout Itemize
1585 \layout Itemize
1586
1586
1587
1587
1588 \family typewriter
1588 \family typewriter
1589 Linux
1589 Linux
1590 \family default
1590 \family default
1591 : works well in Linux console type environments: dark background with light
1591 : works well in Linux console type environments: dark background with light
1592 fonts.
1592 fonts.
1593 It uses bright colors for information, so it is difficult to read if you
1593 It uses bright colors for information, so it is difficult to read if you
1594 have a light colored background.
1594 have a light colored background.
1595 \layout Itemize
1595 \layout Itemize
1596
1596
1597
1597
1598 \family typewriter
1598 \family typewriter
1599 LightBG
1599 LightBG
1600 \family default
1600 \family default
1601 : the basic colors are similar to those in the
1601 : the basic colors are similar to those in the
1602 \family typewriter
1602 \family typewriter
1603 Linux
1603 Linux
1604 \family default
1604 \family default
1605 scheme but darker.
1605 scheme but darker.
1606 It is easy to read in terminals with light backgrounds.
1606 It is easy to read in terminals with light backgrounds.
1607 \layout Standard
1607 \layout Standard
1608
1608
1609 IPython uses colors for two main groups of things: prompts and tracebacks
1609 IPython uses colors for two main groups of things: prompts and tracebacks
1610 which are directly printed to the terminal, and the object introspection
1610 which are directly printed to the terminal, and the object introspection
1611 system which passes large sets of data through a pager.
1611 system which passes large sets of data through a pager.
1612 \layout Subsubsection
1612 \layout Subsubsection
1613
1613
1614 Input/Output prompts and exception tracebacks
1614 Input/Output prompts and exception tracebacks
1615 \layout Standard
1615 \layout Standard
1616
1616
1617 You can test whether the colored prompts and tracebacks work on your system
1617 You can test whether the colored prompts and tracebacks work on your system
1618 interactively by typing
1618 interactively by typing
1619 \family typewriter
1619 \family typewriter
1620 '%colors Linux'
1620 '%colors Linux'
1621 \family default
1621 \family default
1622 at the prompt (use '
1622 at the prompt (use '
1623 \family typewriter
1623 \family typewriter
1624 %colors LightBG'
1624 %colors LightBG'
1625 \family default
1625 \family default
1626 if your terminal has a light background).
1626 if your terminal has a light background).
1627 If the input prompt shows garbage like:
1627 If the input prompt shows garbage like:
1628 \newline
1628 \newline
1629
1629
1630 \family typewriter
1630 \family typewriter
1631 [0;32mIn [[1;32m1[0;32m]: [0;00m
1631 [0;32mIn [[1;32m1[0;32m]: [0;00m
1632 \family default
1632 \family default
1633
1633
1634 \newline
1634 \newline
1635 instead of (in color) something like:
1635 instead of (in color) something like:
1636 \newline
1636 \newline
1637
1637
1638 \family typewriter
1638 \family typewriter
1639 In [1]:
1639 In [1]:
1640 \family default
1640 \family default
1641
1641
1642 \newline
1642 \newline
1643 this means that your terminal doesn't properly handle color escape sequences.
1643 this means that your terminal doesn't properly handle color escape sequences.
1644 You can go to a 'no color' mode by typing '
1644 You can go to a 'no color' mode by typing '
1645 \family typewriter
1645 \family typewriter
1646 %colors NoColor
1646 %colors NoColor
1647 \family default
1647 \family default
1648 '.
1648 '.
1649
1649
1650 \layout Standard
1650 \layout Standard
1651
1651
1652 You can try using a different terminal emulator program.
1652 You can try using a different terminal emulator program.
1653 To permanently set your color preferences, edit the file
1653 To permanently set your color preferences, edit the file
1654 \family typewriter
1654 \family typewriter
1655 $HOME/.ipython/ipythonrc
1655 $HOME/.ipython/ipythonrc
1656 \family default
1656 \family default
1657 and set the
1657 and set the
1658 \family typewriter
1658 \family typewriter
1659 colors
1659 colors
1660 \family default
1660 \family default
1661 option to the desired value.
1661 option to the desired value.
1662 \layout Subsubsection
1662 \layout Subsubsection
1663
1663
1664 Object details (types, docstrings, source code, etc.)
1664 Object details (types, docstrings, source code, etc.)
1665 \layout Standard
1665 \layout Standard
1666
1666
1667 IPython has a set of special functions for studying the objects you are
1667 IPython has a set of special functions for studying the objects you are
1668 working with, discussed in detail in Sec.
1668 working with, discussed in detail in Sec.
1669
1669
1670 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1670 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1671
1671
1672 \end_inset
1672 \end_inset
1673
1673
1674 .
1674 .
1675 But this system relies on passing information which is longer than your
1675 But this system relies on passing information which is longer than your
1676 screen through a data pager, such as the common Unix
1676 screen through a data pager, such as the common Unix
1677 \family typewriter
1677 \family typewriter
1678 less
1678 less
1679 \family default
1679 \family default
1680 and
1680 and
1681 \family typewriter
1681 \family typewriter
1682 more
1682 more
1683 \family default
1683 \family default
1684 programs.
1684 programs.
1685 In order to be able to see this information in color, your pager needs
1685 In order to be able to see this information in color, your pager needs
1686 to be properly configured.
1686 to be properly configured.
1687 I strongly recommend using
1687 I strongly recommend using
1688 \family typewriter
1688 \family typewriter
1689 less
1689 less
1690 \family default
1690 \family default
1691 instead of
1691 instead of
1692 \family typewriter
1692 \family typewriter
1693 more
1693 more
1694 \family default
1694 \family default
1695 , as it seems that
1695 , as it seems that
1696 \family typewriter
1696 \family typewriter
1697 more
1697 more
1698 \family default
1698 \family default
1699 simply can not understand colored text correctly.
1699 simply can not understand colored text correctly.
1700 \layout Standard
1700 \layout Standard
1701
1701
1702 In order to configure
1702 In order to configure
1703 \family typewriter
1703 \family typewriter
1704 less
1704 less
1705 \family default
1705 \family default
1706 as your default pager, do the following:
1706 as your default pager, do the following:
1707 \layout Enumerate
1707 \layout Enumerate
1708
1708
1709 Set the environment
1709 Set the environment
1710 \family typewriter
1710 \family typewriter
1711 PAGER
1711 PAGER
1712 \family default
1712 \family default
1713 variable to
1713 variable to
1714 \family typewriter
1714 \family typewriter
1715 less
1715 less
1716 \family default
1716 \family default
1717 .
1717 .
1718 \layout Enumerate
1718 \layout Enumerate
1719
1719
1720 Set the environment
1720 Set the environment
1721 \family typewriter
1721 \family typewriter
1722 LESS
1722 LESS
1723 \family default
1723 \family default
1724 variable to
1724 variable to
1725 \family typewriter
1725 \family typewriter
1726 -r
1726 -r
1727 \family default
1727 \family default
1728 (plus any other options you always want to pass to
1728 (plus any other options you always want to pass to
1729 \family typewriter
1729 \family typewriter
1730 less
1730 less
1731 \family default
1731 \family default
1732 by default).
1732 by default).
1733 This tells
1733 This tells
1734 \family typewriter
1734 \family typewriter
1735 less
1735 less
1736 \family default
1736 \family default
1737 to properly interpret control sequences, which is how color information
1737 to properly interpret control sequences, which is how color information
1738 is given to your terminal.
1738 is given to your terminal.
1739 \layout Standard
1739 \layout Standard
1740
1740
1741 For the
1741 For the
1742 \family typewriter
1742 \family typewriter
1743 csh
1743 csh
1744 \family default
1744 \family default
1745 or
1745 or
1746 \family typewriter
1746 \family typewriter
1747 tcsh
1747 tcsh
1748 \family default
1748 \family default
1749 shells, add to your
1749 shells, add to your
1750 \family typewriter
1750 \family typewriter
1751 ~/.cshrc
1751 ~/.cshrc
1752 \family default
1752 \family default
1753 file the lines:
1753 file the lines:
1754 \layout Standard
1754 \layout Standard
1755
1755
1756
1756
1757 \family typewriter
1757 \family typewriter
1758 setenv PAGER less
1758 setenv PAGER less
1759 \newline
1759 \newline
1760 setenv LESS -r
1760 setenv LESS -r
1761 \layout Standard
1761 \layout Standard
1762
1762
1763 There is similar syntax for other Unix shells, look at your system documentation
1763 There is similar syntax for other Unix shells, look at your system documentation
1764 for details.
1764 for details.
1765 \layout Standard
1765 \layout Standard
1766
1766
1767 If you are on a system which lacks proper data pagers (such as Windows),
1767 If you are on a system which lacks proper data pagers (such as Windows),
1768 IPython will use a very limited builtin pager.
1768 IPython will use a very limited builtin pager.
1769 \layout Subsection
1769 \layout Subsection
1770
1770
1771
1771
1772 \begin_inset LatexCommand \label{sec:emacs}
1772 \begin_inset LatexCommand \label{sec:emacs}
1773
1773
1774 \end_inset
1774 \end_inset
1775
1775
1776 (X)Emacs configuration
1776 (X)Emacs configuration
1777 \layout Standard
1777 \layout Standard
1778
1778
1779 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1779 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1780 (X)Emacs and IPython get along very well.
1780 (X)Emacs and IPython get along very well.
1781
1781
1782 \layout Standard
1782 \layout Standard
1783
1783
1784
1784
1785 \series bold
1785 \series bold
1786 Important note:
1786 Important note:
1787 \series default
1787 \series default
1788 You will need to use a recent enough version of
1788 You will need to use a recent enough version of
1789 \family typewriter
1789 \family typewriter
1790 python-mode.el
1790 python-mode.el
1791 \family default
1791 \family default
1792 , along with the file
1792 , along with the file
1793 \family typewriter
1793 \family typewriter
1794 ipython.el
1794 ipython.el
1795 \family default
1795 \family default
1796 .
1796 .
1797 You can check that the version you have of
1797 You can check that the version you have of
1798 \family typewriter
1798 \family typewriter
1799 python-mode.el
1799 python-mode.el
1800 \family default
1800 \family default
1801 is new enough by either looking at the revision number in the file itself,
1801 is new enough by either looking at the revision number in the file itself,
1802 or asking for it in (X)Emacs via
1802 or asking for it in (X)Emacs via
1803 \family typewriter
1803 \family typewriter
1804 M-x py-version
1804 M-x py-version
1805 \family default
1805 \family default
1806 .
1806 .
1807 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1807 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1808 \layout Standard
1808 \layout Standard
1809
1809
1810 The file
1810 The file
1811 \family typewriter
1811 \family typewriter
1812 ipython.el
1812 ipython.el
1813 \family default
1813 \family default
1814 is included with the IPython distribution, in the documentation directory
1814 is included with the IPython distribution, in the documentation directory
1815 (where this manual resides in PDF and HTML formats).
1815 (where this manual resides in PDF and HTML formats).
1816 \layout Standard
1816 \layout Standard
1817
1817
1818 Once you put these files in your Emacs path, all you need in your
1818 Once you put these files in your Emacs path, all you need in your
1819 \family typewriter
1819 \family typewriter
1820 .emacs
1820 .emacs
1821 \family default
1821 \family default
1822 file is:
1822 file is:
1823 \layout Standard
1823 \layout Standard
1824
1824
1825
1825
1826 \family typewriter
1826 \family typewriter
1827 (require 'ipython)
1827 (require 'ipython)
1828 \layout Standard
1828 \layout Standard
1829
1829
1830 This should give you full support for executing code snippets via IPython,
1830 This should give you full support for executing code snippets via IPython,
1831 opening IPython as your Python shell via
1831 opening IPython as your Python shell via
1832 \family typewriter
1832 \family typewriter
1833 C-c\SpecialChar ~
1833 C-c\SpecialChar ~
1834 !
1834 !
1835 \family default
1835 \family default
1836 , etc.
1836 , etc.
1837
1837
1838 \layout Subsubsection*
1838 \layout Subsubsection*
1839
1839
1840 Notes
1840 Notes
1841 \layout Itemize
1841 \layout Itemize
1842
1842
1843 There is one caveat you should be aware of: you must start the IPython shell
1843 There is one caveat you should be aware of: you must start the IPython shell
1844
1844
1845 \emph on
1845 \emph on
1846 before
1846 before
1847 \emph default
1847 \emph default
1848 attempting to execute any code regions via
1848 attempting to execute any code regions via
1849 \family typewriter
1849 \family typewriter
1850 C-c\SpecialChar ~
1850 C-c\SpecialChar ~
1851 |
1851 |
1852 \family default
1852 \family default
1853 .
1853 .
1854 Simply type
1854 Simply type
1855 \family typewriter
1855 \family typewriter
1856 C-c\SpecialChar ~
1856 C-c\SpecialChar ~
1857 !
1857 !
1858 \family default
1858 \family default
1859 to start IPython before passing any code regions to the interpreter, and
1859 to start IPython before passing any code regions to the interpreter, and
1860 you shouldn't experience any problems.
1860 you shouldn't experience any problems.
1861 \newline
1861 \newline
1862 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1862 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1863 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1863 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1864 \layout Itemize
1864 \layout Itemize
1865
1865
1866 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1866 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1867 ts should be directed to him through the IPython mailing lists.
1867 ts should be directed to him through the IPython mailing lists.
1868
1868
1869 \layout Itemize
1869 \layout Itemize
1870
1870
1871 This code is still somewhat experimental so it's a bit rough around the
1871 This code is still somewhat experimental so it's a bit rough around the
1872 edges (although in practice, it works quite well).
1872 edges (although in practice, it works quite well).
1873 \layout Itemize
1873 \layout Itemize
1874
1874
1875 Be aware that if you customize
1875 Be aware that if you customize
1876 \family typewriter
1876 \family typewriter
1877 py-python-command
1877 py-python-command
1878 \family default
1878 \family default
1879 previously, this value will override what
1879 previously, this value will override what
1880 \family typewriter
1880 \family typewriter
1881 ipython.el
1881 ipython.el
1882 \family default
1882 \family default
1883 does (because loading the customization variables comes later).
1883 does (because loading the customization variables comes later).
1884 \layout Section
1884 \layout Section
1885
1885
1886
1886
1887 \begin_inset LatexCommand \label{sec:quick_tips}
1887 \begin_inset LatexCommand \label{sec:quick_tips}
1888
1888
1889 \end_inset
1889 \end_inset
1890
1890
1891 Quick tips
1891 Quick tips
1892 \layout Standard
1892 \layout Standard
1893
1893
1894 IPython can be used as an improved replacement for the Python prompt, and
1894 IPython can be used as an improved replacement for the Python prompt, and
1895 for that you don't really need to read any more of this manual.
1895 for that you don't really need to read any more of this manual.
1896 But in this section we'll try to summarize a few tips on how to make the
1896 But in this section we'll try to summarize a few tips on how to make the
1897 most effective use of it for everyday Python development, highlighting
1897 most effective use of it for everyday Python development, highlighting
1898 things you might miss in the rest of the manual (which is getting long).
1898 things you might miss in the rest of the manual (which is getting long).
1899 We'll give references to parts in the manual which provide more detail
1899 We'll give references to parts in the manual which provide more detail
1900 when appropriate.
1900 when appropriate.
1901 \layout Standard
1901 \layout Standard
1902
1902
1903 The following article by Jeremy Jones provides an introductory tutorial
1903 The following article by Jeremy Jones provides an introductory tutorial
1904 about IPython:
1904 about IPython:
1905 \newline
1905 \newline
1906
1906
1907 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1907 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1908
1908
1909 \end_inset
1909 \end_inset
1910
1910
1911
1911
1912 \layout Itemize
1912 \layout Itemize
1913
1913
1914 The TAB key.
1914 The TAB key.
1915 TAB-completion, especially for attributes, is a convenient way to explore
1915 TAB-completion, especially for attributes, is a convenient way to explore
1916 the structure of any object you're dealing with.
1916 the structure of any object you're dealing with.
1917 Simply type
1917 Simply type
1918 \family typewriter
1918 \family typewriter
1919 object_name.<TAB>
1919 object_name.<TAB>
1920 \family default
1920 \family default
1921 and a list of the object's attributes will be printed (see sec.
1921 and a list of the object's attributes will be printed (see sec.
1922
1922
1923 \begin_inset LatexCommand \ref{sec:readline}
1923 \begin_inset LatexCommand \ref{sec:readline}
1924
1924
1925 \end_inset
1925 \end_inset
1926
1926
1927 for more).
1927 for more).
1928 Tab completion also works on file and directory names, which combined with
1928 Tab completion also works on file and directory names, which combined with
1929 IPython's alias system allows you to do from within IPython many of the
1929 IPython's alias system allows you to do from within IPython many of the
1930 things you normally would need the system shell for.
1930 things you normally would need the system shell for.
1931
1931
1932 \layout Itemize
1932 \layout Itemize
1933
1933
1934 Explore your objects.
1934 Explore your objects.
1935 Typing
1935 Typing
1936 \family typewriter
1936 \family typewriter
1937 object_name?
1937 object_name?
1938 \family default
1938 \family default
1939 will print all sorts of details about any object, including docstrings,
1939 will print all sorts of details about any object, including docstrings,
1940 function definition lines (for call arguments) and constructor details
1940 function definition lines (for call arguments) and constructor details
1941 for classes.
1941 for classes.
1942 The magic commands
1942 The magic commands
1943 \family typewriter
1943 \family typewriter
1944 %pdoc
1944 %pdoc
1945 \family default
1945 \family default
1946 ,
1946 ,
1947 \family typewriter
1947 \family typewriter
1948 %pdef
1948 %pdef
1949 \family default
1949 \family default
1950 ,
1950 ,
1951 \family typewriter
1951 \family typewriter
1952 %psource
1952 %psource
1953 \family default
1953 \family default
1954 and
1954 and
1955 \family typewriter
1955 \family typewriter
1956 %pfile
1956 %pfile
1957 \family default
1957 \family default
1958 will respectively print the docstring, function definition line, full source
1958 will respectively print the docstring, function definition line, full source
1959 code and the complete file for any object (when they can be found).
1959 code and the complete file for any object (when they can be found).
1960 If automagic is on (it is by default), you don't need to type the '
1960 If automagic is on (it is by default), you don't need to type the '
1961 \family typewriter
1961 \family typewriter
1962 %
1962 %
1963 \family default
1963 \family default
1964 ' explicitly.
1964 ' explicitly.
1965 See sec.
1965 See sec.
1966
1966
1967 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1967 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1968
1968
1969 \end_inset
1969 \end_inset
1970
1970
1971 for more.
1971 for more.
1972 \layout Itemize
1972 \layout Itemize
1973
1973
1974 The
1974 The
1975 \family typewriter
1975 \family typewriter
1976 %run
1976 %run
1977 \family default
1977 \family default
1978 magic command allows you to run any python script and load all of its data
1978 magic command allows you to run any python script and load all of its data
1979 directly into the interactive namespace.
1979 directly into the interactive namespace.
1980 Since the file is re-read from disk each time, changes you make to it are
1980 Since the file is re-read from disk each time, changes you make to it are
1981 reflected immediately (in contrast to the behavior of
1981 reflected immediately (in contrast to the behavior of
1982 \family typewriter
1982 \family typewriter
1983 import
1983 import
1984 \family default
1984 \family default
1985 ).
1985 ).
1986 I rarely use
1986 I rarely use
1987 \family typewriter
1987 \family typewriter
1988 import
1988 import
1989 \family default
1989 \family default
1990 for code I am testing, relying on
1990 for code I am testing, relying on
1991 \family typewriter
1991 \family typewriter
1992 %run
1992 %run
1993 \family default
1993 \family default
1994 instead.
1994 instead.
1995 See sec.
1995 See sec.
1996
1996
1997 \begin_inset LatexCommand \ref{sec:magic}
1997 \begin_inset LatexCommand \ref{sec:magic}
1998
1998
1999 \end_inset
1999 \end_inset
2000
2000
2001 for more on this and other magic commands, or type the name of any magic
2001 for more on this and other magic commands, or type the name of any magic
2002 command and ? to get details on it.
2002 command and ? to get details on it.
2003 See also sec.
2003 See also sec.
2004
2004
2005 \begin_inset LatexCommand \ref{sec:dreload}
2005 \begin_inset LatexCommand \ref{sec:dreload}
2006
2006
2007 \end_inset
2007 \end_inset
2008
2008
2009 for a recursive reload command.
2009 for a recursive reload command.
2010 \newline
2010 \newline
2011
2011
2012 \family typewriter
2012 \family typewriter
2013 %run
2013 %run
2014 \family default
2014 \family default
2015 also has special flags for timing the execution of your scripts (
2015 also has special flags for timing the execution of your scripts (
2016 \family typewriter
2016 \family typewriter
2017 -t
2017 -t
2018 \family default
2018 \family default
2019 ) and for executing them under the control of either Python's
2019 ) and for executing them under the control of either Python's
2020 \family typewriter
2020 \family typewriter
2021 pdb
2021 pdb
2022 \family default
2022 \family default
2023 debugger (
2023 debugger (
2024 \family typewriter
2024 \family typewriter
2025 -d
2025 -d
2026 \family default
2026 \family default
2027 ) or profiler (
2027 ) or profiler (
2028 \family typewriter
2028 \family typewriter
2029 -p
2029 -p
2030 \family default
2030 \family default
2031 ).
2031 ).
2032 With all of these,
2032 With all of these,
2033 \family typewriter
2033 \family typewriter
2034 %run
2034 %run
2035 \family default
2035 \family default
2036 can be used as the main tool for efficient interactive development of code
2036 can be used as the main tool for efficient interactive development of code
2037 which you write in your editor of choice.
2037 which you write in your editor of choice.
2038 \layout Itemize
2038 \layout Itemize
2039
2039
2040 Use the Python debugger,
2040 Use the Python debugger,
2041 \family typewriter
2041 \family typewriter
2042 pdb
2042 pdb
2043 \family default
2043 \family default
2044
2044
2045 \begin_inset Foot
2045 \begin_inset Foot
2046 collapsed true
2046 collapsed true
2047
2047
2048 \layout Standard
2048 \layout Standard
2049
2049
2050 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2050 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2051 to IPython's improved debugger and profiler support.
2051 to IPython's improved debugger and profiler support.
2052 \end_inset
2052 \end_inset
2053
2053
2054 .
2054 .
2055 The
2055 The
2056 \family typewriter
2056 \family typewriter
2057 %pdb
2057 %pdb
2058 \family default
2058 \family default
2059 command allows you to toggle on and off the automatic invocation of an
2059 command allows you to toggle on and off the automatic invocation of an
2060 IPython-enhanced
2060 IPython-enhanced
2061 \family typewriter
2061 \family typewriter
2062 pdb
2062 pdb
2063 \family default
2063 \family default
2064 debugger (with coloring, tab completion and more) at any uncaught exception.
2064 debugger (with coloring, tab completion and more) at any uncaught exception.
2065 The advantage of this is that
2065 The advantage of this is that
2066 \family typewriter
2066 \family typewriter
2067 pdb
2067 pdb
2068 \family default
2068 \family default
2069 starts
2069 starts
2070 \emph on
2070 \emph on
2071 inside
2071 inside
2072 \emph default
2072 \emph default
2073 the function where the exception occurred, with all data still available.
2073 the function where the exception occurred, with all data still available.
2074 You can print variables, see code, execute statements and even walk up
2074 You can print variables, see code, execute statements and even walk up
2075 and down the call stack to track down the true source of the problem (which
2075 and down the call stack to track down the true source of the problem (which
2076 often is many layers in the stack above where the exception gets triggered).
2076 often is many layers in the stack above where the exception gets triggered).
2077 \newline
2077 \newline
2078 Running programs with
2078 Running programs with
2079 \family typewriter
2079 \family typewriter
2080 %run
2080 %run
2081 \family default
2081 \family default
2082 and pdb active can be an efficient to develop and debug code, in many cases
2082 and pdb active can be an efficient to develop and debug code, in many cases
2083 eliminating the need for
2083 eliminating the need for
2084 \family typewriter
2084 \family typewriter
2085 print
2085 print
2086 \family default
2086 \family default
2087 statements or external debugging tools.
2087 statements or external debugging tools.
2088 I often simply put a
2088 I often simply put a
2089 \family typewriter
2089 \family typewriter
2090 1/0
2090 1/0
2091 \family default
2091 \family default
2092 in a place where I want to take a look so that pdb gets called, quickly
2092 in a place where I want to take a look so that pdb gets called, quickly
2093 view whatever variables I need to or test various pieces of code and then
2093 view whatever variables I need to or test various pieces of code and then
2094 remove the
2094 remove the
2095 \family typewriter
2095 \family typewriter
2096 1/0
2096 1/0
2097 \family default
2097 \family default
2098 .
2098 .
2099 \newline
2099 \newline
2100 Note also that `
2100 Note also that `
2101 \family typewriter
2101 \family typewriter
2102 %run -d
2102 %run -d
2103 \family default
2103 \family default
2104 ' activates
2104 ' activates
2105 \family typewriter
2105 \family typewriter
2106 pdb
2106 pdb
2107 \family default
2107 \family default
2108 and automatically sets initial breakpoints for you to step through your
2108 and automatically sets initial breakpoints for you to step through your
2109 code, watch variables, etc.
2109 code, watch variables, etc.
2110 See Sec.\SpecialChar ~
2110 See Sec.\SpecialChar ~
2111
2111
2112 \begin_inset LatexCommand \ref{sec:cache_output}
2112 \begin_inset LatexCommand \ref{sec:cache_output}
2113
2113
2114 \end_inset
2114 \end_inset
2115
2115
2116 for details.
2116 for details.
2117 \layout Itemize
2117 \layout Itemize
2118
2118
2119 Use the output cache.
2119 Use the output cache.
2120 All output results are automatically stored in a global dictionary named
2120 All output results are automatically stored in a global dictionary named
2121
2121
2122 \family typewriter
2122 \family typewriter
2123 Out
2123 Out
2124 \family default
2124 \family default
2125 and variables named
2125 and variables named
2126 \family typewriter
2126 \family typewriter
2127 _1
2127 _1
2128 \family default
2128 \family default
2129 ,
2129 ,
2130 \family typewriter
2130 \family typewriter
2131 _2
2131 _2
2132 \family default
2132 \family default
2133 , etc.
2133 , etc.
2134 alias them.
2134 alias them.
2135 For example, the result of input line 4 is available either as
2135 For example, the result of input line 4 is available either as
2136 \family typewriter
2136 \family typewriter
2137 Out[4]
2137 Out[4]
2138 \family default
2138 \family default
2139 or as
2139 or as
2140 \family typewriter
2140 \family typewriter
2141 _4
2141 _4
2142 \family default
2142 \family default
2143 .
2143 .
2144 Additionally, three variables named
2144 Additionally, three variables named
2145 \family typewriter
2145 \family typewriter
2146 _
2146 _
2147 \family default
2147 \family default
2148 ,
2148 ,
2149 \family typewriter
2149 \family typewriter
2150 __
2150 __
2151 \family default
2151 \family default
2152 and
2152 and
2153 \family typewriter
2153 \family typewriter
2154 ___
2154 ___
2155 \family default
2155 \family default
2156 are always kept updated with the for the last three results.
2156 are always kept updated with the for the last three results.
2157 This allows you to recall any previous result and further use it for new
2157 This allows you to recall any previous result and further use it for new
2158 calculations.
2158 calculations.
2159 See Sec.\SpecialChar ~
2159 See Sec.\SpecialChar ~
2160
2160
2161 \begin_inset LatexCommand \ref{sec:cache_output}
2161 \begin_inset LatexCommand \ref{sec:cache_output}
2162
2162
2163 \end_inset
2163 \end_inset
2164
2164
2165 for more.
2165 for more.
2166 \layout Itemize
2166 \layout Itemize
2167
2167
2168 Put a '
2168 Put a '
2169 \family typewriter
2169 \family typewriter
2170 ;
2170 ;
2171 \family default
2171 \family default
2172 ' at the end of a line to supress the printing of output.
2172 ' at the end of a line to supress the printing of output.
2173 This is useful when doing calculations which generate long output you are
2173 This is useful when doing calculations which generate long output you are
2174 not interested in seeing.
2174 not interested in seeing.
2175 The
2175 The
2176 \family typewriter
2176 \family typewriter
2177 _*
2177 _*
2178 \family default
2178 \family default
2179 variables and the
2179 variables and the
2180 \family typewriter
2180 \family typewriter
2181 Out[]
2181 Out[]
2182 \family default
2182 \family default
2183 list do get updated with the contents of the output, even if it is not
2183 list do get updated with the contents of the output, even if it is not
2184 printed.
2184 printed.
2185 You can thus still access the generated results this way for further processing.
2185 You can thus still access the generated results this way for further processing.
2186 \layout Itemize
2186 \layout Itemize
2187
2187
2188 A similar system exists for caching input.
2188 A similar system exists for caching input.
2189 All input is stored in a global list called
2189 All input is stored in a global list called
2190 \family typewriter
2190 \family typewriter
2191 In
2191 In
2192 \family default
2192 \family default
2193 , so you can re-execute lines 22 through 28 plus line 34 by typing
2193 , so you can re-execute lines 22 through 28 plus line 34 by typing
2194 \family typewriter
2194 \family typewriter
2195 'exec In[22:29]+In[34]'
2195 'exec In[22:29]+In[34]'
2196 \family default
2196 \family default
2197 (using Python slicing notation).
2197 (using Python slicing notation).
2198 If you need to execute the same set of lines often, you can assign them
2198 If you need to execute the same set of lines often, you can assign them
2199 to a macro with the
2199 to a macro with the
2200 \family typewriter
2200 \family typewriter
2201 %macro
2201 %macro
2202 \family default
2202 \family default
2203
2203
2204 \family typewriter
2204 \family typewriter
2205 function.
2205 function.
2206
2206
2207 \family default
2207 \family default
2208 See sec.
2208 See sec.
2209
2209
2210 \begin_inset LatexCommand \ref{sec:cache_input}
2210 \begin_inset LatexCommand \ref{sec:cache_input}
2211
2211
2212 \end_inset
2212 \end_inset
2213
2213
2214 for more.
2214 for more.
2215 \layout Itemize
2215 \layout Itemize
2216
2216
2217 Use your input history.
2217 Use your input history.
2218 The
2218 The
2219 \family typewriter
2219 \family typewriter
2220 %hist
2220 %hist
2221 \family default
2221 \family default
2222 command can show you all previous input, without line numbers if desired
2222 command can show you all previous input, without line numbers if desired
2223 (option
2223 (option
2224 \family typewriter
2224 \family typewriter
2225 -n
2225 -n
2226 \family default
2226 \family default
2227 ) so you can directly copy and paste code either back in IPython or in a
2227 ) so you can directly copy and paste code either back in IPython or in a
2228 text editor.
2228 text editor.
2229 You can also save all your history by turning on logging via
2229 You can also save all your history by turning on logging via
2230 \family typewriter
2230 \family typewriter
2231 %logstart
2231 %logstart
2232 \family default
2232 \family default
2233 ; these logs can later be either reloaded as IPython sessions or used as
2233 ; these logs can later be either reloaded as IPython sessions or used as
2234 code for your programs.
2234 code for your programs.
2235 \layout Itemize
2235 \layout Itemize
2236
2236
2237 Define your own system aliases.
2237 Define your own system aliases.
2238 Even though IPython gives you access to your system shell via the
2238 Even though IPython gives you access to your system shell via the
2239 \family typewriter
2239 \family typewriter
2240 !
2240 !
2241 \family default
2241 \family default
2242 prefix, it is convenient to have aliases to the system commands you use
2242 prefix, it is convenient to have aliases to the system commands you use
2243 most often.
2243 most often.
2244 This allows you to work seamlessly from inside IPython with the same commands
2244 This allows you to work seamlessly from inside IPython with the same commands
2245 you are used to in your system shell.
2245 you are used to in your system shell.
2246 \newline
2246 \newline
2247 IPython comes with some pre-defined aliases and a complete system for changing
2247 IPython comes with some pre-defined aliases and a complete system for changing
2248 directories, both via a stack (see
2248 directories, both via a stack (see
2249 \family typewriter
2249 \family typewriter
2250 %pushd
2250 %pushd
2251 \family default
2251 \family default
2252 ,
2252 ,
2253 \family typewriter
2253 \family typewriter
2254 %popd
2254 %popd
2255 \family default
2255 \family default
2256 and
2256 and
2257 \family typewriter
2257 \family typewriter
2258 %ds
2258 %ds
2259 \family default
2259 \family default
2260 ) and via direct
2260 ) and via direct
2261 \family typewriter
2261 \family typewriter
2262 %cd
2262 %cd
2263 \family default
2263 \family default
2264 .
2264 .
2265 The latter keeps a history of visited directories and allows you to go
2265 The latter keeps a history of visited directories and allows you to go
2266 to any previously visited one.
2266 to any previously visited one.
2267 \layout Itemize
2267 \layout Itemize
2268
2268
2269 Use Python to manipulate the results of system commands.
2269 Use Python to manipulate the results of system commands.
2270 The `
2270 The `
2271 \family typewriter
2271 \family typewriter
2272 !!
2272 !!
2273 \family default
2273 \family default
2274 ' special syntax, and the
2274 ' special syntax, and the
2275 \family typewriter
2275 \family typewriter
2276 %sc
2276 %sc
2277 \family default
2277 \family default
2278 and
2278 and
2279 \family typewriter
2279 \family typewriter
2280 %sx
2280 %sx
2281 \family default
2281 \family default
2282 magic commands allow you to capture system output into Python variables.
2282 magic commands allow you to capture system output into Python variables.
2283 \layout Itemize
2283 \layout Itemize
2284
2284
2285 Expand python variables when calling the shell (either via
2285 Expand python variables when calling the shell (either via
2286 \family typewriter
2286 \family typewriter
2287 `!'
2287 `!'
2288 \family default
2288 \family default
2289 and
2289 and
2290 \family typewriter
2290 \family typewriter
2291 `!!'
2291 `!!'
2292 \family default
2292 \family default
2293 or via aliases) by prepending a
2293 or via aliases) by prepending a
2294 \family typewriter
2294 \family typewriter
2295 $
2295 $
2296 \family default
2296 \family default
2297 in front of them.
2297 in front of them.
2298 You can also expand complete python expressions.
2298 You can also expand complete python expressions.
2299 See sec.\SpecialChar ~
2299 See sec.\SpecialChar ~
2300
2300
2301 \begin_inset LatexCommand \ref{sub:System-shell-access}
2301 \begin_inset LatexCommand \ref{sub:System-shell-access}
2302
2302
2303 \end_inset
2303 \end_inset
2304
2304
2305 for more.
2305 for more.
2306 \layout Itemize
2306 \layout Itemize
2307
2307
2308 Use profiles to maintain different configurations (modules to load, function
2308 Use profiles to maintain different configurations (modules to load, function
2309 definitions, option settings) for particular tasks.
2309 definitions, option settings) for particular tasks.
2310 You can then have customized versions of IPython for specific purposes.
2310 You can then have customized versions of IPython for specific purposes.
2311 See sec.\SpecialChar ~
2311 See sec.\SpecialChar ~
2312
2312
2313 \begin_inset LatexCommand \ref{sec:profiles}
2313 \begin_inset LatexCommand \ref{sec:profiles}
2314
2314
2315 \end_inset
2315 \end_inset
2316
2316
2317 for more.
2317 for more.
2318 \layout Itemize
2318 \layout Itemize
2319
2319
2320 Embed IPython in your programs.
2320 Embed IPython in your programs.
2321 A few lines of code are enough to load a complete IPython inside your own
2321 A few lines of code are enough to load a complete IPython inside your own
2322 programs, giving you the ability to work with your data interactively after
2322 programs, giving you the ability to work with your data interactively after
2323 automatic processing has been completed.
2323 automatic processing has been completed.
2324 See sec.\SpecialChar ~
2324 See sec.\SpecialChar ~
2325
2325
2326 \begin_inset LatexCommand \ref{sec:embed}
2326 \begin_inset LatexCommand \ref{sec:embed}
2327
2327
2328 \end_inset
2328 \end_inset
2329
2329
2330 for more.
2330 for more.
2331 \layout Itemize
2331 \layout Itemize
2332
2332
2333 Use the Python profiler.
2333 Use the Python profiler.
2334 When dealing with performance issues, the
2334 When dealing with performance issues, the
2335 \family typewriter
2335 \family typewriter
2336 %run
2336 %run
2337 \family default
2337 \family default
2338 command with a
2338 command with a
2339 \family typewriter
2339 \family typewriter
2340 -p
2340 -p
2341 \family default
2341 \family default
2342 option allows you to run complete programs under the control of the Python
2342 option allows you to run complete programs under the control of the Python
2343 profiler.
2343 profiler.
2344 The
2344 The
2345 \family typewriter
2345 \family typewriter
2346 %prun
2346 %prun
2347 \family default
2347 \family default
2348 command does a similar job for single Python expressions (like function
2348 command does a similar job for single Python expressions (like function
2349 calls).
2349 calls).
2350 \layout Itemize
2350 \layout Itemize
2351
2351
2352 Use the IPython.demo.Demo class to load any Python script as an interactive
2352 Use the IPython.demo.Demo class to load any Python script as an interactive
2353 demo.
2353 demo.
2354 With a minimal amount of simple markup, you can control the execution of
2354 With a minimal amount of simple markup, you can control the execution of
2355 the script, stopping as needed.
2355 the script, stopping as needed.
2356 See sec.\SpecialChar ~
2356 See sec.\SpecialChar ~
2357
2357
2358 \begin_inset LatexCommand \ref{sec:interactive-demos}
2358 \begin_inset LatexCommand \ref{sec:interactive-demos}
2359
2359
2360 \end_inset
2360 \end_inset
2361
2361
2362 for more.
2362 for more.
2363 \layout Subsection
2363 \layout Subsection
2364
2364
2365 Source code handling tips
2365 Source code handling tips
2366 \layout Standard
2366 \layout Standard
2367
2367
2368 IPython is a line-oriented program, without full control of the terminal.
2368 IPython is a line-oriented program, without full control of the terminal.
2369 Therefore, it doesn't support true multiline editing.
2369 Therefore, it doesn't support true multiline editing.
2370 However, it has a number of useful tools to help you in dealing effectively
2370 However, it has a number of useful tools to help you in dealing effectively
2371 with more complex editing.
2371 with more complex editing.
2372 \layout Standard
2372 \layout Standard
2373
2373
2374 The
2374 The
2375 \family typewriter
2375 \family typewriter
2376 %edit
2376 %edit
2377 \family default
2377 \family default
2378 command gives a reasonable approximation of multiline editing, by invoking
2378 command gives a reasonable approximation of multiline editing, by invoking
2379 your favorite editor on the spot.
2379 your favorite editor on the spot.
2380 IPython will execute the code you type in there as if it were typed interactive
2380 IPython will execute the code you type in there as if it were typed interactive
2381 ly.
2381 ly.
2382 Type
2382 Type
2383 \family typewriter
2383 \family typewriter
2384 %edit?
2384 %edit?
2385 \family default
2385 \family default
2386 for the full details on the edit command.
2386 for the full details on the edit command.
2387 \layout Standard
2387 \layout Standard
2388
2388
2389 If you have typed various commands during a session, which you'd like to
2389 If you have typed various commands during a session, which you'd like to
2390 reuse, IPython provides you with a number of tools.
2390 reuse, IPython provides you with a number of tools.
2391 Start by using
2391 Start by using
2392 \family typewriter
2392 \family typewriter
2393 %hist
2393 %hist
2394 \family default
2394 \family default
2395 to see your input history, so you can see the line numbers of all input.
2395 to see your input history, so you can see the line numbers of all input.
2396 Let us say that you'd like to reuse lines 10 through 20, plus lines 24
2396 Let us say that you'd like to reuse lines 10 through 20, plus lines 24
2397 and 28.
2397 and 28.
2398 All the commands below can operate on these with the syntax
2398 All the commands below can operate on these with the syntax
2399 \layout LyX-Code
2399 \layout LyX-Code
2400
2400
2401 %command 10-20 24 28
2401 %command 10-20 24 28
2402 \layout Standard
2402 \layout Standard
2403
2403
2404 where the command given can be:
2404 where the command given can be:
2405 \layout Itemize
2405 \layout Itemize
2406
2406
2407
2407
2408 \family typewriter
2408 \family typewriter
2409 %macro <macroname>
2409 %macro <macroname>
2410 \family default
2410 \family default
2411 : this stores the lines into a variable which, when called at the prompt,
2411 : this stores the lines into a variable which, when called at the prompt,
2412 re-executes the input.
2412 re-executes the input.
2413 Macros can be edited later using
2413 Macros can be edited later using
2414 \family typewriter
2414 \family typewriter
2415 `%edit macroname
2415 `%edit macroname
2416 \family default
2416 \family default
2417 ', and they can be stored persistently across sessions with `
2417 ', and they can be stored persistently across sessions with `
2418 \family typewriter
2418 \family typewriter
2419 %store macroname
2419 %store macroname
2420 \family default
2420 \family default
2421 ' (the storage system is per-profile).
2421 ' (the storage system is per-profile).
2422 The combination of quick macros, persistent storage and editing, allows
2422 The combination of quick macros, persistent storage and editing, allows
2423 you to easily refine quick-and-dirty interactive input into permanent utilities
2423 you to easily refine quick-and-dirty interactive input into permanent utilities
2424 , always available both in IPython and as files for general reuse.
2424 , always available both in IPython and as files for general reuse.
2425 \layout Itemize
2425 \layout Itemize
2426
2426
2427
2427
2428 \family typewriter
2428 \family typewriter
2429 %edit
2429 %edit
2430 \family default
2430 \family default
2431 : this will open a text editor with those lines pre-loaded for further modificat
2431 : this will open a text editor with those lines pre-loaded for further modificat
2432 ion.
2432 ion.
2433 It will then execute the resulting file's contents as if you had typed
2433 It will then execute the resulting file's contents as if you had typed
2434 it at the prompt.
2434 it at the prompt.
2435 \layout Itemize
2435 \layout Itemize
2436
2436
2437
2437
2438 \family typewriter
2438 \family typewriter
2439 %save <filename>
2439 %save <filename>
2440 \family default
2440 \family default
2441 : this saves the lines directly to a named file on disk.
2441 : this saves the lines directly to a named file on disk.
2442 \layout Standard
2442 \layout Standard
2443
2443
2444 While
2444 While
2445 \family typewriter
2445 \family typewriter
2446 %macro
2446 %macro
2447 \family default
2447 \family default
2448 saves input lines into memory for interactive re-execution, sometimes you'd
2448 saves input lines into memory for interactive re-execution, sometimes you'd
2449 like to save your input directly to a file.
2449 like to save your input directly to a file.
2450 The
2450 The
2451 \family typewriter
2451 \family typewriter
2452 %save
2452 %save
2453 \family default
2453 \family default
2454 magic does this: its input sytnax is the same as
2454 magic does this: its input sytnax is the same as
2455 \family typewriter
2455 \family typewriter
2456 %macro
2456 %macro
2457 \family default
2457 \family default
2458 , but it saves your input directly to a Python file.
2458 , but it saves your input directly to a Python file.
2459 Note that the
2459 Note that the
2460 \family typewriter
2460 \family typewriter
2461 %logstart
2461 %logstart
2462 \family default
2462 \family default
2463 command also saves input, but it logs
2463 command also saves input, but it logs
2464 \emph on
2464 \emph on
2465 all
2465 all
2466 \emph default
2466 \emph default
2467 input to disk (though you can temporarily suspend it and reactivate it
2467 input to disk (though you can temporarily suspend it and reactivate it
2468 with
2468 with
2469 \family typewriter
2469 \family typewriter
2470 %logoff/%logon
2470 %logoff/%logon
2471 \family default
2471 \family default
2472 );
2472 );
2473 \family typewriter
2473 \family typewriter
2474 %save
2474 %save
2475 \family default
2475 \family default
2476 allows you to select which lines of input you need to save.
2476 allows you to select which lines of input you need to save.
2477 \layout Standard
2478
2479 And
2480 \layout Subsection
2477 \layout Subsection
2481
2478
2482 Effective logging
2479 Effective logging
2483 \layout Standard
2480 \layout Standard
2484
2481
2485 A very useful suggestion sent in by Robert Kern follows:
2482 A very useful suggestion sent in by Robert Kern follows:
2486 \layout Standard
2483 \layout Standard
2487
2484
2488 I recently happened on a nifty way to keep tidy per-project log files.
2485 I recently happened on a nifty way to keep tidy per-project log files.
2489 I made a profile for my project (which is called "parkfield").
2486 I made a profile for my project (which is called "parkfield").
2490 \layout LyX-Code
2487 \layout LyX-Code
2491
2488
2492 include ipythonrc
2489 include ipythonrc
2493 \layout LyX-Code
2490 \layout LyX-Code
2494
2491
2495 logfile '' # cancel earlier logfile invocation
2492 logfile '' # cancel earlier logfile invocation
2496 \layout LyX-Code
2493 \layout LyX-Code
2497
2494
2498 execute import time
2495 execute import time
2499 \layout LyX-Code
2496 \layout LyX-Code
2500
2497
2501 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2498 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2502 \layout LyX-Code
2499 \layout LyX-Code
2503
2500
2504 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2501 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2505 \layout Standard
2502 \layout Standard
2506
2503
2507 I also added a shell alias for convenience:
2504 I also added a shell alias for convenience:
2508 \layout LyX-Code
2505 \layout LyX-Code
2509
2506
2510 alias parkfield="ipython -pylab -profile parkfield"
2507 alias parkfield="ipython -pylab -profile parkfield"
2511 \layout Standard
2508 \layout Standard
2512
2509
2513 Now I have a nice little directory with everything I ever type in, organized
2510 Now I have a nice little directory with everything I ever type in, organized
2514 by project and date.
2511 by project and date.
2515 \layout Standard
2512 \layout Standard
2516
2513
2517
2514
2518 \series bold
2515 \series bold
2519 Contribute your own:
2516 Contribute your own:
2520 \series default
2517 \series default
2521 If you have your own favorite tip on using IPython efficiently for a certain
2518 If you have your own favorite tip on using IPython efficiently for a certain
2522 task (especially things which can't be done in the normal Python interpreter),
2519 task (especially things which can't be done in the normal Python interpreter),
2523 don't hesitate to send it!
2520 don't hesitate to send it!
2524 \layout Section
2521 \layout Section
2525
2522
2526 Command-line use
2523 Command-line use
2527 \layout Standard
2524 \layout Standard
2528
2525
2529 You start IPython with the command:
2526 You start IPython with the command:
2530 \layout Standard
2527 \layout Standard
2531
2528
2532
2529
2533 \family typewriter
2530 \family typewriter
2534 $ ipython [options] files
2531 $ ipython [options] files
2535 \layout Standard
2532 \layout Standard
2536
2533
2537 If invoked with no options, it executes all the files listed in sequence
2534 If invoked with no options, it executes all the files listed in sequence
2538 and drops you into the interpreter while still acknowledging any options
2535 and drops you into the interpreter while still acknowledging any options
2539 you may have set in your ipythonrc file.
2536 you may have set in your ipythonrc file.
2540 This behavior is different from standard Python, which when called as
2537 This behavior is different from standard Python, which when called as
2541 \family typewriter
2538 \family typewriter
2542 python -i
2539 python -i
2543 \family default
2540 \family default
2544 will only execute one file and ignore your configuration setup.
2541 will only execute one file and ignore your configuration setup.
2545 \layout Standard
2542 \layout Standard
2546
2543
2547 Please note that some of the configuration options are not available at
2544 Please note that some of the configuration options are not available at
2548 the command line, simply because they are not practical here.
2545 the command line, simply because they are not practical here.
2549 Look into your ipythonrc configuration file for details on those.
2546 Look into your ipythonrc configuration file for details on those.
2550 This file typically installed in the
2547 This file typically installed in the
2551 \family typewriter
2548 \family typewriter
2552 $HOME/.ipython
2549 $HOME/.ipython
2553 \family default
2550 \family default
2554 directory.
2551 directory.
2555 For Windows users,
2552 For Windows users,
2556 \family typewriter
2553 \family typewriter
2557 $HOME
2554 $HOME
2558 \family default
2555 \family default
2559 resolves to
2556 resolves to
2560 \family typewriter
2557 \family typewriter
2561 C:
2558 C:
2562 \backslash
2559 \backslash
2563
2560
2564 \backslash
2561 \backslash
2565 Documents and Settings
2562 Documents and Settings
2566 \backslash
2563 \backslash
2567
2564
2568 \backslash
2565 \backslash
2569 YourUserName
2566 YourUserName
2570 \family default
2567 \family default
2571 in most instances.
2568 in most instances.
2572 In the rest of this text, we will refer to this directory as
2569 In the rest of this text, we will refer to this directory as
2573 \family typewriter
2570 \family typewriter
2574 IPYTHONDIR
2571 IPYTHONDIR
2575 \family default
2572 \family default
2576 .
2573 .
2577 \layout Subsection
2574 \layout Subsection
2578
2575
2579
2576
2580 \begin_inset LatexCommand \label{sec:threading-opts}
2577 \begin_inset LatexCommand \label{sec:threading-opts}
2581
2578
2582 \end_inset
2579 \end_inset
2583
2580
2584 Special Threading Options
2581 Special Threading Options
2585 \layout Standard
2582 \layout Standard
2586
2583
2587 The following special options are ONLY valid at the beginning of the command
2584 The following special options are ONLY valid at the beginning of the command
2588 line, and not later.
2585 line, and not later.
2589 This is because they control the initial- ization of ipython itself, before
2586 This is because they control the initial- ization of ipython itself, before
2590 the normal option-handling mechanism is active.
2587 the normal option-handling mechanism is active.
2591 \layout List
2588 \layout List
2592 \labelwidthstring 00.00.0000
2589 \labelwidthstring 00.00.0000
2593
2590
2594
2591
2595 \family typewriter
2592 \family typewriter
2596 \series bold
2593 \series bold
2597 -gthread,\SpecialChar ~
2594 -gthread,\SpecialChar ~
2598 -qthread,\SpecialChar ~
2595 -qthread,\SpecialChar ~
2599 -wthread,\SpecialChar ~
2596 -wthread,\SpecialChar ~
2600 -pylab:
2597 -pylab:
2601 \family default
2598 \family default
2602 \series default
2599 \series default
2603 Only
2600 Only
2604 \emph on
2601 \emph on
2605 one
2602 one
2606 \emph default
2603 \emph default
2607 of these can be given, and it can only be given as the first option passed
2604 of these can be given, and it can only be given as the first option passed
2608 to IPython (it will have no effect in any other position).
2605 to IPython (it will have no effect in any other position).
2609 They provide threading support for the GTK Qt and WXPython toolkits, and
2606 They provide threading support for the GTK Qt and WXPython toolkits, and
2610 for the matplotlib library.
2607 for the matplotlib library.
2611 \layout List
2608 \layout List
2612 \labelwidthstring 00.00.0000
2609 \labelwidthstring 00.00.0000
2613
2610
2614 \SpecialChar ~
2611 \SpecialChar ~
2615 With any of the first three options, IPython starts running a separate
2612 With any of the first three options, IPython starts running a separate
2616 thread for the graphical toolkit's operation, so that you can open and
2613 thread for the graphical toolkit's operation, so that you can open and
2617 control graphical elements from within an IPython command line, without
2614 control graphical elements from within an IPython command line, without
2618 blocking.
2615 blocking.
2619 All three provide essentially the same functionality, respectively for
2616 All three provide essentially the same functionality, respectively for
2620 GTK, QT and WXWidgets (via their Python interfaces).
2617 GTK, QT and WXWidgets (via their Python interfaces).
2621 \layout List
2618 \layout List
2622 \labelwidthstring 00.00.0000
2619 \labelwidthstring 00.00.0000
2623
2620
2624 \SpecialChar ~
2621 \SpecialChar ~
2625 Note that with
2622 Note that with
2626 \family typewriter
2623 \family typewriter
2627 -wthread
2624 -wthread
2628 \family default
2625 \family default
2629 , you can additionally use the -wxversion option to request a specific version
2626 , you can additionally use the -wxversion option to request a specific version
2630 of wx to be used.
2627 of wx to be used.
2631 This requires that you have the
2628 This requires that you have the
2632 \family typewriter
2629 \family typewriter
2633 wxversion
2630 wxversion
2634 \family default
2631 \family default
2635 Python module installed, which is part of recent wxPython distributions.
2632 Python module installed, which is part of recent wxPython distributions.
2636 \layout List
2633 \layout List
2637 \labelwidthstring 00.00.0000
2634 \labelwidthstring 00.00.0000
2638
2635
2639 \SpecialChar ~
2636 \SpecialChar ~
2640 If
2637 If
2641 \family typewriter
2638 \family typewriter
2642 -pylab
2639 -pylab
2643 \family default
2640 \family default
2644 is given, IPython loads special support for the mat plotlib library (
2641 is given, IPython loads special support for the mat plotlib library (
2645 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2642 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2646
2643
2647 \end_inset
2644 \end_inset
2648
2645
2649 ), allowing interactive usage of any of its backends as defined in the user's
2646 ), allowing interactive usage of any of its backends as defined in the user's
2650
2647
2651 \family typewriter
2648 \family typewriter
2652 ~/.matplotlib/matplotlibrc
2649 ~/.matplotlib/matplotlibrc
2653 \family default
2650 \family default
2654 file.
2651 file.
2655 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2652 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2656 of matplotlib backend requires it.
2653 of matplotlib backend requires it.
2657 It also modifies the
2654 It also modifies the
2658 \family typewriter
2655 \family typewriter
2659 %run
2656 %run
2660 \family default
2657 \family default
2661 command to correctly execute (without blocking) any matplotlib-based script
2658 command to correctly execute (without blocking) any matplotlib-based script
2662 which calls
2659 which calls
2663 \family typewriter
2660 \family typewriter
2664 show()
2661 show()
2665 \family default
2662 \family default
2666 at the end.
2663 at the end.
2667
2664
2668 \layout List
2665 \layout List
2669 \labelwidthstring 00.00.0000
2666 \labelwidthstring 00.00.0000
2670
2667
2671
2668
2672 \family typewriter
2669 \family typewriter
2673 \series bold
2670 \series bold
2674 -tk
2671 -tk
2675 \family default
2672 \family default
2676 \series default
2673 \series default
2677 The
2674 The
2678 \family typewriter
2675 \family typewriter
2679 -g/q/wthread
2676 -g/q/wthread
2680 \family default
2677 \family default
2681 options, and
2678 options, and
2682 \family typewriter
2679 \family typewriter
2683 -pylab
2680 -pylab
2684 \family default
2681 \family default
2685 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2682 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2686 Tk graphical interfaces.
2683 Tk graphical interfaces.
2687 This means that when either GTK, Qt or WX threading is active, any attempt
2684 This means that when either GTK, Qt or WX threading is active, any attempt
2688 to open a Tk GUI will result in a dead window, and possibly cause the Python
2685 to open a Tk GUI will result in a dead window, and possibly cause the Python
2689 interpreter to crash.
2686 interpreter to crash.
2690 An extra option,
2687 An extra option,
2691 \family typewriter
2688 \family typewriter
2692 -tk
2689 -tk
2693 \family default
2690 \family default
2694 , is available to address this issue.
2691 , is available to address this issue.
2695 It can
2692 It can
2696 \emph on
2693 \emph on
2697 only
2694 only
2698 \emph default
2695 \emph default
2699 be given as a
2696 be given as a
2700 \emph on
2697 \emph on
2701 second
2698 second
2702 \emph default
2699 \emph default
2703 option after any of the above (
2700 option after any of the above (
2704 \family typewriter
2701 \family typewriter
2705 -gthread
2702 -gthread
2706 \family default
2703 \family default
2707 ,
2704 ,
2708 \family typewriter
2705 \family typewriter
2709 -wthread
2706 -wthread
2710 \family default
2707 \family default
2711 or
2708 or
2712 \family typewriter
2709 \family typewriter
2713 -pylab
2710 -pylab
2714 \family default
2711 \family default
2715 ).
2712 ).
2716 \layout List
2713 \layout List
2717 \labelwidthstring 00.00.0000
2714 \labelwidthstring 00.00.0000
2718
2715
2719 \SpecialChar ~
2716 \SpecialChar ~
2720 If
2717 If
2721 \family typewriter
2718 \family typewriter
2722 -tk
2719 -tk
2723 \family default
2720 \family default
2724 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2721 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2725 This is however potentially unreliable, and you will have to test on your
2722 This is however potentially unreliable, and you will have to test on your
2726 platform and Python configuration to determine whether it works for you.
2723 platform and Python configuration to determine whether it works for you.
2727 Debian users have reported success, apparently due to the fact that Debian
2724 Debian users have reported success, apparently due to the fact that Debian
2728 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2725 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2729 Under other Linux environments (such as Fedora Core 2/3), this option has
2726 Under other Linux environments (such as Fedora Core 2/3), this option has
2730 caused random crashes and lockups of the Python interpreter.
2727 caused random crashes and lockups of the Python interpreter.
2731 Under other operating systems (Mac OSX and Windows), you'll need to try
2728 Under other operating systems (Mac OSX and Windows), you'll need to try
2732 it to find out, since currently no user reports are available.
2729 it to find out, since currently no user reports are available.
2733 \layout List
2730 \layout List
2734 \labelwidthstring 00.00.0000
2731 \labelwidthstring 00.00.0000
2735
2732
2736 \SpecialChar ~
2733 \SpecialChar ~
2737 There is unfortunately no way for IPython to determine at run time whether
2734 There is unfortunately no way for IPython to determine at run time whether
2738
2735
2739 \family typewriter
2736 \family typewriter
2740 -tk
2737 -tk
2741 \family default
2738 \family default
2742 will work reliably or not, so you will need to do some experiments before
2739 will work reliably or not, so you will need to do some experiments before
2743 relying on it for regular work.
2740 relying on it for regular work.
2744
2741
2745 \layout Subsection
2742 \layout Subsection
2746
2743
2747
2744
2748 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2745 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2749
2746
2750 \end_inset
2747 \end_inset
2751
2748
2752 Regular Options
2749 Regular Options
2753 \layout Standard
2750 \layout Standard
2754
2751
2755 After the above threading options have been given, regular options can follow
2752 After the above threading options have been given, regular options can follow
2756 in any order.
2753 in any order.
2757 All options can be abbreviated to their shortest non-ambiguous form and
2754 All options can be abbreviated to their shortest non-ambiguous form and
2758 are case-sensitive.
2755 are case-sensitive.
2759 One or two dashes can be used.
2756 One or two dashes can be used.
2760 Some options have an alternate short form, indicated after a
2757 Some options have an alternate short form, indicated after a
2761 \family typewriter
2758 \family typewriter
2762 |
2759 |
2763 \family default
2760 \family default
2764 .
2761 .
2765 \layout Standard
2762 \layout Standard
2766
2763
2767 Most options can also be set from your ipythonrc configuration file.
2764 Most options can also be set from your ipythonrc configuration file.
2768 See the provided example for more details on what the options do.
2765 See the provided example for more details on what the options do.
2769 Options given at the command line override the values set in the ipythonrc
2766 Options given at the command line override the values set in the ipythonrc
2770 file.
2767 file.
2771 \layout Standard
2768 \layout Standard
2772
2769
2773 All options with a
2770 All options with a
2774 \family typewriter
2771 \family typewriter
2775 [no]
2772 [no]
2776 \family default
2773 \family default
2777 prepended can be specified in negated form (
2774 prepended can be specified in negated form (
2778 \family typewriter
2775 \family typewriter
2779 -nooption
2776 -nooption
2780 \family default
2777 \family default
2781 instead of
2778 instead of
2782 \family typewriter
2779 \family typewriter
2783 -option
2780 -option
2784 \family default
2781 \family default
2785 ) to turn the feature off.
2782 ) to turn the feature off.
2786 \layout List
2783 \layout List
2787 \labelwidthstring 00.00.0000
2784 \labelwidthstring 00.00.0000
2788
2785
2789
2786
2790 \family typewriter
2787 \family typewriter
2791 \series bold
2788 \series bold
2792 -help
2789 -help
2793 \family default
2790 \family default
2794 \series default
2791 \series default
2795 : print a help message and exit.
2792 : print a help message and exit.
2796 \layout List
2793 \layout List
2797 \labelwidthstring 00.00.0000
2794 \labelwidthstring 00.00.0000
2798
2795
2799
2796
2800 \family typewriter
2797 \family typewriter
2801 \series bold
2798 \series bold
2802 -pylab:
2799 -pylab:
2803 \family default
2800 \family default
2804 \series default
2801 \series default
2805 this can
2802 this can
2806 \emph on
2803 \emph on
2807 only
2804 only
2808 \emph default
2805 \emph default
2809 be given as the
2806 be given as the
2810 \emph on
2807 \emph on
2811 first
2808 first
2812 \emph default
2809 \emph default
2813 option passed to IPython (it will have no effect in any other position).
2810 option passed to IPython (it will have no effect in any other position).
2814 It adds special support for the matplotlib library (
2811 It adds special support for the matplotlib library (
2815 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2812 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2816
2813
2817 \end_inset
2814 \end_inset
2818
2815
2819 ), allowing interactive usage of any of its backends as defined in the user's
2816 ), allowing interactive usage of any of its backends as defined in the user's
2820
2817
2821 \family typewriter
2818 \family typewriter
2822 .matplotlibrc
2819 .matplotlibrc
2823 \family default
2820 \family default
2824 file.
2821 file.
2825 It automatically activates GTK or WX threading for IPyhton if the choice
2822 It automatically activates GTK or WX threading for IPyhton if the choice
2826 of matplotlib backend requires it.
2823 of matplotlib backend requires it.
2827 It also modifies the
2824 It also modifies the
2828 \family typewriter
2825 \family typewriter
2829 %run
2826 %run
2830 \family default
2827 \family default
2831 command to correctly execute (without blocking) any matplotlib-based script
2828 command to correctly execute (without blocking) any matplotlib-based script
2832 which calls
2829 which calls
2833 \family typewriter
2830 \family typewriter
2834 show()
2831 show()
2835 \family default
2832 \family default
2836 at the end.
2833 at the end.
2837 See Sec.\SpecialChar ~
2834 See Sec.\SpecialChar ~
2838
2835
2839 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2836 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2840
2837
2841 \end_inset
2838 \end_inset
2842
2839
2843 for more details.
2840 for more details.
2844 \layout List
2841 \layout List
2845 \labelwidthstring 00.00.0000
2842 \labelwidthstring 00.00.0000
2846
2843
2847
2844
2848 \family typewriter
2845 \family typewriter
2849 \series bold
2846 \series bold
2850 -autocall <val>:
2847 -autocall <val>:
2851 \family default
2848 \family default
2852 \series default
2849 \series default
2853 Make IPython automatically call any callable object even if you didn't
2850 Make IPython automatically call any callable object even if you didn't
2854 type explicit parentheses.
2851 type explicit parentheses.
2855 For example, `str 43' becomes `str(43)' automatically.
2852 For example, `str 43' becomes `str(43)' automatically.
2856 The value can be `0' to disable the feature, `1' for
2853 The value can be `0' to disable the feature, `1' for
2857 \emph on
2854 \emph on
2858 smart
2855 smart
2859 \emph default
2856 \emph default
2860 autocall, where it is not applied if there are no more arguments on the
2857 autocall, where it is not applied if there are no more arguments on the
2861 line, and `2' for
2858 line, and `2' for
2862 \emph on
2859 \emph on
2863 full
2860 full
2864 \emph default
2861 \emph default
2865 autocall, where all callable objects are automatically called (even if
2862 autocall, where all callable objects are automatically called (even if
2866 no arguments are present).
2863 no arguments are present).
2867 The default is `1'.
2864 The default is `1'.
2868 \layout List
2865 \layout List
2869 \labelwidthstring 00.00.0000
2866 \labelwidthstring 00.00.0000
2870
2867
2871
2868
2872 \family typewriter
2869 \family typewriter
2873 \series bold
2870 \series bold
2874 -[no]autoindent:
2871 -[no]autoindent:
2875 \family default
2872 \family default
2876 \series default
2873 \series default
2877 Turn automatic indentation on/off.
2874 Turn automatic indentation on/off.
2878 \layout List
2875 \layout List
2879 \labelwidthstring 00.00.0000
2876 \labelwidthstring 00.00.0000
2880
2877
2881
2878
2882 \family typewriter
2879 \family typewriter
2883 \series bold
2880 \series bold
2884 -[no]automagic
2881 -[no]automagic
2885 \series default
2882 \series default
2886 :
2883 :
2887 \family default
2884 \family default
2888 make magic commands automatic (without needing their first character to
2885 make magic commands automatic (without needing their first character to
2889 be
2886 be
2890 \family typewriter
2887 \family typewriter
2891 %
2888 %
2892 \family default
2889 \family default
2893 ).
2890 ).
2894 Type
2891 Type
2895 \family typewriter
2892 \family typewriter
2896 %magic
2893 %magic
2897 \family default
2894 \family default
2898 at the IPython prompt for more information.
2895 at the IPython prompt for more information.
2899 \layout List
2896 \layout List
2900 \labelwidthstring 00.00.0000
2897 \labelwidthstring 00.00.0000
2901
2898
2902
2899
2903 \family typewriter
2900 \family typewriter
2904 \series bold
2901 \series bold
2905 -[no]autoedit_syntax:
2902 -[no]autoedit_syntax:
2906 \family default
2903 \family default
2907 \series default
2904 \series default
2908 When a syntax error occurs after editing a file, automatically open the
2905 When a syntax error occurs after editing a file, automatically open the
2909 file to the trouble causing line for convenient fixing.
2906 file to the trouble causing line for convenient fixing.
2910
2907
2911 \layout List
2908 \layout List
2912 \labelwidthstring 00.00.0000
2909 \labelwidthstring 00.00.0000
2913
2910
2914
2911
2915 \family typewriter
2912 \family typewriter
2916 \series bold
2913 \series bold
2917 -[no]banner
2914 -[no]banner
2918 \series default
2915 \series default
2919 :
2916 :
2920 \family default
2917 \family default
2921 Print the initial information banner (default on).
2918 Print the initial information banner (default on).
2922 \layout List
2919 \layout List
2923 \labelwidthstring 00.00.0000
2920 \labelwidthstring 00.00.0000
2924
2921
2925
2922
2926 \family typewriter
2923 \family typewriter
2927 \series bold
2924 \series bold
2928 -c\SpecialChar ~
2925 -c\SpecialChar ~
2929 <command>:
2926 <command>:
2930 \family default
2927 \family default
2931 \series default
2928 \series default
2932 execute the given command string, and set sys.argv to
2929 execute the given command string, and set sys.argv to
2933 \family typewriter
2930 \family typewriter
2934 ['c']
2931 ['c']
2935 \family default
2932 \family default
2936 .
2933 .
2937 This is similar to the
2934 This is similar to the
2938 \family typewriter
2935 \family typewriter
2939 -c
2936 -c
2940 \family default
2937 \family default
2941 option in the normal Python interpreter.
2938 option in the normal Python interpreter.
2942
2939
2943 \layout List
2940 \layout List
2944 \labelwidthstring 00.00.0000
2941 \labelwidthstring 00.00.0000
2945
2942
2946
2943
2947 \family typewriter
2944 \family typewriter
2948 \series bold
2945 \series bold
2949 -cache_size|cs\SpecialChar ~
2946 -cache_size|cs\SpecialChar ~
2950 <n>
2947 <n>
2951 \series default
2948 \series default
2952 :
2949 :
2953 \family default
2950 \family default
2954 size of the output cache (maximum number of entries to hold in memory).
2951 size of the output cache (maximum number of entries to hold in memory).
2955 The default is 1000, you can change it permanently in your config file.
2952 The default is 1000, you can change it permanently in your config file.
2956 Setting it to 0 completely disables the caching system, and the minimum
2953 Setting it to 0 completely disables the caching system, and the minimum
2957 value accepted is 20 (if you provide a value less than 20, it is reset
2954 value accepted is 20 (if you provide a value less than 20, it is reset
2958 to 0 and a warning is issued) This limit is defined because otherwise you'll
2955 to 0 and a warning is issued) This limit is defined because otherwise you'll
2959 spend more time re-flushing a too small cache than working.
2956 spend more time re-flushing a too small cache than working.
2960 \layout List
2957 \layout List
2961 \labelwidthstring 00.00.0000
2958 \labelwidthstring 00.00.0000
2962
2959
2963
2960
2964 \family typewriter
2961 \family typewriter
2965 \series bold
2962 \series bold
2966 -classic|cl
2963 -classic|cl
2967 \series default
2964 \series default
2968 :
2965 :
2969 \family default
2966 \family default
2970 Gives IPython a similar feel to the classic Python prompt.
2967 Gives IPython a similar feel to the classic Python prompt.
2971 \layout List
2968 \layout List
2972 \labelwidthstring 00.00.0000
2969 \labelwidthstring 00.00.0000
2973
2970
2974
2971
2975 \family typewriter
2972 \family typewriter
2976 \series bold
2973 \series bold
2977 -colors\SpecialChar ~
2974 -colors\SpecialChar ~
2978 <scheme>:
2975 <scheme>:
2979 \family default
2976 \family default
2980 \series default
2977 \series default
2981 Color scheme for prompts and exception reporting.
2978 Color scheme for prompts and exception reporting.
2982 Currently implemented: NoColor, Linux and LightBG.
2979 Currently implemented: NoColor, Linux and LightBG.
2983 \layout List
2980 \layout List
2984 \labelwidthstring 00.00.0000
2981 \labelwidthstring 00.00.0000
2985
2982
2986
2983
2987 \family typewriter
2984 \family typewriter
2988 \series bold
2985 \series bold
2989 -[no]color_info:
2986 -[no]color_info:
2990 \family default
2987 \family default
2991 \series default
2988 \series default
2992 IPython can display information about objects via a set of functions, and
2989 IPython can display information about objects via a set of functions, and
2993 optionally can use colors for this, syntax highlighting source code and
2990 optionally can use colors for this, syntax highlighting source code and
2994 various other elements.
2991 various other elements.
2995 However, because this information is passed through a pager (like 'less')
2992 However, because this information is passed through a pager (like 'less')
2996 and many pagers get confused with color codes, this option is off by default.
2993 and many pagers get confused with color codes, this option is off by default.
2997 You can test it and turn it on permanently in your ipythonrc file if it
2994 You can test it and turn it on permanently in your ipythonrc file if it
2998 works for you.
2995 works for you.
2999 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2996 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
3000 that in RedHat 7.2 doesn't.
2997 that in RedHat 7.2 doesn't.
3001 \layout List
2998 \layout List
3002 \labelwidthstring 00.00.0000
2999 \labelwidthstring 00.00.0000
3003
3000
3004 \SpecialChar ~
3001 \SpecialChar ~
3005 Test it and turn it on permanently if it works with your system.
3002 Test it and turn it on permanently if it works with your system.
3006 The magic function
3003 The magic function
3007 \family typewriter
3004 \family typewriter
3008 %color_info
3005 %color_info
3009 \family default
3006 \family default
3010 allows you to toggle this interactively for testing.
3007 allows you to toggle this interactively for testing.
3011 \layout List
3008 \layout List
3012 \labelwidthstring 00.00.0000
3009 \labelwidthstring 00.00.0000
3013
3010
3014
3011
3015 \family typewriter
3012 \family typewriter
3016 \series bold
3013 \series bold
3017 -[no]debug
3014 -[no]debug
3018 \family default
3015 \family default
3019 \series default
3016 \series default
3020 : Show information about the loading process.
3017 : Show information about the loading process.
3021 Very useful to pin down problems with your configuration files or to get
3018 Very useful to pin down problems with your configuration files or to get
3022 details about session restores.
3019 details about session restores.
3023 \layout List
3020 \layout List
3024 \labelwidthstring 00.00.0000
3021 \labelwidthstring 00.00.0000
3025
3022
3026
3023
3027 \family typewriter
3024 \family typewriter
3028 \series bold
3025 \series bold
3029 -[no]deep_reload
3026 -[no]deep_reload
3030 \series default
3027 \series default
3031 :
3028 :
3032 \family default
3029 \family default
3033 IPython can use the
3030 IPython can use the
3034 \family typewriter
3031 \family typewriter
3035 deep_reload
3032 deep_reload
3036 \family default
3033 \family default
3037 module which reloads changes in modules recursively (it replaces the
3034 module which reloads changes in modules recursively (it replaces the
3038 \family typewriter
3035 \family typewriter
3039 reload()
3036 reload()
3040 \family default
3037 \family default
3041 function, so you don't need to change anything to use it).
3038 function, so you don't need to change anything to use it).
3042
3039
3043 \family typewriter
3040 \family typewriter
3044 deep_reload()
3041 deep_reload()
3045 \family default
3042 \family default
3046 forces a full reload of modules whose code may have changed, which the
3043 forces a full reload of modules whose code may have changed, which the
3047 default
3044 default
3048 \family typewriter
3045 \family typewriter
3049 reload()
3046 reload()
3050 \family default
3047 \family default
3051 function does not.
3048 function does not.
3052 \layout List
3049 \layout List
3053 \labelwidthstring 00.00.0000
3050 \labelwidthstring 00.00.0000
3054
3051
3055 \SpecialChar ~
3052 \SpecialChar ~
3056 When deep_reload is off, IPython will use the normal
3053 When deep_reload is off, IPython will use the normal
3057 \family typewriter
3054 \family typewriter
3058 reload()
3055 reload()
3059 \family default
3056 \family default
3060 , but deep_reload will still be available as
3057 , but deep_reload will still be available as
3061 \family typewriter
3058 \family typewriter
3062 dreload()
3059 dreload()
3063 \family default
3060 \family default
3064 .
3061 .
3065 This feature is off by default [which means that you have both normal
3062 This feature is off by default [which means that you have both normal
3066 \family typewriter
3063 \family typewriter
3067 reload()
3064 reload()
3068 \family default
3065 \family default
3069 and
3066 and
3070 \family typewriter
3067 \family typewriter
3071 dreload()
3068 dreload()
3072 \family default
3069 \family default
3073 ].
3070 ].
3074 \layout List
3071 \layout List
3075 \labelwidthstring 00.00.0000
3072 \labelwidthstring 00.00.0000
3076
3073
3077
3074
3078 \family typewriter
3075 \family typewriter
3079 \series bold
3076 \series bold
3080 -editor\SpecialChar ~
3077 -editor\SpecialChar ~
3081 <name>
3078 <name>
3082 \family default
3079 \family default
3083 \series default
3080 \series default
3084 : Which editor to use with the
3081 : Which editor to use with the
3085 \family typewriter
3082 \family typewriter
3086 %edit
3083 %edit
3087 \family default
3084 \family default
3088 command.
3085 command.
3089 By default, IPython will honor your
3086 By default, IPython will honor your
3090 \family typewriter
3087 \family typewriter
3091 EDITOR
3088 EDITOR
3092 \family default
3089 \family default
3093 environment variable (if not set, vi is the Unix default and notepad the
3090 environment variable (if not set, vi is the Unix default and notepad the
3094 Windows one).
3091 Windows one).
3095 Since this editor is invoked on the fly by IPython and is meant for editing
3092 Since this editor is invoked on the fly by IPython and is meant for editing
3096 small code snippets, you may want to use a small, lightweight editor here
3093 small code snippets, you may want to use a small, lightweight editor here
3097 (in case your default
3094 (in case your default
3098 \family typewriter
3095 \family typewriter
3099 EDITOR
3096 EDITOR
3100 \family default
3097 \family default
3101 is something like Emacs).
3098 is something like Emacs).
3102 \layout List
3099 \layout List
3103 \labelwidthstring 00.00.0000
3100 \labelwidthstring 00.00.0000
3104
3101
3105
3102
3106 \family typewriter
3103 \family typewriter
3107 \series bold
3104 \series bold
3108 -ipythondir\SpecialChar ~
3105 -ipythondir\SpecialChar ~
3109 <name>
3106 <name>
3110 \series default
3107 \series default
3111 :
3108 :
3112 \family default
3109 \family default
3113 name of your IPython configuration directory
3110 name of your IPython configuration directory
3114 \family typewriter
3111 \family typewriter
3115 IPYTHONDIR
3112 IPYTHONDIR
3116 \family default
3113 \family default
3117 .
3114 .
3118 This can also be specified through the environment variable
3115 This can also be specified through the environment variable
3119 \family typewriter
3116 \family typewriter
3120 IPYTHONDIR
3117 IPYTHONDIR
3121 \family default
3118 \family default
3122 .
3119 .
3123 \layout List
3120 \layout List
3124 \labelwidthstring 00.00.0000
3121 \labelwidthstring 00.00.0000
3125
3122
3126
3123
3127 \family typewriter
3124 \family typewriter
3128 \series bold
3125 \series bold
3129 -log|l
3126 -log|l
3130 \family default
3127 \family default
3131 \series default
3128 \series default
3132 : generate a log file of all input.
3129 : generate a log file of all input.
3133 The file is named
3130 The file is named
3134 \family typewriter
3131 \family typewriter
3135 ipython_log.py
3132 ipython_log.py
3136 \family default
3133 \family default
3137 in your current directory (which prevents logs from multiple IPython sessions
3134 in your current directory (which prevents logs from multiple IPython sessions
3138 from trampling each other).
3135 from trampling each other).
3139 You can use this to later restore a session by loading your logfile as
3136 You can use this to later restore a session by loading your logfile as
3140 a file to be executed with option
3137 a file to be executed with option
3141 \family typewriter
3138 \family typewriter
3142 -logplay
3139 -logplay
3143 \family default
3140 \family default
3144 (see below).
3141 (see below).
3145 \layout List
3142 \layout List
3146 \labelwidthstring 00.00.0000
3143 \labelwidthstring 00.00.0000
3147
3144
3148
3145
3149 \family typewriter
3146 \family typewriter
3150 \series bold
3147 \series bold
3151 -logfile|lf\SpecialChar ~
3148 -logfile|lf\SpecialChar ~
3152 <name>
3149 <name>
3153 \series default
3150 \series default
3154 :
3151 :
3155 \family default
3152 \family default
3156 specify the name of your logfile.
3153 specify the name of your logfile.
3157 \layout List
3154 \layout List
3158 \labelwidthstring 00.00.0000
3155 \labelwidthstring 00.00.0000
3159
3156
3160
3157
3161 \family typewriter
3158 \family typewriter
3162 \series bold
3159 \series bold
3163 -logplay|lp\SpecialChar ~
3160 -logplay|lp\SpecialChar ~
3164 <name>
3161 <name>
3165 \series default
3162 \series default
3166 :
3163 :
3167 \family default
3164 \family default
3168 you can replay a previous log.
3165 you can replay a previous log.
3169 For restoring a session as close as possible to the state you left it in,
3166 For restoring a session as close as possible to the state you left it in,
3170 use this option (don't just run the logfile).
3167 use this option (don't just run the logfile).
3171 With
3168 With
3172 \family typewriter
3169 \family typewriter
3173 -logplay
3170 -logplay
3174 \family default
3171 \family default
3175 , IPython will try to reconstruct the previous working environment in full,
3172 , IPython will try to reconstruct the previous working environment in full,
3176 not just execute the commands in the logfile.
3173 not just execute the commands in the logfile.
3177 \layout List
3174 \layout List
3178 \labelwidthstring 00.00.0000
3175 \labelwidthstring 00.00.0000
3179
3176
3180 \SpecialChar ~
3177 \SpecialChar ~
3181 When a session is restored, logging is automatically turned on again with
3178 When a session is restored, logging is automatically turned on again with
3182 the name of the logfile it was invoked with (it is read from the log header).
3179 the name of the logfile it was invoked with (it is read from the log header).
3183 So once you've turned logging on for a session, you can quit IPython and
3180 So once you've turned logging on for a session, you can quit IPython and
3184 reload it as many times as you want and it will continue to log its history
3181 reload it as many times as you want and it will continue to log its history
3185 and restore from the beginning every time.
3182 and restore from the beginning every time.
3186 \layout List
3183 \layout List
3187 \labelwidthstring 00.00.0000
3184 \labelwidthstring 00.00.0000
3188
3185
3189 \SpecialChar ~
3186 \SpecialChar ~
3190 Caveats: there are limitations in this option.
3187 Caveats: there are limitations in this option.
3191 The history variables
3188 The history variables
3192 \family typewriter
3189 \family typewriter
3193 _i*
3190 _i*
3194 \family default
3191 \family default
3195 ,
3192 ,
3196 \family typewriter
3193 \family typewriter
3197 _*
3194 _*
3198 \family default
3195 \family default
3199 and
3196 and
3200 \family typewriter
3197 \family typewriter
3201 _dh
3198 _dh
3202 \family default
3199 \family default
3203 don't get restored properly.
3200 don't get restored properly.
3204 In the future we will try to implement full session saving by writing and
3201 In the future we will try to implement full session saving by writing and
3205 retrieving a 'snapshot' of the memory state of IPython.
3202 retrieving a 'snapshot' of the memory state of IPython.
3206 But our first attempts failed because of inherent limitations of Python's
3203 But our first attempts failed because of inherent limitations of Python's
3207 Pickle module, so this may have to wait.
3204 Pickle module, so this may have to wait.
3208 \layout List
3205 \layout List
3209 \labelwidthstring 00.00.0000
3206 \labelwidthstring 00.00.0000
3210
3207
3211
3208
3212 \family typewriter
3209 \family typewriter
3213 \series bold
3210 \series bold
3214 -[no]messages
3211 -[no]messages
3215 \series default
3212 \series default
3216 :
3213 :
3217 \family default
3214 \family default
3218 Print messages which IPython collects about its startup process (default
3215 Print messages which IPython collects about its startup process (default
3219 on).
3216 on).
3220 \layout List
3217 \layout List
3221 \labelwidthstring 00.00.0000
3218 \labelwidthstring 00.00.0000
3222
3219
3223
3220
3224 \family typewriter
3221 \family typewriter
3225 \series bold
3222 \series bold
3226 -[no]pdb
3223 -[no]pdb
3227 \family default
3224 \family default
3228 \series default
3225 \series default
3229 : Automatically call the pdb debugger after every uncaught exception.
3226 : Automatically call the pdb debugger after every uncaught exception.
3230 If you are used to debugging using pdb, this puts you automatically inside
3227 If you are used to debugging using pdb, this puts you automatically inside
3231 of it after any call (either in IPython or in code called by it) which
3228 of it after any call (either in IPython or in code called by it) which
3232 triggers an exception which goes uncaught.
3229 triggers an exception which goes uncaught.
3233 \layout List
3230 \layout List
3234 \labelwidthstring 00.00.0000
3231 \labelwidthstring 00.00.0000
3235
3232
3236
3233
3237 \family typewriter
3234 \family typewriter
3238 \series bold
3235 \series bold
3239 -[no]pprint
3236 -[no]pprint
3240 \series default
3237 \series default
3241 :
3238 :
3242 \family default
3239 \family default
3243 ipython can optionally use the pprint (pretty printer) module for displaying
3240 ipython can optionally use the pprint (pretty printer) module for displaying
3244 results.
3241 results.
3245 pprint tends to give a nicer display of nested data structures.
3242 pprint tends to give a nicer display of nested data structures.
3246 If you like it, you can turn it on permanently in your config file (default
3243 If you like it, you can turn it on permanently in your config file (default
3247 off).
3244 off).
3248 \layout List
3245 \layout List
3249 \labelwidthstring 00.00.0000
3246 \labelwidthstring 00.00.0000
3250
3247
3251
3248
3252 \family typewriter
3249 \family typewriter
3253 \series bold
3250 \series bold
3254 -profile|p <name>
3251 -profile|p <name>
3255 \series default
3252 \series default
3256 :
3253 :
3257 \family default
3254 \family default
3258 assume that your config file is
3255 assume that your config file is
3259 \family typewriter
3256 \family typewriter
3260 ipythonrc-<name>
3257 ipythonrc-<name>
3261 \family default
3258 \family default
3262 (looks in current dir first, then in
3259 (looks in current dir first, then in
3263 \family typewriter
3260 \family typewriter
3264 IPYTHONDIR
3261 IPYTHONDIR
3265 \family default
3262 \family default
3266 ).
3263 ).
3267 This is a quick way to keep and load multiple config files for different
3264 This is a quick way to keep and load multiple config files for different
3268 tasks, especially if you use the include option of config files.
3265 tasks, especially if you use the include option of config files.
3269 You can keep a basic
3266 You can keep a basic
3270 \family typewriter
3267 \family typewriter
3271 IPYTHONDIR/ipythonrc
3268 IPYTHONDIR/ipythonrc
3272 \family default
3269 \family default
3273 file and then have other 'profiles' which include this one and load extra
3270 file and then have other 'profiles' which include this one and load extra
3274 things for particular tasks.
3271 things for particular tasks.
3275 For example:
3272 For example:
3276 \layout List
3273 \layout List
3277 \labelwidthstring 00.00.0000
3274 \labelwidthstring 00.00.0000
3278
3275
3279
3276
3280 \family typewriter
3277 \family typewriter
3281 \SpecialChar ~
3278 \SpecialChar ~
3282
3279
3283 \family default
3280 \family default
3284 1.
3281 1.
3285
3282
3286 \family typewriter
3283 \family typewriter
3287 $HOME/.ipython/ipythonrc
3284 $HOME/.ipython/ipythonrc
3288 \family default
3285 \family default
3289 : load basic things you always want.
3286 : load basic things you always want.
3290 \layout List
3287 \layout List
3291 \labelwidthstring 00.00.0000
3288 \labelwidthstring 00.00.0000
3292
3289
3293
3290
3294 \family typewriter
3291 \family typewriter
3295 \SpecialChar ~
3292 \SpecialChar ~
3296
3293
3297 \family default
3294 \family default
3298 2.
3295 2.
3299
3296
3300 \family typewriter
3297 \family typewriter
3301 $HOME/.ipython/ipythonrc-math
3298 $HOME/.ipython/ipythonrc-math
3302 \family default
3299 \family default
3303 : load (1) and basic math-related modules.
3300 : load (1) and basic math-related modules.
3304
3301
3305 \layout List
3302 \layout List
3306 \labelwidthstring 00.00.0000
3303 \labelwidthstring 00.00.0000
3307
3304
3308
3305
3309 \family typewriter
3306 \family typewriter
3310 \SpecialChar ~
3307 \SpecialChar ~
3311
3308
3312 \family default
3309 \family default
3313 3.
3310 3.
3314
3311
3315 \family typewriter
3312 \family typewriter
3316 $HOME/.ipython/ipythonrc-numeric
3313 $HOME/.ipython/ipythonrc-numeric
3317 \family default
3314 \family default
3318 : load (1) and Numeric and plotting modules.
3315 : load (1) and Numeric and plotting modules.
3319 \layout List
3316 \layout List
3320 \labelwidthstring 00.00.0000
3317 \labelwidthstring 00.00.0000
3321
3318
3322 \SpecialChar ~
3319 \SpecialChar ~
3323 Since it is possible to create an endless loop by having circular file
3320 Since it is possible to create an endless loop by having circular file
3324 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3321 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3325 \layout List
3322 \layout List
3326 \labelwidthstring 00.00.0000
3323 \labelwidthstring 00.00.0000
3327
3324
3328
3325
3329 \family typewriter
3326 \family typewriter
3330 \series bold
3327 \series bold
3331 -prompt_in1|pi1\SpecialChar ~
3328 -prompt_in1|pi1\SpecialChar ~
3332 <string>:
3329 <string>:
3333 \family default
3330 \family default
3334 \series default
3331 \series default
3335 Specify the string used for input prompts.
3332 Specify the string used for input prompts.
3336 Note that if you are using numbered prompts, the number is represented
3333 Note that if you are using numbered prompts, the number is represented
3337 with a '
3334 with a '
3338 \backslash
3335 \backslash
3339 #' in the string.
3336 #' in the string.
3340 Don't forget to quote strings with spaces embedded in them.
3337 Don't forget to quote strings with spaces embedded in them.
3341 Default: '
3338 Default: '
3342 \family typewriter
3339 \family typewriter
3343 In\SpecialChar ~
3340 In\SpecialChar ~
3344 [
3341 [
3345 \backslash
3342 \backslash
3346 #]:
3343 #]:
3347 \family default
3344 \family default
3348 '.
3345 '.
3349 Sec.\SpecialChar ~
3346 Sec.\SpecialChar ~
3350
3347
3351 \begin_inset LatexCommand \ref{sec:prompts}
3348 \begin_inset LatexCommand \ref{sec:prompts}
3352
3349
3353 \end_inset
3350 \end_inset
3354
3351
3355 discusses in detail all the available escapes to customize your prompts.
3352 discusses in detail all the available escapes to customize your prompts.
3356 \layout List
3353 \layout List
3357 \labelwidthstring 00.00.0000
3354 \labelwidthstring 00.00.0000
3358
3355
3359
3356
3360 \family typewriter
3357 \family typewriter
3361 \series bold
3358 \series bold
3362 -prompt_in2|pi2\SpecialChar ~
3359 -prompt_in2|pi2\SpecialChar ~
3363 <string>:
3360 <string>:
3364 \family default
3361 \family default
3365 \series default
3362 \series default
3366 Similar to the previous option, but used for the continuation prompts.
3363 Similar to the previous option, but used for the continuation prompts.
3367 The special sequence '
3364 The special sequence '
3368 \family typewriter
3365 \family typewriter
3369
3366
3370 \backslash
3367 \backslash
3371 D
3368 D
3372 \family default
3369 \family default
3373 ' is similar to '
3370 ' is similar to '
3374 \family typewriter
3371 \family typewriter
3375
3372
3376 \backslash
3373 \backslash
3377 #
3374 #
3378 \family default
3375 \family default
3379 ', but with all digits replaced dots (so you can have your continuation
3376 ', but with all digits replaced dots (so you can have your continuation
3380 prompt aligned with your input prompt).
3377 prompt aligned with your input prompt).
3381 Default: '
3378 Default: '
3382 \family typewriter
3379 \family typewriter
3383 \SpecialChar ~
3380 \SpecialChar ~
3384 \SpecialChar ~
3381 \SpecialChar ~
3385 \SpecialChar ~
3382 \SpecialChar ~
3386 .
3383 .
3387 \backslash
3384 \backslash
3388 D.:
3385 D.:
3389 \family default
3386 \family default
3390 ' (note three spaces at the start for alignment with '
3387 ' (note three spaces at the start for alignment with '
3391 \family typewriter
3388 \family typewriter
3392 In\SpecialChar ~
3389 In\SpecialChar ~
3393 [
3390 [
3394 \backslash
3391 \backslash
3395 #]
3392 #]
3396 \family default
3393 \family default
3397 ').
3394 ').
3398 \layout List
3395 \layout List
3399 \labelwidthstring 00.00.0000
3396 \labelwidthstring 00.00.0000
3400
3397
3401
3398
3402 \family typewriter
3399 \family typewriter
3403 \series bold
3400 \series bold
3404 -prompt_out|po\SpecialChar ~
3401 -prompt_out|po\SpecialChar ~
3405 <string>:
3402 <string>:
3406 \family default
3403 \family default
3407 \series default
3404 \series default
3408 String used for output prompts, also uses numbers like
3405 String used for output prompts, also uses numbers like
3409 \family typewriter
3406 \family typewriter
3410 prompt_in1
3407 prompt_in1
3411 \family default
3408 \family default
3412 .
3409 .
3413 Default: '
3410 Default: '
3414 \family typewriter
3411 \family typewriter
3415 Out[
3412 Out[
3416 \backslash
3413 \backslash
3417 #]:
3414 #]:
3418 \family default
3415 \family default
3419 '
3416 '
3420 \layout List
3417 \layout List
3421 \labelwidthstring 00.00.0000
3418 \labelwidthstring 00.00.0000
3422
3419
3423
3420
3424 \family typewriter
3421 \family typewriter
3425 \series bold
3422 \series bold
3426 -quick
3423 -quick
3427 \family default
3424 \family default
3428 \series default
3425 \series default
3429 : start in bare bones mode (no config file loaded).
3426 : start in bare bones mode (no config file loaded).
3430 \layout List
3427 \layout List
3431 \labelwidthstring 00.00.0000
3428 \labelwidthstring 00.00.0000
3432
3429
3433
3430
3434 \family typewriter
3431 \family typewriter
3435 \series bold
3432 \series bold
3436 -rcfile\SpecialChar ~
3433 -rcfile\SpecialChar ~
3437 <name>
3434 <name>
3438 \series default
3435 \series default
3439 :
3436 :
3440 \family default
3437 \family default
3441 name of your IPython resource configuration file.
3438 name of your IPython resource configuration file.
3442 Normally IPython loads ipythonrc (from current directory) or
3439 Normally IPython loads ipythonrc (from current directory) or
3443 \family typewriter
3440 \family typewriter
3444 IPYTHONDIR/ipythonrc
3441 IPYTHONDIR/ipythonrc
3445 \family default
3442 \family default
3446 .
3443 .
3447 \layout List
3444 \layout List
3448 \labelwidthstring 00.00.0000
3445 \labelwidthstring 00.00.0000
3449
3446
3450 \SpecialChar ~
3447 \SpecialChar ~
3451 If the loading of your config file fails, IPython starts with a bare bones
3448 If the loading of your config file fails, IPython starts with a bare bones
3452 configuration (no modules loaded at all).
3449 configuration (no modules loaded at all).
3453 \layout List
3450 \layout List
3454 \labelwidthstring 00.00.0000
3451 \labelwidthstring 00.00.0000
3455
3452
3456
3453
3457 \family typewriter
3454 \family typewriter
3458 \series bold
3455 \series bold
3459 -[no]readline
3456 -[no]readline
3460 \family default
3457 \family default
3461 \series default
3458 \series default
3462 : use the readline library, which is needed to support name completion and
3459 : use the readline library, which is needed to support name completion and
3463 command history, among other things.
3460 command history, among other things.
3464 It is enabled by default, but may cause problems for users of X/Emacs in
3461 It is enabled by default, but may cause problems for users of X/Emacs in
3465 Python comint or shell buffers.
3462 Python comint or shell buffers.
3466 \layout List
3463 \layout List
3467 \labelwidthstring 00.00.0000
3464 \labelwidthstring 00.00.0000
3468
3465
3469 \SpecialChar ~
3466 \SpecialChar ~
3470 Note that X/Emacs 'eterm' buffers (opened with
3467 Note that X/Emacs 'eterm' buffers (opened with
3471 \family typewriter
3468 \family typewriter
3472 M-x\SpecialChar ~
3469 M-x\SpecialChar ~
3473 term
3470 term
3474 \family default
3471 \family default
3475 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3472 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3476 \family typewriter
3473 \family typewriter
3477 M-x\SpecialChar ~
3474 M-x\SpecialChar ~
3478 shell
3475 shell
3479 \family default
3476 \family default
3480 and
3477 and
3481 \family typewriter
3478 \family typewriter
3482 C-c\SpecialChar ~
3479 C-c\SpecialChar ~
3483 !
3480 !
3484 \family default
3481 \family default
3485 ) buffers do not.
3482 ) buffers do not.
3486 \layout List
3483 \layout List
3487 \labelwidthstring 00.00.0000
3484 \labelwidthstring 00.00.0000
3488
3485
3489
3486
3490 \family typewriter
3487 \family typewriter
3491 \series bold
3488 \series bold
3492 -screen_length|sl\SpecialChar ~
3489 -screen_length|sl\SpecialChar ~
3493 <n>
3490 <n>
3494 \series default
3491 \series default
3495 :
3492 :
3496 \family default
3493 \family default
3497 number of lines of your screen.
3494 number of lines of your screen.
3498 This is used to control printing of very long strings.
3495 This is used to control printing of very long strings.
3499 Strings longer than this number of lines will be sent through a pager instead
3496 Strings longer than this number of lines will be sent through a pager instead
3500 of directly printed.
3497 of directly printed.
3501 \layout List
3498 \layout List
3502 \labelwidthstring 00.00.0000
3499 \labelwidthstring 00.00.0000
3503
3500
3504 \SpecialChar ~
3501 \SpecialChar ~
3505 The default value for this is 0, which means IPython will auto-detect your
3502 The default value for this is 0, which means IPython will auto-detect your
3506 screen size every time it needs to print certain potentially long strings
3503 screen size every time it needs to print certain potentially long strings
3507 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3504 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3508 internally).
3505 internally).
3509 If for some reason this isn't working well (it needs curses support), specify
3506 If for some reason this isn't working well (it needs curses support), specify
3510 it yourself.
3507 it yourself.
3511 Otherwise don't change the default.
3508 Otherwise don't change the default.
3512 \layout List
3509 \layout List
3513 \labelwidthstring 00.00.0000
3510 \labelwidthstring 00.00.0000
3514
3511
3515
3512
3516 \family typewriter
3513 \family typewriter
3517 \series bold
3514 \series bold
3518 -separate_in|si\SpecialChar ~
3515 -separate_in|si\SpecialChar ~
3519 <string>
3516 <string>
3520 \series default
3517 \series default
3521 :
3518 :
3522 \family default
3519 \family default
3523 separator before input prompts.
3520 separator before input prompts.
3524 Default: '
3521 Default: '
3525 \family typewriter
3522 \family typewriter
3526
3523
3527 \backslash
3524 \backslash
3528 n
3525 n
3529 \family default
3526 \family default
3530 '
3527 '
3531 \layout List
3528 \layout List
3532 \labelwidthstring 00.00.0000
3529 \labelwidthstring 00.00.0000
3533
3530
3534
3531
3535 \family typewriter
3532 \family typewriter
3536 \series bold
3533 \series bold
3537 -separate_out|so\SpecialChar ~
3534 -separate_out|so\SpecialChar ~
3538 <string>
3535 <string>
3539 \family default
3536 \family default
3540 \series default
3537 \series default
3541 : separator before output prompts.
3538 : separator before output prompts.
3542 Default: nothing.
3539 Default: nothing.
3543 \layout List
3540 \layout List
3544 \labelwidthstring 00.00.0000
3541 \labelwidthstring 00.00.0000
3545
3542
3546
3543
3547 \family typewriter
3544 \family typewriter
3548 \series bold
3545 \series bold
3549 -separate_out2|so2\SpecialChar ~
3546 -separate_out2|so2\SpecialChar ~
3550 <string>
3547 <string>
3551 \series default
3548 \series default
3552 :
3549 :
3553 \family default
3550 \family default
3554 separator after output prompts.
3551 separator after output prompts.
3555 Default: nothing.
3552 Default: nothing.
3556 \layout List
3553 \layout List
3557 \labelwidthstring 00.00.0000
3554 \labelwidthstring 00.00.0000
3558
3555
3559 \SpecialChar ~
3556 \SpecialChar ~
3560 For these three options, use the value 0 to specify no separator.
3557 For these three options, use the value 0 to specify no separator.
3561 \layout List
3558 \layout List
3562 \labelwidthstring 00.00.0000
3559 \labelwidthstring 00.00.0000
3563
3560
3564
3561
3565 \family typewriter
3562 \family typewriter
3566 \series bold
3563 \series bold
3567 -nosep
3564 -nosep
3568 \series default
3565 \series default
3569 :
3566 :
3570 \family default
3567 \family default
3571 shorthand for
3568 shorthand for
3572 \family typewriter
3569 \family typewriter
3573 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3570 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3574 \family default
3571 \family default
3575 .
3572 .
3576 Simply removes all input/output separators.
3573 Simply removes all input/output separators.
3577 \layout List
3574 \layout List
3578 \labelwidthstring 00.00.0000
3575 \labelwidthstring 00.00.0000
3579
3576
3580
3577
3581 \family typewriter
3578 \family typewriter
3582 \series bold
3579 \series bold
3583 -upgrade
3580 -upgrade
3584 \family default
3581 \family default
3585 \series default
3582 \series default
3586 : allows you to upgrade your
3583 : allows you to upgrade your
3587 \family typewriter
3584 \family typewriter
3588 IPYTHONDIR
3585 IPYTHONDIR
3589 \family default
3586 \family default
3590 configuration when you install a new version of IPython.
3587 configuration when you install a new version of IPython.
3591 Since new versions may include new command line options or example files,
3588 Since new versions may include new command line options or example files,
3592 this copies updated ipythonrc-type files.
3589 this copies updated ipythonrc-type files.
3593 However, it backs up (with a
3590 However, it backs up (with a
3594 \family typewriter
3591 \family typewriter
3595 .old
3592 .old
3596 \family default
3593 \family default
3597 extension) all files which it overwrites so that you can merge back any
3594 extension) all files which it overwrites so that you can merge back any
3598 customizations you might have in your personal files.
3595 customizations you might have in your personal files.
3599 \layout List
3596 \layout List
3600 \labelwidthstring 00.00.0000
3597 \labelwidthstring 00.00.0000
3601
3598
3602
3599
3603 \family typewriter
3600 \family typewriter
3604 \series bold
3601 \series bold
3605 -Version
3602 -Version
3606 \series default
3603 \series default
3607 :
3604 :
3608 \family default
3605 \family default
3609 print version information and exit.
3606 print version information and exit.
3610 \layout List
3607 \layout List
3611 \labelwidthstring 00.00.0000
3608 \labelwidthstring 00.00.0000
3612
3609
3613
3610
3614 \family typewriter
3611 \family typewriter
3615 \series bold
3612 \series bold
3616 -wxversion\SpecialChar ~
3613 -wxversion\SpecialChar ~
3617 <string>:
3614 <string>:
3618 \family default
3615 \family default
3619 \series default
3616 \series default
3620 Select a specific version of wxPython (used in conjunction with
3617 Select a specific version of wxPython (used in conjunction with
3621 \family typewriter
3618 \family typewriter
3622 -wthread
3619 -wthread
3623 \family default
3620 \family default
3624 ).
3621 ).
3625 Requires the wxversion module, part of recent wxPython distributions
3622 Requires the wxversion module, part of recent wxPython distributions
3626 \layout List
3623 \layout List
3627 \labelwidthstring 00.00.0000
3624 \labelwidthstring 00.00.0000
3628
3625
3629
3626
3630 \family typewriter
3627 \family typewriter
3631 \series bold
3628 \series bold
3632 -xmode\SpecialChar ~
3629 -xmode\SpecialChar ~
3633 <modename>
3630 <modename>
3634 \series default
3631 \series default
3635 :
3632 :
3636 \family default
3633 \family default
3637 Mode for exception reporting.
3634 Mode for exception reporting.
3638 \layout List
3635 \layout List
3639 \labelwidthstring 00.00.0000
3636 \labelwidthstring 00.00.0000
3640
3637
3641 \SpecialChar ~
3638 \SpecialChar ~
3642 Valid modes: Plain, Context and Verbose.
3639 Valid modes: Plain, Context and Verbose.
3643 \layout List
3640 \layout List
3644 \labelwidthstring 00.00.0000
3641 \labelwidthstring 00.00.0000
3645
3642
3646 \SpecialChar ~
3643 \SpecialChar ~
3647 Plain: similar to python's normal traceback printing.
3644 Plain: similar to python's normal traceback printing.
3648 \layout List
3645 \layout List
3649 \labelwidthstring 00.00.0000
3646 \labelwidthstring 00.00.0000
3650
3647
3651 \SpecialChar ~
3648 \SpecialChar ~
3652 Context: prints 5 lines of context source code around each line in the
3649 Context: prints 5 lines of context source code around each line in the
3653 traceback.
3650 traceback.
3654 \layout List
3651 \layout List
3655 \labelwidthstring 00.00.0000
3652 \labelwidthstring 00.00.0000
3656
3653
3657 \SpecialChar ~
3654 \SpecialChar ~
3658 Verbose: similar to Context, but additionally prints the variables currently
3655 Verbose: similar to Context, but additionally prints the variables currently
3659 visible where the exception happened (shortening their strings if too long).
3656 visible where the exception happened (shortening their strings if too long).
3660 This can potentially be very slow, if you happen to have a huge data structure
3657 This can potentially be very slow, if you happen to have a huge data structure
3661 whose string representation is complex to compute.
3658 whose string representation is complex to compute.
3662 Your computer may appear to freeze for a while with cpu usage at 100%.
3659 Your computer may appear to freeze for a while with cpu usage at 100%.
3663 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3660 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3664 it more than once).
3661 it more than once).
3665 \layout Section
3662 \layout Section
3666
3663
3667 Interactive use
3664 Interactive use
3668 \layout Standard
3665 \layout Standard
3669
3666
3670
3667
3671 \series bold
3668 \series bold
3672 Warning
3669 Warning
3673 \series default
3670 \series default
3674 : IPython relies on the existence of a global variable called
3671 : IPython relies on the existence of a global variable called
3675 \family typewriter
3672 \family typewriter
3676 __IP
3673 __IP
3677 \family default
3674 \family default
3678 which controls the shell itself.
3675 which controls the shell itself.
3679 If you redefine
3676 If you redefine
3680 \family typewriter
3677 \family typewriter
3681 __IP
3678 __IP
3682 \family default
3679 \family default
3683 to anything, bizarre behavior will quickly occur.
3680 to anything, bizarre behavior will quickly occur.
3684 \layout Standard
3681 \layout Standard
3685
3682
3686 Other than the above warning, IPython is meant to work as a drop-in replacement
3683 Other than the above warning, IPython is meant to work as a drop-in replacement
3687 for the standard interactive interpreter.
3684 for the standard interactive interpreter.
3688 As such, any code which is valid python should execute normally under IPython
3685 As such, any code which is valid python should execute normally under IPython
3689 (cases where this is not true should be reported as bugs).
3686 (cases where this is not true should be reported as bugs).
3690 It does, however, offer many features which are not available at a standard
3687 It does, however, offer many features which are not available at a standard
3691 python prompt.
3688 python prompt.
3692 What follows is a list of these.
3689 What follows is a list of these.
3693 \layout Subsection
3690 \layout Subsection
3694
3691
3695 Caution for Windows users
3692 Caution for Windows users
3696 \layout Standard
3693 \layout Standard
3697
3694
3698 Windows, unfortunately, uses the `
3695 Windows, unfortunately, uses the `
3699 \family typewriter
3696 \family typewriter
3700
3697
3701 \backslash
3698 \backslash
3702
3699
3703 \family default
3700 \family default
3704 ' character as a path separator.
3701 ' character as a path separator.
3705 This is a terrible choice, because `
3702 This is a terrible choice, because `
3706 \family typewriter
3703 \family typewriter
3707
3704
3708 \backslash
3705 \backslash
3709
3706
3710 \family default
3707 \family default
3711 ' also represents the escape character in most modern programming languages,
3708 ' also represents the escape character in most modern programming languages,
3712 including Python.
3709 including Python.
3713 For this reason, issuing many of the commands discussed below (especially
3710 For this reason, issuing many of the commands discussed below (especially
3714 magics which affect the filesystem) with `
3711 magics which affect the filesystem) with `
3715 \family typewriter
3712 \family typewriter
3716
3713
3717 \backslash
3714 \backslash
3718
3715
3719 \family default
3716 \family default
3720 ' in them will cause strange errors.
3717 ' in them will cause strange errors.
3721 \layout Standard
3718 \layout Standard
3722
3719
3723 A partial solution is to use instead the `
3720 A partial solution is to use instead the `
3724 \family typewriter
3721 \family typewriter
3725 /
3722 /
3726 \family default
3723 \family default
3727 ' character as a path separator, which Windows recognizes in
3724 ' character as a path separator, which Windows recognizes in
3728 \emph on
3725 \emph on
3729 most
3726 most
3730 \emph default
3727 \emph default
3731 situations.
3728 situations.
3732 However, in Windows commands `
3729 However, in Windows commands `
3733 \family typewriter
3730 \family typewriter
3734 /
3731 /
3735 \family default
3732 \family default
3736 ' flags options, so you can not use it for the root directory.
3733 ' flags options, so you can not use it for the root directory.
3737 This means that paths beginning at the root must be typed in a contrived
3734 This means that paths beginning at the root must be typed in a contrived
3738 manner like:
3735 manner like:
3739 \newline
3736 \newline
3740
3737
3741 \family typewriter
3738 \family typewriter
3742 %copy
3739 %copy
3743 \backslash
3740 \backslash
3744 opt/foo/bar.txt
3741 opt/foo/bar.txt
3745 \backslash
3742 \backslash
3746 tmp
3743 tmp
3747 \layout Standard
3744 \layout Standard
3748
3745
3749 There is no sensible thing IPython can do to truly work around this flaw
3746 There is no sensible thing IPython can do to truly work around this flaw
3750 in Windows
3747 in Windows
3751 \begin_inset Foot
3748 \begin_inset Foot
3752 collapsed true
3749 collapsed true
3753
3750
3754 \layout Standard
3751 \layout Standard
3755
3752
3756 If anyone comes up with a
3753 If anyone comes up with a
3757 \emph on
3754 \emph on
3758 clean
3755 clean
3759 \emph default
3756 \emph default
3760 solution which works consistently and does not negatively impact other
3757 solution which works consistently and does not negatively impact other
3761 platforms at all, I'll gladly accept a patch.
3758 platforms at all, I'll gladly accept a patch.
3762 \end_inset
3759 \end_inset
3763
3760
3764 .
3761 .
3765 \layout Subsection
3762 \layout Subsection
3766
3763
3767
3764
3768 \begin_inset LatexCommand \label{sec:magic}
3765 \begin_inset LatexCommand \label{sec:magic}
3769
3766
3770 \end_inset
3767 \end_inset
3771
3768
3772 Magic command system
3769 Magic command system
3773 \layout Standard
3770 \layout Standard
3774
3771
3775 IPython will treat any line whose first character is a
3772 IPython will treat any line whose first character is a
3776 \family typewriter
3773 \family typewriter
3777 %
3774 %
3778 \family default
3775 \family default
3779 as a special call to a 'magic' function.
3776 as a special call to a 'magic' function.
3780 These allow you to control the behavior of IPython itself, plus a lot of
3777 These allow you to control the behavior of IPython itself, plus a lot of
3781 system-type features.
3778 system-type features.
3782 They are all prefixed with a
3779 They are all prefixed with a
3783 \family typewriter
3780 \family typewriter
3784 %
3781 %
3785 \family default
3782 \family default
3786 character, but parameters are given without parentheses or quotes.
3783 character, but parameters are given without parentheses or quotes.
3787 \layout Standard
3784 \layout Standard
3788
3785
3789 Example: typing
3786 Example: typing
3790 \family typewriter
3787 \family typewriter
3791 '%cd mydir'
3788 '%cd mydir'
3792 \family default
3789 \family default
3793 (without the quotes) changes you working directory to
3790 (without the quotes) changes you working directory to
3794 \family typewriter
3791 \family typewriter
3795 'mydir'
3792 'mydir'
3796 \family default
3793 \family default
3797 , if it exists.
3794 , if it exists.
3798 \layout Standard
3795 \layout Standard
3799
3796
3800 If you have 'automagic' enabled (in your
3797 If you have 'automagic' enabled (in your
3801 \family typewriter
3798 \family typewriter
3802 ipythonrc
3799 ipythonrc
3803 \family default
3800 \family default
3804 file, via the command line option
3801 file, via the command line option
3805 \family typewriter
3802 \family typewriter
3806 -automagic
3803 -automagic
3807 \family default
3804 \family default
3808 or with the
3805 or with the
3809 \family typewriter
3806 \family typewriter
3810 %automagic
3807 %automagic
3811 \family default
3808 \family default
3812 function), you don't need to type in the
3809 function), you don't need to type in the
3813 \family typewriter
3810 \family typewriter
3814 %
3811 %
3815 \family default
3812 \family default
3816 explicitly.
3813 explicitly.
3817 IPython will scan its internal list of magic functions and call one if
3814 IPython will scan its internal list of magic functions and call one if
3818 it exists.
3815 it exists.
3819 With automagic on you can then just type '
3816 With automagic on you can then just type '
3820 \family typewriter
3817 \family typewriter
3821 cd mydir
3818 cd mydir
3822 \family default
3819 \family default
3823 ' to go to directory '
3820 ' to go to directory '
3824 \family typewriter
3821 \family typewriter
3825 mydir
3822 mydir
3826 \family default
3823 \family default
3827 '.
3824 '.
3828 The automagic system has the lowest possible precedence in name searches,
3825 The automagic system has the lowest possible precedence in name searches,
3829 so defining an identifier with the same name as an existing magic function
3826 so defining an identifier with the same name as an existing magic function
3830 will shadow it for automagic use.
3827 will shadow it for automagic use.
3831 You can still access the shadowed magic function by explicitly using the
3828 You can still access the shadowed magic function by explicitly using the
3832
3829
3833 \family typewriter
3830 \family typewriter
3834 %
3831 %
3835 \family default
3832 \family default
3836 character at the beginning of the line.
3833 character at the beginning of the line.
3837 \layout Standard
3834 \layout Standard
3838
3835
3839 An example (with automagic on) should clarify all this:
3836 An example (with automagic on) should clarify all this:
3840 \layout LyX-Code
3837 \layout LyX-Code
3841
3838
3842 In [1]: cd ipython # %cd is called by automagic
3839 In [1]: cd ipython # %cd is called by automagic
3843 \layout LyX-Code
3840 \layout LyX-Code
3844
3841
3845 /home/fperez/ipython
3842 /home/fperez/ipython
3846 \layout LyX-Code
3843 \layout LyX-Code
3847
3844
3848 In [2]: cd=1 # now cd is just a variable
3845 In [2]: cd=1 # now cd is just a variable
3849 \layout LyX-Code
3846 \layout LyX-Code
3850
3847
3851 In [3]: cd ..
3848 In [3]: cd ..
3852 # and doesn't work as a function anymore
3849 # and doesn't work as a function anymore
3853 \layout LyX-Code
3850 \layout LyX-Code
3854
3851
3855 ------------------------------------------------------------
3852 ------------------------------------------------------------
3856 \layout LyX-Code
3853 \layout LyX-Code
3857
3854
3858 File "<console>", line 1
3855 File "<console>", line 1
3859 \layout LyX-Code
3856 \layout LyX-Code
3860
3857
3861 cd ..
3858 cd ..
3862 \layout LyX-Code
3859 \layout LyX-Code
3863
3860
3864 ^
3861 ^
3865 \layout LyX-Code
3862 \layout LyX-Code
3866
3863
3867 SyntaxError: invalid syntax
3864 SyntaxError: invalid syntax
3868 \layout LyX-Code
3865 \layout LyX-Code
3869
3866
3870 \layout LyX-Code
3867 \layout LyX-Code
3871
3868
3872 In [4]: %cd ..
3869 In [4]: %cd ..
3873 # but %cd always works
3870 # but %cd always works
3874 \layout LyX-Code
3871 \layout LyX-Code
3875
3872
3876 /home/fperez
3873 /home/fperez
3877 \layout LyX-Code
3874 \layout LyX-Code
3878
3875
3879 In [5]: del cd # if you remove the cd variable
3876 In [5]: del cd # if you remove the cd variable
3880 \layout LyX-Code
3877 \layout LyX-Code
3881
3878
3882 In [6]: cd ipython # automagic can work again
3879 In [6]: cd ipython # automagic can work again
3883 \layout LyX-Code
3880 \layout LyX-Code
3884
3881
3885 /home/fperez/ipython
3882 /home/fperez/ipython
3886 \layout Standard
3883 \layout Standard
3887
3884
3888 You can define your own magic functions to extend the system.
3885 You can define your own magic functions to extend the system.
3889 The following is a snippet of code which shows how to do it.
3886 The following is a snippet of code which shows how to do it.
3890 It is provided as file
3887 It is provided as file
3891 \family typewriter
3888 \family typewriter
3892 example-magic.py
3889 example-magic.py
3893 \family default
3890 \family default
3894 in the examples directory:
3891 in the examples directory:
3895 \layout Standard
3892 \layout Standard
3896
3893
3897
3894
3898 \begin_inset ERT
3895 \begin_inset ERT
3899 status Open
3896 status Open
3900
3897
3901 \layout Standard
3898 \layout Standard
3902
3899
3903 \backslash
3900 \backslash
3904 codelist{examples/example-magic.py}
3901 codelist{examples/example-magic.py}
3905 \end_inset
3902 \end_inset
3906
3903
3907
3904
3908 \layout Standard
3905 \layout Standard
3909
3906
3910 You can also define your own aliased names for magic functions.
3907 You can also define your own aliased names for magic functions.
3911 In your
3908 In your
3912 \family typewriter
3909 \family typewriter
3913 ipythonrc
3910 ipythonrc
3914 \family default
3911 \family default
3915 file, placing a line like:
3912 file, placing a line like:
3916 \layout Standard
3913 \layout Standard
3917
3914
3918
3915
3919 \family typewriter
3916 \family typewriter
3920 execute __IP.magic_cl = __IP.magic_clear
3917 execute __IP.magic_cl = __IP.magic_clear
3921 \layout Standard
3918 \layout Standard
3922
3919
3923 will define
3920 will define
3924 \family typewriter
3921 \family typewriter
3925 %cl
3922 %cl
3926 \family default
3923 \family default
3927 as a new name for
3924 as a new name for
3928 \family typewriter
3925 \family typewriter
3929 %clear
3926 %clear
3930 \family default
3927 \family default
3931 .
3928 .
3932 \layout Standard
3929 \layout Standard
3933
3930
3934 Type
3931 Type
3935 \family typewriter
3932 \family typewriter
3936 %magic
3933 %magic
3937 \family default
3934 \family default
3938 for more information, including a list of all available magic functions
3935 for more information, including a list of all available magic functions
3939 at any time and their docstrings.
3936 at any time and their docstrings.
3940 You can also type
3937 You can also type
3941 \family typewriter
3938 \family typewriter
3942 %magic_function_name?
3939 %magic_function_name?
3943 \family default
3940 \family default
3944 (see sec.
3941 (see sec.
3945
3942
3946 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3943 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3947
3944
3948 \end_inset
3945 \end_inset
3949
3946
3950 for information on the
3947 for information on the
3951 \family typewriter
3948 \family typewriter
3952 '?'
3949 '?'
3953 \family default
3950 \family default
3954 system) to get information about any particular magic function you are
3951 system) to get information about any particular magic function you are
3955 interested in.
3952 interested in.
3956 \layout Subsubsection
3953 \layout Subsubsection
3957
3954
3958 Magic commands
3955 Magic commands
3959 \layout Standard
3956 \layout Standard
3960
3957
3961 The rest of this section is automatically generated for each release from
3958 The rest of this section is automatically generated for each release from
3962 the docstrings in the IPython code.
3959 the docstrings in the IPython code.
3963 Therefore the formatting is somewhat minimal, but this method has the advantage
3960 Therefore the formatting is somewhat minimal, but this method has the advantage
3964 of having information always in sync with the code.
3961 of having information always in sync with the code.
3965 \layout Standard
3962 \layout Standard
3966
3963
3967 A list of all the magic commands available in IPython's
3964 A list of all the magic commands available in IPython's
3968 \emph on
3965 \emph on
3969 default
3966 default
3970 \emph default
3967 \emph default
3971 installation follows.
3968 installation follows.
3972 This is similar to what you'll see by simply typing
3969 This is similar to what you'll see by simply typing
3973 \family typewriter
3970 \family typewriter
3974 %magic
3971 %magic
3975 \family default
3972 \family default
3976 at the prompt, but that will also give you information about magic commands
3973 at the prompt, but that will also give you information about magic commands
3977 you may have added as part of your personal customizations.
3974 you may have added as part of your personal customizations.
3978 \layout Standard
3975 \layout Standard
3979
3976
3980
3977
3981 \begin_inset Include \input{magic.tex}
3978 \begin_inset Include \input{magic.tex}
3982 preview false
3979 preview false
3983
3980
3984 \end_inset
3981 \end_inset
3985
3982
3986
3983
3987 \layout Subsection
3984 \layout Subsection
3988
3985
3989 Access to the standard Python help
3986 Access to the standard Python help
3990 \layout Standard
3987 \layout Standard
3991
3988
3992 As of Python 2.1, a help system is available with access to object docstrings
3989 As of Python 2.1, a help system is available with access to object docstrings
3993 and the Python manuals.
3990 and the Python manuals.
3994 Simply type
3991 Simply type
3995 \family typewriter
3992 \family typewriter
3996 'help'
3993 'help'
3997 \family default
3994 \family default
3998 (no quotes) to access it.
3995 (no quotes) to access it.
3999 You can also type
3996 You can also type
4000 \family typewriter
3997 \family typewriter
4001 help(object)
3998 help(object)
4002 \family default
3999 \family default
4003 to obtain information about a given object, and
4000 to obtain information about a given object, and
4004 \family typewriter
4001 \family typewriter
4005 help('keyword')
4002 help('keyword')
4006 \family default
4003 \family default
4007 for information on a keyword.
4004 for information on a keyword.
4008 As noted in sec.
4005 As noted in sec.
4009
4006
4010 \begin_inset LatexCommand \ref{sec:help-access}
4007 \begin_inset LatexCommand \ref{sec:help-access}
4011
4008
4012 \end_inset
4009 \end_inset
4013
4010
4014 , you need to properly configure your environment variable
4011 , you need to properly configure your environment variable
4015 \family typewriter
4012 \family typewriter
4016 PYTHONDOCS
4013 PYTHONDOCS
4017 \family default
4014 \family default
4018 for this feature to work correctly.
4015 for this feature to work correctly.
4019 \layout Subsection
4016 \layout Subsection
4020
4017
4021
4018
4022 \begin_inset LatexCommand \label{sec:dyn-object-info}
4019 \begin_inset LatexCommand \label{sec:dyn-object-info}
4023
4020
4024 \end_inset
4021 \end_inset
4025
4022
4026 Dynamic object information
4023 Dynamic object information
4027 \layout Standard
4024 \layout Standard
4028
4025
4029 Typing
4026 Typing
4030 \family typewriter
4027 \family typewriter
4031 ?word
4028 ?word
4032 \family default
4029 \family default
4033 or
4030 or
4034 \family typewriter
4031 \family typewriter
4035 word?
4032 word?
4036 \family default
4033 \family default
4037 prints detailed information about an object.
4034 prints detailed information about an object.
4038 If certain strings in the object are too long (docstrings, code, etc.) they
4035 If certain strings in the object are too long (docstrings, code, etc.) they
4039 get snipped in the center for brevity.
4036 get snipped in the center for brevity.
4040 This system gives access variable types and values, full source code for
4037 This system gives access variable types and values, full source code for
4041 any object (if available), function prototypes and other useful information.
4038 any object (if available), function prototypes and other useful information.
4042 \layout Standard
4039 \layout Standard
4043
4040
4044 Typing
4041 Typing
4045 \family typewriter
4042 \family typewriter
4046 ??word
4043 ??word
4047 \family default
4044 \family default
4048 or
4045 or
4049 \family typewriter
4046 \family typewriter
4050 word??
4047 word??
4051 \family default
4048 \family default
4052 gives access to the full information without snipping long strings.
4049 gives access to the full information without snipping long strings.
4053 Long strings are sent to the screen through the
4050 Long strings are sent to the screen through the
4054 \family typewriter
4051 \family typewriter
4055 less
4052 less
4056 \family default
4053 \family default
4057 pager if longer than the screen and printed otherwise.
4054 pager if longer than the screen and printed otherwise.
4058 On systems lacking the
4055 On systems lacking the
4059 \family typewriter
4056 \family typewriter
4060 less
4057 less
4061 \family default
4058 \family default
4062 command, IPython uses a very basic internal pager.
4059 command, IPython uses a very basic internal pager.
4063 \layout Standard
4060 \layout Standard
4064
4061
4065 The following magic functions are particularly useful for gathering information
4062 The following magic functions are particularly useful for gathering information
4066 about your working environment.
4063 about your working environment.
4067 You can get more details by typing
4064 You can get more details by typing
4068 \family typewriter
4065 \family typewriter
4069 %magic
4066 %magic
4070 \family default
4067 \family default
4071 or querying them individually (use
4068 or querying them individually (use
4072 \family typewriter
4069 \family typewriter
4073 %function_name?
4070 %function_name?
4074 \family default
4071 \family default
4075 with or without the
4072 with or without the
4076 \family typewriter
4073 \family typewriter
4077 %
4074 %
4078 \family default
4075 \family default
4079 ), this is just a summary:
4076 ), this is just a summary:
4080 \layout List
4077 \layout List
4081 \labelwidthstring 00.00.0000
4078 \labelwidthstring 00.00.0000
4082
4079
4083
4080
4084 \family typewriter
4081 \family typewriter
4085 \series bold
4082 \series bold
4086 %pdoc\SpecialChar ~
4083 %pdoc\SpecialChar ~
4087 <object>
4084 <object>
4088 \family default
4085 \family default
4089 \series default
4086 \series default
4090 : Print (or run through a pager if too long) the docstring for an object.
4087 : Print (or run through a pager if too long) the docstring for an object.
4091 If the given object is a class, it will print both the class and the constructo
4088 If the given object is a class, it will print both the class and the constructo
4092 r docstrings.
4089 r docstrings.
4093 \layout List
4090 \layout List
4094 \labelwidthstring 00.00.0000
4091 \labelwidthstring 00.00.0000
4095
4092
4096
4093
4097 \family typewriter
4094 \family typewriter
4098 \series bold
4095 \series bold
4099 %pdef\SpecialChar ~
4096 %pdef\SpecialChar ~
4100 <object>
4097 <object>
4101 \family default
4098 \family default
4102 \series default
4099 \series default
4103 : Print the definition header for any callable object.
4100 : Print the definition header for any callable object.
4104 If the object is a class, print the constructor information.
4101 If the object is a class, print the constructor information.
4105 \layout List
4102 \layout List
4106 \labelwidthstring 00.00.0000
4103 \labelwidthstring 00.00.0000
4107
4104
4108
4105
4109 \family typewriter
4106 \family typewriter
4110 \series bold
4107 \series bold
4111 %psource\SpecialChar ~
4108 %psource\SpecialChar ~
4112 <object>
4109 <object>
4113 \family default
4110 \family default
4114 \series default
4111 \series default
4115 : Print (or run through a pager if too long) the source code for an object.
4112 : Print (or run through a pager if too long) the source code for an object.
4116 \layout List
4113 \layout List
4117 \labelwidthstring 00.00.0000
4114 \labelwidthstring 00.00.0000
4118
4115
4119
4116
4120 \family typewriter
4117 \family typewriter
4121 \series bold
4118 \series bold
4122 %pfile\SpecialChar ~
4119 %pfile\SpecialChar ~
4123 <object>
4120 <object>
4124 \family default
4121 \family default
4125 \series default
4122 \series default
4126 : Show the entire source file where an object was defined via a pager, opening
4123 : Show the entire source file where an object was defined via a pager, opening
4127 it at the line where the object definition begins.
4124 it at the line where the object definition begins.
4128 \layout List
4125 \layout List
4129 \labelwidthstring 00.00.0000
4126 \labelwidthstring 00.00.0000
4130
4127
4131
4128
4132 \family typewriter
4129 \family typewriter
4133 \series bold
4130 \series bold
4134 %who/%whos
4131 %who/%whos
4135 \family default
4132 \family default
4136 \series default
4133 \series default
4137 : These functions give information about identifiers you have defined interactiv
4134 : These functions give information about identifiers you have defined interactiv
4138 ely (not things you loaded or defined in your configuration files).
4135 ely (not things you loaded or defined in your configuration files).
4139
4136
4140 \family typewriter
4137 \family typewriter
4141 %who
4138 %who
4142 \family default
4139 \family default
4143 just prints a list of identifiers and
4140 just prints a list of identifiers and
4144 \family typewriter
4141 \family typewriter
4145 %whos
4142 %whos
4146 \family default
4143 \family default
4147 prints a table with some basic details about each identifier.
4144 prints a table with some basic details about each identifier.
4148 \layout Standard
4145 \layout Standard
4149
4146
4150 Note that the dynamic object information functions (
4147 Note that the dynamic object information functions (
4151 \family typewriter
4148 \family typewriter
4152 ?/??, %pdoc, %pfile, %pdef, %psource
4149 ?/??, %pdoc, %pfile, %pdef, %psource
4153 \family default
4150 \family default
4154 ) give you access to documentation even on things which are not really defined
4151 ) give you access to documentation even on things which are not really defined
4155 as separate identifiers.
4152 as separate identifiers.
4156 Try for example typing
4153 Try for example typing
4157 \family typewriter
4154 \family typewriter
4158 {}.get?
4155 {}.get?
4159 \family default
4156 \family default
4160 or after doing
4157 or after doing
4161 \family typewriter
4158 \family typewriter
4162 import os
4159 import os
4163 \family default
4160 \family default
4164 , type
4161 , type
4165 \family typewriter
4162 \family typewriter
4166 os.path.abspath??
4163 os.path.abspath??
4167 \family default
4164 \family default
4168 .
4165 .
4169 \layout Subsection
4166 \layout Subsection
4170
4167
4171
4168
4172 \begin_inset LatexCommand \label{sec:readline}
4169 \begin_inset LatexCommand \label{sec:readline}
4173
4170
4174 \end_inset
4171 \end_inset
4175
4172
4176 Readline-based features
4173 Readline-based features
4177 \layout Standard
4174 \layout Standard
4178
4175
4179 These features require the GNU readline library, so they won't work if your
4176 These features require the GNU readline library, so they won't work if your
4180 Python installation lacks readline support.
4177 Python installation lacks readline support.
4181 We will first describe the default behavior IPython uses, and then how
4178 We will first describe the default behavior IPython uses, and then how
4182 to change it to suit your preferences.
4179 to change it to suit your preferences.
4183 \layout Subsubsection
4180 \layout Subsubsection
4184
4181
4185 Command line completion
4182 Command line completion
4186 \layout Standard
4183 \layout Standard
4187
4184
4188 At any time, hitting TAB will complete any available python commands or
4185 At any time, hitting TAB will complete any available python commands or
4189 variable names, and show you a list of the possible completions if there's
4186 variable names, and show you a list of the possible completions if there's
4190 no unambiguous one.
4187 no unambiguous one.
4191 It will also complete filenames in the current directory if no python names
4188 It will also complete filenames in the current directory if no python names
4192 match what you've typed so far.
4189 match what you've typed so far.
4193 \layout Subsubsection
4190 \layout Subsubsection
4194
4191
4195 Search command history
4192 Search command history
4196 \layout Standard
4193 \layout Standard
4197
4194
4198 IPython provides two ways for searching through previous input and thus
4195 IPython provides two ways for searching through previous input and thus
4199 reduce the need for repetitive typing:
4196 reduce the need for repetitive typing:
4200 \layout Enumerate
4197 \layout Enumerate
4201
4198
4202 Start typing, and then use
4199 Start typing, and then use
4203 \family typewriter
4200 \family typewriter
4204 Ctrl-p
4201 Ctrl-p
4205 \family default
4202 \family default
4206 (previous,up) and
4203 (previous,up) and
4207 \family typewriter
4204 \family typewriter
4208 Ctrl-n
4205 Ctrl-n
4209 \family default
4206 \family default
4210 (next,down) to search through only the history items that match what you've
4207 (next,down) to search through only the history items that match what you've
4211 typed so far.
4208 typed so far.
4212 If you use
4209 If you use
4213 \family typewriter
4210 \family typewriter
4214 Ctrl-p/Ctrl-n
4211 Ctrl-p/Ctrl-n
4215 \family default
4212 \family default
4216 at a blank prompt, they just behave like normal arrow keys.
4213 at a blank prompt, they just behave like normal arrow keys.
4217 \layout Enumerate
4214 \layout Enumerate
4218
4215
4219 Hit
4216 Hit
4220 \family typewriter
4217 \family typewriter
4221 Ctrl-r
4218 Ctrl-r
4222 \family default
4219 \family default
4223 : opens a search prompt.
4220 : opens a search prompt.
4224 Begin typing and the system searches your history for lines that contain
4221 Begin typing and the system searches your history for lines that contain
4225 what you've typed so far, completing as much as it can.
4222 what you've typed so far, completing as much as it can.
4226 \layout Subsubsection
4223 \layout Subsubsection
4227
4224
4228 Persistent command history across sessions
4225 Persistent command history across sessions
4229 \layout Standard
4226 \layout Standard
4230
4227
4231 IPython will save your input history when it leaves and reload it next time
4228 IPython will save your input history when it leaves and reload it next time
4232 you restart it.
4229 you restart it.
4233 By default, the history file is named
4230 By default, the history file is named
4234 \family typewriter
4231 \family typewriter
4235 $IPYTHONDIR/history
4232 $IPYTHONDIR/history
4236 \family default
4233 \family default
4237 , but if you've loaded a named profile, '
4234 , but if you've loaded a named profile, '
4238 \family typewriter
4235 \family typewriter
4239 -PROFILE_NAME
4236 -PROFILE_NAME
4240 \family default
4237 \family default
4241 ' is appended to the name.
4238 ' is appended to the name.
4242 This allows you to keep separate histories related to various tasks: commands
4239 This allows you to keep separate histories related to various tasks: commands
4243 related to numerical work will not be clobbered by a system shell history,
4240 related to numerical work will not be clobbered by a system shell history,
4244 for example.
4241 for example.
4245 \layout Subsubsection
4242 \layout Subsubsection
4246
4243
4247 Autoindent
4244 Autoindent
4248 \layout Standard
4245 \layout Standard
4249
4246
4250 IPython can recognize lines ending in ':' and indent the next line, while
4247 IPython can recognize lines ending in ':' and indent the next line, while
4251 also un-indenting automatically after 'raise' or 'return'.
4248 also un-indenting automatically after 'raise' or 'return'.
4252
4249
4253 \layout Standard
4250 \layout Standard
4254
4251
4255 This feature uses the readline library, so it will honor your
4252 This feature uses the readline library, so it will honor your
4256 \family typewriter
4253 \family typewriter
4257 ~/.inputrc
4254 ~/.inputrc
4258 \family default
4255 \family default
4259 configuration (or whatever file your
4256 configuration (or whatever file your
4260 \family typewriter
4257 \family typewriter
4261 INPUTRC
4258 INPUTRC
4262 \family default
4259 \family default
4263 variable points to).
4260 variable points to).
4264 Adding the following lines to your
4261 Adding the following lines to your
4265 \family typewriter
4262 \family typewriter
4266 .inputrc
4263 .inputrc
4267 \family default
4264 \family default
4268 file can make indenting/unindenting more convenient (
4265 file can make indenting/unindenting more convenient (
4269 \family typewriter
4266 \family typewriter
4270 M-i
4267 M-i
4271 \family default
4268 \family default
4272 indents,
4269 indents,
4273 \family typewriter
4270 \family typewriter
4274 M-u
4271 M-u
4275 \family default
4272 \family default
4276 unindents):
4273 unindents):
4277 \layout Standard
4274 \layout Standard
4278
4275
4279
4276
4280 \family typewriter
4277 \family typewriter
4281 $if Python
4278 $if Python
4282 \newline
4279 \newline
4283 "
4280 "
4284 \backslash
4281 \backslash
4285 M-i": "\SpecialChar ~
4282 M-i": "\SpecialChar ~
4286 \SpecialChar ~
4283 \SpecialChar ~
4287 \SpecialChar ~
4284 \SpecialChar ~
4288 \SpecialChar ~
4285 \SpecialChar ~
4289 "
4286 "
4290 \newline
4287 \newline
4291 "
4288 "
4292 \backslash
4289 \backslash
4293 M-u": "
4290 M-u": "
4294 \backslash
4291 \backslash
4295 d
4292 d
4296 \backslash
4293 \backslash
4297 d
4294 d
4298 \backslash
4295 \backslash
4299 d
4296 d
4300 \backslash
4297 \backslash
4301 d"
4298 d"
4302 \newline
4299 \newline
4303 $endif
4300 $endif
4304 \layout Standard
4301 \layout Standard
4305
4302
4306 Note that there are 4 spaces between the quote marks after
4303 Note that there are 4 spaces between the quote marks after
4307 \family typewriter
4304 \family typewriter
4308 "M-i"
4305 "M-i"
4309 \family default
4306 \family default
4310 above.
4307 above.
4311 \layout Standard
4308 \layout Standard
4312
4309
4313
4310
4314 \series bold
4311 \series bold
4315 Warning:
4312 Warning:
4316 \series default
4313 \series default
4317 this feature is ON by default, but it can cause problems with the pasting
4314 this feature is ON by default, but it can cause problems with the pasting
4318 of multi-line indented code (the pasted code gets re-indented on each line).
4315 of multi-line indented code (the pasted code gets re-indented on each line).
4319 A magic function
4316 A magic function
4320 \family typewriter
4317 \family typewriter
4321 %autoindent
4318 %autoindent
4322 \family default
4319 \family default
4323 allows you to toggle it on/off at runtime.
4320 allows you to toggle it on/off at runtime.
4324 You can also disable it permanently on in your
4321 You can also disable it permanently on in your
4325 \family typewriter
4322 \family typewriter
4326 ipythonrc
4323 ipythonrc
4327 \family default
4324 \family default
4328 file (set
4325 file (set
4329 \family typewriter
4326 \family typewriter
4330 autoindent 0
4327 autoindent 0
4331 \family default
4328 \family default
4332 ).
4329 ).
4333 \layout Subsubsection
4330 \layout Subsubsection
4334
4331
4335 Customizing readline behavior
4332 Customizing readline behavior
4336 \layout Standard
4333 \layout Standard
4337
4334
4338 All these features are based on the GNU readline library, which has an extremely
4335 All these features are based on the GNU readline library, which has an extremely
4339 customizable interface.
4336 customizable interface.
4340 Normally, readline is configured via a file which defines the behavior
4337 Normally, readline is configured via a file which defines the behavior
4341 of the library; the details of the syntax for this can be found in the
4338 of the library; the details of the syntax for this can be found in the
4342 readline documentation available with your system or on the Internet.
4339 readline documentation available with your system or on the Internet.
4343 IPython doesn't read this file (if it exists) directly, but it does support
4340 IPython doesn't read this file (if it exists) directly, but it does support
4344 passing to readline valid options via a simple interface.
4341 passing to readline valid options via a simple interface.
4345 In brief, you can customize readline by setting the following options in
4342 In brief, you can customize readline by setting the following options in
4346 your
4343 your
4347 \family typewriter
4344 \family typewriter
4348 ipythonrc
4345 ipythonrc
4349 \family default
4346 \family default
4350 configuration file (note that these options can
4347 configuration file (note that these options can
4351 \emph on
4348 \emph on
4352 not
4349 not
4353 \emph default
4350 \emph default
4354 be specified at the command line):
4351 be specified at the command line):
4355 \layout List
4352 \layout List
4356 \labelwidthstring 00.00.0000
4353 \labelwidthstring 00.00.0000
4357
4354
4358
4355
4359 \family typewriter
4356 \family typewriter
4360 \series bold
4357 \series bold
4361 readline_parse_and_bind:
4358 readline_parse_and_bind:
4362 \family default
4359 \family default
4363 \series default
4360 \series default
4364 this option can appear as many times as you want, each time defining a
4361 this option can appear as many times as you want, each time defining a
4365 string to be executed via a
4362 string to be executed via a
4366 \family typewriter
4363 \family typewriter
4367 readline.parse_and_bind()
4364 readline.parse_and_bind()
4368 \family default
4365 \family default
4369 command.
4366 command.
4370 The syntax for valid commands of this kind can be found by reading the
4367 The syntax for valid commands of this kind can be found by reading the
4371 documentation for the GNU readline library, as these commands are of the
4368 documentation for the GNU readline library, as these commands are of the
4372 kind which readline accepts in its configuration file.
4369 kind which readline accepts in its configuration file.
4373 \layout List
4370 \layout List
4374 \labelwidthstring 00.00.0000
4371 \labelwidthstring 00.00.0000
4375
4372
4376
4373
4377 \family typewriter
4374 \family typewriter
4378 \series bold
4375 \series bold
4379 readline_remove_delims:
4376 readline_remove_delims:
4380 \family default
4377 \family default
4381 \series default
4378 \series default
4382 a string of characters to be removed from the default word-delimiters list
4379 a string of characters to be removed from the default word-delimiters list
4383 used by readline, so that completions may be performed on strings which
4380 used by readline, so that completions may be performed on strings which
4384 contain them.
4381 contain them.
4385 Do not change the default value unless you know what you're doing.
4382 Do not change the default value unless you know what you're doing.
4386 \layout List
4383 \layout List
4387 \labelwidthstring 00.00.0000
4384 \labelwidthstring 00.00.0000
4388
4385
4389
4386
4390 \family typewriter
4387 \family typewriter
4391 \series bold
4388 \series bold
4392 readline_omit__names
4389 readline_omit__names
4393 \family default
4390 \family default
4394 \series default
4391 \series default
4395 : when tab-completion is enabled, hitting
4392 : when tab-completion is enabled, hitting
4396 \family typewriter
4393 \family typewriter
4397 <tab>
4394 <tab>
4398 \family default
4395 \family default
4399 after a '
4396 after a '
4400 \family typewriter
4397 \family typewriter
4401 .
4398 .
4402 \family default
4399 \family default
4403 ' in a name will complete all attributes of an object, including all the
4400 ' in a name will complete all attributes of an object, including all the
4404 special methods whose names include double underscores (like
4401 special methods whose names include double underscores (like
4405 \family typewriter
4402 \family typewriter
4406 __getitem__
4403 __getitem__
4407 \family default
4404 \family default
4408 or
4405 or
4409 \family typewriter
4406 \family typewriter
4410 __class__
4407 __class__
4411 \family default
4408 \family default
4412 ).
4409 ).
4413 If you'd rather not see these names by default, you can set this option
4410 If you'd rather not see these names by default, you can set this option
4414 to 1.
4411 to 1.
4415 Note that even when this option is set, you can still see those names by
4412 Note that even when this option is set, you can still see those names by
4416 explicitly typing a
4413 explicitly typing a
4417 \family typewriter
4414 \family typewriter
4418 _
4415 _
4419 \family default
4416 \family default
4420 after the period and hitting
4417 after the period and hitting
4421 \family typewriter
4418 \family typewriter
4422 <tab>
4419 <tab>
4423 \family default
4420 \family default
4424 : '
4421 : '
4425 \family typewriter
4422 \family typewriter
4426 name._<tab>
4423 name._<tab>
4427 \family default
4424 \family default
4428 ' will always complete attribute names starting with '
4425 ' will always complete attribute names starting with '
4429 \family typewriter
4426 \family typewriter
4430 _
4427 _
4431 \family default
4428 \family default
4432 '.
4429 '.
4433 \layout List
4430 \layout List
4434 \labelwidthstring 00.00.0000
4431 \labelwidthstring 00.00.0000
4435
4432
4436 \SpecialChar ~
4433 \SpecialChar ~
4437 This option is off by default so that new users see all attributes of any
4434 This option is off by default so that new users see all attributes of any
4438 objects they are dealing with.
4435 objects they are dealing with.
4439 \layout Standard
4436 \layout Standard
4440
4437
4441 You will find the default values along with a corresponding detailed explanation
4438 You will find the default values along with a corresponding detailed explanation
4442 in your
4439 in your
4443 \family typewriter
4440 \family typewriter
4444 ipythonrc
4441 ipythonrc
4445 \family default
4442 \family default
4446 file.
4443 file.
4447 \layout Subsection
4444 \layout Subsection
4448
4445
4449 Session logging and restoring
4446 Session logging and restoring
4450 \layout Standard
4447 \layout Standard
4451
4448
4452 You can log all input from a session either by starting IPython with the
4449 You can log all input from a session either by starting IPython with the
4453 command line switches
4450 command line switches
4454 \family typewriter
4451 \family typewriter
4455 -log
4452 -log
4456 \family default
4453 \family default
4457 or
4454 or
4458 \family typewriter
4455 \family typewriter
4459 -logfile
4456 -logfile
4460 \family default
4457 \family default
4461 (see sec.
4458 (see sec.
4462
4459
4463 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4460 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4464
4461
4465 \end_inset
4462 \end_inset
4466
4463
4467 )or by activating the logging at any moment with the magic function
4464 )or by activating the logging at any moment with the magic function
4468 \family typewriter
4465 \family typewriter
4469 %logstart
4466 %logstart
4470 \family default
4467 \family default
4471 .
4468 .
4472
4469
4473 \layout Standard
4470 \layout Standard
4474
4471
4475 Log files can later be reloaded with the
4472 Log files can later be reloaded with the
4476 \family typewriter
4473 \family typewriter
4477 -logplay
4474 -logplay
4478 \family default
4475 \family default
4479 option and IPython will attempt to 'replay' the log by executing all the
4476 option and IPython will attempt to 'replay' the log by executing all the
4480 lines in it, thus restoring the state of a previous session.
4477 lines in it, thus restoring the state of a previous session.
4481 This feature is not quite perfect, but can still be useful in many cases.
4478 This feature is not quite perfect, but can still be useful in many cases.
4482 \layout Standard
4479 \layout Standard
4483
4480
4484 The log files can also be used as a way to have a permanent record of any
4481 The log files can also be used as a way to have a permanent record of any
4485 code you wrote while experimenting.
4482 code you wrote while experimenting.
4486 Log files are regular text files which you can later open in your favorite
4483 Log files are regular text files which you can later open in your favorite
4487 text editor to extract code or to 'clean them up' before using them to
4484 text editor to extract code or to 'clean them up' before using them to
4488 replay a session.
4485 replay a session.
4489 \layout Standard
4486 \layout Standard
4490
4487
4491 The
4488 The
4492 \family typewriter
4489 \family typewriter
4493 %logstart
4490 %logstart
4494 \family default
4491 \family default
4495 function for activating logging in mid-session is used as follows:
4492 function for activating logging in mid-session is used as follows:
4496 \layout Standard
4493 \layout Standard
4497
4494
4498
4495
4499 \family typewriter
4496 \family typewriter
4500 %logstart [log_name [log_mode]]
4497 %logstart [log_name [log_mode]]
4501 \layout Standard
4498 \layout Standard
4502
4499
4503 If no name is given, it defaults to a file named
4500 If no name is given, it defaults to a file named
4504 \family typewriter
4501 \family typewriter
4505 'log'
4502 'log'
4506 \family default
4503 \family default
4507 in your IPYTHONDIR directory, in
4504 in your IPYTHONDIR directory, in
4508 \family typewriter
4505 \family typewriter
4509 'rotate'
4506 'rotate'
4510 \family default
4507 \family default
4511 mode (see below).
4508 mode (see below).
4512 \layout Standard
4509 \layout Standard
4513
4510
4514 '
4511 '
4515 \family typewriter
4512 \family typewriter
4516 %logstart name
4513 %logstart name
4517 \family default
4514 \family default
4518 ' saves to file
4515 ' saves to file
4519 \family typewriter
4516 \family typewriter
4520 'name'
4517 'name'
4521 \family default
4518 \family default
4522 in
4519 in
4523 \family typewriter
4520 \family typewriter
4524 'backup'
4521 'backup'
4525 \family default
4522 \family default
4526 mode.
4523 mode.
4527 It saves your history up to that point and then continues logging.
4524 It saves your history up to that point and then continues logging.
4528 \layout Standard
4525 \layout Standard
4529
4526
4530
4527
4531 \family typewriter
4528 \family typewriter
4532 %logstart
4529 %logstart
4533 \family default
4530 \family default
4534 takes a second optional parameter: logging mode.
4531 takes a second optional parameter: logging mode.
4535 This can be one of (note that the modes are given unquoted):
4532 This can be one of (note that the modes are given unquoted):
4536 \layout List
4533 \layout List
4537 \labelwidthstring 00.00.0000
4534 \labelwidthstring 00.00.0000
4538
4535
4539
4536
4540 \family typewriter
4537 \family typewriter
4541 over
4538 over
4542 \family default
4539 \family default
4543 : overwrite existing
4540 : overwrite existing
4544 \family typewriter
4541 \family typewriter
4545 log_name
4542 log_name
4546 \family default
4543 \family default
4547 .
4544 .
4548 \layout List
4545 \layout List
4549 \labelwidthstring 00.00.0000
4546 \labelwidthstring 00.00.0000
4550
4547
4551
4548
4552 \family typewriter
4549 \family typewriter
4553 backup
4550 backup
4554 \family default
4551 \family default
4555 : rename (if exists) to
4552 : rename (if exists) to
4556 \family typewriter
4553 \family typewriter
4557 log_name~
4554 log_name~
4558 \family default
4555 \family default
4559 and start
4556 and start
4560 \family typewriter
4557 \family typewriter
4561 log_name
4558 log_name
4562 \family default
4559 \family default
4563 .
4560 .
4564 \layout List
4561 \layout List
4565 \labelwidthstring 00.00.0000
4562 \labelwidthstring 00.00.0000
4566
4563
4567
4564
4568 \family typewriter
4565 \family typewriter
4569 append
4566 append
4570 \family default
4567 \family default
4571 : well, that says it.
4568 : well, that says it.
4572 \layout List
4569 \layout List
4573 \labelwidthstring 00.00.0000
4570 \labelwidthstring 00.00.0000
4574
4571
4575
4572
4576 \family typewriter
4573 \family typewriter
4577 rotate
4574 rotate
4578 \family default
4575 \family default
4579 : create rotating logs
4576 : create rotating logs
4580 \family typewriter
4577 \family typewriter
4581 log_name
4578 log_name
4582 \family default
4579 \family default
4583 .
4580 .
4584 \family typewriter
4581 \family typewriter
4585 1~
4582 1~
4586 \family default
4583 \family default
4587 ,
4584 ,
4588 \family typewriter
4585 \family typewriter
4589 log_name.2~
4586 log_name.2~
4590 \family default
4587 \family default
4591 , etc.
4588 , etc.
4592 \layout Standard
4589 \layout Standard
4593
4590
4594 The
4591 The
4595 \family typewriter
4592 \family typewriter
4596 %logoff
4593 %logoff
4597 \family default
4594 \family default
4598 and
4595 and
4599 \family typewriter
4596 \family typewriter
4600 %logon
4597 %logon
4601 \family default
4598 \family default
4602 functions allow you to temporarily stop and resume logging to a file which
4599 functions allow you to temporarily stop and resume logging to a file which
4603 had previously been started with
4600 had previously been started with
4604 \family typewriter
4601 \family typewriter
4605 %logstart
4602 %logstart
4606 \family default
4603 \family default
4607 .
4604 .
4608 They will fail (with an explanation) if you try to use them before logging
4605 They will fail (with an explanation) if you try to use them before logging
4609 has been started.
4606 has been started.
4610 \layout Subsection
4607 \layout Subsection
4611
4608
4612
4609
4613 \begin_inset LatexCommand \label{sub:System-shell-access}
4610 \begin_inset LatexCommand \label{sub:System-shell-access}
4614
4611
4615 \end_inset
4612 \end_inset
4616
4613
4617 System shell access
4614 System shell access
4618 \layout Standard
4615 \layout Standard
4619
4616
4620 Any input line beginning with a
4617 Any input line beginning with a
4621 \family typewriter
4618 \family typewriter
4622 !
4619 !
4623 \family default
4620 \family default
4624 character is passed verbatim (minus the
4621 character is passed verbatim (minus the
4625 \family typewriter
4622 \family typewriter
4626 !
4623 !
4627 \family default
4624 \family default
4628 , of course) to the underlying operating system.
4625 , of course) to the underlying operating system.
4629 For example, typing
4626 For example, typing
4630 \family typewriter
4627 \family typewriter
4631 !ls
4628 !ls
4632 \family default
4629 \family default
4633 will run
4630 will run
4634 \family typewriter
4631 \family typewriter
4635 'ls'
4632 'ls'
4636 \family default
4633 \family default
4637 in the current directory.
4634 in the current directory.
4638 \layout Subsubsection
4635 \layout Subsubsection
4639
4636
4640 Manual capture of command output
4637 Manual capture of command output
4641 \layout Standard
4638 \layout Standard
4642
4639
4643 If the input line begins with
4640 If the input line begins with
4644 \emph on
4641 \emph on
4645 two
4642 two
4646 \emph default
4643 \emph default
4647 exclamation marks,
4644 exclamation marks,
4648 \family typewriter
4645 \family typewriter
4649 !!
4646 !!
4650 \family default
4647 \family default
4651 , the command is executed but its output is captured and returned as a python
4648 , the command is executed but its output is captured and returned as a python
4652 list, split on newlines.
4649 list, split on newlines.
4653 Any output sent by the subprocess to standard error is printed separately,
4650 Any output sent by the subprocess to standard error is printed separately,
4654 so that the resulting list only captures standard output.
4651 so that the resulting list only captures standard output.
4655 The
4652 The
4656 \family typewriter
4653 \family typewriter
4657 !!
4654 !!
4658 \family default
4655 \family default
4659 syntax is a shorthand for the
4656 syntax is a shorthand for the
4660 \family typewriter
4657 \family typewriter
4661 %sx
4658 %sx
4662 \family default
4659 \family default
4663 magic command.
4660 magic command.
4664 \layout Standard
4661 \layout Standard
4665
4662
4666 Finally, the
4663 Finally, the
4667 \family typewriter
4664 \family typewriter
4668 %sc
4665 %sc
4669 \family default
4666 \family default
4670 magic (short for `shell capture') is similar to
4667 magic (short for `shell capture') is similar to
4671 \family typewriter
4668 \family typewriter
4672 %sx
4669 %sx
4673 \family default
4670 \family default
4674 , but allowing more fine-grained control of the capture details, and storing
4671 , but allowing more fine-grained control of the capture details, and storing
4675 the result directly into a named variable.
4672 the result directly into a named variable.
4676 \layout Standard
4673 \layout Standard
4677
4674
4678 See Sec.\SpecialChar ~
4675 See Sec.\SpecialChar ~
4679
4676
4680 \begin_inset LatexCommand \ref{sec:magic}
4677 \begin_inset LatexCommand \ref{sec:magic}
4681
4678
4682 \end_inset
4679 \end_inset
4683
4680
4684 for details on the magics
4681 for details on the magics
4685 \family typewriter
4682 \family typewriter
4686 %sc
4683 %sc
4687 \family default
4684 \family default
4688 and
4685 and
4689 \family typewriter
4686 \family typewriter
4690 %sx
4687 %sx
4691 \family default
4688 \family default
4692 , or use IPython's own help (
4689 , or use IPython's own help (
4693 \family typewriter
4690 \family typewriter
4694 sc?
4691 sc?
4695 \family default
4692 \family default
4696 and
4693 and
4697 \family typewriter
4694 \family typewriter
4698 sx?
4695 sx?
4699 \family default
4696 \family default
4700 ) for further details.
4697 ) for further details.
4701 \layout Standard
4698 \layout Standard
4702
4699
4703 IPython also allows you to expand the value of python variables when making
4700 IPython also allows you to expand the value of python variables when making
4704 system calls.
4701 system calls.
4705 Any python variable or expression which you prepend with
4702 Any python variable or expression which you prepend with
4706 \family typewriter
4703 \family typewriter
4707 $
4704 $
4708 \family default
4705 \family default
4709 will get expanded before the system call is made.
4706 will get expanded before the system call is made.
4710
4707
4711 \layout Standard
4708 \layout Standard
4712
4709
4713
4710
4714 \family typewriter
4711 \family typewriter
4715 In [1]: pyvar='Hello world'
4712 In [1]: pyvar='Hello world'
4716 \newline
4713 \newline
4717 In [2]: !echo "A python variable: $pyvar"
4714 In [2]: !echo "A python variable: $pyvar"
4718 \newline
4715 \newline
4719 A python variable: Hello world
4716 A python variable: Hello world
4720 \layout Standard
4717 \layout Standard
4721
4718
4722 If you want the shell to actually see a literal
4719 If you want the shell to actually see a literal
4723 \family typewriter
4720 \family typewriter
4724 $
4721 $
4725 \family default
4722 \family default
4726 , you need to type it twice:
4723 , you need to type it twice:
4727 \layout Standard
4724 \layout Standard
4728
4725
4729
4726
4730 \family typewriter
4727 \family typewriter
4731 In [3]: !echo "A system variable: $$HOME"
4728 In [3]: !echo "A system variable: $$HOME"
4732 \newline
4729 \newline
4733 A system variable: /home/fperez
4730 A system variable: /home/fperez
4734 \layout Standard
4731 \layout Standard
4735
4732
4736 You can pass arbitrary expressions, though you'll need to delimit them with
4733 You can pass arbitrary expressions, though you'll need to delimit them with
4737
4734
4738 \family typewriter
4735 \family typewriter
4739 {}
4736 {}
4740 \family default
4737 \family default
4741 if there is ambiguity as to the extent of the expression:
4738 if there is ambiguity as to the extent of the expression:
4742 \layout Standard
4739 \layout Standard
4743
4740
4744
4741
4745 \family typewriter
4742 \family typewriter
4746 In [5]: x=10
4743 In [5]: x=10
4747 \newline
4744 \newline
4748 In [6]: y=20
4745 In [6]: y=20
4749 \newline
4746 \newline
4750 In [13]: !echo $x+y
4747 In [13]: !echo $x+y
4751 \newline
4748 \newline
4752 10+y
4749 10+y
4753 \newline
4750 \newline
4754 In [7]: !echo ${x+y}
4751 In [7]: !echo ${x+y}
4755 \newline
4752 \newline
4756 30
4753 30
4757 \layout Standard
4754 \layout Standard
4758
4755
4759 Even object attributes can be expanded:
4756 Even object attributes can be expanded:
4760 \layout Standard
4757 \layout Standard
4761
4758
4762
4759
4763 \family typewriter
4760 \family typewriter
4764 In [12]: !echo $sys.argv
4761 In [12]: !echo $sys.argv
4765 \newline
4762 \newline
4766 [/home/fperez/usr/bin/ipython]
4763 [/home/fperez/usr/bin/ipython]
4767 \layout Subsection
4764 \layout Subsection
4768
4765
4769 System command aliases
4766 System command aliases
4770 \layout Standard
4767 \layout Standard
4771
4768
4772 The
4769 The
4773 \family typewriter
4770 \family typewriter
4774 %alias
4771 %alias
4775 \family default
4772 \family default
4776 magic function and the
4773 magic function and the
4777 \family typewriter
4774 \family typewriter
4778 alias
4775 alias
4779 \family default
4776 \family default
4780 option in the
4777 option in the
4781 \family typewriter
4778 \family typewriter
4782 ipythonrc
4779 ipythonrc
4783 \family default
4780 \family default
4784 configuration file allow you to define magic functions which are in fact
4781 configuration file allow you to define magic functions which are in fact
4785 system shell commands.
4782 system shell commands.
4786 These aliases can have parameters.
4783 These aliases can have parameters.
4787
4784
4788 \layout Standard
4785 \layout Standard
4789
4786
4790 '
4787 '
4791 \family typewriter
4788 \family typewriter
4792 %alias alias_name cmd
4789 %alias alias_name cmd
4793 \family default
4790 \family default
4794 ' defines '
4791 ' defines '
4795 \family typewriter
4792 \family typewriter
4796 alias_name
4793 alias_name
4797 \family default
4794 \family default
4798 ' as an alias for '
4795 ' as an alias for '
4799 \family typewriter
4796 \family typewriter
4800 cmd
4797 cmd
4801 \family default
4798 \family default
4802 '
4799 '
4803 \layout Standard
4800 \layout Standard
4804
4801
4805 Then, typing '
4802 Then, typing '
4806 \family typewriter
4803 \family typewriter
4807 %alias_name params
4804 %alias_name params
4808 \family default
4805 \family default
4809 ' will execute the system command '
4806 ' will execute the system command '
4810 \family typewriter
4807 \family typewriter
4811 cmd params
4808 cmd params
4812 \family default
4809 \family default
4813 ' (from your underlying operating system).
4810 ' (from your underlying operating system).
4814
4811
4815 \layout Standard
4812 \layout Standard
4816
4813
4817 You can also define aliases with parameters using
4814 You can also define aliases with parameters using
4818 \family typewriter
4815 \family typewriter
4819 %s
4816 %s
4820 \family default
4817 \family default
4821 specifiers (one per parameter).
4818 specifiers (one per parameter).
4822 The following example defines the
4819 The following example defines the
4823 \family typewriter
4820 \family typewriter
4824 %parts
4821 %parts
4825 \family default
4822 \family default
4826 function as an alias to the command '
4823 function as an alias to the command '
4827 \family typewriter
4824 \family typewriter
4828 echo first %s second %s
4825 echo first %s second %s
4829 \family default
4826 \family default
4830 ' where each
4827 ' where each
4831 \family typewriter
4828 \family typewriter
4832 %s
4829 %s
4833 \family default
4830 \family default
4834 will be replaced by a positional parameter to the call to
4831 will be replaced by a positional parameter to the call to
4835 \family typewriter
4832 \family typewriter
4836 %parts:
4833 %parts:
4837 \layout Standard
4834 \layout Standard
4838
4835
4839
4836
4840 \family typewriter
4837 \family typewriter
4841 In [1]: alias parts echo first %s second %s
4838 In [1]: alias parts echo first %s second %s
4842 \newline
4839 \newline
4843 In [2]: %parts A B
4840 In [2]: %parts A B
4844 \newline
4841 \newline
4845 first A second B
4842 first A second B
4846 \newline
4843 \newline
4847 In [3]: %parts A
4844 In [3]: %parts A
4848 \newline
4845 \newline
4849 Incorrect number of arguments: 2 expected.
4846 Incorrect number of arguments: 2 expected.
4850
4847
4851 \newline
4848 \newline
4852 parts is an alias to: 'echo first %s second %s'
4849 parts is an alias to: 'echo first %s second %s'
4853 \layout Standard
4850 \layout Standard
4854
4851
4855 If called with no parameters,
4852 If called with no parameters,
4856 \family typewriter
4853 \family typewriter
4857 %alias
4854 %alias
4858 \family default
4855 \family default
4859 prints the table of currently defined aliases.
4856 prints the table of currently defined aliases.
4860 \layout Standard
4857 \layout Standard
4861
4858
4862 The
4859 The
4863 \family typewriter
4860 \family typewriter
4864 %rehash/rehashx
4861 %rehash/rehashx
4865 \family default
4862 \family default
4866 magics allow you to load your entire
4863 magics allow you to load your entire
4867 \family typewriter
4864 \family typewriter
4868 $PATH
4865 $PATH
4869 \family default
4866 \family default
4870 as ipython aliases.
4867 as ipython aliases.
4871 See their respective docstrings (or sec.\SpecialChar ~
4868 See their respective docstrings (or sec.\SpecialChar ~
4872
4869
4873 \begin_inset LatexCommand \ref{sec:magic}
4870 \begin_inset LatexCommand \ref{sec:magic}
4874
4871
4875 \end_inset
4872 \end_inset
4876
4873
4877 for further details).
4874 for further details).
4878 \layout Subsection
4875 \layout Subsection
4879
4876
4880
4877
4881 \begin_inset LatexCommand \label{sec:dreload}
4878 \begin_inset LatexCommand \label{sec:dreload}
4882
4879
4883 \end_inset
4880 \end_inset
4884
4881
4885 Recursive reload
4882 Recursive reload
4886 \layout Standard
4883 \layout Standard
4887
4884
4888 The
4885 The
4889 \family typewriter
4886 \family typewriter
4890 %dreload
4887 %dreload
4891 \family default
4888 \family default
4892 command does a recursive reload of a module: changes made to the module
4889 command does a recursive reload of a module: changes made to the module
4893 since you imported will actually be available without having to exit.
4890 since you imported will actually be available without having to exit.
4894 \layout Subsection
4891 \layout Subsection
4895
4892
4896 Verbose and colored exception traceback printouts
4893 Verbose and colored exception traceback printouts
4897 \layout Standard
4894 \layout Standard
4898
4895
4899 IPython provides the option to see very detailed exception tracebacks, which
4896 IPython provides the option to see very detailed exception tracebacks, which
4900 can be especially useful when debugging large programs.
4897 can be especially useful when debugging large programs.
4901 You can run any Python file with the
4898 You can run any Python file with the
4902 \family typewriter
4899 \family typewriter
4903 %run
4900 %run
4904 \family default
4901 \family default
4905 function to benefit from these detailed tracebacks.
4902 function to benefit from these detailed tracebacks.
4906 Furthermore, both normal and verbose tracebacks can be colored (if your
4903 Furthermore, both normal and verbose tracebacks can be colored (if your
4907 terminal supports it) which makes them much easier to parse visually.
4904 terminal supports it) which makes them much easier to parse visually.
4908 \layout Standard
4905 \layout Standard
4909
4906
4910 See the magic
4907 See the magic
4911 \family typewriter
4908 \family typewriter
4912 xmode
4909 xmode
4913 \family default
4910 \family default
4914 and
4911 and
4915 \family typewriter
4912 \family typewriter
4916 colors
4913 colors
4917 \family default
4914 \family default
4918 functions for details (just type
4915 functions for details (just type
4919 \family typewriter
4916 \family typewriter
4920 %magic
4917 %magic
4921 \family default
4918 \family default
4922 ).
4919 ).
4923 \layout Standard
4920 \layout Standard
4924
4921
4925 These features are basically a terminal version of Ka-Ping Yee's
4922 These features are basically a terminal version of Ka-Ping Yee's
4926 \family typewriter
4923 \family typewriter
4927 cgitb
4924 cgitb
4928 \family default
4925 \family default
4929 module, now part of the standard Python library.
4926 module, now part of the standard Python library.
4930 \layout Subsection
4927 \layout Subsection
4931
4928
4932
4929
4933 \begin_inset LatexCommand \label{sec:cache_input}
4930 \begin_inset LatexCommand \label{sec:cache_input}
4934
4931
4935 \end_inset
4932 \end_inset
4936
4933
4937 Input caching system
4934 Input caching system
4938 \layout Standard
4935 \layout Standard
4939
4936
4940 IPython offers numbered prompts (In/Out) with input and output caching.
4937 IPython offers numbered prompts (In/Out) with input and output caching.
4941 All input is saved and can be retrieved as variables (besides the usual
4938 All input is saved and can be retrieved as variables (besides the usual
4942 arrow key recall).
4939 arrow key recall).
4943 \layout Standard
4940 \layout Standard
4944
4941
4945 The following GLOBAL variables always exist (so don't overwrite them!):
4942 The following GLOBAL variables always exist (so don't overwrite them!):
4946
4943
4947 \family typewriter
4944 \family typewriter
4948 _i
4945 _i
4949 \family default
4946 \family default
4950 : stores previous input.
4947 : stores previous input.
4951
4948
4952 \family typewriter
4949 \family typewriter
4953 _ii
4950 _ii
4954 \family default
4951 \family default
4955 : next previous.
4952 : next previous.
4956
4953
4957 \family typewriter
4954 \family typewriter
4958 _iii
4955 _iii
4959 \family default
4956 \family default
4960 : next-next previous.
4957 : next-next previous.
4961
4958
4962 \family typewriter
4959 \family typewriter
4963 _ih
4960 _ih
4964 \family default
4961 \family default
4965 : a list of all input
4962 : a list of all input
4966 \family typewriter
4963 \family typewriter
4967 _ih[n]
4964 _ih[n]
4968 \family default
4965 \family default
4969 is the input from line
4966 is the input from line
4970 \family typewriter
4967 \family typewriter
4971 n
4968 n
4972 \family default
4969 \family default
4973 and this list is aliased to the global variable
4970 and this list is aliased to the global variable
4974 \family typewriter
4971 \family typewriter
4975 In
4972 In
4976 \family default
4973 \family default
4977 .
4974 .
4978 If you overwrite
4975 If you overwrite
4979 \family typewriter
4976 \family typewriter
4980 In
4977 In
4981 \family default
4978 \family default
4982 with a variable of your own, you can remake the assignment to the internal
4979 with a variable of your own, you can remake the assignment to the internal
4983 list with a simple
4980 list with a simple
4984 \family typewriter
4981 \family typewriter
4985 'In=_ih'
4982 'In=_ih'
4986 \family default
4983 \family default
4987 .
4984 .
4988 \layout Standard
4985 \layout Standard
4989
4986
4990 Additionally, global variables named
4987 Additionally, global variables named
4991 \family typewriter
4988 \family typewriter
4992 _i<n>
4989 _i<n>
4993 \family default
4990 \family default
4994 are dynamically created (
4991 are dynamically created (
4995 \family typewriter
4992 \family typewriter
4996 <n>
4993 <n>
4997 \family default
4994 \family default
4998 being the prompt counter), such that
4995 being the prompt counter), such that
4999 \newline
4996 \newline
5000
4997
5001 \family typewriter
4998 \family typewriter
5002 _i<n> == _ih[<n>] == In[<n>].
4999 _i<n> == _ih[<n>] == In[<n>].
5003 \layout Standard
5000 \layout Standard
5004
5001
5005 For example, what you typed at prompt 14 is available as
5002 For example, what you typed at prompt 14 is available as
5006 \family typewriter
5003 \family typewriter
5007 _i14,
5004 _i14,
5008 \family default
5005 \family default
5009
5006
5010 \family typewriter
5007 \family typewriter
5011 _ih[14]
5008 _ih[14]
5012 \family default
5009 \family default
5013 and
5010 and
5014 \family typewriter
5011 \family typewriter
5015 In[14]
5012 In[14]
5016 \family default
5013 \family default
5017 .
5014 .
5018 \layout Standard
5015 \layout Standard
5019
5016
5020 This allows you to easily cut and paste multi line interactive prompts by
5017 This allows you to easily cut and paste multi line interactive prompts by
5021 printing them out: they print like a clean string, without prompt characters.
5018 printing them out: they print like a clean string, without prompt characters.
5022 You can also manipulate them like regular variables (they are strings),
5019 You can also manipulate them like regular variables (they are strings),
5023 modify or exec them (typing
5020 modify or exec them (typing
5024 \family typewriter
5021 \family typewriter
5025 'exec _i9'
5022 'exec _i9'
5026 \family default
5023 \family default
5027 will re-execute the contents of input prompt 9, '
5024 will re-execute the contents of input prompt 9, '
5028 \family typewriter
5025 \family typewriter
5029 exec In[9:14]+In[18]
5026 exec In[9:14]+In[18]
5030 \family default
5027 \family default
5031 ' will re-execute lines 9 through 13 and line 18).
5028 ' will re-execute lines 9 through 13 and line 18).
5032 \layout Standard
5029 \layout Standard
5033
5030
5034 You can also re-execute multiple lines of input easily by using the magic
5031 You can also re-execute multiple lines of input easily by using the magic
5035
5032
5036 \family typewriter
5033 \family typewriter
5037 %macro
5034 %macro
5038 \family default
5035 \family default
5039 function (which automates the process and allows re-execution without having
5036 function (which automates the process and allows re-execution without having
5040 to type '
5037 to type '
5041 \family typewriter
5038 \family typewriter
5042 exec
5039 exec
5043 \family default
5040 \family default
5044 ' every time).
5041 ' every time).
5045 The macro system also allows you to re-execute previous lines which include
5042 The macro system also allows you to re-execute previous lines which include
5046 magic function calls (which require special processing).
5043 magic function calls (which require special processing).
5047 Type
5044 Type
5048 \family typewriter
5045 \family typewriter
5049 %macro?
5046 %macro?
5050 \family default
5047 \family default
5051 or see sec.
5048 or see sec.
5052
5049
5053 \begin_inset LatexCommand \ref{sec:magic}
5050 \begin_inset LatexCommand \ref{sec:magic}
5054
5051
5055 \end_inset
5052 \end_inset
5056
5053
5057 for more details on the macro system.
5054 for more details on the macro system.
5058 \layout Standard
5055 \layout Standard
5059
5056
5060 A history function
5057 A history function
5061 \family typewriter
5058 \family typewriter
5062 %hist
5059 %hist
5063 \family default
5060 \family default
5064 allows you to see any part of your input history by printing a range of
5061 allows you to see any part of your input history by printing a range of
5065 the
5062 the
5066 \family typewriter
5063 \family typewriter
5067 _i
5064 _i
5068 \family default
5065 \family default
5069 variables.
5066 variables.
5070 \layout Subsection
5067 \layout Subsection
5071
5068
5072
5069
5073 \begin_inset LatexCommand \label{sec:cache_output}
5070 \begin_inset LatexCommand \label{sec:cache_output}
5074
5071
5075 \end_inset
5072 \end_inset
5076
5073
5077 Output caching system
5074 Output caching system
5078 \layout Standard
5075 \layout Standard
5079
5076
5080 For output that is returned from actions, a system similar to the input
5077 For output that is returned from actions, a system similar to the input
5081 cache exists but using
5078 cache exists but using
5082 \family typewriter
5079 \family typewriter
5083 _
5080 _
5084 \family default
5081 \family default
5085 instead of
5082 instead of
5086 \family typewriter
5083 \family typewriter
5087 _i
5084 _i
5088 \family default
5085 \family default
5089 .
5086 .
5090 Only actions that produce a result (NOT assignments, for example) are cached.
5087 Only actions that produce a result (NOT assignments, for example) are cached.
5091 If you are familiar with Mathematica, IPython's
5088 If you are familiar with Mathematica, IPython's
5092 \family typewriter
5089 \family typewriter
5093 _
5090 _
5094 \family default
5091 \family default
5095 variables behave exactly like Mathematica's
5092 variables behave exactly like Mathematica's
5096 \family typewriter
5093 \family typewriter
5097 %
5094 %
5098 \family default
5095 \family default
5099 variables.
5096 variables.
5100 \layout Standard
5097 \layout Standard
5101
5098
5102 The following GLOBAL variables always exist (so don't overwrite them!):
5099 The following GLOBAL variables always exist (so don't overwrite them!):
5103
5100
5104 \layout List
5101 \layout List
5105 \labelwidthstring 00.00.0000
5102 \labelwidthstring 00.00.0000
5106
5103
5107
5104
5108 \family typewriter
5105 \family typewriter
5109 \series bold
5106 \series bold
5110 _
5107 _
5111 \family default
5108 \family default
5112 \series default
5109 \series default
5113 (a
5110 (a
5114 \emph on
5111 \emph on
5115 single
5112 single
5116 \emph default
5113 \emph default
5117 underscore) : stores previous output, like Python's default interpreter.
5114 underscore) : stores previous output, like Python's default interpreter.
5118 \layout List
5115 \layout List
5119 \labelwidthstring 00.00.0000
5116 \labelwidthstring 00.00.0000
5120
5117
5121
5118
5122 \family typewriter
5119 \family typewriter
5123 \series bold
5120 \series bold
5124 __
5121 __
5125 \family default
5122 \family default
5126 \series default
5123 \series default
5127 (two underscores): next previous.
5124 (two underscores): next previous.
5128 \layout List
5125 \layout List
5129 \labelwidthstring 00.00.0000
5126 \labelwidthstring 00.00.0000
5130
5127
5131
5128
5132 \family typewriter
5129 \family typewriter
5133 \series bold
5130 \series bold
5134 ___
5131 ___
5135 \family default
5132 \family default
5136 \series default
5133 \series default
5137 (three underscores): next-next previous.
5134 (three underscores): next-next previous.
5138 \layout Standard
5135 \layout Standard
5139
5136
5140 Additionally, global variables named
5137 Additionally, global variables named
5141 \family typewriter
5138 \family typewriter
5142 _<n>
5139 _<n>
5143 \family default
5140 \family default
5144 are dynamically created (
5141 are dynamically created (
5145 \family typewriter
5142 \family typewriter
5146 <n>
5143 <n>
5147 \family default
5144 \family default
5148 being the prompt counter), such that the result of output
5145 being the prompt counter), such that the result of output
5149 \family typewriter
5146 \family typewriter
5150 <n>
5147 <n>
5151 \family default
5148 \family default
5152 is always available as
5149 is always available as
5153 \family typewriter
5150 \family typewriter
5154 _<n>
5151 _<n>
5155 \family default
5152 \family default
5156 (don't use the angle brackets, just the number, e.g.
5153 (don't use the angle brackets, just the number, e.g.
5157
5154
5158 \family typewriter
5155 \family typewriter
5159 _21
5156 _21
5160 \family default
5157 \family default
5161 ).
5158 ).
5162 \layout Standard
5159 \layout Standard
5163
5160
5164 These global variables are all stored in a global dictionary (not a list,
5161 These global variables are all stored in a global dictionary (not a list,
5165 since it only has entries for lines which returned a result) available
5162 since it only has entries for lines which returned a result) available
5166 under the names
5163 under the names
5167 \family typewriter
5164 \family typewriter
5168 _oh
5165 _oh
5169 \family default
5166 \family default
5170 and
5167 and
5171 \family typewriter
5168 \family typewriter
5172 Out
5169 Out
5173 \family default
5170 \family default
5174 (similar to
5171 (similar to
5175 \family typewriter
5172 \family typewriter
5176 _ih
5173 _ih
5177 \family default
5174 \family default
5178 and
5175 and
5179 \family typewriter
5176 \family typewriter
5180 In
5177 In
5181 \family default
5178 \family default
5182 ).
5179 ).
5183 So the output from line 12 can be obtained as
5180 So the output from line 12 can be obtained as
5184 \family typewriter
5181 \family typewriter
5185 _12
5182 _12
5186 \family default
5183 \family default
5187 ,
5184 ,
5188 \family typewriter
5185 \family typewriter
5189 Out[12]
5186 Out[12]
5190 \family default
5187 \family default
5191 or
5188 or
5192 \family typewriter
5189 \family typewriter
5193 _oh[12]
5190 _oh[12]
5194 \family default
5191 \family default
5195 .
5192 .
5196 If you accidentally overwrite the
5193 If you accidentally overwrite the
5197 \family typewriter
5194 \family typewriter
5198 Out
5195 Out
5199 \family default
5196 \family default
5200 variable you can recover it by typing
5197 variable you can recover it by typing
5201 \family typewriter
5198 \family typewriter
5202 'Out=_oh
5199 'Out=_oh
5203 \family default
5200 \family default
5204 ' at the prompt.
5201 ' at the prompt.
5205 \layout Standard
5202 \layout Standard
5206
5203
5207 This system obviously can potentially put heavy memory demands on your system,
5204 This system obviously can potentially put heavy memory demands on your system,
5208 since it prevents Python's garbage collector from removing any previously
5205 since it prevents Python's garbage collector from removing any previously
5209 computed results.
5206 computed results.
5210 You can control how many results are kept in memory with the option (at
5207 You can control how many results are kept in memory with the option (at
5211 the command line or in your
5208 the command line or in your
5212 \family typewriter
5209 \family typewriter
5213 ipythonrc
5210 ipythonrc
5214 \family default
5211 \family default
5215 file)
5212 file)
5216 \family typewriter
5213 \family typewriter
5217 cache_size
5214 cache_size
5218 \family default
5215 \family default
5219 .
5216 .
5220 If you set it to 0, the whole system is completely disabled and the prompts
5217 If you set it to 0, the whole system is completely disabled and the prompts
5221 revert to the classic
5218 revert to the classic
5222 \family typewriter
5219 \family typewriter
5223 '>>>'
5220 '>>>'
5224 \family default
5221 \family default
5225 of normal Python.
5222 of normal Python.
5226 \layout Subsection
5223 \layout Subsection
5227
5224
5228 Directory history
5225 Directory history
5229 \layout Standard
5226 \layout Standard
5230
5227
5231 Your history of visited directories is kept in the global list
5228 Your history of visited directories is kept in the global list
5232 \family typewriter
5229 \family typewriter
5233 _dh
5230 _dh
5234 \family default
5231 \family default
5235 , and the magic
5232 , and the magic
5236 \family typewriter
5233 \family typewriter
5237 %cd
5234 %cd
5238 \family default
5235 \family default
5239 command can be used to go to any entry in that list.
5236 command can be used to go to any entry in that list.
5240 The
5237 The
5241 \family typewriter
5238 \family typewriter
5242 %dhist
5239 %dhist
5243 \family default
5240 \family default
5244 command allows you to view this history.
5241 command allows you to view this history.
5245 \layout Subsection
5242 \layout Subsection
5246
5243
5247 Automatic parentheses and quotes
5244 Automatic parentheses and quotes
5248 \layout Standard
5245 \layout Standard
5249
5246
5250 These features were adapted from Nathan Gray's LazyPython.
5247 These features were adapted from Nathan Gray's LazyPython.
5251 They are meant to allow less typing for common situations.
5248 They are meant to allow less typing for common situations.
5252 \layout Subsubsection
5249 \layout Subsubsection
5253
5250
5254 Automatic parentheses
5251 Automatic parentheses
5255 \layout Standard
5252 \layout Standard
5256
5253
5257 Callable objects (i.e.
5254 Callable objects (i.e.
5258 functions, methods, etc) can be invoked like this (notice the commas between
5255 functions, methods, etc) can be invoked like this (notice the commas between
5259 the arguments):
5256 the arguments):
5260 \layout Standard
5257 \layout Standard
5261
5258
5262
5259
5263 \family typewriter
5260 \family typewriter
5264 >>> callable_ob arg1, arg2, arg3
5261 >>> callable_ob arg1, arg2, arg3
5265 \layout Standard
5262 \layout Standard
5266
5263
5267 and the input will be translated to this:
5264 and the input will be translated to this:
5268 \layout Standard
5265 \layout Standard
5269
5266
5270
5267
5271 \family typewriter
5268 \family typewriter
5272 --> callable_ob(arg1, arg2, arg3)
5269 --> callable_ob(arg1, arg2, arg3)
5273 \layout Standard
5270 \layout Standard
5274
5271
5275 You can force automatic parentheses by using '/' as the first character
5272 You can force automatic parentheses by using '/' as the first character
5276 of a line.
5273 of a line.
5277 For example:
5274 For example:
5278 \layout Standard
5275 \layout Standard
5279
5276
5280
5277
5281 \family typewriter
5278 \family typewriter
5282 >>> /globals # becomes 'globals()'
5279 >>> /globals # becomes 'globals()'
5283 \layout Standard
5280 \layout Standard
5284
5281
5285 Note that the '/' MUST be the first character on the line! This won't work:
5282 Note that the '/' MUST be the first character on the line! This won't work:
5286
5283
5287 \layout Standard
5284 \layout Standard
5288
5285
5289
5286
5290 \family typewriter
5287 \family typewriter
5291 >>> print /globals # syntax error
5288 >>> print /globals # syntax error
5292 \layout Standard
5289 \layout Standard
5293
5290
5294 In most cases the automatic algorithm should work, so you should rarely
5291 In most cases the automatic algorithm should work, so you should rarely
5295 need to explicitly invoke /.
5292 need to explicitly invoke /.
5296 One notable exception is if you are trying to call a function with a list
5293 One notable exception is if you are trying to call a function with a list
5297 of tuples as arguments (the parenthesis will confuse IPython):
5294 of tuples as arguments (the parenthesis will confuse IPython):
5298 \layout Standard
5295 \layout Standard
5299
5296
5300
5297
5301 \family typewriter
5298 \family typewriter
5302 In [1]: zip (1,2,3),(4,5,6) # won't work
5299 In [1]: zip (1,2,3),(4,5,6) # won't work
5303 \layout Standard
5300 \layout Standard
5304
5301
5305 but this will work:
5302 but this will work:
5306 \layout Standard
5303 \layout Standard
5307
5304
5308
5305
5309 \family typewriter
5306 \family typewriter
5310 In [2]: /zip (1,2,3),(4,5,6)
5307 In [2]: /zip (1,2,3),(4,5,6)
5311 \newline
5308 \newline
5312 ------> zip ((1,2,3),(4,5,6))
5309 ------> zip ((1,2,3),(4,5,6))
5313 \newline
5310 \newline
5314 Out[2]= [(1, 4), (2, 5), (3, 6)]
5311 Out[2]= [(1, 4), (2, 5), (3, 6)]
5315 \layout Standard
5312 \layout Standard
5316
5313
5317 IPython tells you that it has altered your command line by displaying the
5314 IPython tells you that it has altered your command line by displaying the
5318 new command line preceded by
5315 new command line preceded by
5319 \family typewriter
5316 \family typewriter
5320 -->
5317 -->
5321 \family default
5318 \family default
5322 .
5319 .
5323 e.g.:
5320 e.g.:
5324 \layout Standard
5321 \layout Standard
5325
5322
5326
5323
5327 \family typewriter
5324 \family typewriter
5328 In [18]: callable list
5325 In [18]: callable list
5329 \newline
5326 \newline
5330 -------> callable (list)
5327 -------> callable (list)
5331 \layout Subsubsection
5328 \layout Subsubsection
5332
5329
5333 Automatic quoting
5330 Automatic quoting
5334 \layout Standard
5331 \layout Standard
5335
5332
5336 You can force automatic quoting of a function's arguments by using
5333 You can force automatic quoting of a function's arguments by using
5337 \family typewriter
5334 \family typewriter
5338 `,'
5335 `,'
5339 \family default
5336 \family default
5340 or
5337 or
5341 \family typewriter
5338 \family typewriter
5342 `;'
5339 `;'
5343 \family default
5340 \family default
5344 as the first character of a line.
5341 as the first character of a line.
5345 For example:
5342 For example:
5346 \layout Standard
5343 \layout Standard
5347
5344
5348
5345
5349 \family typewriter
5346 \family typewriter
5350 >>> ,my_function /home/me # becomes my_function("/home/me")
5347 >>> ,my_function /home/me # becomes my_function("/home/me")
5351 \layout Standard
5348 \layout Standard
5352
5349
5353 If you use
5350 If you use
5354 \family typewriter
5351 \family typewriter
5355 `;'
5352 `;'
5356 \family default
5353 \family default
5357 instead, the whole argument is quoted as a single string (while
5354 instead, the whole argument is quoted as a single string (while
5358 \family typewriter
5355 \family typewriter
5359 `,'
5356 `,'
5360 \family default
5357 \family default
5361 splits on whitespace):
5358 splits on whitespace):
5362 \layout Standard
5359 \layout Standard
5363
5360
5364
5361
5365 \family typewriter
5362 \family typewriter
5366 >>> ,my_function a b c # becomes my_function("a","b","c")
5363 >>> ,my_function a b c # becomes my_function("a","b","c")
5367 \layout Standard
5364 \layout Standard
5368
5365
5369
5366
5370 \family typewriter
5367 \family typewriter
5371 >>> ;my_function a b c # becomes my_function("a b c")
5368 >>> ;my_function a b c # becomes my_function("a b c")
5372 \layout Standard
5369 \layout Standard
5373
5370
5374 Note that the `
5371 Note that the `
5375 \family typewriter
5372 \family typewriter
5376 ,
5373 ,
5377 \family default
5374 \family default
5378 ' or `
5375 ' or `
5379 \family typewriter
5376 \family typewriter
5380 ;
5377 ;
5381 \family default
5378 \family default
5382 ' MUST be the first character on the line! This won't work:
5379 ' MUST be the first character on the line! This won't work:
5383 \layout Standard
5380 \layout Standard
5384
5381
5385
5382
5386 \family typewriter
5383 \family typewriter
5387 >>> x = ,my_function /home/me # syntax error
5384 >>> x = ,my_function /home/me # syntax error
5388 \layout Section
5385 \layout Section
5389
5386
5390
5387
5391 \begin_inset LatexCommand \label{sec:customization}
5388 \begin_inset LatexCommand \label{sec:customization}
5392
5389
5393 \end_inset
5390 \end_inset
5394
5391
5395 Customization
5392 Customization
5396 \layout Standard
5393 \layout Standard
5397
5394
5398 As we've already mentioned, IPython reads a configuration file which can
5395 As we've already mentioned, IPython reads a configuration file which can
5399 be specified at the command line (
5396 be specified at the command line (
5400 \family typewriter
5397 \family typewriter
5401 -rcfile
5398 -rcfile
5402 \family default
5399 \family default
5403 ) or which by default is assumed to be called
5400 ) or which by default is assumed to be called
5404 \family typewriter
5401 \family typewriter
5405 ipythonrc
5402 ipythonrc
5406 \family default
5403 \family default
5407 .
5404 .
5408 Such a file is looked for in the current directory where IPython is started
5405 Such a file is looked for in the current directory where IPython is started
5409 and then in your
5406 and then in your
5410 \family typewriter
5407 \family typewriter
5411 IPYTHONDIR
5408 IPYTHONDIR
5412 \family default
5409 \family default
5413 , which allows you to have local configuration files for specific projects.
5410 , which allows you to have local configuration files for specific projects.
5414 In this section we will call these types of configuration files simply
5411 In this section we will call these types of configuration files simply
5415 rcfiles (short for resource configuration file).
5412 rcfiles (short for resource configuration file).
5416 \layout Standard
5413 \layout Standard
5417
5414
5418 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5415 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5419 one per line.
5416 one per line.
5420 Lines beginning with a
5417 Lines beginning with a
5421 \family typewriter
5418 \family typewriter
5422 #
5419 #
5423 \family default
5420 \family default
5424 are ignored as comments, but comments can
5421 are ignored as comments, but comments can
5425 \series bold
5422 \series bold
5426 not
5423 not
5427 \series default
5424 \series default
5428 be put on lines with data (the parser is fairly primitive).
5425 be put on lines with data (the parser is fairly primitive).
5429 Note that these are not python files, and this is deliberate, because it
5426 Note that these are not python files, and this is deliberate, because it
5430 allows us to do some things which would be quite tricky to implement if
5427 allows us to do some things which would be quite tricky to implement if
5431 they were normal python files.
5428 they were normal python files.
5432 \layout Standard
5429 \layout Standard
5433
5430
5434 First, an rcfile can contain permanent default values for almost all command
5431 First, an rcfile can contain permanent default values for almost all command
5435 line options (except things like
5432 line options (except things like
5436 \family typewriter
5433 \family typewriter
5437 -help
5434 -help
5438 \family default
5435 \family default
5439 or
5436 or
5440 \family typewriter
5437 \family typewriter
5441 -Version
5438 -Version
5442 \family default
5439 \family default
5443 ).
5440 ).
5444 Sec\SpecialChar ~
5441 Sec\SpecialChar ~
5445
5442
5446 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5443 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5447
5444
5448 \end_inset
5445 \end_inset
5449
5446
5450 contains a description of all command-line options.
5447 contains a description of all command-line options.
5451 However, values you explicitly specify at the command line override the
5448 However, values you explicitly specify at the command line override the
5452 values defined in the rcfile.
5449 values defined in the rcfile.
5453 \layout Standard
5450 \layout Standard
5454
5451
5455 Besides command line option values, the rcfile can specify values for certain
5452 Besides command line option values, the rcfile can specify values for certain
5456 extra special options which are not available at the command line.
5453 extra special options which are not available at the command line.
5457 These options are briefly described below.
5454 These options are briefly described below.
5458
5455
5459 \layout Standard
5456 \layout Standard
5460
5457
5461 Each of these options may appear as many times as you need it in the file.
5458 Each of these options may appear as many times as you need it in the file.
5462 \layout List
5459 \layout List
5463 \labelwidthstring 00.00.0000
5460 \labelwidthstring 00.00.0000
5464
5461
5465
5462
5466 \family typewriter
5463 \family typewriter
5467 \series bold
5464 \series bold
5468 include\SpecialChar ~
5465 include\SpecialChar ~
5469 <file1>\SpecialChar ~
5466 <file1>\SpecialChar ~
5470 <file2>\SpecialChar ~
5467 <file2>\SpecialChar ~
5471 ...
5468 ...
5472 \family default
5469 \family default
5473 \series default
5470 \series default
5474 : you can name
5471 : you can name
5475 \emph on
5472 \emph on
5476 other
5473 other
5477 \emph default
5474 \emph default
5478 rcfiles you want to recursively load up to 15 levels (don't use the
5475 rcfiles you want to recursively load up to 15 levels (don't use the
5479 \family typewriter
5476 \family typewriter
5480 <>
5477 <>
5481 \family default
5478 \family default
5482 brackets in your names!).
5479 brackets in your names!).
5483 This feature allows you to define a 'base' rcfile with general options
5480 This feature allows you to define a 'base' rcfile with general options
5484 and special-purpose files which can be loaded only when needed with particular
5481 and special-purpose files which can be loaded only when needed with particular
5485 configuration options.
5482 configuration options.
5486 To make this more convenient, IPython accepts the
5483 To make this more convenient, IPython accepts the
5487 \family typewriter
5484 \family typewriter
5488 -profile <name>
5485 -profile <name>
5489 \family default
5486 \family default
5490 option (abbreviates to
5487 option (abbreviates to
5491 \family typewriter
5488 \family typewriter
5492 -p <name
5489 -p <name
5493 \family default
5490 \family default
5494 >)
5491 >)
5495 \family typewriter
5492 \family typewriter
5496 which
5493 which
5497 \family default
5494 \family default
5498 tells it to look for an rcfile named
5495 tells it to look for an rcfile named
5499 \family typewriter
5496 \family typewriter
5500 ipythonrc-<name>
5497 ipythonrc-<name>
5501 \family default
5498 \family default
5502 .
5499 .
5503
5500
5504 \layout List
5501 \layout List
5505 \labelwidthstring 00.00.0000
5502 \labelwidthstring 00.00.0000
5506
5503
5507
5504
5508 \family typewriter
5505 \family typewriter
5509 \series bold
5506 \series bold
5510 import_mod\SpecialChar ~
5507 import_mod\SpecialChar ~
5511 <mod1>\SpecialChar ~
5508 <mod1>\SpecialChar ~
5512 <mod2>\SpecialChar ~
5509 <mod2>\SpecialChar ~
5513 ...
5510 ...
5514 \family default
5511 \family default
5515 \series default
5512 \series default
5516 : import modules with '
5513 : import modules with '
5517 \family typewriter
5514 \family typewriter
5518 import
5515 import
5519 \family default
5516 \family default
5520
5517
5521 \family typewriter
5518 \family typewriter
5522 <mod1>,<mod2>,...
5519 <mod1>,<mod2>,...
5523 \family default
5520 \family default
5524 '
5521 '
5525 \layout List
5522 \layout List
5526 \labelwidthstring 00.00.0000
5523 \labelwidthstring 00.00.0000
5527
5524
5528
5525
5529 \family typewriter
5526 \family typewriter
5530 \series bold
5527 \series bold
5531 import_some\SpecialChar ~
5528 import_some\SpecialChar ~
5532 <mod>\SpecialChar ~
5529 <mod>\SpecialChar ~
5533 <f1>\SpecialChar ~
5530 <f1>\SpecialChar ~
5534 <f2>\SpecialChar ~
5531 <f2>\SpecialChar ~
5535 ...
5532 ...
5536 \family default
5533 \family default
5537 \series default
5534 \series default
5538 : import functions with '
5535 : import functions with '
5539 \family typewriter
5536 \family typewriter
5540 from <mod> import
5537 from <mod> import
5541 \family default
5538 \family default
5542
5539
5543 \family typewriter
5540 \family typewriter
5544 <f1>,<f2>,...
5541 <f1>,<f2>,...
5545 \family default
5542 \family default
5546 '
5543 '
5547 \layout List
5544 \layout List
5548 \labelwidthstring 00.00.0000
5545 \labelwidthstring 00.00.0000
5549
5546
5550
5547
5551 \family typewriter
5548 \family typewriter
5552 \series bold
5549 \series bold
5553 import_all\SpecialChar ~
5550 import_all\SpecialChar ~
5554 <mod1>\SpecialChar ~
5551 <mod1>\SpecialChar ~
5555 <mod2>\SpecialChar ~
5552 <mod2>\SpecialChar ~
5556 ...
5553 ...
5557 \family default
5554 \family default
5558 \series default
5555 \series default
5559 : for each module listed import functions with '
5556 : for each module listed import functions with '
5560 \family typewriter
5557 \family typewriter
5561 from <mod> import *
5558 from <mod> import *
5562 \family default
5559 \family default
5563 '
5560 '
5564 \layout List
5561 \layout List
5565 \labelwidthstring 00.00.0000
5562 \labelwidthstring 00.00.0000
5566
5563
5567
5564
5568 \family typewriter
5565 \family typewriter
5569 \series bold
5566 \series bold
5570 execute\SpecialChar ~
5567 execute\SpecialChar ~
5571 <python\SpecialChar ~
5568 <python\SpecialChar ~
5572 code>
5569 code>
5573 \family default
5570 \family default
5574 \series default
5571 \series default
5575 : give any single-line python code to be executed.
5572 : give any single-line python code to be executed.
5576 \layout List
5573 \layout List
5577 \labelwidthstring 00.00.0000
5574 \labelwidthstring 00.00.0000
5578
5575
5579
5576
5580 \family typewriter
5577 \family typewriter
5581 \series bold
5578 \series bold
5582 execfile\SpecialChar ~
5579 execfile\SpecialChar ~
5583 <filename>
5580 <filename>
5584 \family default
5581 \family default
5585 \series default
5582 \series default
5586 : execute the python file given with an '
5583 : execute the python file given with an '
5587 \family typewriter
5584 \family typewriter
5588 execfile(filename)
5585 execfile(filename)
5589 \family default
5586 \family default
5590 ' command.
5587 ' command.
5591 Username expansion is performed on the given names.
5588 Username expansion is performed on the given names.
5592 So if you need any amount of extra fancy customization that won't fit in
5589 So if you need any amount of extra fancy customization that won't fit in
5593 any of the above 'canned' options, you can just put it in a separate python
5590 any of the above 'canned' options, you can just put it in a separate python
5594 file and execute it.
5591 file and execute it.
5595 \layout List
5592 \layout List
5596 \labelwidthstring 00.00.0000
5593 \labelwidthstring 00.00.0000
5597
5594
5598
5595
5599 \family typewriter
5596 \family typewriter
5600 \series bold
5597 \series bold
5601 alias\SpecialChar ~
5598 alias\SpecialChar ~
5602 <alias_def>
5599 <alias_def>
5603 \family default
5600 \family default
5604 \series default
5601 \series default
5605 : this is equivalent to calling '
5602 : this is equivalent to calling '
5606 \family typewriter
5603 \family typewriter
5607 %alias\SpecialChar ~
5604 %alias\SpecialChar ~
5608 <alias_def>
5605 <alias_def>
5609 \family default
5606 \family default
5610 ' at the IPython command line.
5607 ' at the IPython command line.
5611 This way, from within IPython you can do common system tasks without having
5608 This way, from within IPython you can do common system tasks without having
5612 to exit it or use the
5609 to exit it or use the
5613 \family typewriter
5610 \family typewriter
5614 !
5611 !
5615 \family default
5612 \family default
5616 escape.
5613 escape.
5617 IPython isn't meant to be a shell replacement, but it is often very useful
5614 IPython isn't meant to be a shell replacement, but it is often very useful
5618 to be able to do things with files while testing code.
5615 to be able to do things with files while testing code.
5619 This gives you the flexibility to have within IPython any aliases you may
5616 This gives you the flexibility to have within IPython any aliases you may
5620 be used to under your normal system shell.
5617 be used to under your normal system shell.
5621 \layout Subsection
5618 \layout Subsection
5622
5619
5623
5620
5624 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5621 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5625
5622
5626 \end_inset
5623 \end_inset
5627
5624
5628 Sample
5625 Sample
5629 \family typewriter
5626 \family typewriter
5630 ipythonrc
5627 ipythonrc
5631 \family default
5628 \family default
5632 file
5629 file
5633 \layout Standard
5630 \layout Standard
5634
5631
5635 The default rcfile, called
5632 The default rcfile, called
5636 \family typewriter
5633 \family typewriter
5637 ipythonrc
5634 ipythonrc
5638 \family default
5635 \family default
5639 and supplied in your
5636 and supplied in your
5640 \family typewriter
5637 \family typewriter
5641 IPYTHONDIR
5638 IPYTHONDIR
5642 \family default
5639 \family default
5643 directory contains lots of comments on all of these options.
5640 directory contains lots of comments on all of these options.
5644 We reproduce it here for reference:
5641 We reproduce it here for reference:
5645 \layout Standard
5642 \layout Standard
5646
5643
5647
5644
5648 \begin_inset ERT
5645 \begin_inset ERT
5649 status Open
5646 status Open
5650
5647
5651 \layout Standard
5648 \layout Standard
5652
5649
5653 \backslash
5650 \backslash
5654 codelist{../IPython/UserConfig/ipythonrc}
5651 codelist{../IPython/UserConfig/ipythonrc}
5655 \end_inset
5652 \end_inset
5656
5653
5657
5654
5658 \layout Subsection
5655 \layout Subsection
5659
5656
5660
5657
5661 \begin_inset LatexCommand \label{sec:prompts}
5658 \begin_inset LatexCommand \label{sec:prompts}
5662
5659
5663 \end_inset
5660 \end_inset
5664
5661
5665 Fine-tuning your prompt
5662 Fine-tuning your prompt
5666 \layout Standard
5663 \layout Standard
5667
5664
5668 IPython's prompts can be customized using a syntax similar to that of the
5665 IPython's prompts can be customized using a syntax similar to that of the
5669
5666
5670 \family typewriter
5667 \family typewriter
5671 bash
5668 bash
5672 \family default
5669 \family default
5673 shell.
5670 shell.
5674 Many of
5671 Many of
5675 \family typewriter
5672 \family typewriter
5676 bash
5673 bash
5677 \family default
5674 \family default
5678 's escapes are supported, as well as a few additional ones.
5675 's escapes are supported, as well as a few additional ones.
5679 We list them below:
5676 We list them below:
5680 \layout Description
5677 \layout Description
5681
5678
5682
5679
5683 \backslash
5680 \backslash
5684 # the prompt/history count number
5681 # the prompt/history count number
5685 \layout Description
5682 \layout Description
5686
5683
5687
5684
5688 \backslash
5685 \backslash
5689 D the prompt/history count, with the actual digits replaced by dots.
5686 D the prompt/history count, with the actual digits replaced by dots.
5690 Used mainly in continuation prompts (prompt_in2)
5687 Used mainly in continuation prompts (prompt_in2)
5691 \layout Description
5688 \layout Description
5692
5689
5693
5690
5694 \backslash
5691 \backslash
5695 w the current working directory
5692 w the current working directory
5696 \layout Description
5693 \layout Description
5697
5694
5698
5695
5699 \backslash
5696 \backslash
5700 W the basename of current working directory
5697 W the basename of current working directory
5701 \layout Description
5698 \layout Description
5702
5699
5703
5700
5704 \backslash
5701 \backslash
5705 X
5702 X
5706 \emph on
5703 \emph on
5707 n
5704 n
5708 \emph default
5705 \emph default
5709 where
5706 where
5710 \begin_inset Formula $n=0\ldots5.$
5707 \begin_inset Formula $n=0\ldots5.$
5711 \end_inset
5708 \end_inset
5712
5709
5713 The current working directory, with
5710 The current working directory, with
5714 \family typewriter
5711 \family typewriter
5715 $HOME
5712 $HOME
5716 \family default
5713 \family default
5717 replaced by
5714 replaced by
5718 \family typewriter
5715 \family typewriter
5719 ~
5716 ~
5720 \family default
5717 \family default
5721 , and filtered out to contain only
5718 , and filtered out to contain only
5722 \begin_inset Formula $n$
5719 \begin_inset Formula $n$
5723 \end_inset
5720 \end_inset
5724
5721
5725 path elements
5722 path elements
5726 \layout Description
5723 \layout Description
5727
5724
5728
5725
5729 \backslash
5726 \backslash
5730 Y
5727 Y
5731 \emph on
5728 \emph on
5732 n
5729 n
5733 \emph default
5730 \emph default
5734 Similar to
5731 Similar to
5735 \backslash
5732 \backslash
5736 X
5733 X
5737 \emph on
5734 \emph on
5738 n
5735 n
5739 \emph default
5736 \emph default
5740 , but with the
5737 , but with the
5741 \begin_inset Formula $n+1$
5738 \begin_inset Formula $n+1$
5742 \end_inset
5739 \end_inset
5743
5740
5744 element included if it is
5741 element included if it is
5745 \family typewriter
5742 \family typewriter
5746 ~
5743 ~
5747 \family default
5744 \family default
5748 (this is similar to the behavior of the %c
5745 (this is similar to the behavior of the %c
5749 \emph on
5746 \emph on
5750 n
5747 n
5751 \emph default
5748 \emph default
5752 escapes in
5749 escapes in
5753 \family typewriter
5750 \family typewriter
5754 tcsh
5751 tcsh
5755 \family default
5752 \family default
5756 )
5753 )
5757 \layout Description
5754 \layout Description
5758
5755
5759
5756
5760 \backslash
5757 \backslash
5761 u the username of the current user
5758 u the username of the current user
5762 \layout Description
5759 \layout Description
5763
5760
5764
5761
5765 \backslash
5762 \backslash
5766 $ if the effective UID is 0, a #, otherwise a $
5763 $ if the effective UID is 0, a #, otherwise a $
5767 \layout Description
5764 \layout Description
5768
5765
5769
5766
5770 \backslash
5767 \backslash
5771 h the hostname up to the first `.'
5768 h the hostname up to the first `.'
5772 \layout Description
5769 \layout Description
5773
5770
5774
5771
5775 \backslash
5772 \backslash
5776 H the hostname
5773 H the hostname
5777 \layout Description
5774 \layout Description
5778
5775
5779
5776
5780 \backslash
5777 \backslash
5781 n a newline
5778 n a newline
5782 \layout Description
5779 \layout Description
5783
5780
5784
5781
5785 \backslash
5782 \backslash
5786 r a carriage return
5783 r a carriage return
5787 \layout Description
5784 \layout Description
5788
5785
5789
5786
5790 \backslash
5787 \backslash
5791 v IPython version string
5788 v IPython version string
5792 \layout Standard
5789 \layout Standard
5793
5790
5794 In addition to these, ANSI color escapes can be insterted into the prompts,
5791 In addition to these, ANSI color escapes can be insterted into the prompts,
5795 as
5792 as
5796 \family typewriter
5793 \family typewriter
5797
5794
5798 \backslash
5795 \backslash
5799 C_
5796 C_
5800 \emph on
5797 \emph on
5801 ColorName
5798 ColorName
5802 \family default
5799 \family default
5803 \emph default
5800 \emph default
5804 .
5801 .
5805 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5802 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5806 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5803 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5807 Normal, Purple, Red, White, Yellow.
5804 Normal, Purple, Red, White, Yellow.
5808 \layout Standard
5805 \layout Standard
5809
5806
5810 Finally, IPython supports the evaluation of arbitrary expressions in your
5807 Finally, IPython supports the evaluation of arbitrary expressions in your
5811 prompt string.
5808 prompt string.
5812 The prompt strings are evaluated through the syntax of PEP 215, but basically
5809 The prompt strings are evaluated through the syntax of PEP 215, but basically
5813 you can use
5810 you can use
5814 \family typewriter
5811 \family typewriter
5815 $x.y
5812 $x.y
5816 \family default
5813 \family default
5817 to expand the value of
5814 to expand the value of
5818 \family typewriter
5815 \family typewriter
5819 x.y
5816 x.y
5820 \family default
5817 \family default
5821 , and for more complicated expressions you can use braces:
5818 , and for more complicated expressions you can use braces:
5822 \family typewriter
5819 \family typewriter
5823 ${foo()+x}
5820 ${foo()+x}
5824 \family default
5821 \family default
5825 will call function
5822 will call function
5826 \family typewriter
5823 \family typewriter
5827 foo
5824 foo
5828 \family default
5825 \family default
5829 and add to it the value of
5826 and add to it the value of
5830 \family typewriter
5827 \family typewriter
5831 x
5828 x
5832 \family default
5829 \family default
5833 , before putting the result into your prompt.
5830 , before putting the result into your prompt.
5834 For example, using
5831 For example, using
5835 \newline
5832 \newline
5836
5833
5837 \family typewriter
5834 \family typewriter
5838 prompt_in1 '${commands.getoutput("uptime")}
5835 prompt_in1 '${commands.getoutput("uptime")}
5839 \backslash
5836 \backslash
5840 nIn [
5837 nIn [
5841 \backslash
5838 \backslash
5842 #]: '
5839 #]: '
5843 \newline
5840 \newline
5844
5841
5845 \family default
5842 \family default
5846 will print the result of the uptime command on each prompt (assuming the
5843 will print the result of the uptime command on each prompt (assuming the
5847
5844
5848 \family typewriter
5845 \family typewriter
5849 commands
5846 commands
5850 \family default
5847 \family default
5851 module has been imported in your
5848 module has been imported in your
5852 \family typewriter
5849 \family typewriter
5853 ipythonrc
5850 ipythonrc
5854 \family default
5851 \family default
5855 file).
5852 file).
5856 \layout Subsubsection
5853 \layout Subsubsection
5857
5854
5858 Prompt examples
5855 Prompt examples
5859 \layout Standard
5856 \layout Standard
5860
5857
5861 The following options in an ipythonrc file will give you IPython's default
5858 The following options in an ipythonrc file will give you IPython's default
5862 prompts:
5859 prompts:
5863 \layout Standard
5860 \layout Standard
5864
5861
5865
5862
5866 \family typewriter
5863 \family typewriter
5867 prompt_in1 'In [
5864 prompt_in1 'In [
5868 \backslash
5865 \backslash
5869 #]:'
5866 #]:'
5870 \newline
5867 \newline
5871 prompt_in2 '\SpecialChar ~
5868 prompt_in2 '\SpecialChar ~
5872 \SpecialChar ~
5869 \SpecialChar ~
5873 \SpecialChar ~
5870 \SpecialChar ~
5874 .
5871 .
5875 \backslash
5872 \backslash
5876 D.:'
5873 D.:'
5877 \newline
5874 \newline
5878 prompt_out 'Out[
5875 prompt_out 'Out[
5879 \backslash
5876 \backslash
5880 #]:'
5877 #]:'
5881 \layout Standard
5878 \layout Standard
5882
5879
5883 which look like this:
5880 which look like this:
5884 \layout Standard
5881 \layout Standard
5885
5882
5886
5883
5887 \family typewriter
5884 \family typewriter
5888 In [1]: 1+2
5885 In [1]: 1+2
5889 \newline
5886 \newline
5890 Out[1]: 3
5887 Out[1]: 3
5891 \layout Standard
5888 \layout Standard
5892
5889
5893
5890
5894 \family typewriter
5891 \family typewriter
5895 In [2]: for i in (1,2,3):
5892 In [2]: for i in (1,2,3):
5896 \newline
5893 \newline
5897
5894
5898 \begin_inset ERT
5895 \begin_inset ERT
5899 status Collapsed
5896 status Collapsed
5900
5897
5901 \layout Standard
5898 \layout Standard
5902
5899
5903 \backslash
5900 \backslash
5904 hspace*{0mm}
5901 hspace*{0mm}
5905 \end_inset
5902 \end_inset
5906
5903
5907 \SpecialChar ~
5904 \SpecialChar ~
5908 \SpecialChar ~
5905 \SpecialChar ~
5909 \SpecialChar ~
5906 \SpecialChar ~
5910 ...: \SpecialChar ~
5907 ...: \SpecialChar ~
5911 \SpecialChar ~
5908 \SpecialChar ~
5912 \SpecialChar ~
5909 \SpecialChar ~
5913 \SpecialChar ~
5910 \SpecialChar ~
5914 print i,
5911 print i,
5915 \newline
5912 \newline
5916
5913
5917 \begin_inset ERT
5914 \begin_inset ERT
5918 status Collapsed
5915 status Collapsed
5919
5916
5920 \layout Standard
5917 \layout Standard
5921
5918
5922 \backslash
5919 \backslash
5923 hspace*{0mm}
5920 hspace*{0mm}
5924 \end_inset
5921 \end_inset
5925
5922
5926 \SpecialChar ~
5923 \SpecialChar ~
5927 \SpecialChar ~
5924 \SpecialChar ~
5928 \SpecialChar ~
5925 \SpecialChar ~
5929 ...:
5926 ...:
5930 \newline
5927 \newline
5931 1 2 3
5928 1 2 3
5932 \layout Standard
5929 \layout Standard
5933
5930
5934 These will give you a very colorful prompt with path information:
5931 These will give you a very colorful prompt with path information:
5935 \layout Standard
5932 \layout Standard
5936
5933
5937
5934
5938 \family typewriter
5935 \family typewriter
5939 #prompt_in1 '
5936 #prompt_in1 '
5940 \backslash
5937 \backslash
5941 C_Red
5938 C_Red
5942 \backslash
5939 \backslash
5943 u
5940 u
5944 \backslash
5941 \backslash
5945 C_Blue[
5942 C_Blue[
5946 \backslash
5943 \backslash
5947 C_Cyan
5944 C_Cyan
5948 \backslash
5945 \backslash
5949 Y1
5946 Y1
5950 \backslash
5947 \backslash
5951 C_Blue]
5948 C_Blue]
5952 \backslash
5949 \backslash
5953 C_LightGreen
5950 C_LightGreen
5954 \backslash
5951 \backslash
5955 #>'
5952 #>'
5956 \newline
5953 \newline
5957 prompt_in2 ' ..
5954 prompt_in2 ' ..
5958 \backslash
5955 \backslash
5959 D>'
5956 D>'
5960 \newline
5957 \newline
5961 prompt_out '<
5958 prompt_out '<
5962 \backslash
5959 \backslash
5963 #>'
5960 #>'
5964 \layout Standard
5961 \layout Standard
5965
5962
5966 which look like this:
5963 which look like this:
5967 \layout Standard
5964 \layout Standard
5968
5965
5969
5966
5970 \family typewriter
5967 \family typewriter
5971 \color red
5968 \color red
5972 fperez
5969 fperez
5973 \color blue
5970 \color blue
5974 [
5971 [
5975 \color cyan
5972 \color cyan
5976 ~/ipython
5973 ~/ipython
5977 \color blue
5974 \color blue
5978 ]
5975 ]
5979 \color green
5976 \color green
5980 1>
5977 1>
5981 \color default
5978 \color default
5982 1+2
5979 1+2
5983 \newline
5980 \newline
5984
5981
5985 \begin_inset ERT
5982 \begin_inset ERT
5986 status Collapsed
5983 status Collapsed
5987
5984
5988 \layout Standard
5985 \layout Standard
5989
5986
5990 \backslash
5987 \backslash
5991 hspace*{0mm}
5988 hspace*{0mm}
5992 \end_inset
5989 \end_inset
5993
5990
5994 \SpecialChar ~
5991 \SpecialChar ~
5995 \SpecialChar ~
5992 \SpecialChar ~
5996 \SpecialChar ~
5993 \SpecialChar ~
5997 \SpecialChar ~
5994 \SpecialChar ~
5998 \SpecialChar ~
5995 \SpecialChar ~
5999 \SpecialChar ~
5996 \SpecialChar ~
6000 \SpecialChar ~
5997 \SpecialChar ~
6001 \SpecialChar ~
5998 \SpecialChar ~
6002 \SpecialChar ~
5999 \SpecialChar ~
6003 \SpecialChar ~
6000 \SpecialChar ~
6004 \SpecialChar ~
6001 \SpecialChar ~
6005 \SpecialChar ~
6002 \SpecialChar ~
6006 \SpecialChar ~
6003 \SpecialChar ~
6007 \SpecialChar ~
6004 \SpecialChar ~
6008 \SpecialChar ~
6005 \SpecialChar ~
6009 \SpecialChar ~
6006 \SpecialChar ~
6010
6007
6011 \color red
6008 \color red
6012 <1>
6009 <1>
6013 \color default
6010 \color default
6014 3
6011 3
6015 \newline
6012 \newline
6016
6013
6017 \color red
6014 \color red
6018 fperez
6015 fperez
6019 \color blue
6016 \color blue
6020 [
6017 [
6021 \color cyan
6018 \color cyan
6022 ~/ipython
6019 ~/ipython
6023 \color blue
6020 \color blue
6024 ]
6021 ]
6025 \color green
6022 \color green
6026 2>
6023 2>
6027 \color default
6024 \color default
6028 for i in (1,2,3):
6025 for i in (1,2,3):
6029 \newline
6026 \newline
6030
6027
6031 \begin_inset ERT
6028 \begin_inset ERT
6032 status Collapsed
6029 status Collapsed
6033
6030
6034 \layout Standard
6031 \layout Standard
6035
6032
6036 \backslash
6033 \backslash
6037 hspace*{0mm}
6034 hspace*{0mm}
6038 \end_inset
6035 \end_inset
6039
6036
6040 \SpecialChar ~
6037 \SpecialChar ~
6041 \SpecialChar ~
6038 \SpecialChar ~
6042 \SpecialChar ~
6039 \SpecialChar ~
6043 \SpecialChar ~
6040 \SpecialChar ~
6044 \SpecialChar ~
6041 \SpecialChar ~
6045 \SpecialChar ~
6042 \SpecialChar ~
6046 \SpecialChar ~
6043 \SpecialChar ~
6047 \SpecialChar ~
6044 \SpecialChar ~
6048 \SpecialChar ~
6045 \SpecialChar ~
6049 \SpecialChar ~
6046 \SpecialChar ~
6050 \SpecialChar ~
6047 \SpecialChar ~
6051 \SpecialChar ~
6048 \SpecialChar ~
6052 \SpecialChar ~
6049 \SpecialChar ~
6053 \SpecialChar ~
6050 \SpecialChar ~
6054 \SpecialChar ~
6051 \SpecialChar ~
6055
6052
6056 \color green
6053 \color green
6057 ...>
6054 ...>
6058 \color default
6055 \color default
6059 \SpecialChar ~
6056 \SpecialChar ~
6060 \SpecialChar ~
6057 \SpecialChar ~
6061 \SpecialChar ~
6058 \SpecialChar ~
6062 \SpecialChar ~
6059 \SpecialChar ~
6063 print i,
6060 print i,
6064 \newline
6061 \newline
6065
6062
6066 \begin_inset ERT
6063 \begin_inset ERT
6067 status Collapsed
6064 status Collapsed
6068
6065
6069 \layout Standard
6066 \layout Standard
6070
6067
6071 \backslash
6068 \backslash
6072 hspace*{0mm}
6069 hspace*{0mm}
6073 \end_inset
6070 \end_inset
6074
6071
6075 \SpecialChar ~
6072 \SpecialChar ~
6076 \SpecialChar ~
6073 \SpecialChar ~
6077 \SpecialChar ~
6074 \SpecialChar ~
6078 \SpecialChar ~
6075 \SpecialChar ~
6079 \SpecialChar ~
6076 \SpecialChar ~
6080 \SpecialChar ~
6077 \SpecialChar ~
6081 \SpecialChar ~
6078 \SpecialChar ~
6082 \SpecialChar ~
6079 \SpecialChar ~
6083 \SpecialChar ~
6080 \SpecialChar ~
6084 \SpecialChar ~
6081 \SpecialChar ~
6085 \SpecialChar ~
6082 \SpecialChar ~
6086 \SpecialChar ~
6083 \SpecialChar ~
6087 \SpecialChar ~
6084 \SpecialChar ~
6088 \SpecialChar ~
6085 \SpecialChar ~
6089 \SpecialChar ~
6086 \SpecialChar ~
6090
6087
6091 \color green
6088 \color green
6092 ...>
6089 ...>
6093 \color default
6090 \color default
6094
6091
6095 \newline
6092 \newline
6096 1 2 3
6093 1 2 3
6097 \layout Standard
6094 \layout Standard
6098
6095
6099 The following shows the usage of dynamic expression evaluation:
6096 The following shows the usage of dynamic expression evaluation:
6100 \layout Subsection
6097 \layout Subsection
6101
6098
6102
6099
6103 \begin_inset LatexCommand \label{sec:profiles}
6100 \begin_inset LatexCommand \label{sec:profiles}
6104
6101
6105 \end_inset
6102 \end_inset
6106
6103
6107 IPython profiles
6104 IPython profiles
6108 \layout Standard
6105 \layout Standard
6109
6106
6110 As we already mentioned, IPython supports the
6107 As we already mentioned, IPython supports the
6111 \family typewriter
6108 \family typewriter
6112 -profile
6109 -profile
6113 \family default
6110 \family default
6114 command-line option (see sec.
6111 command-line option (see sec.
6115
6112
6116 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
6113 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
6117
6114
6118 \end_inset
6115 \end_inset
6119
6116
6120 ).
6117 ).
6121 A profile is nothing more than a particular configuration file like your
6118 A profile is nothing more than a particular configuration file like your
6122 basic
6119 basic
6123 \family typewriter
6120 \family typewriter
6124 ipythonrc
6121 ipythonrc
6125 \family default
6122 \family default
6126 one, but with particular customizations for a specific purpose.
6123 one, but with particular customizations for a specific purpose.
6127 When you start IPython with '
6124 When you start IPython with '
6128 \family typewriter
6125 \family typewriter
6129 ipython -profile <name>
6126 ipython -profile <name>
6130 \family default
6127 \family default
6131 ', it assumes that in your
6128 ', it assumes that in your
6132 \family typewriter
6129 \family typewriter
6133 IPYTHONDIR
6130 IPYTHONDIR
6134 \family default
6131 \family default
6135 there is a file called
6132 there is a file called
6136 \family typewriter
6133 \family typewriter
6137 ipythonrc-<name>
6134 ipythonrc-<name>
6138 \family default
6135 \family default
6139 , and loads it instead of the normal
6136 , and loads it instead of the normal
6140 \family typewriter
6137 \family typewriter
6141 ipythonrc
6138 ipythonrc
6142 \family default
6139 \family default
6143 .
6140 .
6144 \layout Standard
6141 \layout Standard
6145
6142
6146 This system allows you to maintain multiple configurations which load modules,
6143 This system allows you to maintain multiple configurations which load modules,
6147 set options, define functions, etc.
6144 set options, define functions, etc.
6148 suitable for different tasks and activate them in a very simple manner.
6145 suitable for different tasks and activate them in a very simple manner.
6149 In order to avoid having to repeat all of your basic options (common things
6146 In order to avoid having to repeat all of your basic options (common things
6150 that don't change such as your color preferences, for example), any profile
6147 that don't change such as your color preferences, for example), any profile
6151 can include another configuration file.
6148 can include another configuration file.
6152 The most common way to use profiles is then to have each one include your
6149 The most common way to use profiles is then to have each one include your
6153 basic
6150 basic
6154 \family typewriter
6151 \family typewriter
6155 ipythonrc
6152 ipythonrc
6156 \family default
6153 \family default
6157 file as a starting point, and then add further customizations.
6154 file as a starting point, and then add further customizations.
6158 \layout Standard
6155 \layout Standard
6159
6156
6160 In sections
6157 In sections
6161 \begin_inset LatexCommand \ref{sec:syntax-extensions}
6158 \begin_inset LatexCommand \ref{sec:syntax-extensions}
6162
6159
6163 \end_inset
6160 \end_inset
6164
6161
6165 and
6162 and
6166 \begin_inset LatexCommand \ref{sec:Gnuplot}
6163 \begin_inset LatexCommand \ref{sec:Gnuplot}
6167
6164
6168 \end_inset
6165 \end_inset
6169
6166
6170 we discuss some particular profiles which come as part of the standard
6167 we discuss some particular profiles which come as part of the standard
6171 IPython distribution.
6168 IPython distribution.
6172 You may also look in your
6169 You may also look in your
6173 \family typewriter
6170 \family typewriter
6174 IPYTHONDIR
6171 IPYTHONDIR
6175 \family default
6172 \family default
6176 directory, any file whose name begins with
6173 directory, any file whose name begins with
6177 \family typewriter
6174 \family typewriter
6178 ipythonrc-
6175 ipythonrc-
6179 \family default
6176 \family default
6180 is a profile.
6177 is a profile.
6181 You can use those as examples for further customizations to suit your own
6178 You can use those as examples for further customizations to suit your own
6182 needs.
6179 needs.
6183 \layout Section
6180 \layout Section
6184
6181
6185
6182
6186 \begin_inset OptArg
6183 \begin_inset OptArg
6187 collapsed false
6184 collapsed false
6188
6185
6189 \layout Standard
6186 \layout Standard
6190
6187
6191 IPython as default...
6188 IPython as default...
6192 \end_inset
6189 \end_inset
6193
6190
6194 IPython as your default Python environment
6191 IPython as your default Python environment
6195 \layout Standard
6192 \layout Standard
6196
6193
6197 Python honors the environment variable
6194 Python honors the environment variable
6198 \family typewriter
6195 \family typewriter
6199 PYTHONSTARTUP
6196 PYTHONSTARTUP
6200 \family default
6197 \family default
6201 and will execute at startup the file referenced by this variable.
6198 and will execute at startup the file referenced by this variable.
6202 If you put at the end of this file the following two lines of code:
6199 If you put at the end of this file the following two lines of code:
6203 \layout Standard
6200 \layout Standard
6204
6201
6205
6202
6206 \family typewriter
6203 \family typewriter
6207 import IPython
6204 import IPython
6208 \newline
6205 \newline
6209 IPython.Shell.IPShell().mainloop(sys_exit=1)
6206 IPython.Shell.IPShell().mainloop(sys_exit=1)
6210 \layout Standard
6207 \layout Standard
6211
6208
6212 then IPython will be your working environment anytime you start Python.
6209 then IPython will be your working environment anytime you start Python.
6213 The
6210 The
6214 \family typewriter
6211 \family typewriter
6215 sys_exit=1
6212 sys_exit=1
6216 \family default
6213 \family default
6217 is needed to have IPython issue a call to
6214 is needed to have IPython issue a call to
6218 \family typewriter
6215 \family typewriter
6219 sys.exit()
6216 sys.exit()
6220 \family default
6217 \family default
6221 when it finishes, otherwise you'll be back at the normal Python '
6218 when it finishes, otherwise you'll be back at the normal Python '
6222 \family typewriter
6219 \family typewriter
6223 >>>
6220 >>>
6224 \family default
6221 \family default
6225 ' prompt
6222 ' prompt
6226 \begin_inset Foot
6223 \begin_inset Foot
6227 collapsed true
6224 collapsed true
6228
6225
6229 \layout Standard
6226 \layout Standard
6230
6227
6231 Based on an idea by Holger Krekel.
6228 Based on an idea by Holger Krekel.
6232 \end_inset
6229 \end_inset
6233
6230
6234 .
6231 .
6235 \layout Standard
6232 \layout Standard
6236
6233
6237 This is probably useful to developers who manage multiple Python versions
6234 This is probably useful to developers who manage multiple Python versions
6238 and don't want to have correspondingly multiple IPython versions.
6235 and don't want to have correspondingly multiple IPython versions.
6239 Note that in this mode, there is no way to pass IPython any command-line
6236 Note that in this mode, there is no way to pass IPython any command-line
6240 options, as those are trapped first by Python itself.
6237 options, as those are trapped first by Python itself.
6241 \layout Section
6238 \layout Section
6242
6239
6243
6240
6244 \begin_inset LatexCommand \label{sec:embed}
6241 \begin_inset LatexCommand \label{sec:embed}
6245
6242
6246 \end_inset
6243 \end_inset
6247
6244
6248 Embedding IPython
6245 Embedding IPython
6249 \layout Standard
6246 \layout Standard
6250
6247
6251 It is possible to start an IPython instance
6248 It is possible to start an IPython instance
6252 \emph on
6249 \emph on
6253 inside
6250 inside
6254 \emph default
6251 \emph default
6255 your own Python programs.
6252 your own Python programs.
6256 This allows you to evaluate dynamically the state of your code, operate
6253 This allows you to evaluate dynamically the state of your code, operate
6257 with your variables, analyze them, etc.
6254 with your variables, analyze them, etc.
6258 Note however that any changes you make to values while in the shell do
6255 Note however that any changes you make to values while in the shell do
6259
6256
6260 \emph on
6257 \emph on
6261 not
6258 not
6262 \emph default
6259 \emph default
6263 propagate back to the running code, so it is safe to modify your values
6260 propagate back to the running code, so it is safe to modify your values
6264 because you won't break your code in bizarre ways by doing so.
6261 because you won't break your code in bizarre ways by doing so.
6265 \layout Standard
6262 \layout Standard
6266
6263
6267 This feature allows you to easily have a fully functional python environment
6264 This feature allows you to easily have a fully functional python environment
6268 for doing object introspection anywhere in your code with a simple function
6265 for doing object introspection anywhere in your code with a simple function
6269 call.
6266 call.
6270 In some cases a simple print statement is enough, but if you need to do
6267 In some cases a simple print statement is enough, but if you need to do
6271 more detailed analysis of a code fragment this feature can be very valuable.
6268 more detailed analysis of a code fragment this feature can be very valuable.
6272 \layout Standard
6269 \layout Standard
6273
6270
6274 It can also be useful in scientific computing situations where it is common
6271 It can also be useful in scientific computing situations where it is common
6275 to need to do some automatic, computationally intensive part and then stop
6272 to need to do some automatic, computationally intensive part and then stop
6276 to look at data, plots, etc
6273 to look at data, plots, etc
6277 \begin_inset Foot
6274 \begin_inset Foot
6278 collapsed true
6275 collapsed true
6279
6276
6280 \layout Standard
6277 \layout Standard
6281
6278
6282 This functionality was inspired by IDL's combination of the
6279 This functionality was inspired by IDL's combination of the
6283 \family typewriter
6280 \family typewriter
6284 stop
6281 stop
6285 \family default
6282 \family default
6286 keyword and the
6283 keyword and the
6287 \family typewriter
6284 \family typewriter
6288 .continue
6285 .continue
6289 \family default
6286 \family default
6290 executive command, which I have found very useful in the past, and by a
6287 executive command, which I have found very useful in the past, and by a
6291 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6288 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6292 06/01 concerning similar uses of pyrepl.
6289 06/01 concerning similar uses of pyrepl.
6293 \end_inset
6290 \end_inset
6294
6291
6295 .
6292 .
6296 Opening an IPython instance will give you full access to your data and
6293 Opening an IPython instance will give you full access to your data and
6297 functions, and you can resume program execution once you are done with
6294 functions, and you can resume program execution once you are done with
6298 the interactive part (perhaps to stop again later, as many times as needed).
6295 the interactive part (perhaps to stop again later, as many times as needed).
6299 \layout Standard
6296 \layout Standard
6300
6297
6301 The following code snippet is the bare minimum you need to include in your
6298 The following code snippet is the bare minimum you need to include in your
6302 Python programs for this to work (detailed examples follow later):
6299 Python programs for this to work (detailed examples follow later):
6303 \layout LyX-Code
6300 \layout LyX-Code
6304
6301
6305 from IPython.Shell import IPShellEmbed
6302 from IPython.Shell import IPShellEmbed
6306 \layout LyX-Code
6303 \layout LyX-Code
6307
6304
6308 ipshell = IPShellEmbed()
6305 ipshell = IPShellEmbed()
6309 \layout LyX-Code
6306 \layout LyX-Code
6310
6307
6311 ipshell() # this call anywhere in your program will start IPython
6308 ipshell() # this call anywhere in your program will start IPython
6312 \layout Standard
6309 \layout Standard
6313
6310
6314 You can run embedded instances even in code which is itself being run at
6311 You can run embedded instances even in code which is itself being run at
6315 the IPython interactive prompt with '
6312 the IPython interactive prompt with '
6316 \family typewriter
6313 \family typewriter
6317 %run\SpecialChar ~
6314 %run\SpecialChar ~
6318 <filename>
6315 <filename>
6319 \family default
6316 \family default
6320 '.
6317 '.
6321 Since it's easy to get lost as to where you are (in your top-level IPython
6318 Since it's easy to get lost as to where you are (in your top-level IPython
6322 or in your embedded one), it's a good idea in such cases to set the in/out
6319 or in your embedded one), it's a good idea in such cases to set the in/out
6323 prompts to something different for the embedded instances.
6320 prompts to something different for the embedded instances.
6324 The code examples below illustrate this.
6321 The code examples below illustrate this.
6325 \layout Standard
6322 \layout Standard
6326
6323
6327 You can also have multiple IPython instances in your program and open them
6324 You can also have multiple IPython instances in your program and open them
6328 separately, for example with different options for data presentation.
6325 separately, for example with different options for data presentation.
6329 If you close and open the same instance multiple times, its prompt counters
6326 If you close and open the same instance multiple times, its prompt counters
6330 simply continue from each execution to the next.
6327 simply continue from each execution to the next.
6331 \layout Standard
6328 \layout Standard
6332
6329
6333 Please look at the docstrings in the
6330 Please look at the docstrings in the
6334 \family typewriter
6331 \family typewriter
6335 Shell.py
6332 Shell.py
6336 \family default
6333 \family default
6337 module for more details on the use of this system.
6334 module for more details on the use of this system.
6338 \layout Standard
6335 \layout Standard
6339
6336
6340 The following sample file illustrating how to use the embedding functionality
6337 The following sample file illustrating how to use the embedding functionality
6341 is provided in the examples directory as
6338 is provided in the examples directory as
6342 \family typewriter
6339 \family typewriter
6343 example-embed.py
6340 example-embed.py
6344 \family default
6341 \family default
6345 .
6342 .
6346 It should be fairly self-explanatory:
6343 It should be fairly self-explanatory:
6347 \layout Standard
6344 \layout Standard
6348
6345
6349
6346
6350 \begin_inset ERT
6347 \begin_inset ERT
6351 status Open
6348 status Open
6352
6349
6353 \layout Standard
6350 \layout Standard
6354
6351
6355 \backslash
6352 \backslash
6356 codelist{examples/example-embed.py}
6353 codelist{examples/example-embed.py}
6357 \end_inset
6354 \end_inset
6358
6355
6359
6356
6360 \layout Standard
6357 \layout Standard
6361
6358
6362 Once you understand how the system functions, you can use the following
6359 Once you understand how the system functions, you can use the following
6363 code fragments in your programs which are ready for cut and paste:
6360 code fragments in your programs which are ready for cut and paste:
6364 \layout Standard
6361 \layout Standard
6365
6362
6366
6363
6367 \begin_inset ERT
6364 \begin_inset ERT
6368 status Open
6365 status Open
6369
6366
6370 \layout Standard
6367 \layout Standard
6371
6368
6372 \backslash
6369 \backslash
6373 codelist{examples/example-embed-short.py}
6370 codelist{examples/example-embed-short.py}
6374 \end_inset
6371 \end_inset
6375
6372
6376
6373
6377 \layout Section
6374 \layout Section
6378
6375
6379
6376
6380 \begin_inset LatexCommand \label{sec:using-pdb}
6377 \begin_inset LatexCommand \label{sec:using-pdb}
6381
6378
6382 \end_inset
6379 \end_inset
6383
6380
6384 Using the Python debugger (
6381 Using the Python debugger (
6385 \family typewriter
6382 \family typewriter
6386 pdb
6383 pdb
6387 \family default
6384 \family default
6388 )
6385 )
6389 \layout Subsection
6386 \layout Subsection
6390
6387
6391 Running entire programs via
6388 Running entire programs via
6392 \family typewriter
6389 \family typewriter
6393 pdb
6390 pdb
6394 \layout Standard
6391 \layout Standard
6395
6392
6396
6393
6397 \family typewriter
6394 \family typewriter
6398 pdb
6395 pdb
6399 \family default
6396 \family default
6400 , the Python debugger, is a powerful interactive debugger which allows you
6397 , the Python debugger, is a powerful interactive debugger which allows you
6401 to step through code, set breakpoints, watch variables, etc.
6398 to step through code, set breakpoints, watch variables, etc.
6402 IPython makes it very easy to start any script under the control of
6399 IPython makes it very easy to start any script under the control of
6403 \family typewriter
6400 \family typewriter
6404 pdb
6401 pdb
6405 \family default
6402 \family default
6406 , regardless of whether you have wrapped it into a
6403 , regardless of whether you have wrapped it into a
6407 \family typewriter
6404 \family typewriter
6408 `main()'
6405 `main()'
6409 \family default
6406 \family default
6410 function or not.
6407 function or not.
6411 For this, simply type
6408 For this, simply type
6412 \family typewriter
6409 \family typewriter
6413 `%run -d myscript'
6410 `%run -d myscript'
6414 \family default
6411 \family default
6415 at an IPython prompt.
6412 at an IPython prompt.
6416 See the
6413 See the
6417 \family typewriter
6414 \family typewriter
6418 %run
6415 %run
6419 \family default
6416 \family default
6420 command's documentation (via
6417 command's documentation (via
6421 \family typewriter
6418 \family typewriter
6422 `%run?'
6419 `%run?'
6423 \family default
6420 \family default
6424 or in Sec.\SpecialChar ~
6421 or in Sec.\SpecialChar ~
6425
6422
6426 \begin_inset LatexCommand \ref{sec:magic}
6423 \begin_inset LatexCommand \ref{sec:magic}
6427
6424
6428 \end_inset
6425 \end_inset
6429
6426
6430 ) for more details, including how to control where
6427 ) for more details, including how to control where
6431 \family typewriter
6428 \family typewriter
6432 pdb
6429 pdb
6433 \family default
6430 \family default
6434 will stop execution first.
6431 will stop execution first.
6435 \layout Standard
6432 \layout Standard
6436
6433
6437 For more information on the use of the
6434 For more information on the use of the
6438 \family typewriter
6435 \family typewriter
6439 pdb
6436 pdb
6440 \family default
6437 \family default
6441 debugger, read the included
6438 debugger, read the included
6442 \family typewriter
6439 \family typewriter
6443 pdb.doc
6440 pdb.doc
6444 \family default
6441 \family default
6445 file (part of the standard Python distribution).
6442 file (part of the standard Python distribution).
6446 On a stock Linux system it is located at
6443 On a stock Linux system it is located at
6447 \family typewriter
6444 \family typewriter
6448 /usr/lib/python2.3/pdb.doc
6445 /usr/lib/python2.3/pdb.doc
6449 \family default
6446 \family default
6450 , but the easiest way to read it is by using the
6447 , but the easiest way to read it is by using the
6451 \family typewriter
6448 \family typewriter
6452 help()
6449 help()
6453 \family default
6450 \family default
6454 function of the
6451 function of the
6455 \family typewriter
6452 \family typewriter
6456 pdb
6453 pdb
6457 \family default
6454 \family default
6458 module as follows (in an IPython prompt):
6455 module as follows (in an IPython prompt):
6459 \layout Standard
6456 \layout Standard
6460
6457
6461
6458
6462 \family typewriter
6459 \family typewriter
6463 In [1]: import pdb
6460 In [1]: import pdb
6464 \newline
6461 \newline
6465 In [2]: pdb.help()
6462 In [2]: pdb.help()
6466 \layout Standard
6463 \layout Standard
6467
6464
6468 This will load the
6465 This will load the
6469 \family typewriter
6466 \family typewriter
6470 pdb.doc
6467 pdb.doc
6471 \family default
6468 \family default
6472 document in a file viewer for you automatically.
6469 document in a file viewer for you automatically.
6473 \layout Subsection
6470 \layout Subsection
6474
6471
6475 Automatic invocation of
6472 Automatic invocation of
6476 \family typewriter
6473 \family typewriter
6477 pdb
6474 pdb
6478 \family default
6475 \family default
6479 on exceptions
6476 on exceptions
6480 \layout Standard
6477 \layout Standard
6481
6478
6482 IPython, if started with the
6479 IPython, if started with the
6483 \family typewriter
6480 \family typewriter
6484 -pdb
6481 -pdb
6485 \family default
6482 \family default
6486 option (or if the option is set in your rc file) can call the Python
6483 option (or if the option is set in your rc file) can call the Python
6487 \family typewriter
6484 \family typewriter
6488 pdb
6485 pdb
6489 \family default
6486 \family default
6490 debugger every time your code triggers an uncaught exception
6487 debugger every time your code triggers an uncaught exception
6491 \begin_inset Foot
6488 \begin_inset Foot
6492 collapsed true
6489 collapsed true
6493
6490
6494 \layout Standard
6491 \layout Standard
6495
6492
6496 Many thanks to Christopher Hart for the request which prompted adding this
6493 Many thanks to Christopher Hart for the request which prompted adding this
6497 feature to IPython.
6494 feature to IPython.
6498 \end_inset
6495 \end_inset
6499
6496
6500 .
6497 .
6501 This feature can also be toggled at any time with the
6498 This feature can also be toggled at any time with the
6502 \family typewriter
6499 \family typewriter
6503 %pdb
6500 %pdb
6504 \family default
6501 \family default
6505 magic command.
6502 magic command.
6506 This can be extremely useful in order to find the origin of subtle bugs,
6503 This can be extremely useful in order to find the origin of subtle bugs,
6507 because
6504 because
6508 \family typewriter
6505 \family typewriter
6509 pdb
6506 pdb
6510 \family default
6507 \family default
6511 opens up at the point in your code which triggered the exception, and while
6508 opens up at the point in your code which triggered the exception, and while
6512 your program is at this point `dead', all the data is still available and
6509 your program is at this point `dead', all the data is still available and
6513 you can walk up and down the stack frame and understand the origin of the
6510 you can walk up and down the stack frame and understand the origin of the
6514 problem.
6511 problem.
6515 \layout Standard
6512 \layout Standard
6516
6513
6517 Furthermore, you can use these debugging facilities both with the embedded
6514 Furthermore, you can use these debugging facilities both with the embedded
6518 IPython mode and without IPython at all.
6515 IPython mode and without IPython at all.
6519 For an embedded shell (see sec.
6516 For an embedded shell (see sec.
6520
6517
6521 \begin_inset LatexCommand \ref{sec:embed}
6518 \begin_inset LatexCommand \ref{sec:embed}
6522
6519
6523 \end_inset
6520 \end_inset
6524
6521
6525 ), simply call the constructor with
6522 ), simply call the constructor with
6526 \family typewriter
6523 \family typewriter
6527 `-pdb'
6524 `-pdb'
6528 \family default
6525 \family default
6529 in the argument string and automatically
6526 in the argument string and automatically
6530 \family typewriter
6527 \family typewriter
6531 pdb
6528 pdb
6532 \family default
6529 \family default
6533 will be called if an uncaught exception is triggered by your code.
6530 will be called if an uncaught exception is triggered by your code.
6534
6531
6535 \layout Standard
6532 \layout Standard
6536
6533
6537 For stand-alone use of the feature in your programs which do not use IPython
6534 For stand-alone use of the feature in your programs which do not use IPython
6538 at all, put the following lines toward the top of your `main' routine:
6535 at all, put the following lines toward the top of your `main' routine:
6539 \layout Standard
6536 \layout Standard
6540 \align left
6537 \align left
6541
6538
6542 \family typewriter
6539 \family typewriter
6543 import sys,IPython.ultraTB
6540 import sys,IPython.ultraTB
6544 \newline
6541 \newline
6545 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6542 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6546 call_pdb=1)
6543 call_pdb=1)
6547 \layout Standard
6544 \layout Standard
6548
6545
6549 The
6546 The
6550 \family typewriter
6547 \family typewriter
6551 mode
6548 mode
6552 \family default
6549 \family default
6553 keyword can be either
6550 keyword can be either
6554 \family typewriter
6551 \family typewriter
6555 `Verbose'
6552 `Verbose'
6556 \family default
6553 \family default
6557 or
6554 or
6558 \family typewriter
6555 \family typewriter
6559 `Plain'
6556 `Plain'
6560 \family default
6557 \family default
6561 , giving either very detailed or normal tracebacks respectively.
6558 , giving either very detailed or normal tracebacks respectively.
6562 The
6559 The
6563 \family typewriter
6560 \family typewriter
6564 color_scheme
6561 color_scheme
6565 \family default
6562 \family default
6566 keyword can be one of
6563 keyword can be one of
6567 \family typewriter
6564 \family typewriter
6568 `NoColor'
6565 `NoColor'
6569 \family default
6566 \family default
6570 ,
6567 ,
6571 \family typewriter
6568 \family typewriter
6572 `Linux'
6569 `Linux'
6573 \family default
6570 \family default
6574 (default) or
6571 (default) or
6575 \family typewriter
6572 \family typewriter
6576 `LightBG'
6573 `LightBG'
6577 \family default
6574 \family default
6578 .
6575 .
6579 These are the same options which can be set in IPython with
6576 These are the same options which can be set in IPython with
6580 \family typewriter
6577 \family typewriter
6581 -colors
6578 -colors
6582 \family default
6579 \family default
6583 and
6580 and
6584 \family typewriter
6581 \family typewriter
6585 -xmode
6582 -xmode
6586 \family default
6583 \family default
6587 .
6584 .
6588 \layout Standard
6585 \layout Standard
6589
6586
6590 This will give any of your programs detailed, colored tracebacks with automatic
6587 This will give any of your programs detailed, colored tracebacks with automatic
6591 invocation of
6588 invocation of
6592 \family typewriter
6589 \family typewriter
6593 pdb
6590 pdb
6594 \family default
6591 \family default
6595 .
6592 .
6596 \layout Section
6593 \layout Section
6597
6594
6598
6595
6599 \begin_inset LatexCommand \label{sec:syntax-extensions}
6596 \begin_inset LatexCommand \label{sec:syntax-extensions}
6600
6597
6601 \end_inset
6598 \end_inset
6602
6599
6603 Extensions for syntax processing
6600 Extensions for syntax processing
6604 \layout Standard
6601 \layout Standard
6605
6602
6606 This isn't for the faint of heart, because the potential for breaking things
6603 This isn't for the faint of heart, because the potential for breaking things
6607 is quite high.
6604 is quite high.
6608 But it can be a very powerful and useful feature.
6605 But it can be a very powerful and useful feature.
6609 In a nutshell, you can redefine the way IPython processes the user input
6606 In a nutshell, you can redefine the way IPython processes the user input
6610 line to accept new, special extensions to the syntax without needing to
6607 line to accept new, special extensions to the syntax without needing to
6611 change any of IPython's own code.
6608 change any of IPython's own code.
6612 \layout Standard
6609 \layout Standard
6613
6610
6614 In the
6611 In the
6615 \family typewriter
6612 \family typewriter
6616 IPython/Extensions
6613 IPython/Extensions
6617 \family default
6614 \family default
6618 directory you will find some examples supplied, which we will briefly describe
6615 directory you will find some examples supplied, which we will briefly describe
6619 now.
6616 now.
6620 These can be used `as is' (and both provide very useful functionality),
6617 These can be used `as is' (and both provide very useful functionality),
6621 or you can use them as a starting point for writing your own extensions.
6618 or you can use them as a starting point for writing your own extensions.
6622 \layout Subsection
6619 \layout Subsection
6623
6620
6624 Pasting of code starting with
6621 Pasting of code starting with
6625 \family typewriter
6622 \family typewriter
6626 `>>>
6623 `>>>
6627 \family default
6624 \family default
6628 ' or
6625 ' or
6629 \family typewriter
6626 \family typewriter
6630 `...
6627 `...
6631
6628
6632 \family default
6629 \family default
6633 '
6630 '
6634 \layout Standard
6631 \layout Standard
6635
6632
6636 In the python tutorial it is common to find code examples which have been
6633 In the python tutorial it is common to find code examples which have been
6637 taken from real python sessions.
6634 taken from real python sessions.
6638 The problem with those is that all the lines begin with either
6635 The problem with those is that all the lines begin with either
6639 \family typewriter
6636 \family typewriter
6640 `>>>
6637 `>>>
6641 \family default
6638 \family default
6642 ' or
6639 ' or
6643 \family typewriter
6640 \family typewriter
6644 `...
6641 `...
6645
6642
6646 \family default
6643 \family default
6647 ', which makes it impossible to paste them all at once.
6644 ', which makes it impossible to paste them all at once.
6648 One must instead do a line by line manual copying, carefully removing the
6645 One must instead do a line by line manual copying, carefully removing the
6649 leading extraneous characters.
6646 leading extraneous characters.
6650 \layout Standard
6647 \layout Standard
6651
6648
6652 This extension identifies those starting characters and removes them from
6649 This extension identifies those starting characters and removes them from
6653 the input automatically, so that one can paste multi-line examples directly
6650 the input automatically, so that one can paste multi-line examples directly
6654 into IPython, saving a lot of time.
6651 into IPython, saving a lot of time.
6655 Please look at the file
6652 Please look at the file
6656 \family typewriter
6653 \family typewriter
6657 InterpreterPasteInput.py
6654 InterpreterPasteInput.py
6658 \family default
6655 \family default
6659 in the
6656 in the
6660 \family typewriter
6657 \family typewriter
6661 IPython/Extensions
6658 IPython/Extensions
6662 \family default
6659 \family default
6663 directory for details on how this is done.
6660 directory for details on how this is done.
6664 \layout Standard
6661 \layout Standard
6665
6662
6666 IPython comes with a special profile enabling this feature, called
6663 IPython comes with a special profile enabling this feature, called
6667 \family typewriter
6664 \family typewriter
6668 tutorial
6665 tutorial
6669 \family default
6666 \family default
6670 \emph on
6667 \emph on
6671 .
6668 .
6672
6669
6673 \emph default
6670 \emph default
6674 Simply start IPython via
6671 Simply start IPython via
6675 \family typewriter
6672 \family typewriter
6676 `ipython\SpecialChar ~
6673 `ipython\SpecialChar ~
6677 -p\SpecialChar ~
6674 -p\SpecialChar ~
6678 tutorial'
6675 tutorial'
6679 \family default
6676 \family default
6680 and the feature will be available.
6677 and the feature will be available.
6681 In a normal IPython session you can activate the feature by importing the
6678 In a normal IPython session you can activate the feature by importing the
6682 corresponding module with:
6679 corresponding module with:
6683 \newline
6680 \newline
6684
6681
6685 \family typewriter
6682 \family typewriter
6686 In [1]: import IPython.Extensions.InterpreterPasteInput
6683 In [1]: import IPython.Extensions.InterpreterPasteInput
6687 \layout Standard
6684 \layout Standard
6688
6685
6689 The following is a 'screenshot' of how things work when this extension is
6686 The following is a 'screenshot' of how things work when this extension is
6690 on, copying an example from the standard tutorial:
6687 on, copying an example from the standard tutorial:
6691 \layout Standard
6688 \layout Standard
6692
6689
6693
6690
6694 \family typewriter
6691 \family typewriter
6695 IPython profile: tutorial
6692 IPython profile: tutorial
6696 \newline
6693 \newline
6697 \SpecialChar ~
6694 \SpecialChar ~
6698
6695
6699 \newline
6696 \newline
6700 *** Pasting of code with ">>>" or "..." has been enabled.
6697 *** Pasting of code with ">>>" or "..." has been enabled.
6701 \newline
6698 \newline
6702 \SpecialChar ~
6699 \SpecialChar ~
6703
6700
6704 \newline
6701 \newline
6705 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6702 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6706 \newline
6703 \newline
6707
6704
6708 \begin_inset ERT
6705 \begin_inset ERT
6709 status Collapsed
6706 status Collapsed
6710
6707
6711 \layout Standard
6708 \layout Standard
6712
6709
6713 \backslash
6710 \backslash
6714 hspace*{0mm}
6711 hspace*{0mm}
6715 \end_inset
6712 \end_inset
6716
6713
6717 \SpecialChar ~
6714 \SpecialChar ~
6718 \SpecialChar ~
6715 \SpecialChar ~
6719 ...: ...\SpecialChar ~
6716 ...: ...\SpecialChar ~
6720 \SpecialChar ~
6717 \SpecialChar ~
6721 \SpecialChar ~
6718 \SpecialChar ~
6722 \SpecialChar ~
6719 \SpecialChar ~
6723 """Return a list containing the Fibonacci series up to n."""
6720 """Return a list containing the Fibonacci series up to n."""
6724 \newline
6721 \newline
6725
6722
6726 \begin_inset ERT
6723 \begin_inset ERT
6727 status Collapsed
6724 status Collapsed
6728
6725
6729 \layout Standard
6726 \layout Standard
6730
6727
6731 \backslash
6728 \backslash
6732 hspace*{0mm}
6729 hspace*{0mm}
6733 \end_inset
6730 \end_inset
6734
6731
6735 \SpecialChar ~
6732 \SpecialChar ~
6736 \SpecialChar ~
6733 \SpecialChar ~
6737 ...: ...\SpecialChar ~
6734 ...: ...\SpecialChar ~
6738 \SpecialChar ~
6735 \SpecialChar ~
6739 \SpecialChar ~
6736 \SpecialChar ~
6740 \SpecialChar ~
6737 \SpecialChar ~
6741 result = []
6738 result = []
6742 \newline
6739 \newline
6743
6740
6744 \begin_inset ERT
6741 \begin_inset ERT
6745 status Collapsed
6742 status Collapsed
6746
6743
6747 \layout Standard
6744 \layout Standard
6748
6745
6749 \backslash
6746 \backslash
6750 hspace*{0mm}
6747 hspace*{0mm}
6751 \end_inset
6748 \end_inset
6752
6749
6753 \SpecialChar ~
6750 \SpecialChar ~
6754 \SpecialChar ~
6751 \SpecialChar ~
6755 ...: ...\SpecialChar ~
6752 ...: ...\SpecialChar ~
6756 \SpecialChar ~
6753 \SpecialChar ~
6757 \SpecialChar ~
6754 \SpecialChar ~
6758 \SpecialChar ~
6755 \SpecialChar ~
6759 a, b = 0, 1
6756 a, b = 0, 1
6760 \newline
6757 \newline
6761
6758
6762 \begin_inset ERT
6759 \begin_inset ERT
6763 status Collapsed
6760 status Collapsed
6764
6761
6765 \layout Standard
6762 \layout Standard
6766
6763
6767 \backslash
6764 \backslash
6768 hspace*{0mm}
6765 hspace*{0mm}
6769 \end_inset
6766 \end_inset
6770
6767
6771 \SpecialChar ~
6768 \SpecialChar ~
6772 \SpecialChar ~
6769 \SpecialChar ~
6773 ...: ...\SpecialChar ~
6770 ...: ...\SpecialChar ~
6774 \SpecialChar ~
6771 \SpecialChar ~
6775 \SpecialChar ~
6772 \SpecialChar ~
6776 \SpecialChar ~
6773 \SpecialChar ~
6777 while b < n:
6774 while b < n:
6778 \newline
6775 \newline
6779
6776
6780 \begin_inset ERT
6777 \begin_inset ERT
6781 status Collapsed
6778 status Collapsed
6782
6779
6783 \layout Standard
6780 \layout Standard
6784
6781
6785 \backslash
6782 \backslash
6786 hspace*{0mm}
6783 hspace*{0mm}
6787 \end_inset
6784 \end_inset
6788
6785
6789 \SpecialChar ~
6786 \SpecialChar ~
6790 \SpecialChar ~
6787 \SpecialChar ~
6791 ...: ...\SpecialChar ~
6788 ...: ...\SpecialChar ~
6792 \SpecialChar ~
6789 \SpecialChar ~
6793 \SpecialChar ~
6790 \SpecialChar ~
6794 \SpecialChar ~
6791 \SpecialChar ~
6795 \SpecialChar ~
6792 \SpecialChar ~
6796 \SpecialChar ~
6793 \SpecialChar ~
6797 \SpecialChar ~
6794 \SpecialChar ~
6798 \SpecialChar ~
6795 \SpecialChar ~
6799 result.append(b)\SpecialChar ~
6796 result.append(b)\SpecialChar ~
6800 \SpecialChar ~
6797 \SpecialChar ~
6801 \SpecialChar ~
6798 \SpecialChar ~
6802 # see below
6799 # see below
6803 \newline
6800 \newline
6804
6801
6805 \begin_inset ERT
6802 \begin_inset ERT
6806 status Collapsed
6803 status Collapsed
6807
6804
6808 \layout Standard
6805 \layout Standard
6809
6806
6810 \backslash
6807 \backslash
6811 hspace*{0mm}
6808 hspace*{0mm}
6812 \end_inset
6809 \end_inset
6813
6810
6814 \SpecialChar ~
6811 \SpecialChar ~
6815 \SpecialChar ~
6812 \SpecialChar ~
6816 ...: ...\SpecialChar ~
6813 ...: ...\SpecialChar ~
6817 \SpecialChar ~
6814 \SpecialChar ~
6818 \SpecialChar ~
6815 \SpecialChar ~
6819 \SpecialChar ~
6816 \SpecialChar ~
6820 \SpecialChar ~
6817 \SpecialChar ~
6821 \SpecialChar ~
6818 \SpecialChar ~
6822 \SpecialChar ~
6819 \SpecialChar ~
6823 \SpecialChar ~
6820 \SpecialChar ~
6824 a, b = b, a+b
6821 a, b = b, a+b
6825 \newline
6822 \newline
6826
6823
6827 \begin_inset ERT
6824 \begin_inset ERT
6828 status Collapsed
6825 status Collapsed
6829
6826
6830 \layout Standard
6827 \layout Standard
6831
6828
6832 \backslash
6829 \backslash
6833 hspace*{0mm}
6830 hspace*{0mm}
6834 \end_inset
6831 \end_inset
6835
6832
6836 \SpecialChar ~
6833 \SpecialChar ~
6837 \SpecialChar ~
6834 \SpecialChar ~
6838 ...: ...\SpecialChar ~
6835 ...: ...\SpecialChar ~
6839 \SpecialChar ~
6836 \SpecialChar ~
6840 \SpecialChar ~
6837 \SpecialChar ~
6841 \SpecialChar ~
6838 \SpecialChar ~
6842 return result
6839 return result
6843 \newline
6840 \newline
6844
6841
6845 \begin_inset ERT
6842 \begin_inset ERT
6846 status Collapsed
6843 status Collapsed
6847
6844
6848 \layout Standard
6845 \layout Standard
6849
6846
6850 \backslash
6847 \backslash
6851 hspace*{0mm}
6848 hspace*{0mm}
6852 \end_inset
6849 \end_inset
6853
6850
6854 \SpecialChar ~
6851 \SpecialChar ~
6855 \SpecialChar ~
6852 \SpecialChar ~
6856 ...:
6853 ...:
6857 \newline
6854 \newline
6858 \SpecialChar ~
6855 \SpecialChar ~
6859
6856
6860 \newline
6857 \newline
6861 In [2]: fib2(10)
6858 In [2]: fib2(10)
6862 \newline
6859 \newline
6863 Out[2]: [1, 1, 2, 3, 5, 8]
6860 Out[2]: [1, 1, 2, 3, 5, 8]
6864 \layout Standard
6861 \layout Standard
6865
6862
6866 Note that as currently written, this extension does
6863 Note that as currently written, this extension does
6867 \emph on
6864 \emph on
6868 not
6865 not
6869 \emph default
6866 \emph default
6870 recognize IPython's prompts for pasting.
6867 recognize IPython's prompts for pasting.
6871 Those are more complicated, since the user can change them very easily,
6868 Those are more complicated, since the user can change them very easily,
6872 they involve numbers and can vary in length.
6869 they involve numbers and can vary in length.
6873 One could however extract all the relevant information from the IPython
6870 One could however extract all the relevant information from the IPython
6874 instance and build an appropriate regular expression.
6871 instance and build an appropriate regular expression.
6875 This is left as an exercise for the reader.
6872 This is left as an exercise for the reader.
6876 \layout Subsection
6873 \layout Subsection
6877
6874
6878 Input of physical quantities with units
6875 Input of physical quantities with units
6879 \layout Standard
6876 \layout Standard
6880
6877
6881 The module
6878 The module
6882 \family typewriter
6879 \family typewriter
6883 PhysicalQInput
6880 PhysicalQInput
6884 \family default
6881 \family default
6885 allows a simplified form of input for physical quantities with units.
6882 allows a simplified form of input for physical quantities with units.
6886 This file is meant to be used in conjunction with the
6883 This file is meant to be used in conjunction with the
6887 \family typewriter
6884 \family typewriter
6888 PhysicalQInteractive
6885 PhysicalQInteractive
6889 \family default
6886 \family default
6890 module (in the same directory) and
6887 module (in the same directory) and
6891 \family typewriter
6888 \family typewriter
6892 Physics.PhysicalQuantities
6889 Physics.PhysicalQuantities
6893 \family default
6890 \family default
6894 from Konrad Hinsen's ScientificPython (
6891 from Konrad Hinsen's ScientificPython (
6895 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6892 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6896
6893
6897 \end_inset
6894 \end_inset
6898
6895
6899 ).
6896 ).
6900 \layout Standard
6897 \layout Standard
6901
6898
6902 The
6899 The
6903 \family typewriter
6900 \family typewriter
6904 Physics.PhysicalQuantities
6901 Physics.PhysicalQuantities
6905 \family default
6902 \family default
6906 module defines
6903 module defines
6907 \family typewriter
6904 \family typewriter
6908 PhysicalQuantity
6905 PhysicalQuantity
6909 \family default
6906 \family default
6910 objects, but these must be declared as instances of a class.
6907 objects, but these must be declared as instances of a class.
6911 For example, to define
6908 For example, to define
6912 \family typewriter
6909 \family typewriter
6913 v
6910 v
6914 \family default
6911 \family default
6915 as a velocity of 3\SpecialChar ~
6912 as a velocity of 3\SpecialChar ~
6916 m/s, normally you would write:
6913 m/s, normally you would write:
6917 \family typewriter
6914 \family typewriter
6918
6915
6919 \newline
6916 \newline
6920 In [1]: v = PhysicalQuantity(3,'m/s')
6917 In [1]: v = PhysicalQuantity(3,'m/s')
6921 \layout Standard
6918 \layout Standard
6922
6919
6923 Using the
6920 Using the
6924 \family typewriter
6921 \family typewriter
6925 PhysicalQ_Input
6922 PhysicalQ_Input
6926 \family default
6923 \family default
6927 extension this can be input instead as:
6924 extension this can be input instead as:
6928 \family typewriter
6925 \family typewriter
6929
6926
6930 \newline
6927 \newline
6931 In [1]: v = 3 m/s
6928 In [1]: v = 3 m/s
6932 \family default
6929 \family default
6933
6930
6934 \newline
6931 \newline
6935 which is much more convenient for interactive use (even though it is blatantly
6932 which is much more convenient for interactive use (even though it is blatantly
6936 invalid Python syntax).
6933 invalid Python syntax).
6937 \layout Standard
6934 \layout Standard
6938
6935
6939 The
6936 The
6940 \family typewriter
6937 \family typewriter
6941 physics
6938 physics
6942 \family default
6939 \family default
6943 profile supplied with IPython (enabled via
6940 profile supplied with IPython (enabled via
6944 \family typewriter
6941 \family typewriter
6945 'ipython -p physics'
6942 'ipython -p physics'
6946 \family default
6943 \family default
6947 ) uses these extensions, which you can also activate with:
6944 ) uses these extensions, which you can also activate with:
6948 \layout Standard
6945 \layout Standard
6949
6946
6950
6947
6951 \family typewriter
6948 \family typewriter
6952 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6949 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6953 \newline
6950 \newline
6954 from IPython.Extensions.PhysicalQInteractive import *
6951 from IPython.Extensions.PhysicalQInteractive import *
6955 \newline
6952 \newline
6956 import IPython.Extensions.PhysicalQInput
6953 import IPython.Extensions.PhysicalQInput
6957 \layout Section
6954 \layout Section
6958
6955
6959
6956
6960 \begin_inset LatexCommand \label{sec:IPython-as-shell}
6957 \begin_inset LatexCommand \label{sec:IPython-as-shell}
6961
6958
6962 \end_inset
6959 \end_inset
6963
6960
6964 IPython as a system shell
6961 IPython as a system shell
6965 \layout Standard
6962 \layout Standard
6966
6963
6967 IPython ships with a special profile called
6964 IPython ships with a special profile called
6968 \family typewriter
6965 \family typewriter
6969 pysh
6966 pysh
6970 \family default
6967 \family default
6971 , which you can activate at the command line as
6968 , which you can activate at the command line as
6972 \family typewriter
6969 \family typewriter
6973 `ipython -p pysh'
6970 `ipython -p pysh'
6974 \family default
6971 \family default
6975 .
6972 .
6976 This loads
6973 This loads
6977 \family typewriter
6974 \family typewriter
6978 InterpreterExec
6975 InterpreterExec
6979 \family default
6976 \family default
6980 , along with some additional facilities and a prompt customized for filesystem
6977 , along with some additional facilities and a prompt customized for filesystem
6981 navigation.
6978 navigation.
6982 \layout Standard
6979 \layout Standard
6983
6980
6984 Note that this does
6981 Note that this does
6985 \emph on
6982 \emph on
6986 not
6983 not
6987 \emph default
6984 \emph default
6988 make IPython a full-fledged system shell.
6985 make IPython a full-fledged system shell.
6989 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6986 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6990 you'll suspend pysh itself, not the process you just started.
6987 you'll suspend pysh itself, not the process you just started.
6991
6988
6992 \layout Standard
6989 \layout Standard
6993
6990
6994 What the shell profile allows you to do is to use the convenient and powerful
6991 What the shell profile allows you to do is to use the convenient and powerful
6995 syntax of Python to do quick scripting at the command line.
6992 syntax of Python to do quick scripting at the command line.
6996 Below we describe some of its features.
6993 Below we describe some of its features.
6997 \layout Subsection
6994 \layout Subsection
6998
6995
6999 Aliases
6996 Aliases
7000 \layout Standard
6997 \layout Standard
7001
6998
7002 All of your
6999 All of your
7003 \family typewriter
7000 \family typewriter
7004 $PATH
7001 $PATH
7005 \family default
7002 \family default
7006 has been loaded as IPython aliases, so you should be able to type any normal
7003 has been loaded as IPython aliases, so you should be able to type any normal
7007 system command and have it executed.
7004 system command and have it executed.
7008 See
7005 See
7009 \family typewriter
7006 \family typewriter
7010 %alias?
7007 %alias?
7011 \family default
7008 \family default
7012 and
7009 and
7013 \family typewriter
7010 \family typewriter
7014 %unalias?
7011 %unalias?
7015 \family default
7012 \family default
7016 for details on the alias facilities.
7013 for details on the alias facilities.
7017 See also
7014 See also
7018 \family typewriter
7015 \family typewriter
7019 %rehash?
7016 %rehash?
7020 \family default
7017 \family default
7021 and
7018 and
7022 \family typewriter
7019 \family typewriter
7023 %rehashx?
7020 %rehashx?
7024 \family default
7021 \family default
7025 for details on the mechanism used to load
7022 for details on the mechanism used to load
7026 \family typewriter
7023 \family typewriter
7027 $PATH
7024 $PATH
7028 \family default
7025 \family default
7029 .
7026 .
7030 \layout Subsection
7027 \layout Subsection
7031
7028
7032 Special syntax
7029 Special syntax
7033 \layout Standard
7030 \layout Standard
7034
7031
7035 Any lines which begin with
7032 Any lines which begin with
7036 \family typewriter
7033 \family typewriter
7037 `~'
7034 `~'
7038 \family default
7035 \family default
7039 ,
7036 ,
7040 \family typewriter
7037 \family typewriter
7041 `/'
7038 `/'
7042 \family default
7039 \family default
7043 and
7040 and
7044 \family typewriter
7041 \family typewriter
7045 `.'
7042 `.'
7046 \family default
7043 \family default
7047 will be executed as shell commands instead of as Python code.
7044 will be executed as shell commands instead of as Python code.
7048 The special escapes below are also recognized.
7045 The special escapes below are also recognized.
7049
7046
7050 \family typewriter
7047 \family typewriter
7051 !cmd
7048 !cmd
7052 \family default
7049 \family default
7053 is valid in single or multi-line input, all others are only valid in single-lin
7050 is valid in single or multi-line input, all others are only valid in single-lin
7054 e input:
7051 e input:
7055 \layout Description
7052 \layout Description
7056
7053
7057
7054
7058 \family typewriter
7055 \family typewriter
7059 !cmd
7056 !cmd
7060 \family default
7057 \family default
7061 pass `cmd' directly to the shell
7058 pass `cmd' directly to the shell
7062 \layout Description
7059 \layout Description
7063
7060
7064
7061
7065 \family typewriter
7062 \family typewriter
7066 !!cmd
7063 !!cmd
7067 \family default
7064 \family default
7068 execute `cmd' and return output as a list (split on `
7065 execute `cmd' and return output as a list (split on `
7069 \backslash
7066 \backslash
7070 n')
7067 n')
7071 \layout Description
7068 \layout Description
7072
7069
7073
7070
7074 \family typewriter
7071 \family typewriter
7075 $var=cmd
7072 $var=cmd
7076 \family default
7073 \family default
7077 capture output of cmd into var, as a string
7074 capture output of cmd into var, as a string
7078 \layout Description
7075 \layout Description
7079
7076
7080
7077
7081 \family typewriter
7078 \family typewriter
7082 $$var=cmd
7079 $$var=cmd
7083 \family default
7080 \family default
7084 capture output of cmd into var, as a list (split on `
7081 capture output of cmd into var, as a list (split on `
7085 \backslash
7082 \backslash
7086 n')
7083 n')
7087 \layout Standard
7084 \layout Standard
7088
7085
7089 The
7086 The
7090 \family typewriter
7087 \family typewriter
7091 $
7088 $
7092 \family default
7089 \family default
7093 /
7090 /
7094 \family typewriter
7091 \family typewriter
7095 $$
7092 $$
7096 \family default
7093 \family default
7097 syntaxes make Python variables from system output, which you can later
7094 syntaxes make Python variables from system output, which you can later
7098 use for further scripting.
7095 use for further scripting.
7099 The converse is also possible: when executing an alias or calling to the
7096 The converse is also possible: when executing an alias or calling to the
7100 system via
7097 system via
7101 \family typewriter
7098 \family typewriter
7102 !
7099 !
7103 \family default
7100 \family default
7104 /
7101 /
7105 \family typewriter
7102 \family typewriter
7106 !!
7103 !!
7107 \family default
7104 \family default
7108 , you can expand any python variable or expression by prepending it with
7105 , you can expand any python variable or expression by prepending it with
7109
7106
7110 \family typewriter
7107 \family typewriter
7111 $
7108 $
7112 \family default
7109 \family default
7113 .
7110 .
7114 Full details of the allowed syntax can be found in Python's PEP 215.
7111 Full details of the allowed syntax can be found in Python's PEP 215.
7115 \layout Standard
7112 \layout Standard
7116
7113
7117 A few brief examples will illustrate these (note that the indentation below
7114 A few brief examples will illustrate these (note that the indentation below
7118 may be incorrectly displayed):
7115 may be incorrectly displayed):
7119 \layout Standard
7116 \layout Standard
7120
7117
7121
7118
7122 \family typewriter
7119 \family typewriter
7123 fperez[~/test]|3> !ls *s.py
7120 fperez[~/test]|3> !ls *s.py
7124 \newline
7121 \newline
7125 scopes.py strings.py
7122 scopes.py strings.py
7126 \layout Standard
7123 \layout Standard
7127
7124
7128 ls is an internal alias, so there's no need to use
7125 ls is an internal alias, so there's no need to use
7129 \family typewriter
7126 \family typewriter
7130 !
7127 !
7131 \family default
7128 \family default
7132 :
7129 :
7133 \layout Standard
7130 \layout Standard
7134
7131
7135
7132
7136 \family typewriter
7133 \family typewriter
7137 fperez[~/test]|4> ls *s.py
7134 fperez[~/test]|4> ls *s.py
7138 \newline
7135 \newline
7139 scopes.py* strings.py
7136 scopes.py* strings.py
7140 \layout Standard
7137 \layout Standard
7141
7138
7142 !!ls will return the output into a Python variable:
7139 !!ls will return the output into a Python variable:
7143 \layout Standard
7140 \layout Standard
7144
7141
7145
7142
7146 \family typewriter
7143 \family typewriter
7147 fperez[~/test]|5> !!ls *s.py
7144 fperez[~/test]|5> !!ls *s.py
7148 \newline
7145 \newline
7149
7146
7150 \begin_inset ERT
7147 \begin_inset ERT
7151 status Collapsed
7148 status Collapsed
7152
7149
7153 \layout Standard
7150 \layout Standard
7154
7151
7155 \backslash
7152 \backslash
7156 hspace*{0mm}
7153 hspace*{0mm}
7157 \end_inset
7154 \end_inset
7158
7155
7159 \SpecialChar ~
7156 \SpecialChar ~
7160 \SpecialChar ~
7157 \SpecialChar ~
7161 \SpecialChar ~
7158 \SpecialChar ~
7162 \SpecialChar ~
7159 \SpecialChar ~
7163 \SpecialChar ~
7160 \SpecialChar ~
7164 \SpecialChar ~
7161 \SpecialChar ~
7165 \SpecialChar ~
7162 \SpecialChar ~
7166 \SpecialChar ~
7163 \SpecialChar ~
7167 \SpecialChar ~
7164 \SpecialChar ~
7168 \SpecialChar ~
7165 \SpecialChar ~
7169 \SpecialChar ~
7166 \SpecialChar ~
7170 \SpecialChar ~
7167 \SpecialChar ~
7171 \SpecialChar ~
7168 \SpecialChar ~
7172 \SpecialChar ~
7169 \SpecialChar ~
7173 <5> ['scopes.py', 'strings.py']
7170 <5> ['scopes.py', 'strings.py']
7174 \newline
7171 \newline
7175 fperez[~/test]|6> print _5
7172 fperez[~/test]|6> print _5
7176 \newline
7173 \newline
7177 ['scopes.py', 'strings.py']
7174 ['scopes.py', 'strings.py']
7178 \layout Standard
7175 \layout Standard
7179
7176
7180
7177
7181 \family typewriter
7178 \family typewriter
7182 $
7179 $
7183 \family default
7180 \family default
7184 and
7181 and
7185 \family typewriter
7182 \family typewriter
7186 $$
7183 $$
7187 \family default
7184 \family default
7188 allow direct capture to named variables:
7185 allow direct capture to named variables:
7189 \layout Standard
7186 \layout Standard
7190
7187
7191
7188
7192 \family typewriter
7189 \family typewriter
7193 fperez[~/test]|7> $astr = ls *s.py
7190 fperez[~/test]|7> $astr = ls *s.py
7194 \newline
7191 \newline
7195 fperez[~/test]|8> astr
7192 fperez[~/test]|8> astr
7196 \newline
7193 \newline
7197
7194
7198 \begin_inset ERT
7195 \begin_inset ERT
7199 status Collapsed
7196 status Collapsed
7200
7197
7201 \layout Standard
7198 \layout Standard
7202
7199
7203 \backslash
7200 \backslash
7204 hspace*{0mm}
7201 hspace*{0mm}
7205 \end_inset
7202 \end_inset
7206
7203
7207 \SpecialChar ~
7204 \SpecialChar ~
7208 \SpecialChar ~
7205 \SpecialChar ~
7209 \SpecialChar ~
7206 \SpecialChar ~
7210 \SpecialChar ~
7207 \SpecialChar ~
7211 \SpecialChar ~
7208 \SpecialChar ~
7212 \SpecialChar ~
7209 \SpecialChar ~
7213 \SpecialChar ~
7210 \SpecialChar ~
7214 \SpecialChar ~
7211 \SpecialChar ~
7215 \SpecialChar ~
7212 \SpecialChar ~
7216 \SpecialChar ~
7213 \SpecialChar ~
7217 \SpecialChar ~
7214 \SpecialChar ~
7218 \SpecialChar ~
7215 \SpecialChar ~
7219 \SpecialChar ~
7216 \SpecialChar ~
7220 \SpecialChar ~
7217 \SpecialChar ~
7221 <8> 'scopes.py
7218 <8> 'scopes.py
7222 \backslash
7219 \backslash
7223 nstrings.py'
7220 nstrings.py'
7224 \layout Standard
7221 \layout Standard
7225
7222
7226
7223
7227 \family typewriter
7224 \family typewriter
7228 fperez[~/test]|9> $$alist = ls *s.py
7225 fperez[~/test]|9> $$alist = ls *s.py
7229 \newline
7226 \newline
7230 fperez[~/test]|10> alist
7227 fperez[~/test]|10> alist
7231 \newline
7228 \newline
7232
7229
7233 \begin_inset ERT
7230 \begin_inset ERT
7234 status Collapsed
7231 status Collapsed
7235
7232
7236 \layout Standard
7233 \layout Standard
7237
7234
7238 \backslash
7235 \backslash
7239 hspace*{0mm}
7236 hspace*{0mm}
7240 \end_inset
7237 \end_inset
7241
7238
7242 \SpecialChar ~
7239 \SpecialChar ~
7243 \SpecialChar ~
7240 \SpecialChar ~
7244 \SpecialChar ~
7241 \SpecialChar ~
7245 \SpecialChar ~
7242 \SpecialChar ~
7246 \SpecialChar ~
7243 \SpecialChar ~
7247 \SpecialChar ~
7244 \SpecialChar ~
7248 \SpecialChar ~
7245 \SpecialChar ~
7249 \SpecialChar ~
7246 \SpecialChar ~
7250 \SpecialChar ~
7247 \SpecialChar ~
7251 \SpecialChar ~
7248 \SpecialChar ~
7252 \SpecialChar ~
7249 \SpecialChar ~
7253 \SpecialChar ~
7250 \SpecialChar ~
7254 \SpecialChar ~
7251 \SpecialChar ~
7255 \SpecialChar ~
7252 \SpecialChar ~
7256 <10> ['scopes.py', 'strings.py']
7253 <10> ['scopes.py', 'strings.py']
7257 \layout Standard
7254 \layout Standard
7258
7255
7259 alist is now a normal python list you can loop over.
7256 alist is now a normal python list you can loop over.
7260 Using
7257 Using
7261 \family typewriter
7258 \family typewriter
7262 $
7259 $
7263 \family default
7260 \family default
7264 will expand back the python values when alias calls are made:
7261 will expand back the python values when alias calls are made:
7265 \layout Standard
7262 \layout Standard
7266
7263
7267
7264
7268 \family typewriter
7265 \family typewriter
7269 fperez[~/test]|11> for f in alist:
7266 fperez[~/test]|11> for f in alist:
7270 \newline
7267 \newline
7271
7268
7272 \begin_inset ERT
7269 \begin_inset ERT
7273 status Collapsed
7270 status Collapsed
7274
7271
7275 \layout Standard
7272 \layout Standard
7276
7273
7277 \backslash
7274 \backslash
7278 hspace*{0mm}
7275 hspace*{0mm}
7279 \end_inset
7276 \end_inset
7280
7277
7281 \SpecialChar ~
7278 \SpecialChar ~
7282 \SpecialChar ~
7279 \SpecialChar ~
7283 \SpecialChar ~
7280 \SpecialChar ~
7284 \SpecialChar ~
7281 \SpecialChar ~
7285 \SpecialChar ~
7282 \SpecialChar ~
7286 \SpecialChar ~
7283 \SpecialChar ~
7287 \SpecialChar ~
7284 \SpecialChar ~
7288 \SpecialChar ~
7285 \SpecialChar ~
7289 \SpecialChar ~
7286 \SpecialChar ~
7290 \SpecialChar ~
7287 \SpecialChar ~
7291 \SpecialChar ~
7288 \SpecialChar ~
7292 \SpecialChar ~
7289 \SpecialChar ~
7293 \SpecialChar ~
7290 \SpecialChar ~
7294 \SpecialChar ~
7291 \SpecialChar ~
7295 |..> \SpecialChar ~
7292 |..> \SpecialChar ~
7296 \SpecialChar ~
7293 \SpecialChar ~
7297 \SpecialChar ~
7294 \SpecialChar ~
7298 \SpecialChar ~
7295 \SpecialChar ~
7299 print 'file',f,
7296 print 'file',f,
7300 \newline
7297 \newline
7301
7298
7302 \begin_inset ERT
7299 \begin_inset ERT
7303 status Collapsed
7300 status Collapsed
7304
7301
7305 \layout Standard
7302 \layout Standard
7306
7303
7307 \backslash
7304 \backslash
7308 hspace*{0mm}
7305 hspace*{0mm}
7309 \end_inset
7306 \end_inset
7310
7307
7311 \SpecialChar ~
7308 \SpecialChar ~
7312 \SpecialChar ~
7309 \SpecialChar ~
7313 \SpecialChar ~
7310 \SpecialChar ~
7314 \SpecialChar ~
7311 \SpecialChar ~
7315 \SpecialChar ~
7312 \SpecialChar ~
7316 \SpecialChar ~
7313 \SpecialChar ~
7317 \SpecialChar ~
7314 \SpecialChar ~
7318 \SpecialChar ~
7315 \SpecialChar ~
7319 \SpecialChar ~
7316 \SpecialChar ~
7320 \SpecialChar ~
7317 \SpecialChar ~
7321 \SpecialChar ~
7318 \SpecialChar ~
7322 \SpecialChar ~
7319 \SpecialChar ~
7323 \SpecialChar ~
7320 \SpecialChar ~
7324 \SpecialChar ~
7321 \SpecialChar ~
7325 |..> \SpecialChar ~
7322 |..> \SpecialChar ~
7326 \SpecialChar ~
7323 \SpecialChar ~
7327 \SpecialChar ~
7324 \SpecialChar ~
7328 \SpecialChar ~
7325 \SpecialChar ~
7329 wc -l $f
7326 wc -l $f
7330 \newline
7327 \newline
7331
7328
7332 \begin_inset ERT
7329 \begin_inset ERT
7333 status Collapsed
7330 status Collapsed
7334
7331
7335 \layout Standard
7332 \layout Standard
7336
7333
7337 \backslash
7334 \backslash
7338 hspace*{0mm}
7335 hspace*{0mm}
7339 \end_inset
7336 \end_inset
7340
7337
7341 \SpecialChar ~
7338 \SpecialChar ~
7342 \SpecialChar ~
7339 \SpecialChar ~
7343 \SpecialChar ~
7340 \SpecialChar ~
7344 \SpecialChar ~
7341 \SpecialChar ~
7345 \SpecialChar ~
7342 \SpecialChar ~
7346 \SpecialChar ~
7343 \SpecialChar ~
7347 \SpecialChar ~
7344 \SpecialChar ~
7348 \SpecialChar ~
7345 \SpecialChar ~
7349 \SpecialChar ~
7346 \SpecialChar ~
7350 \SpecialChar ~
7347 \SpecialChar ~
7351 \SpecialChar ~
7348 \SpecialChar ~
7352 \SpecialChar ~
7349 \SpecialChar ~
7353 \SpecialChar ~
7350 \SpecialChar ~
7354 \SpecialChar ~
7351 \SpecialChar ~
7355 |..>
7352 |..>
7356 \newline
7353 \newline
7357 file scopes.py 13 scopes.py
7354 file scopes.py 13 scopes.py
7358 \newline
7355 \newline
7359 file strings.py 4 strings.py
7356 file strings.py 4 strings.py
7360 \layout Standard
7357 \layout Standard
7361
7358
7362 Note that you may need to protect your variables with braces if you want
7359 Note that you may need to protect your variables with braces if you want
7363 to append strings to their names.
7360 to append strings to their names.
7364 To copy all files in alist to
7361 To copy all files in alist to
7365 \family typewriter
7362 \family typewriter
7366 .bak
7363 .bak
7367 \family default
7364 \family default
7368 extensions, you must use:
7365 extensions, you must use:
7369 \layout Standard
7366 \layout Standard
7370
7367
7371
7368
7372 \family typewriter
7369 \family typewriter
7373 fperez[~/test]|12> for f in alist:
7370 fperez[~/test]|12> for f in alist:
7374 \newline
7371 \newline
7375
7372
7376 \begin_inset ERT
7373 \begin_inset ERT
7377 status Collapsed
7374 status Collapsed
7378
7375
7379 \layout Standard
7376 \layout Standard
7380
7377
7381 \backslash
7378 \backslash
7382 hspace*{0mm}
7379 hspace*{0mm}
7383 \end_inset
7380 \end_inset
7384
7381
7385 \SpecialChar ~
7382 \SpecialChar ~
7386 \SpecialChar ~
7383 \SpecialChar ~
7387 \SpecialChar ~
7384 \SpecialChar ~
7388 \SpecialChar ~
7385 \SpecialChar ~
7389 \SpecialChar ~
7386 \SpecialChar ~
7390 \SpecialChar ~
7387 \SpecialChar ~
7391 \SpecialChar ~
7388 \SpecialChar ~
7392 \SpecialChar ~
7389 \SpecialChar ~
7393 \SpecialChar ~
7390 \SpecialChar ~
7394 \SpecialChar ~
7391 \SpecialChar ~
7395 \SpecialChar ~
7392 \SpecialChar ~
7396 \SpecialChar ~
7393 \SpecialChar ~
7397 \SpecialChar ~
7394 \SpecialChar ~
7398 \SpecialChar ~
7395 \SpecialChar ~
7399 |..> \SpecialChar ~
7396 |..> \SpecialChar ~
7400 \SpecialChar ~
7397 \SpecialChar ~
7401 \SpecialChar ~
7398 \SpecialChar ~
7402 \SpecialChar ~
7399 \SpecialChar ~
7403 cp $f ${f}.bak
7400 cp $f ${f}.bak
7404 \layout Standard
7401 \layout Standard
7405
7402
7406 If you try using
7403 If you try using
7407 \family typewriter
7404 \family typewriter
7408 $f.bak
7405 $f.bak
7409 \family default
7406 \family default
7410 , you'll get an AttributeError exception saying that your string object
7407 , you'll get an AttributeError exception saying that your string object
7411 doesn't have a
7408 doesn't have a
7412 \family typewriter
7409 \family typewriter
7413 .bak
7410 .bak
7414 \family default
7411 \family default
7415 attribute.
7412 attribute.
7416 This is because the
7413 This is because the
7417 \family typewriter
7414 \family typewriter
7418 $
7415 $
7419 \family default
7416 \family default
7420 expansion mechanism allows you to expand full Python expressions:
7417 expansion mechanism allows you to expand full Python expressions:
7421 \layout Standard
7418 \layout Standard
7422
7419
7423
7420
7424 \family typewriter
7421 \family typewriter
7425 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7422 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7426 \newline
7423 \newline
7427 sys.platform is: linux2
7424 sys.platform is: linux2
7428 \layout Standard
7425 \layout Standard
7429
7426
7430 IPython's input history handling is still active, which allows you to rerun
7427 IPython's input history handling is still active, which allows you to rerun
7431 a single block of multi-line input by simply using exec:
7428 a single block of multi-line input by simply using exec:
7432 \newline
7429 \newline
7433
7430
7434 \family typewriter
7431 \family typewriter
7435 fperez[~/test]|14> $$alist = ls *.eps
7432 fperez[~/test]|14> $$alist = ls *.eps
7436 \newline
7433 \newline
7437 fperez[~/test]|15> exec _i11
7434 fperez[~/test]|15> exec _i11
7438 \newline
7435 \newline
7439 file image2.eps 921 image2.eps
7436 file image2.eps 921 image2.eps
7440 \newline
7437 \newline
7441 file image.eps 921 image.eps
7438 file image.eps 921 image.eps
7442 \layout Standard
7439 \layout Standard
7443
7440
7444 While these are new special-case syntaxes, they are designed to allow very
7441 While these are new special-case syntaxes, they are designed to allow very
7445 efficient use of the shell with minimal typing.
7442 efficient use of the shell with minimal typing.
7446 At an interactive shell prompt, conciseness of expression wins over readability.
7443 At an interactive shell prompt, conciseness of expression wins over readability.
7447 \layout Subsection
7444 \layout Subsection
7448
7445
7449 Useful functions and modules
7446 Useful functions and modules
7450 \layout Standard
7447 \layout Standard
7451
7448
7452 The os, sys and shutil modules from the Python standard library are automaticall
7449 The os, sys and shutil modules from the Python standard library are automaticall
7453 y loaded.
7450 y loaded.
7454 Some additional functions, useful for shell usage, are listed below.
7451 Some additional functions, useful for shell usage, are listed below.
7455 You can request more help about them with `
7452 You can request more help about them with `
7456 \family typewriter
7453 \family typewriter
7457 ?
7454 ?
7458 \family default
7455 \family default
7459 '.
7456 '.
7460 \layout Description
7457 \layout Description
7461
7458
7462
7459
7463 \family typewriter
7460 \family typewriter
7464 shell
7461 shell
7465 \family default
7462 \family default
7466 - execute a command in the underlying system shell
7463 - execute a command in the underlying system shell
7467 \layout Description
7464 \layout Description
7468
7465
7469
7466
7470 \family typewriter
7467 \family typewriter
7471 system
7468 system
7472 \family default
7469 \family default
7473 - like
7470 - like
7474 \family typewriter
7471 \family typewriter
7475 shell()
7472 shell()
7476 \family default
7473 \family default
7477 , but return the exit status of the command
7474 , but return the exit status of the command
7478 \layout Description
7475 \layout Description
7479
7476
7480
7477
7481 \family typewriter
7478 \family typewriter
7482 sout
7479 sout
7483 \family default
7480 \family default
7484 - capture the output of a command as a string
7481 - capture the output of a command as a string
7485 \layout Description
7482 \layout Description
7486
7483
7487
7484
7488 \family typewriter
7485 \family typewriter
7489 lout
7486 lout
7490 \family default
7487 \family default
7491 - capture the output of a command as a list (split on `
7488 - capture the output of a command as a list (split on `
7492 \backslash
7489 \backslash
7493 n')
7490 n')
7494 \layout Description
7491 \layout Description
7495
7492
7496
7493
7497 \family typewriter
7494 \family typewriter
7498 getoutputerror
7495 getoutputerror
7499 \family default
7496 \family default
7500 - capture (output,error) of a shell commandss
7497 - capture (output,error) of a shell commandss
7501 \layout Standard
7498 \layout Standard
7502
7499
7503
7500
7504 \family typewriter
7501 \family typewriter
7505 sout
7502 sout
7506 \family default
7503 \family default
7507 /
7504 /
7508 \family typewriter
7505 \family typewriter
7509 lout
7506 lout
7510 \family default
7507 \family default
7511 are the functional equivalents of
7508 are the functional equivalents of
7512 \family typewriter
7509 \family typewriter
7513 $
7510 $
7514 \family default
7511 \family default
7515 /
7512 /
7516 \family typewriter
7513 \family typewriter
7517 $$
7514 $$
7518 \family default
7515 \family default
7519 .
7516 .
7520 They are provided to allow you to capture system output in the middle of
7517 They are provided to allow you to capture system output in the middle of
7521 true python code, function definitions, etc (where
7518 true python code, function definitions, etc (where
7522 \family typewriter
7519 \family typewriter
7523 $
7520 $
7524 \family default
7521 \family default
7525 and
7522 and
7526 \family typewriter
7523 \family typewriter
7527 $$
7524 $$
7528 \family default
7525 \family default
7529 are invalid).
7526 are invalid).
7530 \layout Subsection
7527 \layout Subsection
7531
7528
7532 Directory management
7529 Directory management
7533 \layout Standard
7530 \layout Standard
7534
7531
7535 Since each command passed by pysh to the underlying system is executed in
7532 Since each command passed by pysh to the underlying system is executed in
7536 a subshell which exits immediately, you can NOT use !cd to navigate the
7533 a subshell which exits immediately, you can NOT use !cd to navigate the
7537 filesystem.
7534 filesystem.
7538 \layout Standard
7535 \layout Standard
7539
7536
7540 Pysh provides its own builtin
7537 Pysh provides its own builtin
7541 \family typewriter
7538 \family typewriter
7542 `%cd
7539 `%cd
7543 \family default
7540 \family default
7544 ' magic command to move in the filesystem (the
7541 ' magic command to move in the filesystem (the
7545 \family typewriter
7542 \family typewriter
7546 %
7543 %
7547 \family default
7544 \family default
7548 is not required with automagic on).
7545 is not required with automagic on).
7549 It also maintains a list of visited directories (use
7546 It also maintains a list of visited directories (use
7550 \family typewriter
7547 \family typewriter
7551 %dhist
7548 %dhist
7552 \family default
7549 \family default
7553 to see it) and allows direct switching to any of them.
7550 to see it) and allows direct switching to any of them.
7554 Type
7551 Type
7555 \family typewriter
7552 \family typewriter
7556 `cd?
7553 `cd?
7557 \family default
7554 \family default
7558 ' for more details.
7555 ' for more details.
7559 \layout Standard
7556 \layout Standard
7560
7557
7561
7558
7562 \family typewriter
7559 \family typewriter
7563 %pushd
7560 %pushd
7564 \family default
7561 \family default
7565 ,
7562 ,
7566 \family typewriter
7563 \family typewriter
7567 %popd
7564 %popd
7568 \family default
7565 \family default
7569 and
7566 and
7570 \family typewriter
7567 \family typewriter
7571 %dirs
7568 %dirs
7572 \family default
7569 \family default
7573 are provided for directory stack handling.
7570 are provided for directory stack handling.
7574 \layout Subsection
7571 \layout Subsection
7575
7572
7576 Prompt customization
7573 Prompt customization
7577 \layout Standard
7574 \layout Standard
7578
7575
7579 The supplied
7576 The supplied
7580 \family typewriter
7577 \family typewriter
7581 ipythonrc-pysh
7578 ipythonrc-pysh
7582 \family default
7579 \family default
7583 profile comes with an example of a very colored and detailed prompt, mainly
7580 profile comes with an example of a very colored and detailed prompt, mainly
7584 to serve as an illustration.
7581 to serve as an illustration.
7585 The valid escape sequences, besides color names, are:
7582 The valid escape sequences, besides color names, are:
7586 \layout Description
7583 \layout Description
7587
7584
7588
7585
7589 \backslash
7586 \backslash
7590 # - Prompt number.
7587 # - Prompt number.
7591 \layout Description
7588 \layout Description
7592
7589
7593
7590
7594 \backslash
7591 \backslash
7595 D - Dots, as many as there are digits in
7592 D - Dots, as many as there are digits in
7596 \backslash
7593 \backslash
7597 # (so they align).
7594 # (so they align).
7598 \layout Description
7595 \layout Description
7599
7596
7600
7597
7601 \backslash
7598 \backslash
7602 w - Current working directory (cwd).
7599 w - Current working directory (cwd).
7603 \layout Description
7600 \layout Description
7604
7601
7605
7602
7606 \backslash
7603 \backslash
7607 W - Basename of current working directory.
7604 W - Basename of current working directory.
7608 \layout Description
7605 \layout Description
7609
7606
7610
7607
7611 \backslash
7608 \backslash
7612 X
7609 X
7613 \emph on
7610 \emph on
7614 N
7611 N
7615 \emph default
7612 \emph default
7616 - Where
7613 - Where
7617 \emph on
7614 \emph on
7618 N
7615 N
7619 \emph default
7616 \emph default
7620 =0..5.
7617 =0..5.
7621 N terms of the cwd, with $HOME written as ~.
7618 N terms of the cwd, with $HOME written as ~.
7622 \layout Description
7619 \layout Description
7623
7620
7624
7621
7625 \backslash
7622 \backslash
7626 Y
7623 Y
7627 \emph on
7624 \emph on
7628 N
7625 N
7629 \emph default
7626 \emph default
7630 - Where
7627 - Where
7631 \emph on
7628 \emph on
7632 N
7629 N
7633 \emph default
7630 \emph default
7634 =0..5.
7631 =0..5.
7635 Like X
7632 Like X
7636 \emph on
7633 \emph on
7637 N
7634 N
7638 \emph default
7635 \emph default
7639 , but if ~ is term
7636 , but if ~ is term
7640 \emph on
7637 \emph on
7641 N
7638 N
7642 \emph default
7639 \emph default
7643 +1 it's also shown.
7640 +1 it's also shown.
7644 \layout Description
7641 \layout Description
7645
7642
7646
7643
7647 \backslash
7644 \backslash
7648 u - Username.
7645 u - Username.
7649 \layout Description
7646 \layout Description
7650
7647
7651
7648
7652 \backslash
7649 \backslash
7653 H - Full hostname.
7650 H - Full hostname.
7654 \layout Description
7651 \layout Description
7655
7652
7656
7653
7657 \backslash
7654 \backslash
7658 h - Hostname up to first '.'
7655 h - Hostname up to first '.'
7659 \layout Description
7656 \layout Description
7660
7657
7661
7658
7662 \backslash
7659 \backslash
7663 $ - Root symbol ($ or #).
7660 $ - Root symbol ($ or #).
7664
7661
7665 \layout Description
7662 \layout Description
7666
7663
7667
7664
7668 \backslash
7665 \backslash
7669 t - Current time, in H:M:S format.
7666 t - Current time, in H:M:S format.
7670 \layout Description
7667 \layout Description
7671
7668
7672
7669
7673 \backslash
7670 \backslash
7674 v - IPython release version.
7671 v - IPython release version.
7675
7672
7676 \layout Description
7673 \layout Description
7677
7674
7678
7675
7679 \backslash
7676 \backslash
7680 n - Newline.
7677 n - Newline.
7681
7678
7682 \layout Description
7679 \layout Description
7683
7680
7684
7681
7685 \backslash
7682 \backslash
7686 r - Carriage return.
7683 r - Carriage return.
7687
7684
7688 \layout Description
7685 \layout Description
7689
7686
7690
7687
7691 \backslash
7688 \backslash
7692
7689
7693 \backslash
7690 \backslash
7694 - An explicitly escaped '
7691 - An explicitly escaped '
7695 \backslash
7692 \backslash
7696 '.
7693 '.
7697 \layout Standard
7694 \layout Standard
7698
7695
7699 You can configure your prompt colors using any ANSI color escape.
7696 You can configure your prompt colors using any ANSI color escape.
7700 Each color escape sets the color for any subsequent text, until another
7697 Each color escape sets the color for any subsequent text, until another
7701 escape comes in and changes things.
7698 escape comes in and changes things.
7702 The valid color escapes are:
7699 The valid color escapes are:
7703 \layout Description
7700 \layout Description
7704
7701
7705
7702
7706 \backslash
7703 \backslash
7707 C_Black
7704 C_Black
7708 \layout Description
7705 \layout Description
7709
7706
7710
7707
7711 \backslash
7708 \backslash
7712 C_Blue
7709 C_Blue
7713 \layout Description
7710 \layout Description
7714
7711
7715
7712
7716 \backslash
7713 \backslash
7717 C_Brown
7714 C_Brown
7718 \layout Description
7715 \layout Description
7719
7716
7720
7717
7721 \backslash
7718 \backslash
7722 C_Cyan
7719 C_Cyan
7723 \layout Description
7720 \layout Description
7724
7721
7725
7722
7726 \backslash
7723 \backslash
7727 C_DarkGray
7724 C_DarkGray
7728 \layout Description
7725 \layout Description
7729
7726
7730
7727
7731 \backslash
7728 \backslash
7732 C_Green
7729 C_Green
7733 \layout Description
7730 \layout Description
7734
7731
7735
7732
7736 \backslash
7733 \backslash
7737 C_LightBlue
7734 C_LightBlue
7738 \layout Description
7735 \layout Description
7739
7736
7740
7737
7741 \backslash
7738 \backslash
7742 C_LightCyan
7739 C_LightCyan
7743 \layout Description
7740 \layout Description
7744
7741
7745
7742
7746 \backslash
7743 \backslash
7747 C_LightGray
7744 C_LightGray
7748 \layout Description
7745 \layout Description
7749
7746
7750
7747
7751 \backslash
7748 \backslash
7752 C_LightGreen
7749 C_LightGreen
7753 \layout Description
7750 \layout Description
7754
7751
7755
7752
7756 \backslash
7753 \backslash
7757 C_LightPurple
7754 C_LightPurple
7758 \layout Description
7755 \layout Description
7759
7756
7760
7757
7761 \backslash
7758 \backslash
7762 C_LightRed
7759 C_LightRed
7763 \layout Description
7760 \layout Description
7764
7761
7765
7762
7766 \backslash
7763 \backslash
7767 C_Purple
7764 C_Purple
7768 \layout Description
7765 \layout Description
7769
7766
7770
7767
7771 \backslash
7768 \backslash
7772 C_Red
7769 C_Red
7773 \layout Description
7770 \layout Description
7774
7771
7775
7772
7776 \backslash
7773 \backslash
7777 C_White
7774 C_White
7778 \layout Description
7775 \layout Description
7779
7776
7780
7777
7781 \backslash
7778 \backslash
7782 C_Yellow
7779 C_Yellow
7783 \layout Description
7780 \layout Description
7784
7781
7785
7782
7786 \backslash
7783 \backslash
7787 C_Normal Stop coloring, defaults to your terminal settings.
7784 C_Normal Stop coloring, defaults to your terminal settings.
7788 \layout Section
7785 \layout Section
7789
7786
7790
7787
7791 \begin_inset LatexCommand \label{sec:Threading-support}
7788 \begin_inset LatexCommand \label{sec:Threading-support}
7792
7789
7793 \end_inset
7790 \end_inset
7794
7791
7795 Threading support
7792 Threading support
7796 \layout Standard
7793 \layout Standard
7797
7794
7798
7795
7799 \series bold
7796 \series bold
7800 WARNING:
7797 WARNING:
7801 \series default
7798 \series default
7802 The threading support is still somewhat experimental, and it has only seen
7799 The threading support is still somewhat experimental, and it has only seen
7803 reasonable testing under Linux.
7800 reasonable testing under Linux.
7804 Threaded code is particularly tricky to debug, and it tends to show extremely
7801 Threaded code is particularly tricky to debug, and it tends to show extremely
7805 platform-dependent behavior.
7802 platform-dependent behavior.
7806 Since I only have access to Linux machines, I will have to rely on user's
7803 Since I only have access to Linux machines, I will have to rely on user's
7807 experiences and assistance for this area of IPython to improve under other
7804 experiences and assistance for this area of IPython to improve under other
7808 platforms.
7805 platforms.
7809 \layout Standard
7806 \layout Standard
7810
7807
7811 IPython, via the
7808 IPython, via the
7812 \family typewriter
7809 \family typewriter
7813 -gthread
7810 -gthread
7814 \family default
7811 \family default
7815 ,
7812 ,
7816 \family typewriter
7813 \family typewriter
7817 -qthread
7814 -qthread
7818 \family default
7815 \family default
7819 and
7816 and
7820 \family typewriter
7817 \family typewriter
7821 -wthread
7818 -wthread
7822 \family default
7819 \family default
7823 options (described in Sec.\SpecialChar ~
7820 options (described in Sec.\SpecialChar ~
7824
7821
7825 \begin_inset LatexCommand \ref{sec:threading-opts}
7822 \begin_inset LatexCommand \ref{sec:threading-opts}
7826
7823
7827 \end_inset
7824 \end_inset
7828
7825
7829 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7826 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7830 respectively.
7827 respectively.
7831 These GUI toolkits need to control the python main loop of execution, so
7828 These GUI toolkits need to control the python main loop of execution, so
7832 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7829 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7833 will immediately freeze the shell.
7830 will immediately freeze the shell.
7834
7831
7835 \layout Standard
7832 \layout Standard
7836
7833
7837 IPython, with one of these options (you can only use one at a time), separates
7834 IPython, with one of these options (you can only use one at a time), separates
7838 the graphical loop and IPython's code execution run into different threads.
7835 the graphical loop and IPython's code execution run into different threads.
7839 This allows you to test interactively (with
7836 This allows you to test interactively (with
7840 \family typewriter
7837 \family typewriter
7841 %run
7838 %run
7842 \family default
7839 \family default
7843 , for example) your GUI code without blocking.
7840 , for example) your GUI code without blocking.
7844 \layout Standard
7841 \layout Standard
7845
7842
7846 A nice mini-tutorial on using IPython along with the Qt Designer application
7843 A nice mini-tutorial on using IPython along with the Qt Designer application
7847 is available at the SciPy wiki:
7844 is available at the SciPy wiki:
7848 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7845 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7849
7846
7850 \end_inset
7847 \end_inset
7851
7848
7852 .
7849 .
7853 \layout Subsection
7850 \layout Subsection
7854
7851
7855 Tk issues
7852 Tk issues
7856 \layout Standard
7853 \layout Standard
7857
7854
7858 As indicated in Sec.\SpecialChar ~
7855 As indicated in Sec.\SpecialChar ~
7859
7856
7860 \begin_inset LatexCommand \ref{sec:threading-opts}
7857 \begin_inset LatexCommand \ref{sec:threading-opts}
7861
7858
7862 \end_inset
7859 \end_inset
7863
7860
7864 , a special
7861 , a special
7865 \family typewriter
7862 \family typewriter
7866 -tk
7863 -tk
7867 \family default
7864 \family default
7868 option is provided to try and allow Tk graphical applications to coexist
7865 option is provided to try and allow Tk graphical applications to coexist
7869 interactively with WX, Qt or GTK ones.
7866 interactively with WX, Qt or GTK ones.
7870 Whether this works at all, however, is very platform and configuration
7867 Whether this works at all, however, is very platform and configuration
7871 dependent.
7868 dependent.
7872 Please experiment with simple test cases before committing to using this
7869 Please experiment with simple test cases before committing to using this
7873 combination of Tk and GTK/Qt/WX threading in a production environment.
7870 combination of Tk and GTK/Qt/WX threading in a production environment.
7874 \layout Subsection
7871 \layout Subsection
7875
7872
7876 Signals and Threads
7873 Signals and Threads
7877 \layout Standard
7874 \layout Standard
7878
7875
7879 When any of the thread systems (GTK, Qt or WX) are active, either directly
7876 When any of the thread systems (GTK, Qt or WX) are active, either directly
7880 or via
7877 or via
7881 \family typewriter
7878 \family typewriter
7882 -pylab
7879 -pylab
7883 \family default
7880 \family default
7884 with a threaded backend, it is impossible to interrupt long-running Python
7881 with a threaded backend, it is impossible to interrupt long-running Python
7885 code via
7882 code via
7886 \family typewriter
7883 \family typewriter
7887 Ctrl-C
7884 Ctrl-C
7888 \family default
7885 \family default
7889 .
7886 .
7890 IPython can not pass the KeyboardInterrupt exception (or the underlying
7887 IPython can not pass the KeyboardInterrupt exception (or the underlying
7891
7888
7892 \family typewriter
7889 \family typewriter
7893 SIGINT
7890 SIGINT
7894 \family default
7891 \family default
7895 ) across threads, so any long-running process started from IPython will
7892 ) across threads, so any long-running process started from IPython will
7896 run to completion, or will have to be killed via an external (OS-based)
7893 run to completion, or will have to be killed via an external (OS-based)
7897 mechanism.
7894 mechanism.
7898 \layout Standard
7895 \layout Standard
7899
7896
7900 To the best of my knowledge, this limitation is imposed by the Python interprete
7897 To the best of my knowledge, this limitation is imposed by the Python interprete
7901 r itself, and it comes from the difficulty of writing portable signal/threaded
7898 r itself, and it comes from the difficulty of writing portable signal/threaded
7902 code.
7899 code.
7903 If any user is an expert on this topic and can suggest a better solution,
7900 If any user is an expert on this topic and can suggest a better solution,
7904 I would love to hear about it.
7901 I would love to hear about it.
7905 In the IPython sources, look at the
7902 In the IPython sources, look at the
7906 \family typewriter
7903 \family typewriter
7907 Shell.py
7904 Shell.py
7908 \family default
7905 \family default
7909 module, and in particular at the
7906 module, and in particular at the
7910 \family typewriter
7907 \family typewriter
7911 runcode()
7908 runcode()
7912 \family default
7909 \family default
7913 method.
7910 method.
7914
7911
7915 \layout Subsection
7912 \layout Subsection
7916
7913
7917 I/O pitfalls
7914 I/O pitfalls
7918 \layout Standard
7915 \layout Standard
7919
7916
7920 Be mindful that the Python interpreter switches between threads every
7917 Be mindful that the Python interpreter switches between threads every
7921 \begin_inset Formula $N$
7918 \begin_inset Formula $N$
7922 \end_inset
7919 \end_inset
7923
7920
7924 bytecodes, where the default value as of Python\SpecialChar ~
7921 bytecodes, where the default value as of Python\SpecialChar ~
7925 2.3 is
7922 2.3 is
7926 \begin_inset Formula $N=100.$
7923 \begin_inset Formula $N=100.$
7927 \end_inset
7924 \end_inset
7928
7925
7929 This value can be read by using the
7926 This value can be read by using the
7930 \family typewriter
7927 \family typewriter
7931 sys.getcheckinterval()
7928 sys.getcheckinterval()
7932 \family default
7929 \family default
7933 function, and it can be reset via
7930 function, and it can be reset via
7934 \family typewriter
7931 \family typewriter
7935 sys.setcheckinterval(
7932 sys.setcheckinterval(
7936 \emph on
7933 \emph on
7937 N
7934 N
7938 \emph default
7935 \emph default
7939 )
7936 )
7940 \family default
7937 \family default
7941 .
7938 .
7942 This switching of threads can cause subtly confusing effects if one of
7939 This switching of threads can cause subtly confusing effects if one of
7943 your threads is doing file I/O.
7940 your threads is doing file I/O.
7944 In text mode, most systems only flush file buffers when they encounter
7941 In text mode, most systems only flush file buffers when they encounter
7945 a
7942 a
7946 \family typewriter
7943 \family typewriter
7947 `
7944 `
7948 \backslash
7945 \backslash
7949 n'
7946 n'
7950 \family default
7947 \family default
7951 .
7948 .
7952 An instruction as simple as
7949 An instruction as simple as
7953 \family typewriter
7950 \family typewriter
7954
7951
7955 \newline
7952 \newline
7956 \SpecialChar ~
7953 \SpecialChar ~
7957 \SpecialChar ~
7954 \SpecialChar ~
7958 print >> filehandle,
7955 print >> filehandle,
7959 \begin_inset Quotes eld
7956 \begin_inset Quotes eld
7960 \end_inset
7957 \end_inset
7961
7958
7962 hello world
7959 hello world
7963 \begin_inset Quotes erd
7960 \begin_inset Quotes erd
7964 \end_inset
7961 \end_inset
7965
7962
7966
7963
7967 \family default
7964 \family default
7968
7965
7969 \newline
7966 \newline
7970 actually consists of several bytecodes, so it is possible that the newline
7967 actually consists of several bytecodes, so it is possible that the newline
7971 does not reach your file before the next thread switch.
7968 does not reach your file before the next thread switch.
7972 Similarly, if you are writing to a file in binary mode, the file won't
7969 Similarly, if you are writing to a file in binary mode, the file won't
7973 be flushed until the buffer fills, and your other thread may see apparently
7970 be flushed until the buffer fills, and your other thread may see apparently
7974 truncated files.
7971 truncated files.
7975
7972
7976 \layout Standard
7973 \layout Standard
7977
7974
7978 For this reason, if you are using IPython's thread support and have (for
7975 For this reason, if you are using IPython's thread support and have (for
7979 example) a GUI application which will read data generated by files written
7976 example) a GUI application which will read data generated by files written
7980 to from the IPython thread, the safest approach is to open all of your
7977 to from the IPython thread, the safest approach is to open all of your
7981 files in unbuffered mode (the third argument to the
7978 files in unbuffered mode (the third argument to the
7982 \family typewriter
7979 \family typewriter
7983 file/open
7980 file/open
7984 \family default
7981 \family default
7985 function is the buffering value):
7982 function is the buffering value):
7986 \newline
7983 \newline
7987
7984
7988 \family typewriter
7985 \family typewriter
7989 \SpecialChar ~
7986 \SpecialChar ~
7990 \SpecialChar ~
7987 \SpecialChar ~
7991 filehandle = open(filename,mode,0)
7988 filehandle = open(filename,mode,0)
7992 \layout Standard
7989 \layout Standard
7993
7990
7994 This is obviously a brute force way of avoiding race conditions with the
7991 This is obviously a brute force way of avoiding race conditions with the
7995 file buffering.
7992 file buffering.
7996 If you want to do it cleanly, and you have a resource which is being shared
7993 If you want to do it cleanly, and you have a resource which is being shared
7997 by the interactive IPython loop and your GUI thread, you should really
7994 by the interactive IPython loop and your GUI thread, you should really
7998 handle it with thread locking and syncrhonization properties.
7995 handle it with thread locking and syncrhonization properties.
7999 The Python documentation discusses these.
7996 The Python documentation discusses these.
8000 \layout Section
7997 \layout Section
8001
7998
8002
7999
8003 \begin_inset LatexCommand \label{sec:interactive-demos}
8000 \begin_inset LatexCommand \label{sec:interactive-demos}
8004
8001
8005 \end_inset
8002 \end_inset
8006
8003
8007 Interactive demos with IPython
8004 Interactive demos with IPython
8008 \layout Standard
8005 \layout Standard
8009
8006
8010 IPython ships with a basic system for running scripts interactively in sections,
8007 IPython ships with a basic system for running scripts interactively in sections,
8011 useful when presenting code to audiences.
8008 useful when presenting code to audiences.
8012 A few tags embedded in comments (so that the script remains valid Python
8009 A few tags embedded in comments (so that the script remains valid Python
8013 code) divide a file into separate blocks, and the demo can be run one block
8010 code) divide a file into separate blocks, and the demo can be run one block
8014 at a time, with IPython printing (with syntax highlighting) the block before
8011 at a time, with IPython printing (with syntax highlighting) the block before
8015 executing it, and returning to the interactive prompt after each block.
8012 executing it, and returning to the interactive prompt after each block.
8016 The interactive namespace is updated after each block is run with the contents
8013 The interactive namespace is updated after each block is run with the contents
8017 of the demo's namespace.
8014 of the demo's namespace.
8018 \layout Standard
8015 \layout Standard
8019
8016
8020 This allows you to show a piece of code, run it and then execute interactively
8017 This allows you to show a piece of code, run it and then execute interactively
8021 commands based on the variables just created.
8018 commands based on the variables just created.
8022 Once you want to continue, you simply execute the next block of the demo.
8019 Once you want to continue, you simply execute the next block of the demo.
8023 The following listing shows the markup necessary for dividing a script
8020 The following listing shows the markup necessary for dividing a script
8024 into sections for execution as a demo.
8021 into sections for execution as a demo.
8025 \layout Standard
8022 \layout Standard
8026
8023
8027
8024
8028 \begin_inset ERT
8025 \begin_inset ERT
8029 status Open
8026 status Open
8030
8027
8031 \layout Standard
8028 \layout Standard
8032
8029
8033 \backslash
8030 \backslash
8034 codelist{examples/example-demo.py}
8031 codelist{examples/example-demo.py}
8035 \end_inset
8032 \end_inset
8036
8033
8037
8034
8038 \layout Standard
8035 \layout Standard
8039
8036
8040 In order to run a file as a demo, you must first make a
8037 In order to run a file as a demo, you must first make a
8041 \family typewriter
8038 \family typewriter
8042 Demo
8039 Demo
8043 \family default
8040 \family default
8044 object out of it.
8041 object out of it.
8045 If the file is named
8042 If the file is named
8046 \family typewriter
8043 \family typewriter
8047 myscript.py
8044 myscript.py
8048 \family default
8045 \family default
8049 , the following code will make a demo:
8046 , the following code will make a demo:
8050 \layout LyX-Code
8047 \layout LyX-Code
8051
8048
8052 from IPython.demo import Demo
8049 from IPython.demo import Demo
8053 \layout LyX-Code
8050 \layout LyX-Code
8054
8051
8055 mydemo = Demo('myscript.py')
8052 mydemo = Demo('myscript.py')
8056 \layout Standard
8053 \layout Standard
8057
8054
8058 This creates the
8055 This creates the
8059 \family typewriter
8056 \family typewriter
8060 mydemo
8057 mydemo
8061 \family default
8058 \family default
8062 object, whose blocks you run one at a time by simply calling the object
8059 object, whose blocks you run one at a time by simply calling the object
8063 with no arguments.
8060 with no arguments.
8064 If you have autocall active in IPython (the default), all you need to do
8061 If you have autocall active in IPython (the default), all you need to do
8065 is type
8062 is type
8066 \layout LyX-Code
8063 \layout LyX-Code
8067
8064
8068 mydemo
8065 mydemo
8069 \layout Standard
8066 \layout Standard
8070
8067
8071 and IPython will call it, executing each block.
8068 and IPython will call it, executing each block.
8072 Demo objects can be restarted, you can move forward or back skipping blocks,
8069 Demo objects can be restarted, you can move forward or back skipping blocks,
8073 re-execute the last block, etc.
8070 re-execute the last block, etc.
8074 Simply use the Tab key on a demo object to see its methods, and call
8071 Simply use the Tab key on a demo object to see its methods, and call
8075 \family typewriter
8072 \family typewriter
8076 `?'
8073 `?'
8077 \family default
8074 \family default
8078 on them to see their docstrings for more usage details.
8075 on them to see their docstrings for more usage details.
8079 In addition, the
8076 In addition, the
8080 \family typewriter
8077 \family typewriter
8081 demo
8078 demo
8082 \family default
8079 \family default
8083 module itself contains a comprehensive docstring, which you can access
8080 module itself contains a comprehensive docstring, which you can access
8084 via
8081 via
8085 \layout LyX-Code
8082 \layout LyX-Code
8086
8083
8087 from IPython import demo
8084 from IPython import demo
8088 \layout LyX-Code
8085 \layout LyX-Code
8089
8086
8090 demo?
8087 demo?
8091 \layout Standard
8088 \layout Standard
8092
8089
8093
8090
8094 \series bold
8091 \series bold
8095 Limitations:
8092 Limitations:
8096 \series default
8093 \series default
8097 It is important to note that these demos are limited to fairly simple uses.
8094 It is important to note that these demos are limited to fairly simple uses.
8098 In particular, you can
8095 In particular, you can
8099 \emph on
8096 \emph on
8100 not
8097 not
8101 \emph default
8098 \emph default
8102 put division marks in indented code (loops, if statements, function definitions
8099 put division marks in indented code (loops, if statements, function definitions
8103 , etc.) Supporting something like this would basically require tracking the
8100 , etc.) Supporting something like this would basically require tracking the
8104 internal execution state of the Python interpreter, so only top-level divisions
8101 internal execution state of the Python interpreter, so only top-level divisions
8105 are allowed.
8102 are allowed.
8106 If you want to be able to open an IPython instance at an arbitrary point
8103 If you want to be able to open an IPython instance at an arbitrary point
8107 in a program, you can use IPython's embedding facilities, described in
8104 in a program, you can use IPython's embedding facilities, described in
8108 detail in Sec\SpecialChar \@.
8105 detail in Sec\SpecialChar \@.
8109 \SpecialChar ~
8106 \SpecialChar ~
8110
8107
8111 \begin_inset LatexCommand \ref{sec:embed}
8108 \begin_inset LatexCommand \ref{sec:embed}
8112
8109
8113 \end_inset
8110 \end_inset
8114
8111
8115 .
8112 .
8116 \layout Section
8113 \layout Section
8117
8114
8118
8115
8119 \begin_inset LatexCommand \label{sec:matplotlib-support}
8116 \begin_inset LatexCommand \label{sec:matplotlib-support}
8120
8117
8121 \end_inset
8118 \end_inset
8122
8119
8123 Plotting with
8120 Plotting with
8124 \family typewriter
8121 \family typewriter
8125 matplotlib
8122 matplotlib
8126 \family default
8123 \family default
8127
8124
8128 \layout Standard
8125 \layout Standard
8129
8126
8130 The matplotlib library (
8127 The matplotlib library (
8131 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
8128 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
8132
8129
8133 \end_inset
8130 \end_inset
8134
8131
8135 ) provides high quality 2D plotting for Python.
8132 ) provides high quality 2D plotting for Python.
8136 Matplotlib can produce plots on screen using a variety of GUI toolkits,
8133 Matplotlib can produce plots on screen using a variety of GUI toolkits,
8137 including Tk, GTK and WXPython.
8134 including Tk, GTK and WXPython.
8138 It also provides a number of commands useful for scientific computing,
8135 It also provides a number of commands useful for scientific computing,
8139 all with a syntax compatible with that of the popular Matlab program.
8136 all with a syntax compatible with that of the popular Matlab program.
8140 \layout Standard
8137 \layout Standard
8141
8138
8142 IPython accepts the special option
8139 IPython accepts the special option
8143 \family typewriter
8140 \family typewriter
8144 -pylab
8141 -pylab
8145 \family default
8142 \family default
8146 (Sec.\SpecialChar ~
8143 (Sec.\SpecialChar ~
8147
8144
8148 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
8145 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
8149
8146
8150 \end_inset
8147 \end_inset
8151
8148
8152 ).
8149 ).
8153 This configures it to support matplotlib, honoring the settings in the
8150 This configures it to support matplotlib, honoring the settings in the
8154
8151
8155 \family typewriter
8152 \family typewriter
8156 .matplotlibrc
8153 .matplotlibrc
8157 \family default
8154 \family default
8158 file.
8155 file.
8159 IPython will detect the user's choice of matplotlib GUI backend, and automatica
8156 IPython will detect the user's choice of matplotlib GUI backend, and automatica
8160 lly select the proper threading model to prevent blocking.
8157 lly select the proper threading model to prevent blocking.
8161 It also sets matplotlib in interactive mode and modifies
8158 It also sets matplotlib in interactive mode and modifies
8162 \family typewriter
8159 \family typewriter
8163 %run
8160 %run
8164 \family default
8161 \family default
8165 slightly, so that any matplotlib-based script can be executed using
8162 slightly, so that any matplotlib-based script can be executed using
8166 \family typewriter
8163 \family typewriter
8167 %run
8164 %run
8168 \family default
8165 \family default
8169 and the final
8166 and the final
8170 \family typewriter
8167 \family typewriter
8171 show()
8168 show()
8172 \family default
8169 \family default
8173 command does not block the interactive shell.
8170 command does not block the interactive shell.
8174 \layout Standard
8171 \layout Standard
8175
8172
8176 The
8173 The
8177 \family typewriter
8174 \family typewriter
8178 -pylab
8175 -pylab
8179 \family default
8176 \family default
8180 option must be given first in order for IPython to configure its threading
8177 option must be given first in order for IPython to configure its threading
8181 mode.
8178 mode.
8182 However, you can still issue other options afterwards.
8179 However, you can still issue other options afterwards.
8183 This allows you to have a matplotlib-based environment customized with
8180 This allows you to have a matplotlib-based environment customized with
8184 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
8181 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
8185
8182
8186 \begin_inset LatexCommand \ref{sec:profiles}
8183 \begin_inset LatexCommand \ref{sec:profiles}
8187
8184
8188 \end_inset
8185 \end_inset
8189
8186
8190 ): ``
8187 ): ``
8191 \family typewriter
8188 \family typewriter
8192 ipython -pylab -p myprofile
8189 ipython -pylab -p myprofile
8193 \family default
8190 \family default
8194 '' will load the profile defined in
8191 '' will load the profile defined in
8195 \family typewriter
8192 \family typewriter
8196 ipythonrc-myprofile
8193 ipythonrc-myprofile
8197 \family default
8194 \family default
8198 after configuring matplotlib.
8195 after configuring matplotlib.
8199 \layout Section
8196 \layout Section
8200
8197
8201
8198
8202 \begin_inset LatexCommand \label{sec:Gnuplot}
8199 \begin_inset LatexCommand \label{sec:Gnuplot}
8203
8200
8204 \end_inset
8201 \end_inset
8205
8202
8206 Plotting with
8203 Plotting with
8207 \family typewriter
8204 \family typewriter
8208 Gnuplot
8205 Gnuplot
8209 \layout Standard
8206 \layout Standard
8210
8207
8211 Through the magic extension system described in sec.
8208 Through the magic extension system described in sec.
8212
8209
8213 \begin_inset LatexCommand \ref{sec:magic}
8210 \begin_inset LatexCommand \ref{sec:magic}
8214
8211
8215 \end_inset
8212 \end_inset
8216
8213
8217 , IPython incorporates a mechanism for conveniently interfacing with the
8214 , IPython incorporates a mechanism for conveniently interfacing with the
8218 Gnuplot system (
8215 Gnuplot system (
8219 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
8216 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
8220
8217
8221 \end_inset
8218 \end_inset
8222
8219
8223 ).
8220 ).
8224 Gnuplot is a very complete 2D and 3D plotting package available for many
8221 Gnuplot is a very complete 2D and 3D plotting package available for many
8225 operating systems and commonly included in modern Linux distributions.
8222 operating systems and commonly included in modern Linux distributions.
8226
8223
8227 \layout Standard
8224 \layout Standard
8228
8225
8229 Besides having Gnuplot installed, this functionality requires the
8226 Besides having Gnuplot installed, this functionality requires the
8230 \family typewriter
8227 \family typewriter
8231 Gnuplot.py
8228 Gnuplot.py
8232 \family default
8229 \family default
8233 module for interfacing python with Gnuplot.
8230 module for interfacing python with Gnuplot.
8234 It can be downloaded from:
8231 It can be downloaded from:
8235 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8232 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8236
8233
8237 \end_inset
8234 \end_inset
8238
8235
8239 .
8236 .
8240 \layout Subsection
8237 \layout Subsection
8241
8238
8242 Proper Gnuplot configuration
8239 Proper Gnuplot configuration
8243 \layout Standard
8240 \layout Standard
8244
8241
8245 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8242 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8246 However, as of
8243 However, as of
8247 \family typewriter
8244 \family typewriter
8248 Gnuplot.py
8245 Gnuplot.py
8249 \family default
8246 \family default
8250 version 1.7, a new option was added to communicate between Python and Gnuplot
8247 version 1.7, a new option was added to communicate between Python and Gnuplot
8251 via FIFOs (pipes).
8248 via FIFOs (pipes).
8252 This mechanism, while fast, also breaks the mouse system.
8249 This mechanism, while fast, also breaks the mouse system.
8253 You must therefore set the variable
8250 You must therefore set the variable
8254 \family typewriter
8251 \family typewriter
8255 prefer_fifo_data
8252 prefer_fifo_data
8256 \family default
8253 \family default
8257 to
8254 to
8258 \family typewriter
8255 \family typewriter
8259 0
8256 0
8260 \family default
8257 \family default
8261 in file
8258 in file
8262 \family typewriter
8259 \family typewriter
8263 gp_unix.py
8260 gp_unix.py
8264 \family default
8261 \family default
8265 if you wish to keep the interactive mouse and keyboard features working
8262 if you wish to keep the interactive mouse and keyboard features working
8266 properly (
8263 properly (
8267 \family typewriter
8264 \family typewriter
8268 prefer_inline_data
8265 prefer_inline_data
8269 \family default
8266 \family default
8270 also must be
8267 also must be
8271 \family typewriter
8268 \family typewriter
8272 0
8269 0
8273 \family default
8270 \family default
8274 , but this is the default so unless you've changed it manually you should
8271 , but this is the default so unless you've changed it manually you should
8275 be fine).
8272 be fine).
8276 \layout Standard
8273 \layout Standard
8277
8274
8278 'Out of the box', Gnuplot is configured with a rather poor set of size,
8275 'Out of the box', Gnuplot is configured with a rather poor set of size,
8279 color and linewidth choices which make the graphs fairly hard to read on
8276 color and linewidth choices which make the graphs fairly hard to read on
8280 modern high-resolution displays (although they work fine on old 640x480
8277 modern high-resolution displays (although they work fine on old 640x480
8281 ones).
8278 ones).
8282 Below is a section of my
8279 Below is a section of my
8283 \family typewriter
8280 \family typewriter
8284 .Xdefaults
8281 .Xdefaults
8285 \family default
8282 \family default
8286 file which I use for having a more convenient Gnuplot setup.
8283 file which I use for having a more convenient Gnuplot setup.
8287 Remember to load it by running
8284 Remember to load it by running
8288 \family typewriter
8285 \family typewriter
8289 `xrdb .Xdefaults`
8286 `xrdb .Xdefaults`
8290 \family default
8287 \family default
8291 :
8288 :
8292 \layout Standard
8289 \layout Standard
8293
8290
8294
8291
8295 \family typewriter
8292 \family typewriter
8296 !******************************************************************
8293 !******************************************************************
8297 \newline
8294 \newline
8298 ! gnuplot options
8295 ! gnuplot options
8299 \newline
8296 \newline
8300 ! modify this for a convenient window size
8297 ! modify this for a convenient window size
8301 \newline
8298 \newline
8302 gnuplot*geometry: 780x580
8299 gnuplot*geometry: 780x580
8303 \layout Standard
8300 \layout Standard
8304
8301
8305
8302
8306 \family typewriter
8303 \family typewriter
8307 ! on-screen font (not for PostScript)
8304 ! on-screen font (not for PostScript)
8308 \newline
8305 \newline
8309 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8306 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8310 \layout Standard
8307 \layout Standard
8311
8308
8312
8309
8313 \family typewriter
8310 \family typewriter
8314 ! color options
8311 ! color options
8315 \newline
8312 \newline
8316 gnuplot*background: black
8313 gnuplot*background: black
8317 \newline
8314 \newline
8318 gnuplot*textColor: white
8315 gnuplot*textColor: white
8319 \newline
8316 \newline
8320 gnuplot*borderColor: white
8317 gnuplot*borderColor: white
8321 \newline
8318 \newline
8322 gnuplot*axisColor: white
8319 gnuplot*axisColor: white
8323 \newline
8320 \newline
8324 gnuplot*line1Color: red
8321 gnuplot*line1Color: red
8325 \newline
8322 \newline
8326 gnuplot*line2Color: green
8323 gnuplot*line2Color: green
8327 \newline
8324 \newline
8328 gnuplot*line3Color: blue
8325 gnuplot*line3Color: blue
8329 \newline
8326 \newline
8330 gnuplot*line4Color: magenta
8327 gnuplot*line4Color: magenta
8331 \newline
8328 \newline
8332 gnuplot*line5Color: cyan
8329 gnuplot*line5Color: cyan
8333 \newline
8330 \newline
8334 gnuplot*line6Color: sienna
8331 gnuplot*line6Color: sienna
8335 \newline
8332 \newline
8336 gnuplot*line7Color: orange
8333 gnuplot*line7Color: orange
8337 \newline
8334 \newline
8338 gnuplot*line8Color: coral
8335 gnuplot*line8Color: coral
8339 \layout Standard
8336 \layout Standard
8340
8337
8341
8338
8342 \family typewriter
8339 \family typewriter
8343 ! multiplicative factor for point styles
8340 ! multiplicative factor for point styles
8344 \newline
8341 \newline
8345 gnuplot*pointsize: 2
8342 gnuplot*pointsize: 2
8346 \layout Standard
8343 \layout Standard
8347
8344
8348
8345
8349 \family typewriter
8346 \family typewriter
8350 ! line width options (in pixels)
8347 ! line width options (in pixels)
8351 \newline
8348 \newline
8352 gnuplot*borderWidth: 2
8349 gnuplot*borderWidth: 2
8353 \newline
8350 \newline
8354 gnuplot*axisWidth: 2
8351 gnuplot*axisWidth: 2
8355 \newline
8352 \newline
8356 gnuplot*line1Width: 2
8353 gnuplot*line1Width: 2
8357 \newline
8354 \newline
8358 gnuplot*line2Width: 2
8355 gnuplot*line2Width: 2
8359 \newline
8356 \newline
8360 gnuplot*line3Width: 2
8357 gnuplot*line3Width: 2
8361 \newline
8358 \newline
8362 gnuplot*line4Width: 2
8359 gnuplot*line4Width: 2
8363 \newline
8360 \newline
8364 gnuplot*line5Width: 2
8361 gnuplot*line5Width: 2
8365 \newline
8362 \newline
8366 gnuplot*line6Width: 2
8363 gnuplot*line6Width: 2
8367 \newline
8364 \newline
8368 gnuplot*line7Width: 2
8365 gnuplot*line7Width: 2
8369 \newline
8366 \newline
8370 gnuplot*line8Width: 2
8367 gnuplot*line8Width: 2
8371 \layout Subsection
8368 \layout Subsection
8372
8369
8373 The
8370 The
8374 \family typewriter
8371 \family typewriter
8375 IPython.GnuplotRuntime
8372 IPython.GnuplotRuntime
8376 \family default
8373 \family default
8377 module
8374 module
8378 \layout Standard
8375 \layout Standard
8379
8376
8380 IPython includes a module called
8377 IPython includes a module called
8381 \family typewriter
8378 \family typewriter
8382 Gnuplot2.py
8379 Gnuplot2.py
8383 \family default
8380 \family default
8384 which extends and improves the default
8381 which extends and improves the default
8385 \family typewriter
8382 \family typewriter
8386 Gnuplot
8383 Gnuplot
8387 \family default
8384 \family default
8388 .
8385 .
8389 \family typewriter
8386 \family typewriter
8390 py
8387 py
8391 \family default
8388 \family default
8392 (which it still relies upon).
8389 (which it still relies upon).
8393 For example, the new
8390 For example, the new
8394 \family typewriter
8391 \family typewriter
8395 plot
8392 plot
8396 \family default
8393 \family default
8397 function adds several improvements to the original making it more convenient
8394 function adds several improvements to the original making it more convenient
8398 for interactive use, and
8395 for interactive use, and
8399 \family typewriter
8396 \family typewriter
8400 hardcopy
8397 hardcopy
8401 \family default
8398 \family default
8402 fixes a bug in the original which under some circumstances blocks the creation
8399 fixes a bug in the original which under some circumstances blocks the creation
8403 of PostScript output.
8400 of PostScript output.
8404 \layout Standard
8401 \layout Standard
8405
8402
8406 For scripting use,
8403 For scripting use,
8407 \family typewriter
8404 \family typewriter
8408 GnuplotRuntime.py
8405 GnuplotRuntime.py
8409 \family default
8406 \family default
8410 is provided, which wraps
8407 is provided, which wraps
8411 \family typewriter
8408 \family typewriter
8412 Gnuplot2.py
8409 Gnuplot2.py
8413 \family default
8410 \family default
8414 and creates a series of global aliases.
8411 and creates a series of global aliases.
8415 These make it easy to control Gnuplot plotting jobs through the Python
8412 These make it easy to control Gnuplot plotting jobs through the Python
8416 language.
8413 language.
8417 \layout Standard
8414 \layout Standard
8418
8415
8419 Below is some example code which illustrates how to configure Gnuplot inside
8416 Below is some example code which illustrates how to configure Gnuplot inside
8420 your own programs but have it available for further interactive use through
8417 your own programs but have it available for further interactive use through
8421 an embedded IPython instance.
8418 an embedded IPython instance.
8422 Simply run this file at a system prompt.
8419 Simply run this file at a system prompt.
8423 This file is provided as
8420 This file is provided as
8424 \family typewriter
8421 \family typewriter
8425 example-gnuplot.py
8422 example-gnuplot.py
8426 \family default
8423 \family default
8427 in the examples directory:
8424 in the examples directory:
8428 \layout Standard
8425 \layout Standard
8429
8426
8430
8427
8431 \begin_inset ERT
8428 \begin_inset ERT
8432 status Open
8429 status Open
8433
8430
8434 \layout Standard
8431 \layout Standard
8435
8432
8436 \backslash
8433 \backslash
8437 codelist{examples/example-gnuplot.py}
8434 codelist{examples/example-gnuplot.py}
8438 \end_inset
8435 \end_inset
8439
8436
8440
8437
8441 \layout Subsection
8438 \layout Subsection
8442
8439
8443 The
8440 The
8444 \family typewriter
8441 \family typewriter
8445 numeric
8442 numeric
8446 \family default
8443 \family default
8447 profile: a scientific computing environment
8444 profile: a scientific computing environment
8448 \layout Standard
8445 \layout Standard
8449
8446
8450 The
8447 The
8451 \family typewriter
8448 \family typewriter
8452 numeric
8449 numeric
8453 \family default
8450 \family default
8454 IPython profile, which you can activate with
8451 IPython profile, which you can activate with
8455 \family typewriter
8452 \family typewriter
8456 `ipython -p numeric
8453 `ipython -p numeric
8457 \family default
8454 \family default
8458 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8455 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8459 other useful things for numerical computing), contained in the
8456 other useful things for numerical computing), contained in the
8460 \family typewriter
8457 \family typewriter
8461 IPython.GnuplotInteractive
8458 IPython.GnuplotInteractive
8462 \family default
8459 \family default
8463 module.
8460 module.
8464 This will create the globals
8461 This will create the globals
8465 \family typewriter
8462 \family typewriter
8466 Gnuplot
8463 Gnuplot
8467 \family default
8464 \family default
8468 (an alias to the improved Gnuplot2 module),
8465 (an alias to the improved Gnuplot2 module),
8469 \family typewriter
8466 \family typewriter
8470 gp
8467 gp
8471 \family default
8468 \family default
8472 (a Gnuplot active instance), the new magic commands
8469 (a Gnuplot active instance), the new magic commands
8473 \family typewriter
8470 \family typewriter
8474 %gpc
8471 %gpc
8475 \family default
8472 \family default
8476 and
8473 and
8477 \family typewriter
8474 \family typewriter
8478 %gp_set_instance
8475 %gp_set_instance
8479 \family default
8476 \family default
8480 and several other convenient globals.
8477 and several other convenient globals.
8481 Type
8478 Type
8482 \family typewriter
8479 \family typewriter
8483 gphelp()
8480 gphelp()
8484 \family default
8481 \family default
8485 for further details.
8482 for further details.
8486 \layout Standard
8483 \layout Standard
8487
8484
8488 This should turn IPython into a convenient environment for numerical computing,
8485 This should turn IPython into a convenient environment for numerical computing,
8489 with all the functions in the NumPy library and the Gnuplot facilities
8486 with all the functions in the NumPy library and the Gnuplot facilities
8490 for plotting.
8487 for plotting.
8491 Further improvements can be obtained by loading the SciPy libraries for
8488 Further improvements can be obtained by loading the SciPy libraries for
8492 scientific computing, available at
8489 scientific computing, available at
8493 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8490 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8494
8491
8495 \end_inset
8492 \end_inset
8496
8493
8497 .
8494 .
8498 \layout Standard
8495 \layout Standard
8499
8496
8500 If you are in the middle of a working session with numerical objects and
8497 If you are in the middle of a working session with numerical objects and
8501 need to plot them but you didn't start the
8498 need to plot them but you didn't start the
8502 \family typewriter
8499 \family typewriter
8503 numeric
8500 numeric
8504 \family default
8501 \family default
8505 profile, you can load these extensions at any time by typing
8502 profile, you can load these extensions at any time by typing
8506 \newline
8503 \newline
8507
8504
8508 \family typewriter
8505 \family typewriter
8509 from IPython.GnuplotInteractive import *
8506 from IPython.GnuplotInteractive import *
8510 \newline
8507 \newline
8511
8508
8512 \family default
8509 \family default
8513 at the IPython prompt.
8510 at the IPython prompt.
8514 This will allow you to keep your objects intact and start using Gnuplot
8511 This will allow you to keep your objects intact and start using Gnuplot
8515 to view them.
8512 to view them.
8516 \layout Section
8513 \layout Section
8517
8514
8518 Reporting bugs
8515 Reporting bugs
8519 \layout Subsection*
8516 \layout Subsection*
8520
8517
8521 Automatic crash reports
8518 Automatic crash reports
8522 \layout Standard
8519 \layout Standard
8523
8520
8524 Ideally, IPython itself shouldn't crash.
8521 Ideally, IPython itself shouldn't crash.
8525 It will catch exceptions produced by you, but bugs in its internals will
8522 It will catch exceptions produced by you, but bugs in its internals will
8526 still crash it.
8523 still crash it.
8527 \layout Standard
8524 \layout Standard
8528
8525
8529 In such a situation, IPython will leave a file named
8526 In such a situation, IPython will leave a file named
8530 \family typewriter
8527 \family typewriter
8531 IPython_crash_report.txt
8528 IPython_crash_report.txt
8532 \family default
8529 \family default
8533 in your IPYTHONDIR directory (that way if crashes happen several times
8530 in your IPYTHONDIR directory (that way if crashes happen several times
8534 it won't litter many directories, the post-mortem file is always located
8531 it won't litter many directories, the post-mortem file is always located
8535 in the same place and new occurrences just overwrite the previous one).
8532 in the same place and new occurrences just overwrite the previous one).
8536 If you can mail this file to the developers (see sec.
8533 If you can mail this file to the developers (see sec.
8537
8534
8538 \begin_inset LatexCommand \ref{sec:credits}
8535 \begin_inset LatexCommand \ref{sec:credits}
8539
8536
8540 \end_inset
8537 \end_inset
8541
8538
8542 for names and addresses), it will help us
8539 for names and addresses), it will help us
8543 \emph on
8540 \emph on
8544 a lot
8541 a lot
8545 \emph default
8542 \emph default
8546 in understanding the cause of the problem and fixing it sooner.
8543 in understanding the cause of the problem and fixing it sooner.
8547 \layout Subsection*
8544 \layout Subsection*
8548
8545
8549 The bug tracker
8546 The bug tracker
8550 \layout Standard
8547 \layout Standard
8551
8548
8552 IPython also has an online bug-tracker, located at
8549 IPython also has an online bug-tracker, located at
8553 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8550 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8554
8551
8555 \end_inset
8552 \end_inset
8556
8553
8557 .
8554 .
8558 In addition to mailing the developers, it would be a good idea to file
8555 In addition to mailing the developers, it would be a good idea to file
8559 a bug report here.
8556 a bug report here.
8560 This will ensure that the issue is properly followed to conclusion.
8557 This will ensure that the issue is properly followed to conclusion.
8561 \layout Standard
8558 \layout Standard
8562
8559
8563 You can also use this bug tracker to file feature requests.
8560 You can also use this bug tracker to file feature requests.
8564 \layout Section
8561 \layout Section
8565
8562
8566 Brief history
8563 Brief history
8567 \layout Subsection
8564 \layout Subsection
8568
8565
8569 Origins
8566 Origins
8570 \layout Standard
8567 \layout Standard
8571
8568
8572 The current IPython system grew out of the following three projects:
8569 The current IPython system grew out of the following three projects:
8573 \layout List
8570 \layout List
8574 \labelwidthstring 00.00.0000
8571 \labelwidthstring 00.00.0000
8575
8572
8576 ipython by Fernando P
8573 ipython by Fernando P
8577 \begin_inset ERT
8574 \begin_inset ERT
8578 status Collapsed
8575 status Collapsed
8579
8576
8580 \layout Standard
8577 \layout Standard
8581
8578
8582 \backslash
8579 \backslash
8583 '{e}
8580 '{e}
8584 \end_inset
8581 \end_inset
8585
8582
8586 rez.
8583 rez.
8587 I was working on adding Mathematica-type prompts and a flexible configuration
8584 I was working on adding Mathematica-type prompts and a flexible configuration
8588 system (something better than
8585 system (something better than
8589 \family typewriter
8586 \family typewriter
8590 $PYTHONSTARTUP
8587 $PYTHONSTARTUP
8591 \family default
8588 \family default
8592 ) to the standard Python interactive interpreter.
8589 ) to the standard Python interactive interpreter.
8593 \layout List
8590 \layout List
8594 \labelwidthstring 00.00.0000
8591 \labelwidthstring 00.00.0000
8595
8592
8596 IPP by Janko Hauser.
8593 IPP by Janko Hauser.
8597 Very well organized, great usability.
8594 Very well organized, great usability.
8598 Had an old help system.
8595 Had an old help system.
8599 IPP was used as the `container' code into which I added the functionality
8596 IPP was used as the `container' code into which I added the functionality
8600 from ipython and LazyPython.
8597 from ipython and LazyPython.
8601 \layout List
8598 \layout List
8602 \labelwidthstring 00.00.0000
8599 \labelwidthstring 00.00.0000
8603
8600
8604 LazyPython by Nathan Gray.
8601 LazyPython by Nathan Gray.
8605 Simple but
8602 Simple but
8606 \emph on
8603 \emph on
8607 very
8604 very
8608 \emph default
8605 \emph default
8609 powerful.
8606 powerful.
8610 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8607 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8611 were all taken from here.
8608 were all taken from here.
8612 \layout Standard
8609 \layout Standard
8613
8610
8614 When I found out (see sec.
8611 When I found out (see sec.
8615
8612
8616 \begin_inset LatexCommand \ref{figgins}
8613 \begin_inset LatexCommand \ref{figgins}
8617
8614
8618 \end_inset
8615 \end_inset
8619
8616
8620 ) about IPP and LazyPython I tried to join all three into a unified system.
8617 ) about IPP and LazyPython I tried to join all three into a unified system.
8621 I thought this could provide a very nice working environment, both for
8618 I thought this could provide a very nice working environment, both for
8622 regular programming and scientific computing: shell-like features, IDL/Matlab
8619 regular programming and scientific computing: shell-like features, IDL/Matlab
8623 numerics, Mathematica-type prompt history and great object introspection
8620 numerics, Mathematica-type prompt history and great object introspection
8624 and help facilities.
8621 and help facilities.
8625 I think it worked reasonably well, though it was a lot more work than I
8622 I think it worked reasonably well, though it was a lot more work than I
8626 had initially planned.
8623 had initially planned.
8627 \layout Subsection
8624 \layout Subsection
8628
8625
8629 Current status
8626 Current status
8630 \layout Standard
8627 \layout Standard
8631
8628
8632 The above listed features work, and quite well for the most part.
8629 The above listed features work, and quite well for the most part.
8633 But until a major internal restructuring is done (see below), only bug
8630 But until a major internal restructuring is done (see below), only bug
8634 fixing will be done, no other features will be added (unless very minor
8631 fixing will be done, no other features will be added (unless very minor
8635 and well localized in the cleaner parts of the code).
8632 and well localized in the cleaner parts of the code).
8636 \layout Standard
8633 \layout Standard
8637
8634
8638 IPython consists of some 18000 lines of pure python code, of which roughly
8635 IPython consists of some 18000 lines of pure python code, of which roughly
8639 two thirds is reasonably clean.
8636 two thirds is reasonably clean.
8640 The rest is, messy code which needs a massive restructuring before any
8637 The rest is, messy code which needs a massive restructuring before any
8641 further major work is done.
8638 further major work is done.
8642 Even the messy code is fairly well documented though, and most of the problems
8639 Even the messy code is fairly well documented though, and most of the problems
8643 in the (non-existent) class design are well pointed to by a PyChecker run.
8640 in the (non-existent) class design are well pointed to by a PyChecker run.
8644 So the rewriting work isn't that bad, it will just be time-consuming.
8641 So the rewriting work isn't that bad, it will just be time-consuming.
8645 \layout Subsection
8642 \layout Subsection
8646
8643
8647 Future
8644 Future
8648 \layout Standard
8645 \layout Standard
8649
8646
8650 See the separate
8647 See the separate
8651 \family typewriter
8648 \family typewriter
8652 new_design
8649 new_design
8653 \family default
8650 \family default
8654 document for details.
8651 document for details.
8655 Ultimately, I would like to see IPython become part of the standard Python
8652 Ultimately, I would like to see IPython become part of the standard Python
8656 distribution as a `big brother with batteries' to the standard Python interacti
8653 distribution as a `big brother with batteries' to the standard Python interacti
8657 ve interpreter.
8654 ve interpreter.
8658 But that will never happen with the current state of the code, so all contribut
8655 But that will never happen with the current state of the code, so all contribut
8659 ions are welcome.
8656 ions are welcome.
8660 \layout Section
8657 \layout Section
8661
8658
8662 License
8659 License
8663 \layout Standard
8660 \layout Standard
8664
8661
8665 IPython is released under the terms of the BSD license, whose general form
8662 IPython is released under the terms of the BSD license, whose general form
8666 can be found at:
8663 can be found at:
8667 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8664 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8668
8665
8669 \end_inset
8666 \end_inset
8670
8667
8671 .
8668 .
8672 The full text of the IPython license is reproduced below:
8669 The full text of the IPython license is reproduced below:
8673 \layout Quote
8670 \layout Quote
8674
8671
8675
8672
8676 \family typewriter
8673 \family typewriter
8677 \size small
8674 \size small
8678 IPython is released under a BSD-type license.
8675 IPython is released under a BSD-type license.
8679 \layout Quote
8676 \layout Quote
8680
8677
8681
8678
8682 \family typewriter
8679 \family typewriter
8683 \size small
8680 \size small
8684 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8681 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8685 \layout Quote
8682 \layout Quote
8686
8683
8687
8684
8688 \family typewriter
8685 \family typewriter
8689 \size small
8686 \size small
8690 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8687 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8691 \newline
8688 \newline
8692 Nathaniel Gray <n8gray@caltech.edu>.
8689 Nathaniel Gray <n8gray@caltech.edu>.
8693 \layout Quote
8690 \layout Quote
8694
8691
8695
8692
8696 \family typewriter
8693 \family typewriter
8697 \size small
8694 \size small
8698 All rights reserved.
8695 All rights reserved.
8699 \layout Quote
8696 \layout Quote
8700
8697
8701
8698
8702 \family typewriter
8699 \family typewriter
8703 \size small
8700 \size small
8704 Redistribution and use in source and binary forms, with or without modification,
8701 Redistribution and use in source and binary forms, with or without modification,
8705 are permitted provided that the following conditions are met:
8702 are permitted provided that the following conditions are met:
8706 \layout Quote
8703 \layout Quote
8707
8704
8708
8705
8709 \family typewriter
8706 \family typewriter
8710 \size small
8707 \size small
8711 a.
8708 a.
8712 Redistributions of source code must retain the above copyright notice,
8709 Redistributions of source code must retain the above copyright notice,
8713 this list of conditions and the following disclaimer.
8710 this list of conditions and the following disclaimer.
8714 \layout Quote
8711 \layout Quote
8715
8712
8716
8713
8717 \family typewriter
8714 \family typewriter
8718 \size small
8715 \size small
8719 b.
8716 b.
8720 Redistributions in binary form must reproduce the above copyright notice,
8717 Redistributions in binary form must reproduce the above copyright notice,
8721 this list of conditions and the following disclaimer in the documentation
8718 this list of conditions and the following disclaimer in the documentation
8722 and/or other materials provided with the distribution.
8719 and/or other materials provided with the distribution.
8723 \layout Quote
8720 \layout Quote
8724
8721
8725
8722
8726 \family typewriter
8723 \family typewriter
8727 \size small
8724 \size small
8728 c.
8725 c.
8729 Neither the name of the copyright holders nor the names of any contributors
8726 Neither the name of the copyright holders nor the names of any contributors
8730 to this software may be used to endorse or promote products derived from
8727 to this software may be used to endorse or promote products derived from
8731 this software without specific prior written permission.
8728 this software without specific prior written permission.
8732 \layout Quote
8729 \layout Quote
8733
8730
8734
8731
8735 \family typewriter
8732 \family typewriter
8736 \size small
8733 \size small
8737 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8734 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8738 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8735 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8739 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8736 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8740 PURPOSE ARE DISCLAIMED.
8737 PURPOSE ARE DISCLAIMED.
8741 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8738 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8742 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8739 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8743 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8740 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8744 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8741 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8745 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8742 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8746 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8743 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8747 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8744 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8748
8745
8749 \layout Standard
8746 \layout Standard
8750
8747
8751 Individual authors are the holders of the copyright for their code and are
8748 Individual authors are the holders of the copyright for their code and are
8752 listed in each file.
8749 listed in each file.
8753 \layout Standard
8750 \layout Standard
8754
8751
8755 Some files (
8752 Some files (
8756 \family typewriter
8753 \family typewriter
8757 DPyGetOpt.py
8754 DPyGetOpt.py
8758 \family default
8755 \family default
8759 , for example) may be licensed under different conditions.
8756 , for example) may be licensed under different conditions.
8760 Ultimately each file indicates clearly the conditions under which its author/au
8757 Ultimately each file indicates clearly the conditions under which its author/au
8761 thors have decided to publish the code.
8758 thors have decided to publish the code.
8762 \layout Standard
8759 \layout Standard
8763
8760
8764 Versions of IPython up to and including 0.6.3 were released under the GNU
8761 Versions of IPython up to and including 0.6.3 were released under the GNU
8765 Lesser General Public License (LGPL), available at
8762 Lesser General Public License (LGPL), available at
8766 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8763 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8767
8764
8768 \end_inset
8765 \end_inset
8769
8766
8770 .
8767 .
8771 \layout Section
8768 \layout Section
8772
8769
8773
8770
8774 \begin_inset LatexCommand \label{sec:credits}
8771 \begin_inset LatexCommand \label{sec:credits}
8775
8772
8776 \end_inset
8773 \end_inset
8777
8774
8778 Credits
8775 Credits
8779 \layout Standard
8776 \layout Standard
8780
8777
8781 IPython is mainly developed by Fernando P
8778 IPython is mainly developed by Fernando P
8782 \begin_inset ERT
8779 \begin_inset ERT
8783 status Collapsed
8780 status Collapsed
8784
8781
8785 \layout Standard
8782 \layout Standard
8786
8783
8787 \backslash
8784 \backslash
8788 '{e}
8785 '{e}
8789 \end_inset
8786 \end_inset
8790
8787
8791 rez
8788 rez
8792 \family typewriter
8789 \family typewriter
8793 <fperez@colorado.edu>
8790 <fperez@colorado.edu>
8794 \family default
8791 \family default
8795 , but the project was born from mixing in Fernando's code with the IPP project
8792 , but the project was born from mixing in Fernando's code with the IPP project
8796 by Janko Hauser
8793 by Janko Hauser
8797 \family typewriter
8794 \family typewriter
8798 <jhauser-AT-zscout.de>
8795 <jhauser-AT-zscout.de>
8799 \family default
8796 \family default
8800 and LazyPython by Nathan Gray
8797 and LazyPython by Nathan Gray
8801 \family typewriter
8798 \family typewriter
8802 <n8gray-AT-caltech.edu>
8799 <n8gray-AT-caltech.edu>
8803 \family default
8800 \family default
8804 .
8801 .
8805 For all IPython-related requests, please contact Fernando.
8802 For all IPython-related requests, please contact Fernando.
8806
8803
8807 \layout Standard
8804 \layout Standard
8808
8805
8809 As of late 2005, the following developers have joined the core team:
8806 As of late 2005, the following developers have joined the core team:
8810 \layout List
8807 \layout List
8811 \labelwidthstring 00.00.0000
8808 \labelwidthstring 00.00.0000
8812
8809
8813 Robert\SpecialChar ~
8810 Robert\SpecialChar ~
8814 Kern
8811 Kern
8815 \family typewriter
8812 \family typewriter
8816 <rkern-AT-enthought.com>
8813 <rkern-AT-enthought.com>
8817 \family default
8814 \family default
8818 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8815 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8819 ve notebooks (XML documents) and graphical interface.
8816 ve notebooks (XML documents) and graphical interface.
8820 This project was awarded to the students Tzanko Matev
8817 This project was awarded to the students Tzanko Matev
8821 \family typewriter
8818 \family typewriter
8822 <tsanko-AT-gmail.com>
8819 <tsanko-AT-gmail.com>
8823 \family default
8820 \family default
8824 and Toni Alatalo
8821 and Toni Alatalo
8825 \family typewriter
8822 \family typewriter
8826 <antont-AT-an.org>
8823 <antont-AT-an.org>
8827 \layout List
8824 \layout List
8828 \labelwidthstring 00.00.0000
8825 \labelwidthstring 00.00.0000
8829
8826
8830 Brian\SpecialChar ~
8827 Brian\SpecialChar ~
8831 Granger
8828 Granger
8832 \family typewriter
8829 \family typewriter
8833 <bgranger-AT-scu.edu>
8830 <bgranger-AT-scu.edu>
8834 \family default
8831 \family default
8835 : extending IPython to allow support for interactive parallel computing.
8832 : extending IPython to allow support for interactive parallel computing.
8836 \layout Standard
8833 \layout Standard
8837
8834
8838 User or development help should be requested via the IPython mailing lists:
8835 User or development help should be requested via the IPython mailing lists:
8839 \layout Description
8836 \layout Description
8840
8837
8841 User\SpecialChar ~
8838 User\SpecialChar ~
8842 list:
8839 list:
8843 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8840 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8844
8841
8845 \end_inset
8842 \end_inset
8846
8843
8847
8844
8848 \layout Description
8845 \layout Description
8849
8846
8850 Developer's\SpecialChar ~
8847 Developer's\SpecialChar ~
8851 list:
8848 list:
8852 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8849 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8853
8850
8854 \end_inset
8851 \end_inset
8855
8852
8856
8853
8857 \layout Standard
8854 \layout Standard
8858
8855
8859 The IPython project is also very grateful to
8856 The IPython project is also very grateful to
8860 \begin_inset Foot
8857 \begin_inset Foot
8861 collapsed true
8858 collapsed true
8862
8859
8863 \layout Standard
8860 \layout Standard
8864
8861
8865 I've mangled email addresses to reduce spam, since the IPython manuals can
8862 I've mangled email addresses to reduce spam, since the IPython manuals can
8866 be accessed online.
8863 be accessed online.
8867 \end_inset
8864 \end_inset
8868
8865
8869 :
8866 :
8870 \layout Standard
8867 \layout Standard
8871
8868
8872 Bill Bumgarner
8869 Bill Bumgarner
8873 \family typewriter
8870 \family typewriter
8874 <bbum-AT-friday.com>
8871 <bbum-AT-friday.com>
8875 \family default
8872 \family default
8876 : for providing the DPyGetOpt module which gives very powerful and convenient
8873 : for providing the DPyGetOpt module which gives very powerful and convenient
8877 handling of command-line options (light years ahead of what Python 2.1.1's
8874 handling of command-line options (light years ahead of what Python 2.1.1's
8878 getopt module does).
8875 getopt module does).
8879 \layout Standard
8876 \layout Standard
8880
8877
8881 Ka-Ping Yee
8878 Ka-Ping Yee
8882 \family typewriter
8879 \family typewriter
8883 <ping-AT-lfw.org>
8880 <ping-AT-lfw.org>
8884 \family default
8881 \family default
8885 : for providing the Itpl module for convenient and powerful string interpolation
8882 : for providing the Itpl module for convenient and powerful string interpolation
8886 with a much nicer syntax than formatting through the '%' operator.
8883 with a much nicer syntax than formatting through the '%' operator.
8887 \layout Standard
8884 \layout Standard
8888
8885
8889 Arnd Baecker
8886 Arnd Baecker
8890 \family typewriter
8887 \family typewriter
8891 <baecker-AT-physik.tu-dresden.de>
8888 <baecker-AT-physik.tu-dresden.de>
8892 \family default
8889 \family default
8893 : for his many very useful suggestions and comments, and lots of help with
8890 : for his many very useful suggestions and comments, and lots of help with
8894 testing and documentation checking.
8891 testing and documentation checking.
8895 Many of IPython's newer features are a result of discussions with him (bugs
8892 Many of IPython's newer features are a result of discussions with him (bugs
8896 are still my fault, not his).
8893 are still my fault, not his).
8897 \layout Standard
8894 \layout Standard
8898
8895
8899 Obviously Guido van\SpecialChar ~
8896 Obviously Guido van\SpecialChar ~
8900 Rossum and the whole Python development team, that goes
8897 Rossum and the whole Python development team, that goes
8901 without saying.
8898 without saying.
8902 \layout Standard
8899 \layout Standard
8903
8900
8904 IPython's website is generously hosted at
8901 IPython's website is generously hosted at
8905 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8902 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8906
8903
8907 \end_inset
8904 \end_inset
8908
8905
8909 by Enthought (
8906 by Enthought (
8910 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8907 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8911
8908
8912 \end_inset
8909 \end_inset
8913
8910
8914 ).
8911 ).
8915 I am very grateful to them and all of the SciPy team for their contribution.
8912 I am very grateful to them and all of the SciPy team for their contribution.
8916 \layout Standard
8913 \layout Standard
8917
8914
8918
8915
8919 \begin_inset LatexCommand \label{figgins}
8916 \begin_inset LatexCommand \label{figgins}
8920
8917
8921 \end_inset
8918 \end_inset
8922
8919
8923 Fernando would also like to thank Stephen Figgins
8920 Fernando would also like to thank Stephen Figgins
8924 \family typewriter
8921 \family typewriter
8925 <fig-AT-monitor.net>
8922 <fig-AT-monitor.net>
8926 \family default
8923 \family default
8927 , an O'Reilly Python editor.
8924 , an O'Reilly Python editor.
8928 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8925 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8929 started.
8926 started.
8930 You can read it at:
8927 You can read it at:
8931 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8928 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8932
8929
8933 \end_inset
8930 \end_inset
8934
8931
8935 .
8932 .
8936 \layout Standard
8933 \layout Standard
8937
8934
8938 And last but not least, all the kind IPython users who have emailed new
8935 And last but not least, all the kind IPython users who have emailed new
8939 code, bug reports, fixes, comments and ideas.
8936 code, bug reports, fixes, comments and ideas.
8940 A brief list follows, please let me know if I have ommitted your name by
8937 A brief list follows, please let me know if I have ommitted your name by
8941 accident:
8938 accident:
8942 \layout List
8939 \layout List
8943 \labelwidthstring 00.00.0000
8940 \labelwidthstring 00.00.0000
8944
8941
8945 Jack\SpecialChar ~
8942 Jack\SpecialChar ~
8946 Moffit
8943 Moffit
8947 \family typewriter
8944 \family typewriter
8948 <jack-AT-xiph.org>
8945 <jack-AT-xiph.org>
8949 \family default
8946 \family default
8950 Bug fixes, including the infamous color problem.
8947 Bug fixes, including the infamous color problem.
8951 This bug alone caused many lost hours and frustration, many thanks to him
8948 This bug alone caused many lost hours and frustration, many thanks to him
8952 for the fix.
8949 for the fix.
8953 I've always been a fan of Ogg & friends, now I have one more reason to
8950 I've always been a fan of Ogg & friends, now I have one more reason to
8954 like these folks.
8951 like these folks.
8955 \newline
8952 \newline
8956 Jack is also contributing with Debian packaging and many other things.
8953 Jack is also contributing with Debian packaging and many other things.
8957 \layout List
8954 \layout List
8958 \labelwidthstring 00.00.0000
8955 \labelwidthstring 00.00.0000
8959
8956
8960 Alexander\SpecialChar ~
8957 Alexander\SpecialChar ~
8961 Schmolck
8958 Schmolck
8962 \family typewriter
8959 \family typewriter
8963 <a.schmolck-AT-gmx.net>
8960 <a.schmolck-AT-gmx.net>
8964 \family default
8961 \family default
8965 Emacs work, bug reports, bug fixes, ideas, lots more.
8962 Emacs work, bug reports, bug fixes, ideas, lots more.
8966 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8963 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8967 for IPython under (X)Emacs.
8964 for IPython under (X)Emacs.
8968 \layout List
8965 \layout List
8969 \labelwidthstring 00.00.0000
8966 \labelwidthstring 00.00.0000
8970
8967
8971 Andrea\SpecialChar ~
8968 Andrea\SpecialChar ~
8972 Riciputi
8969 Riciputi
8973 \family typewriter
8970 \family typewriter
8974 <andrea.riciputi-AT-libero.it>
8971 <andrea.riciputi-AT-libero.it>
8975 \family default
8972 \family default
8976 Mac OSX information, Fink package management.
8973 Mac OSX information, Fink package management.
8977 \layout List
8974 \layout List
8978 \labelwidthstring 00.00.0000
8975 \labelwidthstring 00.00.0000
8979
8976
8980 Gary\SpecialChar ~
8977 Gary\SpecialChar ~
8981 Bishop
8978 Bishop
8982 \family typewriter
8979 \family typewriter
8983 <gb-AT-cs.unc.edu>
8980 <gb-AT-cs.unc.edu>
8984 \family default
8981 \family default
8985 Bug reports, and patches to work around the exception handling idiosyncracies
8982 Bug reports, and patches to work around the exception handling idiosyncracies
8986 of WxPython.
8983 of WxPython.
8987 Readline and color support for Windows.
8984 Readline and color support for Windows.
8988 \layout List
8985 \layout List
8989 \labelwidthstring 00.00.0000
8986 \labelwidthstring 00.00.0000
8990
8987
8991 Jeffrey\SpecialChar ~
8988 Jeffrey\SpecialChar ~
8992 Collins
8989 Collins
8993 \family typewriter
8990 \family typewriter
8994 <Jeff.Collins-AT-vexcel.com>
8991 <Jeff.Collins-AT-vexcel.com>
8995 \family default
8992 \family default
8996 Bug reports.
8993 Bug reports.
8997 Much improved readline support, including fixes for Python 2.3.
8994 Much improved readline support, including fixes for Python 2.3.
8998 \layout List
8995 \layout List
8999 \labelwidthstring 00.00.0000
8996 \labelwidthstring 00.00.0000
9000
8997
9001 Dryice\SpecialChar ~
8998 Dryice\SpecialChar ~
9002 Liu
8999 Liu
9003 \family typewriter
9000 \family typewriter
9004 <dryice-AT-liu.com.cn>
9001 <dryice-AT-liu.com.cn>
9005 \family default
9002 \family default
9006 FreeBSD port.
9003 FreeBSD port.
9007 \layout List
9004 \layout List
9008 \labelwidthstring 00.00.0000
9005 \labelwidthstring 00.00.0000
9009
9006
9010 Mike\SpecialChar ~
9007 Mike\SpecialChar ~
9011 Heeter
9008 Heeter
9012 \family typewriter
9009 \family typewriter
9013 <korora-AT-SDF.LONESTAR.ORG>
9010 <korora-AT-SDF.LONESTAR.ORG>
9014 \layout List
9011 \layout List
9015 \labelwidthstring 00.00.0000
9012 \labelwidthstring 00.00.0000
9016
9013
9017 Christopher\SpecialChar ~
9014 Christopher\SpecialChar ~
9018 Hart
9015 Hart
9019 \family typewriter
9016 \family typewriter
9020 <hart-AT-caltech.edu>
9017 <hart-AT-caltech.edu>
9021 \family default
9018 \family default
9022 PDB integration.
9019 PDB integration.
9023 \layout List
9020 \layout List
9024 \labelwidthstring 00.00.0000
9021 \labelwidthstring 00.00.0000
9025
9022
9026 Milan\SpecialChar ~
9023 Milan\SpecialChar ~
9027 Zamazal
9024 Zamazal
9028 \family typewriter
9025 \family typewriter
9029 <pdm-AT-zamazal.org>
9026 <pdm-AT-zamazal.org>
9030 \family default
9027 \family default
9031 Emacs info.
9028 Emacs info.
9032 \layout List
9029 \layout List
9033 \labelwidthstring 00.00.0000
9030 \labelwidthstring 00.00.0000
9034
9031
9035 Philip\SpecialChar ~
9032 Philip\SpecialChar ~
9036 Hisley
9033 Hisley
9037 \family typewriter
9034 \family typewriter
9038 <compsys-AT-starpower.net>
9035 <compsys-AT-starpower.net>
9039 \layout List
9036 \layout List
9040 \labelwidthstring 00.00.0000
9037 \labelwidthstring 00.00.0000
9041
9038
9042 Holger\SpecialChar ~
9039 Holger\SpecialChar ~
9043 Krekel
9040 Krekel
9044 \family typewriter
9041 \family typewriter
9045 <pyth-AT-devel.trillke.net>
9042 <pyth-AT-devel.trillke.net>
9046 \family default
9043 \family default
9047 Tab completion, lots more.
9044 Tab completion, lots more.
9048 \layout List
9045 \layout List
9049 \labelwidthstring 00.00.0000
9046 \labelwidthstring 00.00.0000
9050
9047
9051 Robin\SpecialChar ~
9048 Robin\SpecialChar ~
9052 Siebler
9049 Siebler
9053 \family typewriter
9050 \family typewriter
9054 <robinsiebler-AT-starband.net>
9051 <robinsiebler-AT-starband.net>
9055 \layout List
9052 \layout List
9056 \labelwidthstring 00.00.0000
9053 \labelwidthstring 00.00.0000
9057
9054
9058 Ralf\SpecialChar ~
9055 Ralf\SpecialChar ~
9059 Ahlbrink
9056 Ahlbrink
9060 \family typewriter
9057 \family typewriter
9061 <ralf_ahlbrink-AT-web.de>
9058 <ralf_ahlbrink-AT-web.de>
9062 \layout List
9059 \layout List
9063 \labelwidthstring 00.00.0000
9060 \labelwidthstring 00.00.0000
9064
9061
9065 Thorsten\SpecialChar ~
9062 Thorsten\SpecialChar ~
9066 Kampe
9063 Kampe
9067 \family typewriter
9064 \family typewriter
9068 <thorsten-AT-thorstenkampe.de>
9065 <thorsten-AT-thorstenkampe.de>
9069 \layout List
9066 \layout List
9070 \labelwidthstring 00.00.0000
9067 \labelwidthstring 00.00.0000
9071
9068
9072 Fredrik\SpecialChar ~
9069 Fredrik\SpecialChar ~
9073 Kant
9070 Kant
9074 \family typewriter
9071 \family typewriter
9075 <fredrik.kant-AT-front.com>
9072 <fredrik.kant-AT-front.com>
9076 \family default
9073 \family default
9077 Windows setup.
9074 Windows setup.
9078 \layout List
9075 \layout List
9079 \labelwidthstring 00.00.0000
9076 \labelwidthstring 00.00.0000
9080
9077
9081 Syver\SpecialChar ~
9078 Syver\SpecialChar ~
9082 Enstad
9079 Enstad
9083 \family typewriter
9080 \family typewriter
9084 <syver-en-AT-online.no>
9081 <syver-en-AT-online.no>
9085 \family default
9082 \family default
9086 Windows setup.
9083 Windows setup.
9087 \layout List
9084 \layout List
9088 \labelwidthstring 00.00.0000
9085 \labelwidthstring 00.00.0000
9089
9086
9090 Richard
9087 Richard
9091 \family typewriter
9088 \family typewriter
9092 <rxe-AT-renre-europe.com>
9089 <rxe-AT-renre-europe.com>
9093 \family default
9090 \family default
9094 Global embedding.
9091 Global embedding.
9095 \layout List
9092 \layout List
9096 \labelwidthstring 00.00.0000
9093 \labelwidthstring 00.00.0000
9097
9094
9098 Hayden\SpecialChar ~
9095 Hayden\SpecialChar ~
9099 Callow
9096 Callow
9100 \family typewriter
9097 \family typewriter
9101 <h.callow-AT-elec.canterbury.ac.nz>
9098 <h.callow-AT-elec.canterbury.ac.nz>
9102 \family default
9099 \family default
9103 Gnuplot.py 1.6 compatibility.
9100 Gnuplot.py 1.6 compatibility.
9104 \layout List
9101 \layout List
9105 \labelwidthstring 00.00.0000
9102 \labelwidthstring 00.00.0000
9106
9103
9107 Leonardo\SpecialChar ~
9104 Leonardo\SpecialChar ~
9108 Santagada
9105 Santagada
9109 \family typewriter
9106 \family typewriter
9110 <retype-AT-terra.com.br>
9107 <retype-AT-terra.com.br>
9111 \family default
9108 \family default
9112 Fixes for Windows installation.
9109 Fixes for Windows installation.
9113 \layout List
9110 \layout List
9114 \labelwidthstring 00.00.0000
9111 \labelwidthstring 00.00.0000
9115
9112
9116 Christopher\SpecialChar ~
9113 Christopher\SpecialChar ~
9117 Armstrong
9114 Armstrong
9118 \family typewriter
9115 \family typewriter
9119 <radix-AT-twistedmatrix.com>
9116 <radix-AT-twistedmatrix.com>
9120 \family default
9117 \family default
9121 Bugfixes.
9118 Bugfixes.
9122 \layout List
9119 \layout List
9123 \labelwidthstring 00.00.0000
9120 \labelwidthstring 00.00.0000
9124
9121
9125 Francois\SpecialChar ~
9122 Francois\SpecialChar ~
9126 Pinard
9123 Pinard
9127 \family typewriter
9124 \family typewriter
9128 <pinard-AT-iro.umontreal.ca>
9125 <pinard-AT-iro.umontreal.ca>
9129 \family default
9126 \family default
9130 Code and documentation fixes.
9127 Code and documentation fixes.
9131 \layout List
9128 \layout List
9132 \labelwidthstring 00.00.0000
9129 \labelwidthstring 00.00.0000
9133
9130
9134 Cory\SpecialChar ~
9131 Cory\SpecialChar ~
9135 Dodt
9132 Dodt
9136 \family typewriter
9133 \family typewriter
9137 <cdodt-AT-fcoe.k12.ca.us>
9134 <cdodt-AT-fcoe.k12.ca.us>
9138 \family default
9135 \family default
9139 Bug reports and Windows ideas.
9136 Bug reports and Windows ideas.
9140 Patches for Windows installer.
9137 Patches for Windows installer.
9141 \layout List
9138 \layout List
9142 \labelwidthstring 00.00.0000
9139 \labelwidthstring 00.00.0000
9143
9140
9144 Olivier\SpecialChar ~
9141 Olivier\SpecialChar ~
9145 Aubert
9142 Aubert
9146 \family typewriter
9143 \family typewriter
9147 <oaubert-AT-bat710.univ-lyon1.fr>
9144 <oaubert-AT-bat710.univ-lyon1.fr>
9148 \family default
9145 \family default
9149 New magics.
9146 New magics.
9150 \layout List
9147 \layout List
9151 \labelwidthstring 00.00.0000
9148 \labelwidthstring 00.00.0000
9152
9149
9153 King\SpecialChar ~
9150 King\SpecialChar ~
9154 C.\SpecialChar ~
9151 C.\SpecialChar ~
9155 Shu
9152 Shu
9156 \family typewriter
9153 \family typewriter
9157 <kingshu-AT-myrealbox.com>
9154 <kingshu-AT-myrealbox.com>
9158 \family default
9155 \family default
9159 Autoindent patch.
9156 Autoindent patch.
9160 \layout List
9157 \layout List
9161 \labelwidthstring 00.00.0000
9158 \labelwidthstring 00.00.0000
9162
9159
9163 Chris\SpecialChar ~
9160 Chris\SpecialChar ~
9164 Drexler
9161 Drexler
9165 \family typewriter
9162 \family typewriter
9166 <chris-AT-ac-drexler.de>
9163 <chris-AT-ac-drexler.de>
9167 \family default
9164 \family default
9168 Readline packages for Win32/CygWin.
9165 Readline packages for Win32/CygWin.
9169 \layout List
9166 \layout List
9170 \labelwidthstring 00.00.0000
9167 \labelwidthstring 00.00.0000
9171
9168
9172 Gustavo\SpecialChar ~
9169 Gustavo\SpecialChar ~
9173 Cordova\SpecialChar ~
9170 Cordova\SpecialChar ~
9174 Avila
9171 Avila
9175 \family typewriter
9172 \family typewriter
9176 <gcordova-AT-sismex.com>
9173 <gcordova-AT-sismex.com>
9177 \family default
9174 \family default
9178 EvalDict code for nice, lightweight string interpolation.
9175 EvalDict code for nice, lightweight string interpolation.
9179 \layout List
9176 \layout List
9180 \labelwidthstring 00.00.0000
9177 \labelwidthstring 00.00.0000
9181
9178
9182 Kasper\SpecialChar ~
9179 Kasper\SpecialChar ~
9183 Souren
9180 Souren
9184 \family typewriter
9181 \family typewriter
9185 <Kasper.Souren-AT-ircam.fr>
9182 <Kasper.Souren-AT-ircam.fr>
9186 \family default
9183 \family default
9187 Bug reports, ideas.
9184 Bug reports, ideas.
9188 \layout List
9185 \layout List
9189 \labelwidthstring 00.00.0000
9186 \labelwidthstring 00.00.0000
9190
9187
9191 Gever\SpecialChar ~
9188 Gever\SpecialChar ~
9192 Tulley
9189 Tulley
9193 \family typewriter
9190 \family typewriter
9194 <gever-AT-helium.com>
9191 <gever-AT-helium.com>
9195 \family default
9192 \family default
9196 Code contributions.
9193 Code contributions.
9197 \layout List
9194 \layout List
9198 \labelwidthstring 00.00.0000
9195 \labelwidthstring 00.00.0000
9199
9196
9200 Ralf\SpecialChar ~
9197 Ralf\SpecialChar ~
9201 Schmitt
9198 Schmitt
9202 \family typewriter
9199 \family typewriter
9203 <ralf-AT-brainbot.com>
9200 <ralf-AT-brainbot.com>
9204 \family default
9201 \family default
9205 Bug reports & fixes.
9202 Bug reports & fixes.
9206 \layout List
9203 \layout List
9207 \labelwidthstring 00.00.0000
9204 \labelwidthstring 00.00.0000
9208
9205
9209 Oliver\SpecialChar ~
9206 Oliver\SpecialChar ~
9210 Sander
9207 Sander
9211 \family typewriter
9208 \family typewriter
9212 <osander-AT-gmx.de>
9209 <osander-AT-gmx.de>
9213 \family default
9210 \family default
9214 Bug reports.
9211 Bug reports.
9215 \layout List
9212 \layout List
9216 \labelwidthstring 00.00.0000
9213 \labelwidthstring 00.00.0000
9217
9214
9218 Rod\SpecialChar ~
9215 Rod\SpecialChar ~
9219 Holland
9216 Holland
9220 \family typewriter
9217 \family typewriter
9221 <rhh-AT-structurelabs.com>
9218 <rhh-AT-structurelabs.com>
9222 \family default
9219 \family default
9223 Bug reports and fixes to logging module.
9220 Bug reports and fixes to logging module.
9224 \layout List
9221 \layout List
9225 \labelwidthstring 00.00.0000
9222 \labelwidthstring 00.00.0000
9226
9223
9227 Daniel\SpecialChar ~
9224 Daniel\SpecialChar ~
9228 'Dang'\SpecialChar ~
9225 'Dang'\SpecialChar ~
9229 Griffith
9226 Griffith
9230 \family typewriter
9227 \family typewriter
9231 <pythondev-dang-AT-lazytwinacres.net>
9228 <pythondev-dang-AT-lazytwinacres.net>
9232 \family default
9229 \family default
9233 Fixes, enhancement suggestions for system shell use.
9230 Fixes, enhancement suggestions for system shell use.
9234 \layout List
9231 \layout List
9235 \labelwidthstring 00.00.0000
9232 \labelwidthstring 00.00.0000
9236
9233
9237 Viktor\SpecialChar ~
9234 Viktor\SpecialChar ~
9238 Ransmayr
9235 Ransmayr
9239 \family typewriter
9236 \family typewriter
9240 <viktor.ransmayr-AT-t-online.de>
9237 <viktor.ransmayr-AT-t-online.de>
9241 \family default
9238 \family default
9242 Tests and reports on Windows installation issues.
9239 Tests and reports on Windows installation issues.
9243 Contributed a true Windows binary installer.
9240 Contributed a true Windows binary installer.
9244 \layout List
9241 \layout List
9245 \labelwidthstring 00.00.0000
9242 \labelwidthstring 00.00.0000
9246
9243
9247 Mike\SpecialChar ~
9244 Mike\SpecialChar ~
9248 Salib
9245 Salib
9249 \family typewriter
9246 \family typewriter
9250 <msalib-AT-mit.edu>
9247 <msalib-AT-mit.edu>
9251 \family default
9248 \family default
9252 Help fixing a subtle bug related to traceback printing.
9249 Help fixing a subtle bug related to traceback printing.
9253 \layout List
9250 \layout List
9254 \labelwidthstring 00.00.0000
9251 \labelwidthstring 00.00.0000
9255
9252
9256 W.J.\SpecialChar ~
9253 W.J.\SpecialChar ~
9257 van\SpecialChar ~
9254 van\SpecialChar ~
9258 der\SpecialChar ~
9255 der\SpecialChar ~
9259 Laan
9256 Laan
9260 \family typewriter
9257 \family typewriter
9261 <gnufnork-AT-hetdigitalegat.nl>
9258 <gnufnork-AT-hetdigitalegat.nl>
9262 \family default
9259 \family default
9263 Bash-like prompt specials.
9260 Bash-like prompt specials.
9264 \layout List
9261 \layout List
9265 \labelwidthstring 00.00.0000
9262 \labelwidthstring 00.00.0000
9266
9263
9267 Ville\SpecialChar ~
9264 Ville\SpecialChar ~
9268 Vainio
9265 Vainio
9269 \family typewriter
9266 \family typewriter
9270 <vivainio-AT-kolumbus.fi>
9267 <vivainio-AT-kolumbus.fi>
9271 \family default
9268 \family default
9272 Bugfixes and suggestions.
9269 Bugfixes and suggestions.
9273 Excellent patches for many new features.
9270 Excellent patches for many new features.
9274 \layout List
9271 \layout List
9275 \labelwidthstring 00.00.0000
9272 \labelwidthstring 00.00.0000
9276
9273
9277 Antoon\SpecialChar ~
9274 Antoon\SpecialChar ~
9278 Pardon
9275 Pardon
9279 \family typewriter
9276 \family typewriter
9280 <Antoon.Pardon-AT-rece.vub.ac.be>
9277 <Antoon.Pardon-AT-rece.vub.ac.be>
9281 \family default
9278 \family default
9282 Critical fix for the multithreaded IPython.
9279 Critical fix for the multithreaded IPython.
9283 \layout List
9280 \layout List
9284 \labelwidthstring 00.00.0000
9281 \labelwidthstring 00.00.0000
9285
9282
9286 John\SpecialChar ~
9283 John\SpecialChar ~
9287 Hunter
9284 Hunter
9288 \family typewriter
9285 \family typewriter
9289 <jdhunter-AT-nitace.bsd.uchicago.edu>
9286 <jdhunter-AT-nitace.bsd.uchicago.edu>
9290 \family default
9287 \family default
9291 Matplotlib author, helped with all the development of support for matplotlib
9288 Matplotlib author, helped with all the development of support for matplotlib
9292 in IPyhton, including making necessary changes to matplotlib itself.
9289 in IPyhton, including making necessary changes to matplotlib itself.
9293 \layout List
9290 \layout List
9294 \labelwidthstring 00.00.0000
9291 \labelwidthstring 00.00.0000
9295
9292
9296 Matthew\SpecialChar ~
9293 Matthew\SpecialChar ~
9297 Arnison
9294 Arnison
9298 \family typewriter
9295 \family typewriter
9299 <maffew-AT-cat.org.au>
9296 <maffew-AT-cat.org.au>
9300 \family default
9297 \family default
9301 Bug reports, `
9298 Bug reports, `
9302 \family typewriter
9299 \family typewriter
9303 %run -d
9300 %run -d
9304 \family default
9301 \family default
9305 ' idea.
9302 ' idea.
9306 \layout List
9303 \layout List
9307 \labelwidthstring 00.00.0000
9304 \labelwidthstring 00.00.0000
9308
9305
9309 Prabhu\SpecialChar ~
9306 Prabhu\SpecialChar ~
9310 Ramachandran
9307 Ramachandran
9311 \family typewriter
9308 \family typewriter
9312 <prabhu_r-AT-users.sourceforge.net>
9309 <prabhu_r-AT-users.sourceforge.net>
9313 \family default
9310 \family default
9314 Help with (X)Emacs support, threading patches, ideas...
9311 Help with (X)Emacs support, threading patches, ideas...
9315 \layout List
9312 \layout List
9316 \labelwidthstring 00.00.0000
9313 \labelwidthstring 00.00.0000
9317
9314
9318 Norbert\SpecialChar ~
9315 Norbert\SpecialChar ~
9319 Tretkowski
9316 Tretkowski
9320 \family typewriter
9317 \family typewriter
9321 <tretkowski-AT-inittab.de>
9318 <tretkowski-AT-inittab.de>
9322 \family default
9319 \family default
9323 help with Debian packaging and distribution.
9320 help with Debian packaging and distribution.
9324 \layout List
9321 \layout List
9325 \labelwidthstring 00.00.0000
9322 \labelwidthstring 00.00.0000
9326
9323
9327 George\SpecialChar ~
9324 George\SpecialChar ~
9328 Sakkis <
9325 Sakkis <
9329 \family typewriter
9326 \family typewriter
9330 gsakkis-AT-eden.rutgers.edu>
9327 gsakkis-AT-eden.rutgers.edu>
9331 \family default
9328 \family default
9332 New matcher for tab-completing named arguments of user-defined functions.
9329 New matcher for tab-completing named arguments of user-defined functions.
9333 \layout List
9330 \layout List
9334 \labelwidthstring 00.00.0000
9331 \labelwidthstring 00.00.0000
9335
9332
9336 JοΏ½rgen\SpecialChar ~
9333 JοΏ½rgen\SpecialChar ~
9337 Stenarson
9334 Stenarson
9338 \family typewriter
9335 \family typewriter
9339 <jorgen.stenarson-AT-bostream.nu>
9336 <jorgen.stenarson-AT-bostream.nu>
9340 \family default
9337 \family default
9341 Wildcard support implementation for searching namespaces.
9338 Wildcard support implementation for searching namespaces.
9342 \layout List
9339 \layout List
9343 \labelwidthstring 00.00.0000
9340 \labelwidthstring 00.00.0000
9344
9341
9345 Vivian\SpecialChar ~
9342 Vivian\SpecialChar ~
9346 De\SpecialChar ~
9343 De\SpecialChar ~
9347 Smedt
9344 Smedt
9348 \family typewriter
9345 \family typewriter
9349 <vivian-AT-vdesmedt.com>
9346 <vivian-AT-vdesmedt.com>
9350 \family default
9347 \family default
9351 Debugger enhancements, so that when pdb is activated from within IPython,
9348 Debugger enhancements, so that when pdb is activated from within IPython,
9352 coloring, tab completion and other features continue to work seamlessly.
9349 coloring, tab completion and other features continue to work seamlessly.
9353 \layout List
9350 \layout List
9354 \labelwidthstring 00.00.0000
9351 \labelwidthstring 00.00.0000
9355
9352
9356 Scott\SpecialChar ~
9353 Scott\SpecialChar ~
9357 Tsai
9354 Tsai
9358 \family typewriter
9355 \family typewriter
9359 <scottt958-AT-yahoo.com.tw>
9356 <scottt958-AT-yahoo.com.tw>
9360 \family default
9357 \family default
9361 Support for automatic editor invocation on syntax errors (see
9358 Support for automatic editor invocation on syntax errors (see
9362 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9359 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9363
9360
9364 \end_inset
9361 \end_inset
9365
9362
9366 ).
9363 ).
9367 \layout List
9364 \layout List
9368 \labelwidthstring 00.00.0000
9365 \labelwidthstring 00.00.0000
9369
9366
9370 Alexander\SpecialChar ~
9367 Alexander\SpecialChar ~
9371 Belchenko
9368 Belchenko
9372 \family typewriter
9369 \family typewriter
9373 <bialix-AT-ukr.net>
9370 <bialix-AT-ukr.net>
9374 \family default
9371 \family default
9375 Improvements for win32 paging system.
9372 Improvements for win32 paging system.
9376 \the_end
9373 \the_end
@@ -1,103 +1,103 b''
1 #!/bin/sh
1 #!/bin/sh
2 # IPython release script
2 # IPython release script
3
3
4 PYVER=`python -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1$2}' `
4 PYVER=`python -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1$2}' `
5 version=`ipython -Version`
5 version=`ipython -Version`
6 ipdir=~/ipython/ipython
6 ipdir=~/ipython/ipython
7
7
8 echo
8 echo
9 echo "Releasing IPython version $version"
9 echo "Releasing IPython version $version"
10 echo "=================================="
10 echo "=================================="
11
11
12 echo "Marking ChangeLog with release information and making NEWS file..."
12 echo "Marking ChangeLog with release information and making NEWS file..."
13
13
14 # Stamp changelog and save a copy of the status at each version, in case later
14 # Stamp changelog and save a copy of the status at each version, in case later
15 # we want the NEWS file to start from a point before the very last release (if
15 # we want the NEWS file to start from a point before the very last release (if
16 # very small interim releases have no significant changes).
16 # very small interim releases have no significant changes).
17
17
18 cd $ipdir/doc
18 cd $ipdir/doc
19 cp ChangeLog ChangeLog.old
19 cp ChangeLog ChangeLog.old
20 cp ChangeLog ChangeLog.$version
20 cp ChangeLog ChangeLog.$version
21 daystamp=`date +%Y-%m-%d`
21 daystamp=`date +%Y-%m-%d`
22 echo $daystamp " ***" Released version $version > ChangeLog
22 echo $daystamp " ***" Released version $version > ChangeLog
23 echo >> ChangeLog
23 echo >> ChangeLog
24 cat ChangeLog.old >> ChangeLog
24 cat ChangeLog.old >> ChangeLog
25 rm ChangeLog.old
25 rm ChangeLog.old
26
26
27 # Build NEWS file
27 # Build NEWS file
28 echo "Changes between the last two releases (major or minor)" > NEWS
28 echo "Changes between the last two releases (major or minor)" > NEWS
29 echo "Note that this is an auto-generated diff of the ChangeLogs" >> NEWS
29 echo "Note that this is an auto-generated diff of the ChangeLogs" >> NEWS
30 echo >> NEWS
30 echo >> NEWS
31 diff ChangeLog.previous ChangeLog | grep -v '^0a' | sed 's/^> //g' >> NEWS
31 diff ChangeLog.previous ChangeLog | grep -v '^0a' | sed 's/^> //g' >> NEWS
32 cp ChangeLog ChangeLog.previous
32 cp ChangeLog ChangeLog.previous
33
33
34 # Clean up build/dist directories
34 # Clean up build/dist directories
35 rm -rf $ipdir/build/*
35 rm -rf $ipdir/build/*
36 rm -rf $ipdir/dist/*
36 rm -rf $ipdir/dist/*
37
37
38 # Perform local backup
38 # Perform local backup
39 cd $ipdir/tools
39 cd $ipdir/tools
40 ./bkp.py
40 ./bkp.py
41
41
42 # Build source and binary distros
42 # Build source and binary distros
43 cd $ipdir
43 cd $ipdir
44 ./setup.py sdist --formats=gztar
44 ./setup.py sdist --formats=gztar
45 #./setup.py bdist_rpm --release=py$PYVER
45 #./setup.py bdist_rpm --release=py$PYVER
46 python2.3 ./setup.py bdist_rpm --release=py23 --python=/usr/bin/python2.3
46 python2.3 ./setup.py bdist_rpm --release=py23 --python=/usr/bin/python2.3
47
47
48 # A 2.4-specific RPM, where we must use the --python option to ensure that
48 # A 2.4-specific RPM, where we must use the --python option to ensure that
49 # the resulting RPM is really built with 2.4 (so things go to
49 # the resulting RPM is really built with 2.4 (so things go to
50 # lib/python2.4/...)
50 # lib/python2.4/...)
51 python2.4 ./setup.py bdist_rpm --release=py24 --python=/usr/bin/python2.4
51 python2.4 ./setup.py bdist_rpm --release=py24 --python=/usr/bin/python2.4
52
52
53 # Build eggs
53 # Build eggs
54 python2.3 ./setup_bdist_egg.py
54 python2.3 ./setup_bdist_egg.py
55 python2.4 ./setup_bdist_egg.py
55 python2.4 ./setup_bdist_egg.py
56
56
57 # Call the windows build separately, so that the extra Windows scripts don't
57 # Call the windows build separately, so that the extra Windows scripts don't
58 # get pulled into Unix builds (setup.py has code which checks for
58 # get pulled into Unix builds (setup.py has code which checks for
59 # bdist_wininst)
59 # bdist_wininst)
60 #./setup.py bdist_wininst --install-script=ipython_win_post_install.py
60 #./setup.py bdist_wininst --install-script=ipython_win_post_install.py
61
61
62 # For now, make the win32 installer with a hand-built 2.3.5 python, which is
62 # For now, make the win32 installer with a hand-built 2.3.5 python, which is
63 # the only one that fixes a crash in the post-install phase.
63 # the only one that fixes a crash in the post-install phase.
64 $HOME/tmp/local/bin/python2.3 setup.py bdist_wininst \
64 $HOME/tmp/local/bin/python2.3 setup.py bdist_wininst \
65 --install-script=ipython_win_post_install.py
65 --install-script=ipython_win_post_install.py
66
66
67
67
68 # Register with the Python Package Index (PyPI)
68 # Register with the Python Package Index (PyPI)
69 echo "Registering with PyPI..."
69 echo "Registering with PyPI..."
70 cd $ipdir
70 cd $ipdir
71 ./setup.py register
71 ./setup.py register
72
72
73 # Upload all files
73 # Upload all files
74 cd $ipdir/dist
74 cd $ipdir/dist
75 echo "Uploading distribution files..."
75 echo "Uploading distribution files..."
76 scp * fperez@scipy.org:www/dist/
76 scp * ipython@ipython.scipy.org:www/dist/
77
77
78 echo "Uploading backup files..."
78 echo "Uploading backup files..."
79 cd ~/ipython/backup
79 cd ~/ipython/backup
80 scp `ls -1tr | tail -1` fperez@scipy.org:www/backup/
80 scp `ls -1tr | tail -1` ipython@ipython.scipy.org:www/backup/
81
81
82 echo "Updating webpage..."
82 echo "Updating webpage..."
83 cd $ipdir/doc
83 cd $ipdir/doc
84 www=~/ipython/homepage
84 www=~/ipython/homepage
85 cp ChangeLog NEWS $www
85 cp ChangeLog NEWS $www
86 rm -rf $www/doc/*
86 rm -rf $www/doc/*
87 cp -r manual.pdf manual/ $www/doc
87 cp -r manual.pdf manual/ $www/doc
88 cd $www
88 cd $www
89 ./update
89 ./update
90
90
91 # Alert package maintainers
91 # Alert package maintainers
92 echo "Alerting package maintainers..."
92 echo "Alerting package maintainers..."
93 maintainers='fperez@colorado.edu ariciputi@users.sourceforge.net jack@xiph.org tretkowski@inittab.de dryice@hotpop.com'
93 maintainers='fperez@colorado.edu ariciputi@users.sourceforge.net jack@xiph.org tretkowski@inittab.de dryice@hotpop.com'
94 #maintainers='fperez@colorado.edu'
94 #maintainers='fperez@colorado.edu'
95
95
96 for email in $maintainers
96 for email in $maintainers
97 do
97 do
98 echo "Emailing $email..."
98 echo "Emailing $email..."
99 mail -s "[Package maintainer notice] A new IPython is out. Version: $version" \
99 mail -s "[Package maintainer notice] A new IPython is out. Version: $version" \
100 $email < NEWS
100 $email < NEWS
101 done
101 done
102
102
103 echo "Done!"
103 echo "Done!"
General Comments 0
You need to be logged in to leave comments. Login now