##// END OF EJS Templates
Namespace fixes for embedded instances, as well as tab-complete enhancements...
fperez -
Show More
@@ -1,192 +1,214 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Word completion for GNU readline 2.0.
2 """Word completion for GNU readline 2.0.
3
3
4 ---------------------------------------------------------------------------
4 ---------------------------------------------------------------------------
5 NOTE: This version is a re-implementation of rlcompleter with selectable
5 NOTE: This version is a re-implementation of rlcompleter with selectable
6 namespace.
6 namespace.
7
7
8 The problem with rlcompleter is that it's hardwired to work with
8 The problem with rlcompleter is that it's hardwired to work with
9 __main__.__dict__, and in some cases one may have 'sandboxed' namespaces. So
9 __main__.__dict__, and in some cases one may have 'sandboxed' namespaces. So
10 this class is a ripoff of rlcompleter, with the namespace to work in as an
10 this class is a ripoff of rlcompleter, with the namespace to work in as an
11 optional parameter.
11 optional parameter.
12
12
13 This class can be used just like rlcompleter, but the Completer class now has
13 This class can be used just like rlcompleter, but the Completer class now has
14 a constructor with the optional 'namespace' parameter.
14 a constructor with the optional 'namespace' parameter.
15
15
16 A patch has been submitted to Python@sourceforge for these changes to go in
16 A patch has been submitted to Python@sourceforge for these changes to go in
17 the standard Python distribution.
17 the standard Python distribution.
18
18
19 The patch went in for Python 2.3. Once IPython drops support for Python 2.2,
19 The patch went in for Python 2.3. Once IPython drops support for Python 2.2,
20 this file can be significantly reduced.
20 this file can be significantly reduced.
21 ---------------------------------------------------------------------------
21 ---------------------------------------------------------------------------
22
22
23 Original rlcompleter documentation:
23 Original rlcompleter documentation:
24
24
25 This requires the latest extension to the readline module (the
25 This requires the latest extension to the readline module (the
26 completes keywords, built-ins and globals in __main__; when completing
26 completes keywords, built-ins and globals in __main__; when completing
27 NAME.NAME..., it evaluates (!) the expression up to the last dot and
27 NAME.NAME..., it evaluates (!) the expression up to the last dot and
28 completes its attributes.
28 completes its attributes.
29
29
30 It's very cool to do "import string" type "string.", hit the
30 It's very cool to do "import string" type "string.", hit the
31 completion key (twice), and see the list of names defined by the
31 completion key (twice), and see the list of names defined by the
32 string module!
32 string module!
33
33
34 Tip: to use the tab key as the completion key, call
34 Tip: to use the tab key as the completion key, call
35
35
36 readline.parse_and_bind("tab: complete")
36 readline.parse_and_bind("tab: complete")
37
37
38 Notes:
38 Notes:
39
39
40 - Exceptions raised by the completer function are *ignored* (and
40 - Exceptions raised by the completer function are *ignored* (and
41 generally cause the completion to fail). This is a feature -- since
41 generally cause the completion to fail). This is a feature -- since
42 readline sets the tty device in raw (or cbreak) mode, printing a
42 readline sets the tty device in raw (or cbreak) mode, printing a
43 traceback wouldn't work well without some complicated hoopla to save,
43 traceback wouldn't work well without some complicated hoopla to save,
44 reset and restore the tty state.
44 reset and restore the tty state.
45
45
46 - The evaluation of the NAME.NAME... form may cause arbitrary
46 - The evaluation of the NAME.NAME... form may cause arbitrary
47 application defined code to be executed if an object with a
47 application defined code to be executed if an object with a
48 __getattr__ hook is found. Since it is the responsibility of the
48 __getattr__ hook is found. Since it is the responsibility of the
49 application (or the user) to enable this feature, I consider this an
49 application (or the user) to enable this feature, I consider this an
50 acceptable risk. More complicated expressions (e.g. function calls or
50 acceptable risk. More complicated expressions (e.g. function calls or
51 indexing operations) are *not* evaluated.
51 indexing operations) are *not* evaluated.
52
52
53 - GNU readline is also used by the built-in functions input() and
53 - GNU readline is also used by the built-in functions input() and
54 raw_input(), and thus these also benefit/suffer from the completer
54 raw_input(), and thus these also benefit/suffer from the completer
55 features. Clearly an interactive application can benefit by
55 features. Clearly an interactive application can benefit by
56 specifying its own completer function and using raw_input() for all
56 specifying its own completer function and using raw_input() for all
57 its input.
57 its input.
58
58
59 - When the original stdin is not a tty device, GNU readline is never
59 - When the original stdin is not a tty device, GNU readline is never
60 used, and this module (and the readline module) are silently inactive.
60 used, and this module (and the readline module) are silently inactive.
61
61
62 """
62 """
63
63
64 #*****************************************************************************
64 #*****************************************************************************
65 #
65 #
66 # Since this file is essentially a minimally modified copy of the rlcompleter
66 # Since this file is essentially a minimally modified copy of the rlcompleter
67 # module which is part of the standard Python distribution, I assume that the
67 # module which is part of the standard Python distribution, I assume that the
68 # proper procedure is to maintain its copyright as belonging to the Python
68 # proper procedure is to maintain its copyright as belonging to the Python
69 # Software Foundation:
69 # Software Foundation:
70 #
70 #
71 # Copyright (C) 2001 Python Software Foundation, www.python.org
71 # Copyright (C) 2001 Python Software Foundation, www.python.org
72 #
72 #
73 # Distributed under the terms of the Python Software Foundation license.
73 # Distributed under the terms of the Python Software Foundation license.
74 #
74 #
75 # Full text available at:
75 # Full text available at:
76 #
76 #
77 # http://www.python.org/2.1/license.html
77 # http://www.python.org/2.1/license.html
78 #
78 #
79 #*****************************************************************************
79 #*****************************************************************************
80
80
81 import readline
82 import __builtin__
81 import __builtin__
83 import __main__
82 import __main__
83 import readline
84 import keyword
85 import types
84
86
85 __all__ = ["Completer"]
87 __all__ = ["Completer"]
86
88
87 class Completer:
89 class Completer:
88 def __init__(self, namespace = None):
90 def __init__(self,namespace=None,global_namespace=None):
89 """Create a new completer for the command line.
91 """Create a new completer for the command line.
90
92
91 Completer([namespace]) -> completer instance.
93 Completer([namespace,global_namespace]) -> completer instance.
92
94
93 If unspecified, the default namespace where completions are performed
95 If unspecified, the default namespace where completions are performed
94 is __main__ (technically, __main__.__dict__). Namespaces should be
96 is __main__ (technically, __main__.__dict__). Namespaces should be
95 given as dictionaries.
97 given as dictionaries.
96
98
99 An optional second namespace can be given. This allows the completer
100 to handle cases where both the local and global scopes need to be
101 distinguished.
102
97 Completer instances should be used as the completion mechanism of
103 Completer instances should be used as the completion mechanism of
98 readline via the set_completer() call:
104 readline via the set_completer() call:
99
105
100 readline.set_completer(Completer(my_namespace).complete)
106 readline.set_completer(Completer(my_namespace).complete)
101 """
107 """
102
108
103 if namespace and type(namespace) != type({}):
109 if namespace and type(namespace) != types.DictType:
104 raise TypeError,'namespace must be a dictionary'
110 raise TypeError,'namespace must be a dictionary'
105
111
112 if global_namespace and type(global_namespace) != types.DictType:
113 raise TypeError,'global_namespace must be a dictionary'
114
106 # Don't bind to namespace quite yet, but flag whether the user wants a
115 # Don't bind to namespace quite yet, but flag whether the user wants a
107 # specific namespace or to use __main__.__dict__. This will allow us
116 # specific namespace or to use __main__.__dict__. This will allow us
108 # to bind to __main__.__dict__ at completion time, not now.
117 # to bind to __main__.__dict__ at completion time, not now.
109 if namespace is None:
118 if namespace is None:
110 self.use_main_ns = 1
119 self.use_main_ns = 1
111 else:
120 else:
112 self.use_main_ns = 0
121 self.use_main_ns = 0
113 self.namespace = namespace
122 self.namespace = namespace
114
123
124 # The global namespace, if given, can be bound directly
125 if global_namespace is None:
126 self.global_namespace = {}
127 else:
128 self.global_namespace = global_namespace
129
115 def complete(self, text, state):
130 def complete(self, text, state):
116 """Return the next possible completion for 'text'.
131 """Return the next possible completion for 'text'.
117
132
118 This is called successively with state == 0, 1, 2, ... until it
133 This is called successively with state == 0, 1, 2, ... until it
119 returns None. The completion should begin with 'text'.
134 returns None. The completion should begin with 'text'.
120
135
121 """
136 """
122 if self.use_main_ns:
137 if self.use_main_ns:
123 self.namespace = __main__.__dict__
138 self.namespace = __main__.__dict__
124
139
125 if state == 0:
140 if state == 0:
126 if "." in text:
141 if "." in text:
127 self.matches = self.attr_matches(text)
142 self.matches = self.attr_matches(text)
128 else:
143 else:
129 self.matches = self.global_matches(text)
144 self.matches = self.global_matches(text)
130 try:
145 try:
131 return self.matches[state]
146 return self.matches[state]
132 except IndexError:
147 except IndexError:
133 return None
148 return None
134
149
135 def global_matches(self, text):
150 def global_matches(self, text):
136 """Compute matches when text is a simple name.
151 """Compute matches when text is a simple name.
137
152
138 Return a list of all keywords, built-in functions and names currently
153 Return a list of all keywords, built-in functions and names currently
139 defined in self.namespace that match.
154 defined in self.namespace or self.global_namespace that match.
140
155
141 """
156 """
142 import keyword
143 matches = []
157 matches = []
158 match_append = matches.append
144 n = len(text)
159 n = len(text)
145 for list in [keyword.kwlist,
160 for lst in [keyword.kwlist,
146 __builtin__.__dict__.keys(),
161 __builtin__.__dict__.keys(),
147 self.namespace.keys()]:
162 self.namespace.keys(),
148 for word in list:
163 self.global_namespace.keys()]:
164 for word in lst:
149 if word[:n] == text and word != "__builtins__":
165 if word[:n] == text and word != "__builtins__":
150 matches.append(word)
166 match_append(word)
151 return matches
167 return matches
152
168
153 def attr_matches(self, text):
169 def attr_matches(self, text):
154 """Compute matches when text contains a dot.
170 """Compute matches when text contains a dot.
155
171
156 Assuming the text is of the form NAME.NAME....[NAME], and is
172 Assuming the text is of the form NAME.NAME....[NAME], and is
157 evaluatable in self.namespace, it will be evaluated and its attributes
173 evaluatable in self.namespace or self.global_namespace, it will be
158 (as revealed by dir()) are used as possible completions. (For class
174 evaluated and its attributes (as revealed by dir()) are used as
159 instances, class members are are also considered.)
175 possible completions. (For class instances, class members are are
176 also considered.)
160
177
161 WARNING: this can still invoke arbitrary C code, if an object
178 WARNING: this can still invoke arbitrary C code, if an object
162 with a __getattr__ hook is evaluated.
179 with a __getattr__ hook is evaluated.
163
180
164 """
181 """
165 import re
182 import re
166
183
167 # Another option, seems to work great. Catches things like ''.<tab>
184 # Another option, seems to work great. Catches things like ''.<tab>
168 m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text)
185 m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text)
169
186
170 if not m:
187 if not m:
171 return []
188 return []
172 expr, attr = m.group(1, 3)
189 expr, attr = m.group(1, 3)
173 object = eval(expr, self.namespace)
190 print 'expr:',expr # dbg
191 try:
192 object = eval(expr, self.namespace)
193 except:
194 object = eval(expr, self.global_namespace)
195 print 'obj:',object # dbg
174 words = [w for w in dir(object) if isinstance(w, basestring)]
196 words = [w for w in dir(object) if isinstance(w, basestring)]
175 if hasattr(object,'__class__'):
197 if hasattr(object,'__class__'):
176 words.append('__class__')
198 words.append('__class__')
177 words.extend(get_class_members(object.__class__))
199 words.extend(get_class_members(object.__class__))
178 n = len(attr)
200 n = len(attr)
179 matches = []
201 matches = []
180 for word in words:
202 for word in words:
181 if word[:n] == attr and word != "__builtins__":
203 if word[:n] == attr and word != "__builtins__":
182 matches.append("%s.%s" % (expr, word))
204 matches.append("%s.%s" % (expr, word))
183 return matches
205 return matches
184
206
185 def get_class_members(klass):
207 def get_class_members(klass):
186 ret = dir(klass)
208 ret = dir(klass)
187 if hasattr(klass,'__bases__'):
209 if hasattr(klass,'__bases__'):
188 for base in klass.__bases__:
210 for base in klass.__bases__:
189 ret.extend(get_class_members(base))
211 ret.extend(get_class_members(base))
190 return ret
212 return ret
191
213
192 readline.set_completer(Completer().complete)
214 readline.set_completer(Completer().complete)
@@ -1,900 +1,901 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 927 2005-12-08 23:19:59Z fperez $"""
7 $Id: Shell.py 952 2005-12-26 17:51:33Z fperez $"""
8
8
9 #*****************************************************************************
9 #*****************************************************************************
10 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
10 # Copyright (C) 2001-2004 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 sys
23 import sys
24 import os
24 import os
25 import code
25 import code
26 import threading
26 import threading
27 import signal
27 import signal
28
28
29 import IPython
29 import IPython
30 from IPython.iplib import InteractiveShell
30 from IPython.iplib import InteractiveShell
31 from IPython.ipmaker import make_IPython
31 from IPython.ipmaker import make_IPython
32 from IPython.genutils import Term,warn,error,flag_calls
32 from IPython.genutils import Term,warn,error,flag_calls
33 from IPython.Struct import Struct
33 from IPython.Struct import Struct
34 from IPython.Magic import Magic
34 from IPython.Magic import Magic
35 from IPython import ultraTB
35 from IPython import ultraTB
36
36
37 # global flag to pass around information about Ctrl-C without exceptions
37 # global flag to pass around information about Ctrl-C without exceptions
38 KBINT = False
38 KBINT = False
39
39
40 # global flag to turn on/off Tk support.
40 # global flag to turn on/off Tk support.
41 USE_TK = False
41 USE_TK = False
42
42
43 #-----------------------------------------------------------------------------
43 #-----------------------------------------------------------------------------
44 # 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
45 # interface. Later when the internals are reorganized, code that uses this
45 # interface. Later when the internals are reorganized, code that uses this
46 # shouldn't have to change.
46 # shouldn't have to change.
47
47
48 class IPShell:
48 class IPShell:
49 """Create an IPython instance."""
49 """Create an IPython instance."""
50
50
51 def __init__(self,argv=None,user_ns=None,debug=1,
51 def __init__(self,argv=None,user_ns=None,debug=1,
52 shell_class=InteractiveShell):
52 shell_class=InteractiveShell):
53 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
53 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
54 shell_class=shell_class)
54 shell_class=shell_class)
55
55
56 def mainloop(self,sys_exit=0,banner=None):
56 def mainloop(self,sys_exit=0,banner=None):
57 self.IP.mainloop(banner)
57 self.IP.mainloop(banner)
58 if sys_exit:
58 if sys_exit:
59 sys.exit()
59 sys.exit()
60
60
61 #-----------------------------------------------------------------------------
61 #-----------------------------------------------------------------------------
62 class IPShellEmbed:
62 class IPShellEmbed:
63 """Allow embedding an IPython shell into a running program.
63 """Allow embedding an IPython shell into a running program.
64
64
65 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
66 alias to the embed() method of an InteractiveShell instance.
66 alias to the embed() method of an InteractiveShell instance.
67
67
68 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):
69
69
70 ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override])
70 ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override])
71
71
72 - argv: list containing valid command-line options for IPython, as they
72 - argv: list containing valid command-line options for IPython, as they
73 would appear in sys.argv[1:].
73 would appear in sys.argv[1:].
74
74
75 For example, the following command-line options:
75 For example, the following command-line options:
76
76
77 $ ipython -prompt_in1 'Input <\\#>' -colors LightBG
77 $ ipython -prompt_in1 'Input <\\#>' -colors LightBG
78
78
79 would be passed in the argv list as:
79 would be passed in the argv list as:
80
80
81 ['-prompt_in1','Input <\\#>','-colors','LightBG']
81 ['-prompt_in1','Input <\\#>','-colors','LightBG']
82
82
83 - banner: string which gets printed every time the interpreter starts.
83 - banner: string which gets printed every time the interpreter starts.
84
84
85 - exit_msg: string which gets printed every time the interpreter exits.
85 - exit_msg: string which gets printed every time the interpreter exits.
86
86
87 - 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
88 used by IPython. These options are read from your ~/.ipython/ipythonrc
88 used by IPython. These options are read from your ~/.ipython/ipythonrc
89 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
90 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
91 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
92 embeddable instances configured in any way you want without editing any
92 embeddable instances configured in any way you want without editing any
93 global files (thus keeping your interactive IPython configuration
93 global files (thus keeping your interactive IPython configuration
94 unchanged).
94 unchanged).
95
95
96 Then the ipshell instance can be called anywhere inside your code:
96 Then the ipshell instance can be called anywhere inside your code:
97
97
98 ipshell(header='') -> Opens up an IPython shell.
98 ipshell(header='') -> Opens up an IPython shell.
99
99
100 - 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
101 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
102 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
103 location-specific information.
103 location-specific information.
104
104
105 For more details, see the __call__ method below.
105 For more details, see the __call__ method below.
106
106
107 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
108 resumes.
108 resumes.
109
109
110 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
111 <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
112 by the IDL stop/continue commands."""
112 by the IDL stop/continue commands."""
113
113
114 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):
115 """Note that argv here is a string, NOT a list."""
115 """Note that argv here is a string, NOT a list."""
116 self.set_banner(banner)
116 self.set_banner(banner)
117 self.set_exit_msg(exit_msg)
117 self.set_exit_msg(exit_msg)
118 self.set_dummy_mode(0)
118 self.set_dummy_mode(0)
119
119
120 # 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
121 # 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.
122 self.sys_displayhook_ori = sys.displayhook
122 self.sys_displayhook_ori = sys.displayhook
123
123
124 # save readline completer status
124 # save readline completer status
125 try:
125 try:
126 #print 'Save completer',sys.ipcompleter # dbg
126 #print 'Save completer',sys.ipcompleter # dbg
127 self.sys_ipcompleter_ori = sys.ipcompleter
127 self.sys_ipcompleter_ori = sys.ipcompleter
128 except:
128 except:
129 pass # not nested with IPython
129 pass # not nested with IPython
130
130
131 # FIXME. Passing user_ns breaks namespace handling.
131 # FIXME. Passing user_ns breaks namespace handling.
132 #self.IP = make_IPython(argv,user_ns=__main__.__dict__)
132 #self.IP = make_IPython(argv,user_ns=__main__.__dict__)
133 self.IP = make_IPython(argv,rc_override=rc_override,embedded=True)
133 self.IP = make_IPython(argv,rc_override=rc_override,embedded=True)
134
134
135 # copy our own displayhook also
135 # copy our own displayhook also
136 self.sys_displayhook_embed = sys.displayhook
136 self.sys_displayhook_embed = sys.displayhook
137 # and leave the system's display hook clean
137 # and leave the system's display hook clean
138 sys.displayhook = self.sys_displayhook_ori
138 sys.displayhook = self.sys_displayhook_ori
139 # 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
140 # trapped
140 # trapped
141 sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors,
141 sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors,
142 mode = self.IP.rc.xmode,
142 mode = self.IP.rc.xmode,
143 call_pdb = self.IP.rc.pdb)
143 call_pdb = self.IP.rc.pdb)
144 self.restore_system_completer()
144 self.restore_system_completer()
145
145
146 def restore_system_completer(self):
146 def restore_system_completer(self):
147 """Restores the readline completer which was in place.
147 """Restores the readline completer which was in place.
148
148
149 This allows embedded IPython within IPython not to disrupt the
149 This allows embedded IPython within IPython not to disrupt the
150 parent's completion.
150 parent's completion.
151 """
151 """
152
152
153 try:
153 try:
154 self.IP.readline.set_completer(self.sys_ipcompleter_ori)
154 self.IP.readline.set_completer(self.sys_ipcompleter_ori)
155 sys.ipcompleter = self.sys_ipcompleter_ori
155 sys.ipcompleter = self.sys_ipcompleter_ori
156 except:
156 except:
157 pass
157 pass
158
158
159 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):
160 """Activate the interactive interpreter.
160 """Activate the interactive interpreter.
161
161
162 __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start
162 __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start
163 the interpreter shell with the given local and global namespaces, and
163 the interpreter shell with the given local and global namespaces, and
164 optionally print a header string at startup.
164 optionally print a header string at startup.
165
165
166 The shell can be globally activated/deactivated using the
166 The shell can be globally activated/deactivated using the
167 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
168 for debugging globally.
168 for debugging globally.
169
169
170 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
171 state of dummy_mode with the optional keyword parameter 'dummy'. For
171 state of dummy_mode with the optional keyword parameter 'dummy'. For
172 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
173 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).
174
174
175 The optional keyword parameter dummy controls whether the call
175 The optional keyword parameter dummy controls whether the call
176 actually does anything. """
176 actually does anything. """
177
177
178 # Allow the dummy parameter to override the global __dummy_mode
178 # Allow the dummy parameter to override the global __dummy_mode
179 if dummy or (dummy != 0 and self.__dummy_mode):
179 if dummy or (dummy != 0 and self.__dummy_mode):
180 return
180 return
181
181
182 # Set global subsystems (display,completions) to our values
182 # Set global subsystems (display,completions) to our values
183 sys.displayhook = self.sys_displayhook_embed
183 sys.displayhook = self.sys_displayhook_embed
184 if self.IP.has_readline:
184 if self.IP.has_readline:
185 self.IP.readline.set_completer(self.IP.Completer.complete)
185 self.IP.readline.set_completer(self.IP.Completer.complete)
186
186
187 if self.banner and header:
187 if self.banner and header:
188 format = '%s\n%s\n'
188 format = '%s\n%s\n'
189 else:
189 else:
190 format = '%s%s\n'
190 format = '%s%s\n'
191 banner = format % (self.banner,header)
191 banner = format % (self.banner,header)
192
192
193 # 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
194 # our call and get the original caller's namespaces.
194 # our call and get the original caller's namespaces.
195 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)
196
196
197 if self.exit_msg:
197 if self.exit_msg:
198 print self.exit_msg
198 print self.exit_msg
199
199
200 # Restore global systems (display, completion)
200 # Restore global systems (display, completion)
201 sys.displayhook = self.sys_displayhook_ori
201 sys.displayhook = self.sys_displayhook_ori
202 self.restore_system_completer()
202 self.restore_system_completer()
203
203
204 def set_dummy_mode(self,dummy):
204 def set_dummy_mode(self,dummy):
205 """Sets the embeddable shell's dummy mode parameter.
205 """Sets the embeddable shell's dummy mode parameter.
206
206
207 set_dummy_mode(dummy): dummy = 0 or 1.
207 set_dummy_mode(dummy): dummy = 0 or 1.
208
208
209 This parameter is persistent and makes calls to the embeddable shell
209 This parameter is persistent and makes calls to the embeddable shell
210 silently return without performing any action. This allows you to
210 silently return without performing any action. This allows you to
211 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.
212
212
213 If you need to manually"""
213 If you need to manually"""
214
214
215 if dummy not in [0,1]:
215 if dummy not in [0,1,False,True]:
216 raise ValueError,'dummy parameter must be 0 or 1'
216 raise ValueError,'dummy parameter must be boolean'
217 self.__dummy_mode = dummy
217 self.__dummy_mode = dummy
218
218
219 def get_dummy_mode(self):
219 def get_dummy_mode(self):
220 """Return the current value of the dummy mode parameter.
220 """Return the current value of the dummy mode parameter.
221 """
221 """
222 return self.__dummy_mode
222 return self.__dummy_mode
223
223
224 def set_banner(self,banner):
224 def set_banner(self,banner):
225 """Sets the global banner.
225 """Sets the global banner.
226
226
227 This banner gets prepended to every header printed when the shell
227 This banner gets prepended to every header printed when the shell
228 instance is called."""
228 instance is called."""
229
229
230 self.banner = banner
230 self.banner = banner
231
231
232 def set_exit_msg(self,exit_msg):
232 def set_exit_msg(self,exit_msg):
233 """Sets the global exit_msg.
233 """Sets the global exit_msg.
234
234
235 This exit message gets printed upon exiting every time the embedded
235 This exit message gets printed upon exiting every time the embedded
236 shell is called. It is None by default. """
236 shell is called. It is None by default. """
237
237
238 self.exit_msg = exit_msg
238 self.exit_msg = exit_msg
239
239
240 #-----------------------------------------------------------------------------
240 #-----------------------------------------------------------------------------
241 def sigint_handler (signum,stack_frame):
241 def sigint_handler (signum,stack_frame):
242 """Sigint handler for threaded apps.
242 """Sigint handler for threaded apps.
243
243
244 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
245 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
246 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
247 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)."""
248
248
249 global KBINT
249 global KBINT
250
250
251 print '\nKeyboardInterrupt - Press <Enter> to continue.',
251 print '\nKeyboardInterrupt - Press <Enter> to continue.',
252 Term.cout.flush()
252 Term.cout.flush()
253 # 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
254 KBINT = True
254 KBINT = True
255
255
256 class MTInteractiveShell(InteractiveShell):
256 class MTInteractiveShell(InteractiveShell):
257 """Simple multi-threaded shell."""
257 """Simple multi-threaded shell."""
258
258
259 # Threading strategy taken from:
259 # Threading strategy taken from:
260 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
260 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
261 # McErlean and John Finlay. Modified with corrections by Antoon Pardon,
261 # McErlean and John Finlay. Modified with corrections by Antoon Pardon,
262 # from the pygtk mailing list, to avoid lockups with system calls.
262 # from the pygtk mailing list, to avoid lockups with system calls.
263
263
264 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
264 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
265 user_ns = None, banner2='',**kw):
265 user_ns = None, banner2='',**kw):
266 """Similar to the normal InteractiveShell, but with threading control"""
266 """Similar to the normal InteractiveShell, but with threading control"""
267
267
268 IPython.iplib.InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2)
268 IPython.iplib.InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2)
269
269
270 # Locking control variable
270 # Locking control variable
271 self.thread_ready = threading.Condition()
271 self.thread_ready = threading.Condition()
272
272
273 # Stuff to do at closing time
273 # Stuff to do at closing time
274 self._kill = False
274 self._kill = False
275 on_kill = kw.get('on_kill')
275 on_kill = kw.get('on_kill')
276 if on_kill is None:
276 if on_kill is None:
277 on_kill = []
277 on_kill = []
278 # Check that all things to kill are callable:
278 # Check that all things to kill are callable:
279 for t in on_kill:
279 for t in on_kill:
280 if not callable(t):
280 if not callable(t):
281 raise TypeError,'on_kill must be a list of callables'
281 raise TypeError,'on_kill must be a list of callables'
282 self.on_kill = on_kill
282 self.on_kill = on_kill
283
283
284 def runsource(self, source, filename="<input>", symbol="single"):
284 def runsource(self, source, filename="<input>", symbol="single"):
285 """Compile and run some source in the interpreter.
285 """Compile and run some source in the interpreter.
286
286
287 Modified version of code.py's runsource(), to handle threading issues.
287 Modified version of code.py's runsource(), to handle threading issues.
288 See the original for full docstring details."""
288 See the original for full docstring details."""
289
289
290 global KBINT
290 global KBINT
291
291
292 # If Ctrl-C was typed, we reset the flag and return right away
292 # If Ctrl-C was typed, we reset the flag and return right away
293 if KBINT:
293 if KBINT:
294 KBINT = False
294 KBINT = False
295 return False
295 return False
296
296
297 try:
297 try:
298 code = self.compile(source, filename, symbol)
298 code = self.compile(source, filename, symbol)
299 except (OverflowError, SyntaxError, ValueError):
299 except (OverflowError, SyntaxError, ValueError):
300 # Case 1
300 # Case 1
301 self.showsyntaxerror(filename)
301 self.showsyntaxerror(filename)
302 return False
302 return False
303
303
304 if code is None:
304 if code is None:
305 # Case 2
305 # Case 2
306 return True
306 return True
307
307
308 # Case 3
308 # Case 3
309 # Store code in self, so the execution thread can handle it
309 # Store code in self, so the execution thread can handle it
310 self.thread_ready.acquire()
310 self.thread_ready.acquire()
311 self.code_to_run = code
311 self.code_to_run = code
312 self.thread_ready.wait() # Wait until processed in timeout interval
312 self.thread_ready.wait() # Wait until processed in timeout interval
313 self.thread_ready.release()
313 self.thread_ready.release()
314
314
315 return False
315 return False
316
316
317 def runcode(self):
317 def runcode(self):
318 """Execute a code object.
318 """Execute a code object.
319
319
320 Multithreaded wrapper around IPython's runcode()."""
320 Multithreaded wrapper around IPython's runcode()."""
321
321
322 # lock thread-protected stuff
322 # lock thread-protected stuff
323 self.thread_ready.acquire()
323 self.thread_ready.acquire()
324
324
325 # Install sigint handler
325 # Install sigint handler
326 try:
326 try:
327 signal.signal(signal.SIGINT, sigint_handler)
327 signal.signal(signal.SIGINT, sigint_handler)
328 except SystemError:
328 except SystemError:
329 # This happens under Windows, which seems to have all sorts
329 # This happens under Windows, which seems to have all sorts
330 # of problems with signal handling. Oh well...
330 # of problems with signal handling. Oh well...
331 pass
331 pass
332
332
333 if self._kill:
333 if self._kill:
334 print >>Term.cout, 'Closing threads...',
334 print >>Term.cout, 'Closing threads...',
335 Term.cout.flush()
335 Term.cout.flush()
336 for tokill in self.on_kill:
336 for tokill in self.on_kill:
337 tokill()
337 tokill()
338 print >>Term.cout, 'Done.'
338 print >>Term.cout, 'Done.'
339
339
340 # Run pending code by calling parent class
340 # Run pending code by calling parent class
341 if self.code_to_run is not None:
341 if self.code_to_run is not None:
342 self.thread_ready.notify()
342 self.thread_ready.notify()
343 InteractiveShell.runcode(self,self.code_to_run)
343 InteractiveShell.runcode(self,self.code_to_run)
344
344
345 # We're done with thread-protected variables
345 # We're done with thread-protected variables
346 self.thread_ready.release()
346 self.thread_ready.release()
347 # This MUST return true for gtk threading to work
347 # This MUST return true for gtk threading to work
348 return True
348 return True
349
349
350 def kill (self):
350 def kill (self):
351 """Kill the thread, returning when it has been shut down."""
351 """Kill the thread, returning when it has been shut down."""
352 self.thread_ready.acquire()
352 self.thread_ready.acquire()
353 self._kill = True
353 self._kill = True
354 self.thread_ready.release()
354 self.thread_ready.release()
355
355
356 class MatplotlibShellBase:
356 class MatplotlibShellBase:
357 """Mixin class to provide the necessary modifications to regular IPython
357 """Mixin class to provide the necessary modifications to regular IPython
358 shell classes for matplotlib support.
358 shell classes for matplotlib support.
359
359
360 Given Python's MRO, this should be used as the FIRST class in the
360 Given Python's MRO, this should be used as the FIRST class in the
361 inheritance hierarchy, so that it overrides the relevant methods."""
361 inheritance hierarchy, so that it overrides the relevant methods."""
362
362
363 def _matplotlib_config(self,name):
363 def _matplotlib_config(self,name):
364 """Return various items needed to setup the user's shell with matplotlib"""
364 """Return various items needed to setup the user's shell with matplotlib"""
365
365
366 # Initialize matplotlib to interactive mode always
366 # Initialize matplotlib to interactive mode always
367 import matplotlib
367 import matplotlib
368 from matplotlib import backends
368 from matplotlib import backends
369 matplotlib.interactive(True)
369 matplotlib.interactive(True)
370
370
371 def use(arg):
371 def use(arg):
372 """IPython wrapper for matplotlib's backend switcher.
372 """IPython wrapper for matplotlib's backend switcher.
373
373
374 In interactive use, we can not allow switching to a different
374 In interactive use, we can not allow switching to a different
375 interactive backend, since thread conflicts will most likely crash
375 interactive backend, since thread conflicts will most likely crash
376 the python interpreter. This routine does a safety check first,
376 the python interpreter. This routine does a safety check first,
377 and refuses to perform a dangerous switch. It still allows
377 and refuses to perform a dangerous switch. It still allows
378 switching to non-interactive backends."""
378 switching to non-interactive backends."""
379
379
380 if arg in backends.interactive_bk and arg != self.mpl_backend:
380 if arg in backends.interactive_bk and arg != self.mpl_backend:
381 m=('invalid matplotlib backend switch.\n'
381 m=('invalid matplotlib backend switch.\n'
382 'This script attempted to switch to the interactive '
382 'This script attempted to switch to the interactive '
383 'backend: `%s`\n'
383 'backend: `%s`\n'
384 'Your current choice of interactive backend is: `%s`\n\n'
384 'Your current choice of interactive backend is: `%s`\n\n'
385 'Switching interactive matplotlib backends at runtime\n'
385 'Switching interactive matplotlib backends at runtime\n'
386 'would crash the python interpreter, '
386 'would crash the python interpreter, '
387 'and IPython has blocked it.\n\n'
387 'and IPython has blocked it.\n\n'
388 'You need to either change your choice of matplotlib backend\n'
388 'You need to either change your choice of matplotlib backend\n'
389 'by editing your .matplotlibrc file, or run this script as a \n'
389 'by editing your .matplotlibrc file, or run this script as a \n'
390 'standalone file from the command line, not using IPython.\n' %
390 'standalone file from the command line, not using IPython.\n' %
391 (arg,self.mpl_backend) )
391 (arg,self.mpl_backend) )
392 raise RuntimeError, m
392 raise RuntimeError, m
393 else:
393 else:
394 self.mpl_use(arg)
394 self.mpl_use(arg)
395 self.mpl_use._called = True
395 self.mpl_use._called = True
396
396
397 self.matplotlib = matplotlib
397 self.matplotlib = matplotlib
398 self.mpl_backend = matplotlib.rcParams['backend']
398 self.mpl_backend = matplotlib.rcParams['backend']
399
399
400 # we also need to block switching of interactive backends by use()
400 # we also need to block switching of interactive backends by use()
401 self.mpl_use = matplotlib.use
401 self.mpl_use = matplotlib.use
402 self.mpl_use._called = False
402 self.mpl_use._called = False
403 # overwrite the original matplotlib.use with our wrapper
403 # overwrite the original matplotlib.use with our wrapper
404 matplotlib.use = use
404 matplotlib.use = use
405
405
406
406
407 # This must be imported last in the matplotlib series, after
407 # This must be imported last in the matplotlib series, after
408 # backend/interactivity choices have been made
408 # backend/interactivity choices have been made
409 try:
409 try:
410 import matplotlib.pylab as pylab
410 import matplotlib.pylab as pylab
411 self.pylab = pylab
411 self.pylab = pylab
412 self.pylab_name = 'pylab'
412 self.pylab_name = 'pylab'
413 except ImportError:
413 except ImportError:
414 import matplotlib.matlab as matlab
414 import matplotlib.matlab as matlab
415 self.pylab = matlab
415 self.pylab = matlab
416 self.pylab_name = 'matlab'
416 self.pylab_name = 'matlab'
417
417
418 self.pylab.show._needmain = False
418 self.pylab.show._needmain = False
419 # We need to detect at runtime whether show() is called by the user.
419 # We need to detect at runtime whether show() is called by the user.
420 # For this, we wrap it into a decorator which adds a 'called' flag.
420 # For this, we wrap it into a decorator which adds a 'called' flag.
421 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
421 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
422
422
423 # Build a user namespace initialized with matplotlib/matlab features.
423 # Build a user namespace initialized with matplotlib/matlab features.
424 user_ns = {'__name__':'__main__',
424 user_ns = {'__name__':'__main__',
425 '__builtins__' : __builtin__ }
425 '__builtins__' : __builtin__ }
426
426
427 # Be careful not to remove the final \n in the code string below, or
427 # Be careful not to remove the final \n in the code string below, or
428 # things will break badly with py22 (I think it's a python bug, 2.3 is
428 # things will break badly with py22 (I think it's a python bug, 2.3 is
429 # OK).
429 # OK).
430 pname = self.pylab_name # Python can't interpolate dotted var names
430 pname = self.pylab_name # Python can't interpolate dotted var names
431 exec ("import matplotlib\n"
431 exec ("import matplotlib\n"
432 "import matplotlib.%(pname)s as %(pname)s\n"
432 "import matplotlib.%(pname)s as %(pname)s\n"
433 "from matplotlib.%(pname)s import *\n" % locals()) in user_ns
433 "from matplotlib.%(pname)s import *\n" % locals()) in user_ns
434
434
435 # Build matplotlib info banner
435 # Build matplotlib info banner
436 b="""
436 b="""
437 Welcome to pylab, a matplotlib-based Python environment.
437 Welcome to pylab, a matplotlib-based Python environment.
438 For more information, type 'help(pylab)'.
438 For more information, type 'help(pylab)'.
439 """
439 """
440 return user_ns,b
440 return user_ns,b
441
441
442 def mplot_exec(self,fname,*where,**kw):
442 def mplot_exec(self,fname,*where,**kw):
443 """Execute a matplotlib script.
443 """Execute a matplotlib script.
444
444
445 This is a call to execfile(), but wrapped in safeties to properly
445 This is a call to execfile(), but wrapped in safeties to properly
446 handle interactive rendering and backend switching."""
446 handle interactive rendering and backend switching."""
447
447
448 #print '*** Matplotlib runner ***' # dbg
448 #print '*** Matplotlib runner ***' # dbg
449 # turn off rendering until end of script
449 # turn off rendering until end of script
450 isInteractive = self.matplotlib.rcParams['interactive']
450 isInteractive = self.matplotlib.rcParams['interactive']
451 self.matplotlib.interactive(False)
451 self.matplotlib.interactive(False)
452 self.safe_execfile(fname,*where,**kw)
452 self.safe_execfile(fname,*where,**kw)
453 self.matplotlib.interactive(isInteractive)
453 self.matplotlib.interactive(isInteractive)
454 # make rendering call now, if the user tried to do it
454 # make rendering call now, if the user tried to do it
455 if self.pylab.draw_if_interactive.called:
455 if self.pylab.draw_if_interactive.called:
456 self.pylab.draw()
456 self.pylab.draw()
457 self.pylab.draw_if_interactive.called = False
457 self.pylab.draw_if_interactive.called = False
458
458
459 # if a backend switch was performed, reverse it now
459 # if a backend switch was performed, reverse it now
460 if self.mpl_use._called:
460 if self.mpl_use._called:
461 self.matplotlib.rcParams['backend'] = self.mpl_backend
461 self.matplotlib.rcParams['backend'] = self.mpl_backend
462
462
463 def magic_run(self,parameter_s=''):
463 def magic_run(self,parameter_s=''):
464 Magic.magic_run(self,parameter_s,runner=self.mplot_exec)
464 Magic.magic_run(self,parameter_s,runner=self.mplot_exec)
465
465
466 # Fix the docstring so users see the original as well
466 # Fix the docstring so users see the original as well
467 magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__,
467 magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__,
468 "\n *** Modified %run for Matplotlib,"
468 "\n *** Modified %run for Matplotlib,"
469 " with proper interactive handling ***")
469 " with proper interactive handling ***")
470
470
471 # Now we provide 2 versions of a matplotlib-aware IPython base shells, single
471 # Now we provide 2 versions of a matplotlib-aware IPython base shells, single
472 # and multithreaded. Note that these are meant for internal use, the IPShell*
472 # and multithreaded. Note that these are meant for internal use, the IPShell*
473 # classes below are the ones meant for public consumption.
473 # classes below are the ones meant for public consumption.
474
474
475 class MatplotlibShell(MatplotlibShellBase,InteractiveShell):
475 class MatplotlibShell(MatplotlibShellBase,InteractiveShell):
476 """Single-threaded shell with matplotlib support."""
476 """Single-threaded shell with matplotlib support."""
477
477
478 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
478 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
479 user_ns = None, **kw):
479 user_ns = None, **kw):
480 user_ns,b2 = self._matplotlib_config(name)
480 user_ns,b2 = self._matplotlib_config(name)
481 InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw)
481 InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw)
482
482
483 class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell):
483 class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell):
484 """Multi-threaded shell with matplotlib support."""
484 """Multi-threaded shell with matplotlib support."""
485
485
486 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
486 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
487 user_ns = None, **kw):
487 user_ns = None, **kw):
488 user_ns,b2 = self._matplotlib_config(name)
488 user_ns,b2 = self._matplotlib_config(name)
489 MTInteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw)
489 MTInteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw)
490
490
491 #-----------------------------------------------------------------------------
491 #-----------------------------------------------------------------------------
492 # Utility functions for the different GUI enabled IPShell* classes.
492 # Utility functions for the different GUI enabled IPShell* classes.
493
493
494 def get_tk():
494 def get_tk():
495 """Tries to import Tkinter and returns a withdrawn Tkinter root
495 """Tries to import Tkinter and returns a withdrawn Tkinter root
496 window. If Tkinter is already imported or not available, this
496 window. If Tkinter is already imported or not available, this
497 returns None. This function calls `hijack_tk` underneath.
497 returns None. This function calls `hijack_tk` underneath.
498 """
498 """
499 if not USE_TK or sys.modules.has_key('Tkinter'):
499 if not USE_TK or sys.modules.has_key('Tkinter'):
500 return None
500 return None
501 else:
501 else:
502 try:
502 try:
503 import Tkinter
503 import Tkinter
504 except ImportError:
504 except ImportError:
505 return None
505 return None
506 else:
506 else:
507 hijack_tk()
507 hijack_tk()
508 r = Tkinter.Tk()
508 r = Tkinter.Tk()
509 r.withdraw()
509 r.withdraw()
510 return r
510 return r
511
511
512 def hijack_tk():
512 def hijack_tk():
513 """Modifies Tkinter's mainloop with a dummy so when a module calls
513 """Modifies Tkinter's mainloop with a dummy so when a module calls
514 mainloop, it does not block.
514 mainloop, it does not block.
515
515
516 """
516 """
517 def misc_mainloop(self, n=0):
517 def misc_mainloop(self, n=0):
518 pass
518 pass
519 def tkinter_mainloop(n=0):
519 def tkinter_mainloop(n=0):
520 pass
520 pass
521
521
522 import Tkinter
522 import Tkinter
523 Tkinter.Misc.mainloop = misc_mainloop
523 Tkinter.Misc.mainloop = misc_mainloop
524 Tkinter.mainloop = tkinter_mainloop
524 Tkinter.mainloop = tkinter_mainloop
525
525
526 def update_tk(tk):
526 def update_tk(tk):
527 """Updates the Tkinter event loop. This is typically called from
527 """Updates the Tkinter event loop. This is typically called from
528 the respective WX or GTK mainloops.
528 the respective WX or GTK mainloops.
529 """
529 """
530 if tk:
530 if tk:
531 tk.update()
531 tk.update()
532
532
533 def hijack_wx():
533 def hijack_wx():
534 """Modifies wxPython's MainLoop with a dummy so user code does not
534 """Modifies wxPython's MainLoop with a dummy so user code does not
535 block IPython. The hijacked mainloop function is returned.
535 block IPython. The hijacked mainloop function is returned.
536 """
536 """
537 def dummy_mainloop(*args, **kw):
537 def dummy_mainloop(*args, **kw):
538 pass
538 pass
539 import wxPython
539 import wxPython
540 ver = wxPython.__version__
540 ver = wxPython.__version__
541 orig_mainloop = None
541 orig_mainloop = None
542 if ver[:3] >= '2.5':
542 if ver[:3] >= '2.5':
543 import wx
543 import wx
544 if hasattr(wx, '_core_'): core = getattr(wx, '_core_')
544 if hasattr(wx, '_core_'): core = getattr(wx, '_core_')
545 elif hasattr(wx, '_core'): core = getattr(wx, '_core')
545 elif hasattr(wx, '_core'): core = getattr(wx, '_core')
546 else: raise AttributeError('Could not find wx core module')
546 else: raise AttributeError('Could not find wx core module')
547 orig_mainloop = core.PyApp_MainLoop
547 orig_mainloop = core.PyApp_MainLoop
548 core.PyApp_MainLoop = dummy_mainloop
548 core.PyApp_MainLoop = dummy_mainloop
549 elif ver[:3] == '2.4':
549 elif ver[:3] == '2.4':
550 orig_mainloop = wxPython.wxc.wxPyApp_MainLoop
550 orig_mainloop = wxPython.wxc.wxPyApp_MainLoop
551 wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop
551 wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop
552 else:
552 else:
553 warn("Unable to find either wxPython version 2.4 or >= 2.5.")
553 warn("Unable to find either wxPython version 2.4 or >= 2.5.")
554 return orig_mainloop
554 return orig_mainloop
555
555
556 def hijack_gtk():
556 def hijack_gtk():
557 """Modifies pyGTK's mainloop with a dummy so user code does not
557 """Modifies pyGTK's mainloop with a dummy so user code does not
558 block IPython. This function returns the original `gtk.mainloop`
558 block IPython. This function returns the original `gtk.mainloop`
559 function that has been hijacked.
559 function that has been hijacked.
560 """
560 """
561 def dummy_mainloop(*args, **kw):
561 def dummy_mainloop(*args, **kw):
562 pass
562 pass
563 import gtk
563 import gtk
564 if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main
564 if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main
565 else: orig_mainloop = gtk.mainloop
565 else: orig_mainloop = gtk.mainloop
566 gtk.mainloop = dummy_mainloop
566 gtk.mainloop = dummy_mainloop
567 gtk.main = dummy_mainloop
567 gtk.main = dummy_mainloop
568 return orig_mainloop
568 return orig_mainloop
569
569
570 #-----------------------------------------------------------------------------
570 #-----------------------------------------------------------------------------
571 # The IPShell* classes below are the ones meant to be run by external code as
571 # The IPShell* classes below are the ones meant to be run by external code as
572 # IPython instances. Note that unless a specific threading strategy is
572 # IPython instances. Note that unless a specific threading strategy is
573 # desired, the factory function start() below should be used instead (it
573 # desired, the factory function start() below should be used instead (it
574 # selects the proper threaded class).
574 # selects the proper threaded class).
575
575
576 class IPShellGTK(threading.Thread):
576 class IPShellGTK(threading.Thread):
577 """Run a gtk mainloop() in a separate thread.
577 """Run a gtk mainloop() in a separate thread.
578
578
579 Python commands can be passed to the thread where they will be executed.
579 Python commands can be passed to the thread where they will be executed.
580 This is implemented by periodically checking for passed code using a
580 This is implemented by periodically checking for passed code using a
581 GTK timeout callback."""
581 GTK timeout callback."""
582
582
583 TIMEOUT = 100 # Millisecond interval between timeouts.
583 TIMEOUT = 100 # Millisecond interval between timeouts.
584
584
585 def __init__(self,argv=None,user_ns=None,debug=1,
585 def __init__(self,argv=None,user_ns=None,debug=1,
586 shell_class=MTInteractiveShell):
586 shell_class=MTInteractiveShell):
587
587
588 import gtk
588 import gtk
589
589
590 self.gtk = gtk
590 self.gtk = gtk
591 self.gtk_mainloop = hijack_gtk()
591 self.gtk_mainloop = hijack_gtk()
592
592
593 # Allows us to use both Tk and GTK.
593 # Allows us to use both Tk and GTK.
594 self.tk = get_tk()
594 self.tk = get_tk()
595
595
596 if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit
596 if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit
597 else: mainquit = self.gtk.mainquit
597 else: mainquit = self.gtk.mainquit
598
598
599 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
599 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
600 shell_class=shell_class,
600 shell_class=shell_class,
601 on_kill=[mainquit])
601 on_kill=[mainquit])
602
602
603 # HACK: slot for banner in self; it will be passed to the mainloop
603 # HACK: slot for banner in self; it will be passed to the mainloop
604 # method only and .run() needs it. The actual value will be set by
604 # method only and .run() needs it. The actual value will be set by
605 # .mainloop().
605 # .mainloop().
606 self._banner = None
606 self._banner = None
607
607
608 threading.Thread.__init__(self)
608 threading.Thread.__init__(self)
609
609
610 def run(self):
610 def run(self):
611 self.IP.mainloop(self._banner)
611 self.IP.mainloop(self._banner)
612 self.IP.kill()
612 self.IP.kill()
613
613
614 def mainloop(self,sys_exit=0,banner=None):
614 def mainloop(self,sys_exit=0,banner=None):
615
615
616 self._banner = banner
616 self._banner = banner
617
617
618 if self.gtk.pygtk_version >= (2,4,0):
618 if self.gtk.pygtk_version >= (2,4,0):
619 import gobject
619 import gobject
620 gobject.idle_add(self.on_timer)
620 gobject.idle_add(self.on_timer)
621 else:
621 else:
622 self.gtk.idle_add(self.on_timer)
622 self.gtk.idle_add(self.on_timer)
623
623
624 if sys.platform != 'win32':
624 if sys.platform != 'win32':
625 try:
625 try:
626 if self.gtk.gtk_version[0] >= 2:
626 if self.gtk.gtk_version[0] >= 2:
627 self.gtk.threads_init()
627 self.gtk.threads_init()
628 except AttributeError:
628 except AttributeError:
629 pass
629 pass
630 except RuntimeError:
630 except RuntimeError:
631 error('Your pyGTK likely has not been compiled with '
631 error('Your pyGTK likely has not been compiled with '
632 'threading support.\n'
632 'threading support.\n'
633 'The exception printout is below.\n'
633 'The exception printout is below.\n'
634 'You can either rebuild pyGTK with threads, or '
634 'You can either rebuild pyGTK with threads, or '
635 'try using \n'
635 'try using \n'
636 'matplotlib with a different backend (like Tk or WX).\n'
636 'matplotlib with a different backend (like Tk or WX).\n'
637 'Note that matplotlib will most likely not work in its '
637 'Note that matplotlib will most likely not work in its '
638 'current state!')
638 'current state!')
639 self.IP.InteractiveTB()
639 self.IP.InteractiveTB()
640 self.start()
640 self.start()
641 self.gtk.threads_enter()
641 self.gtk.threads_enter()
642 self.gtk_mainloop()
642 self.gtk_mainloop()
643 self.gtk.threads_leave()
643 self.gtk.threads_leave()
644 self.join()
644 self.join()
645
645
646 def on_timer(self):
646 def on_timer(self):
647 update_tk(self.tk)
647 update_tk(self.tk)
648 return self.IP.runcode()
648 return self.IP.runcode()
649
649
650
650
651 class IPShellWX(threading.Thread):
651 class IPShellWX(threading.Thread):
652 """Run a wx mainloop() in a separate thread.
652 """Run a wx mainloop() in a separate thread.
653
653
654 Python commands can be passed to the thread where they will be executed.
654 Python commands can be passed to the thread where they will be executed.
655 This is implemented by periodically checking for passed code using a
655 This is implemented by periodically checking for passed code using a
656 GTK timeout callback."""
656 GTK timeout callback."""
657
657
658 TIMEOUT = 100 # Millisecond interval between timeouts.
658 TIMEOUT = 100 # Millisecond interval between timeouts.
659
659
660 def __init__(self,argv=None,user_ns=None,debug=1,
660 def __init__(self,argv=None,user_ns=None,debug=1,
661 shell_class=MTInteractiveShell):
661 shell_class=MTInteractiveShell):
662
662
663 import wxPython.wx as wx
663 import wxPython.wx as wx
664
664
665 threading.Thread.__init__(self)
665 threading.Thread.__init__(self)
666 self.wx = wx
666 self.wx = wx
667 self.wx_mainloop = hijack_wx()
667 self.wx_mainloop = hijack_wx()
668
668
669 # Allows us to use both Tk and GTK.
669 # Allows us to use both Tk and GTK.
670 self.tk = get_tk()
670 self.tk = get_tk()
671
671
672 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
672 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
673 shell_class=shell_class,
673 shell_class=shell_class,
674 on_kill=[self.wxexit])
674 on_kill=[self.wxexit])
675 # HACK: slot for banner in self; it will be passed to the mainloop
675 # HACK: slot for banner in self; it will be passed to the mainloop
676 # method only and .run() needs it. The actual value will be set by
676 # method only and .run() needs it. The actual value will be set by
677 # .mainloop().
677 # .mainloop().
678 self._banner = None
678 self._banner = None
679
679
680 self.app = None
680 self.app = None
681
681
682 def wxexit(self, *args):
682 def wxexit(self, *args):
683 if self.app is not None:
683 if self.app is not None:
684 self.app.agent.timer.Stop()
684 self.app.agent.timer.Stop()
685 self.app.ExitMainLoop()
685 self.app.ExitMainLoop()
686
686
687 def run(self):
687 def run(self):
688 self.IP.mainloop(self._banner)
688 self.IP.mainloop(self._banner)
689 self.IP.kill()
689 self.IP.kill()
690
690
691 def mainloop(self,sys_exit=0,banner=None):
691 def mainloop(self,sys_exit=0,banner=None):
692
692
693 self._banner = banner
693 self._banner = banner
694
694
695 self.start()
695 self.start()
696
696
697 class TimerAgent(self.wx.wxMiniFrame):
697 class TimerAgent(self.wx.wxMiniFrame):
698 wx = self.wx
698 wx = self.wx
699 IP = self.IP
699 IP = self.IP
700 tk = self.tk
700 tk = self.tk
701 def __init__(self, parent, interval):
701 def __init__(self, parent, interval):
702 style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ
702 style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ
703 self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200),
703 self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200),
704 size=(100, 100),style=style)
704 size=(100, 100),style=style)
705 self.Show(False)
705 self.Show(False)
706 self.interval = interval
706 self.interval = interval
707 self.timerId = self.wx.wxNewId()
707 self.timerId = self.wx.wxNewId()
708
708
709 def StartWork(self):
709 def StartWork(self):
710 self.timer = self.wx.wxTimer(self, self.timerId)
710 self.timer = self.wx.wxTimer(self, self.timerId)
711 self.wx.EVT_TIMER(self, self.timerId, self.OnTimer)
711 self.wx.EVT_TIMER(self, self.timerId, self.OnTimer)
712 self.timer.Start(self.interval)
712 self.timer.Start(self.interval)
713
713
714 def OnTimer(self, event):
714 def OnTimer(self, event):
715 update_tk(self.tk)
715 update_tk(self.tk)
716 self.IP.runcode()
716 self.IP.runcode()
717
717
718 class App(self.wx.wxApp):
718 class App(self.wx.wxApp):
719 wx = self.wx
719 wx = self.wx
720 TIMEOUT = self.TIMEOUT
720 TIMEOUT = self.TIMEOUT
721 def OnInit(self):
721 def OnInit(self):
722 'Create the main window and insert the custom frame'
722 'Create the main window and insert the custom frame'
723 self.agent = TimerAgent(None, self.TIMEOUT)
723 self.agent = TimerAgent(None, self.TIMEOUT)
724 self.agent.Show(self.wx.false)
724 self.agent.Show(self.wx.false)
725 self.agent.StartWork()
725 self.agent.StartWork()
726 return self.wx.true
726 return self.wx.true
727
727
728 self.app = App(redirect=False)
728 self.app = App(redirect=False)
729 self.wx_mainloop(self.app)
729 self.wx_mainloop(self.app)
730 self.join()
730 self.join()
731
731
732
732
733 class IPShellQt(threading.Thread):
733 class IPShellQt(threading.Thread):
734 """Run a Qt event loop in a separate thread.
734 """Run a Qt event loop in a separate thread.
735
735
736 Python commands can be passed to the thread where they will be executed.
736 Python commands can be passed to the thread where they will be executed.
737 This is implemented by periodically checking for passed code using a
737 This is implemented by periodically checking for passed code using a
738 Qt timer / slot."""
738 Qt timer / slot."""
739
739
740 TIMEOUT = 100 # Millisecond interval between timeouts.
740 TIMEOUT = 100 # Millisecond interval between timeouts.
741
741
742 def __init__(self,argv=None,user_ns=None,debug=0,
742 def __init__(self,argv=None,user_ns=None,debug=0,
743 shell_class=MTInteractiveShell):
743 shell_class=MTInteractiveShell):
744
744
745 import qt
745 import qt
746
746
747 class newQApplication:
747 class newQApplication:
748 def __init__( self ):
748 def __init__( self ):
749 self.QApplication = qt.QApplication
749 self.QApplication = qt.QApplication
750
750
751 def __call__( *args, **kwargs ):
751 def __call__( *args, **kwargs ):
752 return qt.qApp
752 return qt.qApp
753
753
754 def exec_loop( *args, **kwargs ):
754 def exec_loop( *args, **kwargs ):
755 pass
755 pass
756
756
757 def __getattr__( self, name ):
757 def __getattr__( self, name ):
758 return getattr( self.QApplication, name )
758 return getattr( self.QApplication, name )
759
759
760 qt.QApplication = newQApplication()
760 qt.QApplication = newQApplication()
761
761
762 # Allows us to use both Tk and QT.
762 # Allows us to use both Tk and QT.
763 self.tk = get_tk()
763 self.tk = get_tk()
764
764
765 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
765 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
766 shell_class=shell_class,
766 shell_class=shell_class,
767 on_kill=[qt.qApp.exit])
767 on_kill=[qt.qApp.exit])
768
768
769 # HACK: slot for banner in self; it will be passed to the mainloop
769 # HACK: slot for banner in self; it will be passed to the mainloop
770 # method only and .run() needs it. The actual value will be set by
770 # method only and .run() needs it. The actual value will be set by
771 # .mainloop().
771 # .mainloop().
772 self._banner = None
772 self._banner = None
773
773
774 threading.Thread.__init__(self)
774 threading.Thread.__init__(self)
775
775
776 def run(self):
776 def run(self):
777 self.IP.mainloop(self._banner)
777 self.IP.mainloop(self._banner)
778 self.IP.kill()
778 self.IP.kill()
779
779
780 def mainloop(self,sys_exit=0,banner=None):
780 def mainloop(self,sys_exit=0,banner=None):
781
781
782 import qt
782 import qt
783
783
784 self._banner = banner
784 self._banner = banner
785
785
786 if qt.QApplication.startingUp():
786 if qt.QApplication.startingUp():
787 a = qt.QApplication.QApplication(sys.argv)
787 a = qt.QApplication.QApplication(sys.argv)
788 self.timer = qt.QTimer()
788 self.timer = qt.QTimer()
789 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
789 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
790
790
791 self.start()
791 self.start()
792 self.timer.start( self.TIMEOUT, True )
792 self.timer.start( self.TIMEOUT, True )
793 while True:
793 while True:
794 if self.IP._kill: break
794 if self.IP._kill: break
795 qt.qApp.exec_loop()
795 qt.qApp.exec_loop()
796 self.join()
796 self.join()
797
797
798 def on_timer(self):
798 def on_timer(self):
799 update_tk(self.tk)
799 update_tk(self.tk)
800 result = self.IP.runcode()
800 result = self.IP.runcode()
801 self.timer.start( self.TIMEOUT, True )
801 self.timer.start( self.TIMEOUT, True )
802 return result
802 return result
803
803
804 # A set of matplotlib public IPython shell classes, for single-threaded
804 # A set of matplotlib public IPython shell classes, for single-threaded
805 # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use.
805 # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use.
806 class IPShellMatplotlib(IPShell):
806 class IPShellMatplotlib(IPShell):
807 """Subclass IPShell with MatplotlibShell as the internal shell.
807 """Subclass IPShell with MatplotlibShell as the internal shell.
808
808
809 Single-threaded class, meant for the Tk* and FLTK* backends.
809 Single-threaded class, meant for the Tk* and FLTK* backends.
810
810
811 Having this on a separate class simplifies the external driver code."""
811 Having this on a separate class simplifies the external driver code."""
812
812
813 def __init__(self,argv=None,user_ns=None,debug=1):
813 def __init__(self,argv=None,user_ns=None,debug=1):
814 IPShell.__init__(self,argv,user_ns,debug,shell_class=MatplotlibShell)
814 IPShell.__init__(self,argv,user_ns,debug,shell_class=MatplotlibShell)
815
815
816 class IPShellMatplotlibGTK(IPShellGTK):
816 class IPShellMatplotlibGTK(IPShellGTK):
817 """Subclass IPShellGTK with MatplotlibMTShell as the internal shell.
817 """Subclass IPShellGTK with MatplotlibMTShell as the internal shell.
818
818
819 Multi-threaded class, meant for the GTK* backends."""
819 Multi-threaded class, meant for the GTK* backends."""
820
820
821 def __init__(self,argv=None,user_ns=None,debug=1):
821 def __init__(self,argv=None,user_ns=None,debug=1):
822 IPShellGTK.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
822 IPShellGTK.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
823
823
824 class IPShellMatplotlibWX(IPShellWX):
824 class IPShellMatplotlibWX(IPShellWX):
825 """Subclass IPShellWX with MatplotlibMTShell as the internal shell.
825 """Subclass IPShellWX with MatplotlibMTShell as the internal shell.
826
826
827 Multi-threaded class, meant for the WX* backends."""
827 Multi-threaded class, meant for the WX* backends."""
828
828
829 def __init__(self,argv=None,user_ns=None,debug=1):
829 def __init__(self,argv=None,user_ns=None,debug=1):
830 IPShellWX.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
830 IPShellWX.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
831
831
832 class IPShellMatplotlibQt(IPShellQt):
832 class IPShellMatplotlibQt(IPShellQt):
833 """Subclass IPShellQt with MatplotlibMTShell as the internal shell.
833 """Subclass IPShellQt with MatplotlibMTShell as the internal shell.
834
834
835 Multi-threaded class, meant for the Qt* backends."""
835 Multi-threaded class, meant for the Qt* backends."""
836
836
837 def __init__(self,argv=None,user_ns=None,debug=1):
837 def __init__(self,argv=None,user_ns=None,debug=1):
838 IPShellQt.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
838 IPShellQt.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
839
839
840 #-----------------------------------------------------------------------------
840 #-----------------------------------------------------------------------------
841 # Factory functions to actually start the proper thread-aware shell
841 # Factory functions to actually start the proper thread-aware shell
842
842
843 def _matplotlib_shell_class():
843 def _matplotlib_shell_class():
844 """Factory function to handle shell class selection for matplotlib.
844 """Factory function to handle shell class selection for matplotlib.
845
845
846 The proper shell class to use depends on the matplotlib backend, since
846 The proper shell class to use depends on the matplotlib backend, since
847 each backend requires a different threading strategy."""
847 each backend requires a different threading strategy."""
848
848
849 try:
849 try:
850 import matplotlib
850 import matplotlib
851 except ImportError:
851 except ImportError:
852 error('matplotlib could NOT be imported! Starting normal IPython.')
852 error('matplotlib could NOT be imported! Starting normal IPython.')
853 sh_class = IPShell
853 sh_class = IPShell
854 else:
854 else:
855 backend = matplotlib.rcParams['backend']
855 backend = matplotlib.rcParams['backend']
856 if backend.startswith('GTK'):
856 if backend.startswith('GTK'):
857 sh_class = IPShellMatplotlibGTK
857 sh_class = IPShellMatplotlibGTK
858 elif backend.startswith('WX'):
858 elif backend.startswith('WX'):
859 sh_class = IPShellMatplotlibWX
859 sh_class = IPShellMatplotlibWX
860 elif backend.startswith('Qt'):
860 elif backend.startswith('Qt'):
861 sh_class = IPShellMatplotlibQt
861 sh_class = IPShellMatplotlibQt
862 else:
862 else:
863 sh_class = IPShellMatplotlib
863 sh_class = IPShellMatplotlib
864 #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg
864 #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg
865 return sh_class
865 return sh_class
866
866
867 # This is the one which should be called by external code.
867 # This is the one which should be called by external code.
868 def start():
868 def start():
869 """Return a running shell instance, dealing with threading options.
869 """Return a running shell instance, dealing with threading options.
870
870
871 This is a factory function which will instantiate the proper IPython shell
871 This is a factory function which will instantiate the proper IPython shell
872 based on the user's threading choice. Such a selector is needed because
872 based on the user's threading choice. Such a selector is needed because
873 different GUI toolkits require different thread handling details."""
873 different GUI toolkits require different thread handling details."""
874
874
875 global USE_TK
875 global USE_TK
876 # Crude sys.argv hack to extract the threading options.
876 # Crude sys.argv hack to extract the threading options.
877 if len(sys.argv) > 1:
877 argv = sys.argv
878 if len(sys.argv) > 2:
878 if len(argv) > 1:
879 arg2 = sys.argv[2]
879 if len(argv) > 2:
880 arg2 = argv[2]
880 if arg2.endswith('-tk'):
881 if arg2.endswith('-tk'):
881 USE_TK = True
882 USE_TK = True
882 arg1 = sys.argv[1]
883 arg1 = argv[1]
883 if arg1.endswith('-gthread'):
884 if arg1.endswith('-gthread'):
884 shell = IPShellGTK
885 shell = IPShellGTK
885 elif arg1.endswith( '-qthread' ):
886 elif arg1.endswith( '-qthread' ):
886 shell = IPShellQt
887 shell = IPShellQt
887 elif arg1.endswith('-wthread'):
888 elif arg1.endswith('-wthread'):
888 shell = IPShellWX
889 shell = IPShellWX
889 elif arg1.endswith('-pylab'):
890 elif arg1.endswith('-pylab'):
890 shell = _matplotlib_shell_class()
891 shell = _matplotlib_shell_class()
891 else:
892 else:
892 shell = IPShell
893 shell = IPShell
893 else:
894 else:
894 shell = IPShell
895 shell = IPShell
895 return shell()
896 return shell()
896
897
897 # Some aliases for backwards compatibility
898 # Some aliases for backwards compatibility
898 IPythonShell = IPShell
899 IPythonShell = IPShell
899 IPythonShellEmbed = IPShellEmbed
900 IPythonShellEmbed = IPShellEmbed
900 #************************ End of file <Shell.py> ***************************
901 #************************ End of file <Shell.py> ***************************
@@ -1,2112 +1,2132 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 951 2005-12-25 00:57:24Z fperez $
9 $Id: iplib.py 952 2005-12-26 17:51:33Z 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-2004 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2004 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, much of that class has been copied
20 # Python standard library. Over time, much 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. The Python License (sec. 2) allows for this, but it's always
22 # subclassing. The Python License (sec. 2) allows for this, but it's always
23 # nice to acknowledge credit where credit is due.
23 # nice to acknowledge credit where credit is due.
24 #*****************************************************************************
24 #*****************************************************************************
25
25
26 #****************************************************************************
26 #****************************************************************************
27 # Modules and globals
27 # Modules and globals
28
28
29 from __future__ import generators # for 2.2 backwards-compatibility
29 from __future__ import generators # for 2.2 backwards-compatibility
30
30
31 from IPython import Release
31 from IPython import Release
32 __author__ = '%s <%s>\n%s <%s>' % \
32 __author__ = '%s <%s>\n%s <%s>' % \
33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
34 __license__ = Release.license
34 __license__ = Release.license
35 __version__ = Release.version
35 __version__ = Release.version
36
36
37 # Python standard modules
37 # Python standard modules
38 import __main__
38 import __main__
39 import __builtin__
39 import __builtin__
40 import exceptions
40 import exceptions
41 import keyword
41 import keyword
42 import new
42 import new
43 import os, sys, shutil
43 import os, sys, shutil
44 import code, glob, types, re
44 import code, glob, types, re
45 import string, StringIO
45 import string, StringIO
46 import inspect, pydoc
46 import inspect, pydoc
47 import bdb, pdb
47 import bdb, pdb
48 import UserList # don't subclass list so this works with Python2.1
48 import UserList # don't subclass list so this works with Python2.1
49 from pprint import pprint, pformat
49 from pprint import pprint, pformat
50 import cPickle as pickle
50 import cPickle as pickle
51 import traceback
51 import traceback
52 from codeop import CommandCompiler
52 from codeop import CommandCompiler
53
53
54 # IPython's own modules
54 # IPython's own modules
55 import IPython
55 import IPython
56 from IPython import OInspect,PyColorize,ultraTB
56 from IPython import OInspect,PyColorize,ultraTB
57 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
57 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
58 from IPython.Logger import Logger
58 from IPython.Logger import Logger
59 from IPython.Magic import Magic,magic2python,shlex_split
59 from IPython.Magic import Magic,magic2python,shlex_split
60 from IPython.usage import cmd_line_usage,interactive_usage
60 from IPython.usage import cmd_line_usage,interactive_usage
61 from IPython.Struct import Struct
61 from IPython.Struct import Struct
62 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
62 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
63 from IPython.FakeModule import FakeModule
63 from IPython.FakeModule import FakeModule
64 from IPython.background_jobs import BackgroundJobManager
64 from IPython.background_jobs import BackgroundJobManager
65 from IPython.PyColorize import Parser
65 from IPython.PyColorize import Parser
66 from IPython.genutils import *
66 from IPython.genutils import *
67
67
68 # Global pointer to the running
68 # Global pointer to the running
69
69
70 # store the builtin raw_input globally, and use this always, in case user code
70 # store the builtin raw_input globally, and use this always, in case user code
71 # overwrites it (like wx.py.PyShell does)
71 # overwrites it (like wx.py.PyShell does)
72 raw_input_original = raw_input
72 raw_input_original = raw_input
73
73
74 #****************************************************************************
74 #****************************************************************************
75 # Some utility function definitions
75 # Some utility function definitions
76
76
77 class Bunch: pass
77 class Bunch: pass
78
78
79 def esc_quotes(strng):
79 def esc_quotes(strng):
80 """Return the input string with single and double quotes escaped out"""
80 """Return the input string with single and double quotes escaped out"""
81
81
82 return strng.replace('"','\\"').replace("'","\\'")
82 return strng.replace('"','\\"').replace("'","\\'")
83
83
84 def import_fail_info(mod_name,fns=None):
84 def import_fail_info(mod_name,fns=None):
85 """Inform load failure for a module."""
85 """Inform load failure for a module."""
86
86
87 if fns == None:
87 if fns == None:
88 warn("Loading of %s failed.\n" % (mod_name,))
88 warn("Loading of %s failed.\n" % (mod_name,))
89 else:
89 else:
90 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
90 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
91
91
92 def qw_lol(indata):
92 def qw_lol(indata):
93 """qw_lol('a b') -> [['a','b']],
93 """qw_lol('a b') -> [['a','b']],
94 otherwise it's just a call to qw().
94 otherwise it's just a call to qw().
95
95
96 We need this to make sure the modules_some keys *always* end up as a
96 We need this to make sure the modules_some keys *always* end up as a
97 list of lists."""
97 list of lists."""
98
98
99 if type(indata) in StringTypes:
99 if type(indata) in StringTypes:
100 return [qw(indata)]
100 return [qw(indata)]
101 else:
101 else:
102 return qw(indata)
102 return qw(indata)
103
103
104 def ipmagic(arg_s):
104 def ipmagic(arg_s):
105 """Call a magic function by name.
105 """Call a magic function by name.
106
106
107 Input: a string containing the name of the magic function to call and any
107 Input: a string containing the name of the magic function to call and any
108 additional arguments to be passed to the magic.
108 additional arguments to be passed to the magic.
109
109
110 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
110 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
111 prompt:
111 prompt:
112
112
113 In[1]: %name -opt foo bar
113 In[1]: %name -opt foo bar
114
114
115 To call a magic without arguments, simply use ipmagic('name').
115 To call a magic without arguments, simply use ipmagic('name').
116
116
117 This provides a proper Python function to call IPython's magics in any
117 This provides a proper Python function to call IPython's magics in any
118 valid Python code you can type at the interpreter, including loops and
118 valid Python code you can type at the interpreter, including loops and
119 compound statements. It is added by IPython to the Python builtin
119 compound statements. It is added by IPython to the Python builtin
120 namespace upon initialization."""
120 namespace upon initialization."""
121
121
122 args = arg_s.split(' ',1)
122 args = arg_s.split(' ',1)
123 magic_name = args[0]
123 magic_name = args[0]
124 if magic_name.startswith(__IPYTHON__.ESC_MAGIC):
124 if magic_name.startswith(__IPYTHON__.ESC_MAGIC):
125 magic_name = magic_name[1:]
125 magic_name = magic_name[1:]
126 try:
126 try:
127 magic_args = args[1]
127 magic_args = args[1]
128 except IndexError:
128 except IndexError:
129 magic_args = ''
129 magic_args = ''
130 fn = getattr(__IPYTHON__,'magic_'+magic_name,None)
130 fn = getattr(__IPYTHON__,'magic_'+magic_name,None)
131 if fn is None:
131 if fn is None:
132 error("Magic function `%s` not found." % magic_name)
132 error("Magic function `%s` not found." % magic_name)
133 else:
133 else:
134 magic_args = __IPYTHON__.var_expand(magic_args)
134 magic_args = __IPYTHON__.var_expand(magic_args)
135 return fn(magic_args)
135 return fn(magic_args)
136
136
137 def ipalias(arg_s):
137 def ipalias(arg_s):
138 """Call an alias by name.
138 """Call an alias by name.
139
139
140 Input: a string containing the name of the alias to call and any
140 Input: a string containing the name of the alias to call and any
141 additional arguments to be passed to the magic.
141 additional arguments to be passed to the magic.
142
142
143 ipalias('name -opt foo bar') is equivalent to typing at the ipython
143 ipalias('name -opt foo bar') is equivalent to typing at the ipython
144 prompt:
144 prompt:
145
145
146 In[1]: name -opt foo bar
146 In[1]: name -opt foo bar
147
147
148 To call an alias without arguments, simply use ipalias('name').
148 To call an alias without arguments, simply use ipalias('name').
149
149
150 This provides a proper Python function to call IPython's aliases in any
150 This provides a proper Python function to call IPython's aliases in any
151 valid Python code you can type at the interpreter, including loops and
151 valid Python code you can type at the interpreter, including loops and
152 compound statements. It is added by IPython to the Python builtin
152 compound statements. It is added by IPython to the Python builtin
153 namespace upon initialization."""
153 namespace upon initialization."""
154
154
155 args = arg_s.split(' ',1)
155 args = arg_s.split(' ',1)
156 alias_name = args[0]
156 alias_name = args[0]
157 try:
157 try:
158 alias_args = args[1]
158 alias_args = args[1]
159 except IndexError:
159 except IndexError:
160 alias_args = ''
160 alias_args = ''
161 if alias_name in __IPYTHON__.alias_table:
161 if alias_name in __IPYTHON__.alias_table:
162 __IPYTHON__.call_alias(alias_name,alias_args)
162 __IPYTHON__.call_alias(alias_name,alias_args)
163 else:
163 else:
164 error("Alias `%s` not found." % alias_name)
164 error("Alias `%s` not found." % alias_name)
165
165
166 #-----------------------------------------------------------------------------
166 #-----------------------------------------------------------------------------
167 # Local use classes
167 # Local use classes
168 try:
168 try:
169 from IPython import FlexCompleter
169 from IPython import FlexCompleter
170
170
171 class MagicCompleter(FlexCompleter.Completer):
171 class MagicCompleter(FlexCompleter.Completer):
172 """Extension of the completer class to work on %-prefixed lines."""
172 """Extension of the completer class to work on %-prefixed lines."""
173
173
174 def __init__(self,shell,namespace=None,omit__names=0,alias_table=None):
174 def __init__(self,shell,namespace=None,global_namespace=None,
175 omit__names=0,alias_table=None):
175 """MagicCompleter() -> completer
176 """MagicCompleter() -> completer
176
177
177 Return a completer object suitable for use by the readline library
178 Return a completer object suitable for use by the readline library
178 via readline.set_completer().
179 via readline.set_completer().
179
180
180 Inputs:
181 Inputs:
181
182
182 - shell: a pointer to the ipython shell itself. This is needed
183 - shell: a pointer to the ipython shell itself. This is needed
183 because this completer knows about magic functions, and those can
184 because this completer knows about magic functions, and those can
184 only be accessed via the ipython instance.
185 only be accessed via the ipython instance.
185
186
186 - namespace: an optional dict where completions are performed.
187 - namespace: an optional dict where completions are performed.
188
189 - global_namespace: secondary optional dict for completions, to
190 handle cases (such as IPython embedded inside functions) where
191 both Python scopes are visible.
187
192
188 - The optional omit__names parameter sets the completer to omit the
193 - The optional omit__names parameter sets the completer to omit the
189 'magic' names (__magicname__) for python objects unless the text
194 'magic' names (__magicname__) for python objects unless the text
190 to be completed explicitly starts with one or more underscores.
195 to be completed explicitly starts with one or more underscores.
191
196
192 - If alias_table is supplied, it should be a dictionary of aliases
197 - If alias_table is supplied, it should be a dictionary of aliases
193 to complete. """
198 to complete. """
194
199
195 FlexCompleter.Completer.__init__(self,namespace)
200 FlexCompleter.Completer.__init__(self,namespace)
196 self.magic_prefix = shell.name+'.magic_'
201 self.magic_prefix = shell.name+'.magic_'
197 self.magic_escape = shell.ESC_MAGIC
202 self.magic_escape = shell.ESC_MAGIC
198 self.readline = FlexCompleter.readline
203 self.readline = FlexCompleter.readline
199 delims = self.readline.get_completer_delims()
204 delims = self.readline.get_completer_delims()
200 delims = delims.replace(self.magic_escape,'')
205 delims = delims.replace(self.magic_escape,'')
201 self.readline.set_completer_delims(delims)
206 self.readline.set_completer_delims(delims)
202 self.get_line_buffer = self.readline.get_line_buffer
207 self.get_line_buffer = self.readline.get_line_buffer
203 self.omit__names = omit__names
208 self.omit__names = omit__names
204 self.merge_completions = shell.rc.readline_merge_completions
209 self.merge_completions = shell.rc.readline_merge_completions
205
210
206 if alias_table is None:
211 if alias_table is None:
207 alias_table = {}
212 alias_table = {}
208 self.alias_table = alias_table
213 self.alias_table = alias_table
209 # Regexp to split filenames with spaces in them
214 # Regexp to split filenames with spaces in them
210 self.space_name_re = re.compile(r'([^\\] )')
215 self.space_name_re = re.compile(r'([^\\] )')
211 # Hold a local ref. to glob.glob for speed
216 # Hold a local ref. to glob.glob for speed
212 self.glob = glob.glob
217 self.glob = glob.glob
213 # Special handling of backslashes needed in win32 platforms
218 # Special handling of backslashes needed in win32 platforms
214 if sys.platform == "win32":
219 if sys.platform == "win32":
215 self.clean_glob = self._clean_glob_win32
220 self.clean_glob = self._clean_glob_win32
216 else:
221 else:
217 self.clean_glob = self._clean_glob
222 self.clean_glob = self._clean_glob
218 self.matchers = [self.python_matches,
223 self.matchers = [self.python_matches,
219 self.file_matches,
224 self.file_matches,
220 self.alias_matches,
225 self.alias_matches,
221 self.python_func_kw_matches]
226 self.python_func_kw_matches]
222
227
223 # Code contributed by Alex Schmolck, for ipython/emacs integration
228 # Code contributed by Alex Schmolck, for ipython/emacs integration
224 def all_completions(self, text):
229 def all_completions(self, text):
225 """Return all possible completions for the benefit of emacs."""
230 """Return all possible completions for the benefit of emacs."""
226
231
227 completions = []
232 completions = []
233 comp_append = completions.append
228 try:
234 try:
229 for i in xrange(sys.maxint):
235 for i in xrange(sys.maxint):
230 res = self.complete(text, i)
236 res = self.complete(text, i)
231
237
232 if not res: break
238 if not res: break
233
239
234 completions.append(res)
240 comp_append(res)
235 #XXX workaround for ``notDefined.<tab>``
241 #XXX workaround for ``notDefined.<tab>``
236 except NameError:
242 except NameError:
237 pass
243 pass
238 return completions
244 return completions
239 # /end Alex Schmolck code.
245 # /end Alex Schmolck code.
240
246
241 def _clean_glob(self,text):
247 def _clean_glob(self,text):
242 return self.glob("%s*" % text)
248 return self.glob("%s*" % text)
243
249
244 def _clean_glob_win32(self,text):
250 def _clean_glob_win32(self,text):
245 return [f.replace("\\","/")
251 return [f.replace("\\","/")
246 for f in self.glob("%s*" % text)]
252 for f in self.glob("%s*" % text)]
247
253
248 def file_matches(self, text):
254 def file_matches(self, text):
249 """Match filneames, expanding ~USER type strings.
255 """Match filneames, expanding ~USER type strings.
250
256
251 Most of the seemingly convoluted logic in this completer is an
257 Most of the seemingly convoluted logic in this completer is an
252 attempt to handle filenames with spaces in them. And yet it's not
258 attempt to handle filenames with spaces in them. And yet it's not
253 quite perfect, because Python's readline doesn't expose all of the
259 quite perfect, because Python's readline doesn't expose all of the
254 GNU readline details needed for this to be done correctly.
260 GNU readline details needed for this to be done correctly.
255
261
256 For a filename with a space in it, the printed completions will be
262 For a filename with a space in it, the printed completions will be
257 only the parts after what's already been typed (instead of the
263 only the parts after what's already been typed (instead of the
258 full completions, as is normally done). I don't think with the
264 full completions, as is normally done). I don't think with the
259 current (as of Python 2.3) Python readline it's possible to do
265 current (as of Python 2.3) Python readline it's possible to do
260 better."""
266 better."""
261
267
262 #print 'Completer->file_matches: <%s>' % text # dbg
268 #print 'Completer->file_matches: <%s>' % text # dbg
263
269
264 # chars that require escaping with backslash - i.e. chars
270 # chars that require escaping with backslash - i.e. chars
265 # that readline treats incorrectly as delimiters, but we
271 # that readline treats incorrectly as delimiters, but we
266 # don't want to treat as delimiters in filename matching
272 # don't want to treat as delimiters in filename matching
267 # when escaped with backslash
273 # when escaped with backslash
268
274
269 protectables = ' ()[]{}'
275 protectables = ' ()[]{}'
270
276
271 def protect_filename(s):
277 def protect_filename(s):
272 return "".join([(ch in protectables and '\\' + ch or ch)
278 return "".join([(ch in protectables and '\\' + ch or ch)
273 for ch in s])
279 for ch in s])
274
280
275 lbuf = self.get_line_buffer()[:self.readline.get_endidx()]
281 lbuf = self.get_line_buffer()[:self.readline.get_endidx()]
276 open_quotes = 0 # track strings with open quotes
282 open_quotes = 0 # track strings with open quotes
277 try:
283 try:
278 lsplit = shlex_split(lbuf)[-1]
284 lsplit = shlex_split(lbuf)[-1]
279 except ValueError:
285 except ValueError:
280 # typically an unmatched ", or backslash without escaped char.
286 # typically an unmatched ", or backslash without escaped char.
281 if lbuf.count('"')==1:
287 if lbuf.count('"')==1:
282 open_quotes = 1
288 open_quotes = 1
283 lsplit = lbuf.split('"')[-1]
289 lsplit = lbuf.split('"')[-1]
284 elif lbuf.count("'")==1:
290 elif lbuf.count("'")==1:
285 open_quotes = 1
291 open_quotes = 1
286 lsplit = lbuf.split("'")[-1]
292 lsplit = lbuf.split("'")[-1]
287 else:
293 else:
288 return None
294 return None
289 except IndexError:
295 except IndexError:
290 # tab pressed on empty line
296 # tab pressed on empty line
291 lsplit = ""
297 lsplit = ""
292
298
293 if lsplit != protect_filename(lsplit):
299 if lsplit != protect_filename(lsplit):
294 # if protectables are found, do matching on the whole escaped
300 # if protectables are found, do matching on the whole escaped
295 # name
301 # name
296 has_protectables = 1
302 has_protectables = 1
297 text0,text = text,lsplit
303 text0,text = text,lsplit
298 else:
304 else:
299 has_protectables = 0
305 has_protectables = 0
300 text = os.path.expanduser(text)
306 text = os.path.expanduser(text)
301
307
302 if text == "":
308 if text == "":
303 return [protect_filename(f) for f in self.glob("*")]
309 return [protect_filename(f) for f in self.glob("*")]
304
310
305 m0 = self.clean_glob(text.replace('\\',''))
311 m0 = self.clean_glob(text.replace('\\',''))
306 if has_protectables:
312 if has_protectables:
307 # If we had protectables, we need to revert our changes to the
313 # If we had protectables, we need to revert our changes to the
308 # beginning of filename so that we don't double-write the part
314 # beginning of filename so that we don't double-write the part
309 # of the filename we have so far
315 # of the filename we have so far
310 len_lsplit = len(lsplit)
316 len_lsplit = len(lsplit)
311 matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0]
317 matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0]
312 else:
318 else:
313 if open_quotes:
319 if open_quotes:
314 # if we have a string with an open quote, we don't need to
320 # if we have a string with an open quote, we don't need to
315 # protect the names at all (and we _shouldn't_, as it
321 # protect the names at all (and we _shouldn't_, as it
316 # would cause bugs when the filesystem call is made).
322 # would cause bugs when the filesystem call is made).
317 matches = m0
323 matches = m0
318 else:
324 else:
319 matches = [protect_filename(f) for f in m0]
325 matches = [protect_filename(f) for f in m0]
320 if len(matches) == 1 and os.path.isdir(matches[0]):
326 if len(matches) == 1 and os.path.isdir(matches[0]):
321 # Takes care of links to directories also. Use '/'
327 # Takes care of links to directories also. Use '/'
322 # explicitly, even under Windows, so that name completions
328 # explicitly, even under Windows, so that name completions
323 # don't end up escaped.
329 # don't end up escaped.
324 matches[0] += '/'
330 matches[0] += '/'
325 return matches
331 return matches
326
332
327 def alias_matches(self, text):
333 def alias_matches(self, text):
328 """Match internal system aliases"""
334 """Match internal system aliases"""
329 #print 'Completer->alias_matches:',text # dbg
335 #print 'Completer->alias_matches:',text # dbg
330 text = os.path.expanduser(text)
336 text = os.path.expanduser(text)
331 aliases = self.alias_table.keys()
337 aliases = self.alias_table.keys()
332 if text == "":
338 if text == "":
333 return aliases
339 return aliases
334 else:
340 else:
335 return [alias for alias in aliases if alias.startswith(text)]
341 return [alias for alias in aliases if alias.startswith(text)]
336
342
337 def python_matches(self,text):
343 def python_matches(self,text):
338 """Match attributes or global python names"""
344 """Match attributes or global python names"""
339 #print 'Completer->python_matches' # dbg
345 #print 'Completer->python_matches' # dbg
340 if "." in text:
346 if "." in text:
341 try:
347 try:
342 matches = self.attr_matches(text)
348 matches = self.attr_matches(text)
343 if text.endswith('.') and self.omit__names:
349 if text.endswith('.') and self.omit__names:
344 if self.omit__names == 1:
350 if self.omit__names == 1:
345 # true if txt is _not_ a __ name, false otherwise:
351 # true if txt is _not_ a __ name, false otherwise:
346 no__name = (lambda txt:
352 no__name = (lambda txt:
347 re.match(r'.*\.__.*?__',txt) is None)
353 re.match(r'.*\.__.*?__',txt) is None)
348 else:
354 else:
349 # true if txt is _not_ a _ name, false otherwise:
355 # true if txt is _not_ a _ name, false otherwise:
350 no__name = (lambda txt:
356 no__name = (lambda txt:
351 re.match(r'.*\._.*?',txt) is None)
357 re.match(r'.*\._.*?',txt) is None)
352 matches = filter(no__name, matches)
358 matches = filter(no__name, matches)
353 except NameError:
359 except NameError:
354 # catches <undefined attributes>.<tab>
360 # catches <undefined attributes>.<tab>
355 matches = []
361 matches = []
356 else:
362 else:
357 matches = self.global_matches(text)
363 matches = self.global_matches(text)
358 # this is so completion finds magics when automagic is on:
364 # this is so completion finds magics when automagic is on:
359 if matches == [] and not text.startswith(os.sep):
365 if matches == [] and not text.startswith(os.sep):
360 matches = self.attr_matches(self.magic_prefix+text)
366 matches = self.attr_matches(self.magic_prefix+text)
361 return matches
367 return matches
362
368
363 def _default_arguments(self, obj):
369 def _default_arguments(self, obj):
364 """Return the list of default arguments of obj if it is callable,
370 """Return the list of default arguments of obj if it is callable,
365 or empty list otherwise."""
371 or empty list otherwise."""
366
372
367 if not (inspect.isfunction(obj) or inspect.ismethod(obj)):
373 if not (inspect.isfunction(obj) or inspect.ismethod(obj)):
368 # for classes, check for __init__,__new__
374 # for classes, check for __init__,__new__
369 if inspect.isclass(obj):
375 if inspect.isclass(obj):
370 obj = (getattr(obj,'__init__',None) or
376 obj = (getattr(obj,'__init__',None) or
371 getattr(obj,'__new__',None))
377 getattr(obj,'__new__',None))
372 # for all others, check if they are __call__able
378 # for all others, check if they are __call__able
373 elif hasattr(obj, '__call__'):
379 elif hasattr(obj, '__call__'):
374 obj = obj.__call__
380 obj = obj.__call__
375 # XXX: is there a way to handle the builtins ?
381 # XXX: is there a way to handle the builtins ?
376 try:
382 try:
377 args,_,_1,defaults = inspect.getargspec(obj)
383 args,_,_1,defaults = inspect.getargspec(obj)
378 if defaults:
384 if defaults:
379 return args[-len(defaults):]
385 return args[-len(defaults):]
380 except TypeError: pass
386 except TypeError: pass
381 return []
387 return []
382
388
383 def python_func_kw_matches(self,text):
389 def python_func_kw_matches(self,text):
384 """Match named parameters (kwargs) of the last open function"""
390 """Match named parameters (kwargs) of the last open function"""
385
391
386 if "." in text: # a parameter cannot be dotted
392 if "." in text: # a parameter cannot be dotted
387 return []
393 return []
388 try: regexp = self.__funcParamsRegex
394 try: regexp = self.__funcParamsRegex
389 except AttributeError:
395 except AttributeError:
390 regexp = self.__funcParamsRegex = re.compile(r'''
396 regexp = self.__funcParamsRegex = re.compile(r'''
391 '.*?' | # single quoted strings or
397 '.*?' | # single quoted strings or
392 ".*?" | # double quoted strings or
398 ".*?" | # double quoted strings or
393 \w+ | # identifier
399 \w+ | # identifier
394 \S # other characters
400 \S # other characters
395 ''', re.VERBOSE | re.DOTALL)
401 ''', re.VERBOSE | re.DOTALL)
396 # 1. find the nearest identifier that comes before an unclosed
402 # 1. find the nearest identifier that comes before an unclosed
397 # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo"
403 # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo"
398 tokens = regexp.findall(self.get_line_buffer())
404 tokens = regexp.findall(self.get_line_buffer())
399 tokens.reverse()
405 tokens.reverse()
400 iterTokens = iter(tokens); openPar = 0
406 iterTokens = iter(tokens); openPar = 0
401 for token in iterTokens:
407 for token in iterTokens:
402 if token == ')':
408 if token == ')':
403 openPar -= 1
409 openPar -= 1
404 elif token == '(':
410 elif token == '(':
405 openPar += 1
411 openPar += 1
406 if openPar > 0:
412 if openPar > 0:
407 # found the last unclosed parenthesis
413 # found the last unclosed parenthesis
408 break
414 break
409 else:
415 else:
410 return []
416 return []
411 # 2. Concatenate any dotted names (e.g. "foo.bar" for "foo.bar(x, pa" )
417 # 2. Concatenate any dotted names (e.g. "foo.bar" for "foo.bar(x, pa" )
412 ids = []
418 ids = []
413 isId = re.compile(r'\w+$').match
419 isId = re.compile(r'\w+$').match
414 while True:
420 while True:
415 try:
421 try:
416 ids.append(iterTokens.next())
422 ids.append(iterTokens.next())
417 if not isId(ids[-1]):
423 if not isId(ids[-1]):
418 ids.pop(); break
424 ids.pop(); break
419 if not iterTokens.next() == '.':
425 if not iterTokens.next() == '.':
420 break
426 break
421 except StopIteration:
427 except StopIteration:
422 break
428 break
423 # lookup the candidate callable matches either using global_matches
429 # lookup the candidate callable matches either using global_matches
424 # or attr_matches for dotted names
430 # or attr_matches for dotted names
425 if len(ids) == 1:
431 if len(ids) == 1:
426 callableMatches = self.global_matches(ids[0])
432 callableMatches = self.global_matches(ids[0])
427 else:
433 else:
428 callableMatches = self.attr_matches('.'.join(ids[::-1]))
434 callableMatches = self.attr_matches('.'.join(ids[::-1]))
429 argMatches = []
435 argMatches = []
430 for callableMatch in callableMatches:
436 for callableMatch in callableMatches:
431 try: namedArgs = self._default_arguments(eval(callableMatch,
437 try: namedArgs = self._default_arguments(eval(callableMatch,
432 self.namespace))
438 self.namespace))
433 except: continue
439 except: continue
434 for namedArg in namedArgs:
440 for namedArg in namedArgs:
435 if namedArg.startswith(text):
441 if namedArg.startswith(text):
436 argMatches.append("%s=" %namedArg)
442 argMatches.append("%s=" %namedArg)
437 return argMatches
443 return argMatches
438
444
439 def complete(self, text, state):
445 def complete(self, text, state):
440 """Return the next possible completion for 'text'.
446 """Return the next possible completion for 'text'.
441
447
442 This is called successively with state == 0, 1, 2, ... until it
448 This is called successively with state == 0, 1, 2, ... until it
443 returns None. The completion should begin with 'text'. """
449 returns None. The completion should begin with 'text'. """
444
450
445 #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg
451 #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg
446 magic_escape = self.magic_escape
452 magic_escape = self.magic_escape
447 magic_prefix = self.magic_prefix
453 magic_prefix = self.magic_prefix
448
454
449 try:
455 try:
450 if text.startswith(magic_escape):
456 if text.startswith(magic_escape):
451 text = text.replace(magic_escape,magic_prefix)
457 text = text.replace(magic_escape,magic_prefix)
452 elif text.startswith('~'):
458 elif text.startswith('~'):
453 text = os.path.expanduser(text)
459 text = os.path.expanduser(text)
454 if state == 0:
460 if state == 0:
455 # Extend the list of completions with the results of each
461 # Extend the list of completions with the results of each
456 # matcher, so we return results to the user from all
462 # matcher, so we return results to the user from all
457 # namespaces.
463 # namespaces.
458 if self.merge_completions:
464 if self.merge_completions:
459 self.matches = []
465 self.matches = []
460 for matcher in self.matchers:
466 for matcher in self.matchers:
461 self.matches.extend(matcher(text))
467 self.matches.extend(matcher(text))
462 else:
468 else:
463 for matcher in self.matchers:
469 for matcher in self.matchers:
464 self.matches = matcher(text)
470 self.matches = matcher(text)
465 if self.matches:
471 if self.matches:
466 break
472 break
467
473
468 try:
474 try:
469 return self.matches[state].replace(magic_prefix,magic_escape)
475 return self.matches[state].replace(magic_prefix,magic_escape)
470 except IndexError:
476 except IndexError:
471 return None
477 return None
472 except:
478 except:
473 # If completion fails, don't annoy the user.
479 # If completion fails, don't annoy the user.
474 pass
480 pass
475
481
476 except ImportError:
482 except ImportError:
477 pass # no readline support
483 pass # no readline support
478
484
479 except KeyError:
485 except KeyError:
480 pass # Windows doesn't set TERM, it doesn't matter
486 pass # Windows doesn't set TERM, it doesn't matter
481
487
482
488
483 class InputList(UserList.UserList):
489 class InputList(UserList.UserList):
484 """Class to store user input.
490 """Class to store user input.
485
491
486 It's basically a list, but slices return a string instead of a list, thus
492 It's basically a list, but slices return a string instead of a list, thus
487 allowing things like (assuming 'In' is an instance):
493 allowing things like (assuming 'In' is an instance):
488
494
489 exec In[4:7]
495 exec In[4:7]
490
496
491 or
497 or
492
498
493 exec In[5:9] + In[14] + In[21:25]"""
499 exec In[5:9] + In[14] + In[21:25]"""
494
500
495 def __getslice__(self,i,j):
501 def __getslice__(self,i,j):
496 return ''.join(UserList.UserList.__getslice__(self,i,j))
502 return ''.join(UserList.UserList.__getslice__(self,i,j))
497
503
498 #****************************************************************************
504 #****************************************************************************
499 # Local use exceptions
505 # Local use exceptions
500 class SpaceInInput(exceptions.Exception):
506 class SpaceInInput(exceptions.Exception):
501 pass
507 pass
502
508
503 #****************************************************************************
509 #****************************************************************************
504 # Main IPython class
510 # Main IPython class
505
511
506 class InteractiveShell(code.InteractiveConsole, Logger, Magic):
512 class InteractiveShell(code.InteractiveConsole, Logger, Magic):
507 """An enhanced console for Python."""
513 """An enhanced console for Python."""
508
514
509 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
515 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
510 user_ns = None,user_global_ns=None,banner2='',
516 user_ns = None,user_global_ns=None,banner2='',
511 custom_exceptions=((),None),embedded=False):
517 custom_exceptions=((),None),embedded=False):
512
518
513 # Put a reference to self in builtins so that any form of embedded or
519 # Put a reference to self in builtins so that any form of embedded or
514 # imported code can test for being inside IPython.
520 # imported code can test for being inside IPython.
515 __builtin__.__IPYTHON__ = self
521 __builtin__.__IPYTHON__ = self
516
522
517 # And load into builtins ipmagic/ipalias as well
523 # And load into builtins ipmagic/ipalias as well
518 __builtin__.ipmagic = ipmagic
524 __builtin__.ipmagic = ipmagic
519 __builtin__.ipalias = ipalias
525 __builtin__.ipalias = ipalias
520
526
521 # Add to __builtin__ other parts of IPython's public API
527 # Add to __builtin__ other parts of IPython's public API
522 __builtin__.ip_set_hook = self.set_hook
528 __builtin__.ip_set_hook = self.set_hook
523
529
524 # Keep in the builtins a flag for when IPython is active. We set it
530 # Keep in the builtins a flag for when IPython is active. We set it
525 # with setdefault so that multiple nested IPythons don't clobber one
531 # with setdefault so that multiple nested IPythons don't clobber one
526 # another. Each will increase its value by one upon being activated,
532 # another. Each will increase its value by one upon being activated,
527 # which also gives us a way to determine the nesting level.
533 # which also gives us a way to determine the nesting level.
528 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
534 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
529
535
530 # Inform the user of ipython's fast exit magics.
536 # Inform the user of ipython's fast exit magics.
531 _exit = ' Use %Exit or %Quit to exit without confirmation.'
537 _exit = ' Use %Exit or %Quit to exit without confirmation.'
532 __builtin__.exit += _exit
538 __builtin__.exit += _exit
533 __builtin__.quit += _exit
539 __builtin__.quit += _exit
534
540
535 # We need to know whether the instance is meant for embedding, since
541 # We need to know whether the instance is meant for embedding, since
536 # global/local namespaces need to be handled differently in that case
542 # global/local namespaces need to be handled differently in that case
537 self.embedded = embedded
543 self.embedded = embedded
538
544
539 # compiler command
545 # compiler command
540 self.compile = CommandCompiler()
546 self.compile = CommandCompiler()
541
547
542 # User input buffer
548 # User input buffer
543 self.buffer = []
549 self.buffer = []
544
550
545 # Default name given in compilation of code
551 # Default name given in compilation of code
546 self.filename = '<ipython console>'
552 self.filename = '<ipython console>'
547
553
548 # Create the namespace where the user will operate. user_ns is
554 # Create the namespace where the user will operate. user_ns is
549 # normally the only one used, and it is passed to the exec calls as
555 # normally the only one used, and it is passed to the exec calls as
550 # the locals argument. But we do carry a user_global_ns namespace
556 # the locals argument. But we do carry a user_global_ns namespace
551 # given as the exec 'globals' argument, This is useful in embedding
557 # given as the exec 'globals' argument, This is useful in embedding
552 # situations where the ipython shell opens in a context where the
558 # situations where the ipython shell opens in a context where the
553 # distinction between locals and globals is meaningful.
559 # distinction between locals and globals is meaningful.
554
560
555 # FIXME. For some strange reason, __builtins__ is showing up at user
561 # FIXME. For some strange reason, __builtins__ is showing up at user
556 # level as a dict instead of a module. This is a manual fix, but I
562 # level as a dict instead of a module. This is a manual fix, but I
557 # should really track down where the problem is coming from. Alex
563 # should really track down where the problem is coming from. Alex
558 # Schmolck reported this problem first.
564 # Schmolck reported this problem first.
559
565
560 # A useful post by Alex Martelli on this topic:
566 # A useful post by Alex Martelli on this topic:
561 # Re: inconsistent value from __builtins__
567 # Re: inconsistent value from __builtins__
562 # Von: Alex Martelli <aleaxit@yahoo.com>
568 # Von: Alex Martelli <aleaxit@yahoo.com>
563 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
569 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
564 # Gruppen: comp.lang.python
570 # Gruppen: comp.lang.python
565 # Referenzen: 1
571 # Referenzen: 1
566
572
567 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
573 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
568 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
574 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
569 # > <type 'dict'>
575 # > <type 'dict'>
570 # > >>> print type(__builtins__)
576 # > >>> print type(__builtins__)
571 # > <type 'module'>
577 # > <type 'module'>
572 # > Is this difference in return value intentional?
578 # > Is this difference in return value intentional?
573
579
574 # Well, it's documented that '__builtins__' can be either a dictionary
580 # Well, it's documented that '__builtins__' can be either a dictionary
575 # or a module, and it's been that way for a long time. Whether it's
581 # or a module, and it's been that way for a long time. Whether it's
576 # intentional (or sensible), I don't know. In any case, the idea is that
582 # intentional (or sensible), I don't know. In any case, the idea is that
577 # if you need to access the built-in namespace directly, you should start
583 # if you need to access the built-in namespace directly, you should start
578 # with "import __builtin__" (note, no 's') which will definitely give you
584 # with "import __builtin__" (note, no 's') which will definitely give you
579 # a module. Yeah, it's somewhatΒ confusing:-(.
585 # a module. Yeah, it's somewhatΒ confusing:-(.
580
586
581 if user_ns is None:
587 if user_ns is None:
582 # Set __name__ to __main__ to better match the behavior of the
588 # Set __name__ to __main__ to better match the behavior of the
583 # normal interpreter.
589 # normal interpreter.
584 user_ns = {'__name__' :'__main__',
590 user_ns = {'__name__' :'__main__',
585 '__builtins__' : __builtin__,
591 '__builtins__' : __builtin__,
586 }
592 }
587
593
588 if user_global_ns is None:
594 if user_global_ns is None:
589 user_global_ns = {}
595 user_global_ns = {}
590
596
591 # Assign namespaces
597 # Assign namespaces
592 # This is the namespace where all normal user variables live
598 # This is the namespace where all normal user variables live
593 self.user_ns = user_ns
599 self.user_ns = user_ns
594 # Embedded instances require a separate namespace for globals.
600 # Embedded instances require a separate namespace for globals.
595 # Normally this one is unused by non-embedded instances.
601 # Normally this one is unused by non-embedded instances.
596 self.user_global_ns = user_global_ns
602 self.user_global_ns = user_global_ns
597 # A namespace to keep track of internal data structures to prevent
603 # A namespace to keep track of internal data structures to prevent
598 # them from cluttering user-visible stuff. Will be updated later
604 # them from cluttering user-visible stuff. Will be updated later
599 self.internal_ns = {}
605 self.internal_ns = {}
600
606
601 # Namespace of system aliases. Each entry in the alias
607 # Namespace of system aliases. Each entry in the alias
602 # table must be a 2-tuple of the form (N,name), where N is the number
608 # table must be a 2-tuple of the form (N,name), where N is the number
603 # of positional arguments of the alias.
609 # of positional arguments of the alias.
604 self.alias_table = {}
610 self.alias_table = {}
605
611
606 # A table holding all the namespaces IPython deals with, so that
612 # A table holding all the namespaces IPython deals with, so that
607 # introspection facilities can search easily.
613 # introspection facilities can search easily.
608 self.ns_table = {'user':user_ns,
614 self.ns_table = {'user':user_ns,
609 'user_global':user_global_ns,
615 'user_global':user_global_ns,
610 'alias':self.alias_table,
616 'alias':self.alias_table,
611 'internal':self.internal_ns,
617 'internal':self.internal_ns,
612 'builtin':__builtin__.__dict__
618 'builtin':__builtin__.__dict__
613 }
619 }
614
620
615 # The user namespace MUST have a pointer to the shell itself.
621 # The user namespace MUST have a pointer to the shell itself.
616 self.user_ns[name] = self
622 self.user_ns[name] = self
617
623
618 # We need to insert into sys.modules something that looks like a
624 # We need to insert into sys.modules something that looks like a
619 # module but which accesses the IPython namespace, for shelve and
625 # module but which accesses the IPython namespace, for shelve and
620 # pickle to work interactively. Normally they rely on getting
626 # pickle to work interactively. Normally they rely on getting
621 # everything out of __main__, but for embedding purposes each IPython
627 # everything out of __main__, but for embedding purposes each IPython
622 # instance has its own private namespace, so we can't go shoving
628 # instance has its own private namespace, so we can't go shoving
623 # everything into __main__.
629 # everything into __main__.
624
630
625 try:
631 # note, however, that we should only do this for non-embedded
626 main_name = self.user_ns['__name__']
632 # ipythons, which really mimic the __main__.__dict__ with their own
627 except KeyError:
633 # namespace. Embedded instances, on the other hand, should not do
628 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
634 # this because they need to manage the user local/global namespaces
629 else:
635 # only, but they live within a 'normal' __main__ (meaning, they
630 #print "pickle hack in place" # dbg
636 # shouldn't overtake the execution environment of the script they're
631 sys.modules[main_name] = FakeModule(self.user_ns)
637 # embedded in).
638
639 if not embedded:
640 try:
641 main_name = self.user_ns['__name__']
642 except KeyError:
643 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
644 else:
645 #print "pickle hack in place" # dbg
646 sys.modules[main_name] = FakeModule(self.user_ns)
632
647
633 # List of input with multi-line handling.
648 # List of input with multi-line handling.
634 # Fill its zero entry, user counter starts at 1
649 # Fill its zero entry, user counter starts at 1
635 self.input_hist = InputList(['\n'])
650 self.input_hist = InputList(['\n'])
636
651
637 # list of visited directories
652 # list of visited directories
638 try:
653 try:
639 self.dir_hist = [os.getcwd()]
654 self.dir_hist = [os.getcwd()]
640 except IOError, e:
655 except IOError, e:
641 self.dir_hist = []
656 self.dir_hist = []
642
657
643 # dict of output history
658 # dict of output history
644 self.output_hist = {}
659 self.output_hist = {}
645
660
646 # dict of things NOT to alias (keywords, builtins and some special magics)
661 # dict of things NOT to alias (keywords, builtins and some special magics)
647 no_alias = {}
662 no_alias = {}
648 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
663 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
649 for key in keyword.kwlist + no_alias_magics:
664 for key in keyword.kwlist + no_alias_magics:
650 no_alias[key] = 1
665 no_alias[key] = 1
651 no_alias.update(__builtin__.__dict__)
666 no_alias.update(__builtin__.__dict__)
652 self.no_alias = no_alias
667 self.no_alias = no_alias
653
668
654 # make global variables for user access to these
669 # make global variables for user access to these
655 self.user_ns['_ih'] = self.input_hist
670 self.user_ns['_ih'] = self.input_hist
656 self.user_ns['_oh'] = self.output_hist
671 self.user_ns['_oh'] = self.output_hist
657 self.user_ns['_dh'] = self.dir_hist
672 self.user_ns['_dh'] = self.dir_hist
658
673
659 # user aliases to input and output histories
674 # user aliases to input and output histories
660 self.user_ns['In'] = self.input_hist
675 self.user_ns['In'] = self.input_hist
661 self.user_ns['Out'] = self.output_hist
676 self.user_ns['Out'] = self.output_hist
662
677
663 # Store the actual shell's name
678 # Store the actual shell's name
664 self.name = name
679 self.name = name
665
680
666 # Object variable to store code object waiting execution. This is
681 # Object variable to store code object waiting execution. This is
667 # used mainly by the multithreaded shells, but it can come in handy in
682 # used mainly by the multithreaded shells, but it can come in handy in
668 # other situations. No need to use a Queue here, since it's a single
683 # other situations. No need to use a Queue here, since it's a single
669 # item which gets cleared once run.
684 # item which gets cleared once run.
670 self.code_to_run = None
685 self.code_to_run = None
671
686
672 # Job manager (for jobs run as background threads)
687 # Job manager (for jobs run as background threads)
673 self.jobs = BackgroundJobManager()
688 self.jobs = BackgroundJobManager()
674 # Put the job manager into builtins so it's always there.
689 # Put the job manager into builtins so it's always there.
675 __builtin__.jobs = self.jobs
690 __builtin__.jobs = self.jobs
676
691
677 # escapes for automatic behavior on the command line
692 # escapes for automatic behavior on the command line
678 self.ESC_SHELL = '!'
693 self.ESC_SHELL = '!'
679 self.ESC_HELP = '?'
694 self.ESC_HELP = '?'
680 self.ESC_MAGIC = '%'
695 self.ESC_MAGIC = '%'
681 self.ESC_QUOTE = ','
696 self.ESC_QUOTE = ','
682 self.ESC_QUOTE2 = ';'
697 self.ESC_QUOTE2 = ';'
683 self.ESC_PAREN = '/'
698 self.ESC_PAREN = '/'
684
699
685 # And their associated handlers
700 # And their associated handlers
686 self.esc_handlers = {self.ESC_PAREN:self.handle_auto,
701 self.esc_handlers = {self.ESC_PAREN:self.handle_auto,
687 self.ESC_QUOTE:self.handle_auto,
702 self.ESC_QUOTE:self.handle_auto,
688 self.ESC_QUOTE2:self.handle_auto,
703 self.ESC_QUOTE2:self.handle_auto,
689 self.ESC_MAGIC:self.handle_magic,
704 self.ESC_MAGIC:self.handle_magic,
690 self.ESC_HELP:self.handle_help,
705 self.ESC_HELP:self.handle_help,
691 self.ESC_SHELL:self.handle_shell_escape,
706 self.ESC_SHELL:self.handle_shell_escape,
692 }
707 }
693
708
694 # class initializations
709 # class initializations
695 Logger.__init__(self,log_ns = self.user_ns)
710 Logger.__init__(self,log_ns = self.user_ns)
696 Magic.__init__(self,self)
711 Magic.__init__(self,self)
697
712
698 # an ugly hack to get a pointer to the shell, so I can start writing
713 # an ugly hack to get a pointer to the shell, so I can start writing
699 # magic code via this pointer instead of the current mixin salad.
714 # magic code via this pointer instead of the current mixin salad.
700 Magic.set_shell(self,self)
715 Magic.set_shell(self,self)
701
716
702 # Python source parser/formatter for syntax highlighting
717 # Python source parser/formatter for syntax highlighting
703 pyformat = Parser().format
718 pyformat = Parser().format
704 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
719 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
705
720
706 # hooks holds pointers used for user-side customizations
721 # hooks holds pointers used for user-side customizations
707 self.hooks = Struct()
722 self.hooks = Struct()
708
723
709 # Set all default hooks, defined in the IPython.hooks module.
724 # Set all default hooks, defined in the IPython.hooks module.
710 hooks = IPython.hooks
725 hooks = IPython.hooks
711 for hook_name in hooks.__all__:
726 for hook_name in hooks.__all__:
712 self.set_hook(hook_name,getattr(hooks,hook_name))
727 self.set_hook(hook_name,getattr(hooks,hook_name))
713
728
714 # Flag to mark unconditional exit
729 # Flag to mark unconditional exit
715 self.exit_now = False
730 self.exit_now = False
716
731
717 self.usage_min = """\
732 self.usage_min = """\
718 An enhanced console for Python.
733 An enhanced console for Python.
719 Some of its features are:
734 Some of its features are:
720 - Readline support if the readline library is present.
735 - Readline support if the readline library is present.
721 - Tab completion in the local namespace.
736 - Tab completion in the local namespace.
722 - Logging of input, see command-line options.
737 - Logging of input, see command-line options.
723 - System shell escape via ! , eg !ls.
738 - System shell escape via ! , eg !ls.
724 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
739 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
725 - Keeps track of locally defined variables via %who, %whos.
740 - Keeps track of locally defined variables via %who, %whos.
726 - Show object information with a ? eg ?x or x? (use ?? for more info).
741 - Show object information with a ? eg ?x or x? (use ?? for more info).
727 """
742 """
728 if usage: self.usage = usage
743 if usage: self.usage = usage
729 else: self.usage = self.usage_min
744 else: self.usage = self.usage_min
730
745
731 # Storage
746 # Storage
732 self.rc = rc # This will hold all configuration information
747 self.rc = rc # This will hold all configuration information
733 self.inputcache = []
748 self.inputcache = []
734 self._boundcache = []
749 self._boundcache = []
735 self.pager = 'less'
750 self.pager = 'less'
736 # temporary files used for various purposes. Deleted at exit.
751 # temporary files used for various purposes. Deleted at exit.
737 self.tempfiles = []
752 self.tempfiles = []
738
753
739 # Keep track of readline usage (later set by init_readline)
754 # Keep track of readline usage (later set by init_readline)
740 self.has_readline = 0
755 self.has_readline = 0
741
756
742 # for pushd/popd management
757 # for pushd/popd management
743 try:
758 try:
744 self.home_dir = get_home_dir()
759 self.home_dir = get_home_dir()
745 except HomeDirError,msg:
760 except HomeDirError,msg:
746 fatal(msg)
761 fatal(msg)
747
762
748 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
763 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
749
764
750 # Functions to call the underlying shell.
765 # Functions to call the underlying shell.
751
766
752 # utility to expand user variables via Itpl
767 # utility to expand user variables via Itpl
753 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
768 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
754 self.user_ns))
769 self.user_ns))
755 # The first is similar to os.system, but it doesn't return a value,
770 # The first is similar to os.system, but it doesn't return a value,
756 # and it allows interpolation of variables in the user's namespace.
771 # and it allows interpolation of variables in the user's namespace.
757 self.system = lambda cmd: shell(self.var_expand(cmd),
772 self.system = lambda cmd: shell(self.var_expand(cmd),
758 header='IPython system call: ',
773 header='IPython system call: ',
759 verbose=self.rc.system_verbose)
774 verbose=self.rc.system_verbose)
760 # These are for getoutput and getoutputerror:
775 # These are for getoutput and getoutputerror:
761 self.getoutput = lambda cmd: \
776 self.getoutput = lambda cmd: \
762 getoutput(self.var_expand(cmd),
777 getoutput(self.var_expand(cmd),
763 header='IPython system call: ',
778 header='IPython system call: ',
764 verbose=self.rc.system_verbose)
779 verbose=self.rc.system_verbose)
765 self.getoutputerror = lambda cmd: \
780 self.getoutputerror = lambda cmd: \
766 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
781 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
767 self.user_ns)),
782 self.user_ns)),
768 header='IPython system call: ',
783 header='IPython system call: ',
769 verbose=self.rc.system_verbose)
784 verbose=self.rc.system_verbose)
770
785
771 # RegExp for splitting line contents into pre-char//first
786 # RegExp for splitting line contents into pre-char//first
772 # word-method//rest. For clarity, each group in on one line.
787 # word-method//rest. For clarity, each group in on one line.
773
788
774 # WARNING: update the regexp if the above escapes are changed, as they
789 # WARNING: update the regexp if the above escapes are changed, as they
775 # are hardwired in.
790 # are hardwired in.
776
791
777 # Don't get carried away with trying to make the autocalling catch too
792 # Don't get carried away with trying to make the autocalling catch too
778 # much: it's better to be conservative rather than to trigger hidden
793 # much: it's better to be conservative rather than to trigger hidden
779 # evals() somewhere and end up causing side effects.
794 # evals() somewhere and end up causing side effects.
780
795
781 self.line_split = re.compile(r'^([\s*,;/])'
796 self.line_split = re.compile(r'^([\s*,;/])'
782 r'([\?\w\.]+\w*\s*)'
797 r'([\?\w\.]+\w*\s*)'
783 r'(\(?.*$)')
798 r'(\(?.*$)')
784
799
785 # Original re, keep around for a while in case changes break something
800 # Original re, keep around for a while in case changes break something
786 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
801 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
787 # r'(\s*[\?\w\.]+\w*\s*)'
802 # r'(\s*[\?\w\.]+\w*\s*)'
788 # r'(\(?.*$)')
803 # r'(\(?.*$)')
789
804
790 # RegExp to identify potential function names
805 # RegExp to identify potential function names
791 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
806 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
792 # RegExp to exclude strings with this start from autocalling
807 # RegExp to exclude strings with this start from autocalling
793 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
808 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
794 # try to catch also methods for stuff in lists/tuples/dicts: off
809 # try to catch also methods for stuff in lists/tuples/dicts: off
795 # (experimental). For this to work, the line_split regexp would need
810 # (experimental). For this to work, the line_split regexp would need
796 # to be modified so it wouldn't break things at '['. That line is
811 # to be modified so it wouldn't break things at '['. That line is
797 # nasty enough that I shouldn't change it until I can test it _well_.
812 # nasty enough that I shouldn't change it until I can test it _well_.
798 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
813 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
799
814
800 # keep track of where we started running (mainly for crash post-mortem)
815 # keep track of where we started running (mainly for crash post-mortem)
801 self.starting_dir = os.getcwd()
816 self.starting_dir = os.getcwd()
802
817
803 # Attributes for Logger mixin class, make defaults here
818 # Attributes for Logger mixin class, make defaults here
804 self._dolog = 0
819 self._dolog = 0
805 self.LOG = ''
820 self.LOG = ''
806 self.LOGDEF = '.InteractiveShell.log'
821 self.LOGDEF = '.InteractiveShell.log'
807 self.LOGMODE = 'over'
822 self.LOGMODE = 'over'
808 self.LOGHEAD = Itpl(
823 self.LOGHEAD = Itpl(
809 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
824 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
810 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
825 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
811 #log# opts = $self.rc.opts
826 #log# opts = $self.rc.opts
812 #log# args = $self.rc.args
827 #log# args = $self.rc.args
813 #log# It is safe to make manual edits below here.
828 #log# It is safe to make manual edits below here.
814 #log#-----------------------------------------------------------------------
829 #log#-----------------------------------------------------------------------
815 """)
830 """)
816 # Various switches which can be set
831 # Various switches which can be set
817 self.CACHELENGTH = 5000 # this is cheap, it's just text
832 self.CACHELENGTH = 5000 # this is cheap, it's just text
818 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
833 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
819 self.banner2 = banner2
834 self.banner2 = banner2
820
835
821 # TraceBack handlers:
836 # TraceBack handlers:
822 # Need two, one for syntax errors and one for other exceptions.
837 # Need two, one for syntax errors and one for other exceptions.
823 self.SyntaxTB = ultraTB.ListTB(color_scheme='NoColor')
838 self.SyntaxTB = ultraTB.ListTB(color_scheme='NoColor')
824 # This one is initialized with an offset, meaning we always want to
839 # This one is initialized with an offset, meaning we always want to
825 # remove the topmost item in the traceback, which is our own internal
840 # remove the topmost item in the traceback, which is our own internal
826 # code. Valid modes: ['Plain','Context','Verbose']
841 # code. Valid modes: ['Plain','Context','Verbose']
827 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
842 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
828 color_scheme='NoColor',
843 color_scheme='NoColor',
829 tb_offset = 1)
844 tb_offset = 1)
830 # and add any custom exception handlers the user may have specified
845 # and add any custom exception handlers the user may have specified
831 self.set_custom_exc(*custom_exceptions)
846 self.set_custom_exc(*custom_exceptions)
832
847
833 # Object inspector
848 # Object inspector
834 ins_colors = OInspect.InspectColors
849 ins_colors = OInspect.InspectColors
835 code_colors = PyColorize.ANSICodeColors
850 code_colors = PyColorize.ANSICodeColors
836 self.inspector = OInspect.Inspector(ins_colors,code_colors,'NoColor')
851 self.inspector = OInspect.Inspector(ins_colors,code_colors,'NoColor')
837 self.autoindent = 0
852 self.autoindent = 0
838
853
839 # Make some aliases automatically
854 # Make some aliases automatically
840 # Prepare list of shell aliases to auto-define
855 # Prepare list of shell aliases to auto-define
841 if os.name == 'posix':
856 if os.name == 'posix':
842 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
857 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
843 'mv mv -i','rm rm -i','cp cp -i',
858 'mv mv -i','rm rm -i','cp cp -i',
844 'cat cat','less less','clear clear',
859 'cat cat','less less','clear clear',
845 # a better ls
860 # a better ls
846 'ls ls -F',
861 'ls ls -F',
847 # long ls
862 # long ls
848 'll ls -lF',
863 'll ls -lF',
849 # color ls
864 # color ls
850 'lc ls -F -o --color',
865 'lc ls -F -o --color',
851 # ls normal files only
866 # ls normal files only
852 'lf ls -F -o --color %l | grep ^-',
867 'lf ls -F -o --color %l | grep ^-',
853 # ls symbolic links
868 # ls symbolic links
854 'lk ls -F -o --color %l | grep ^l',
869 'lk ls -F -o --color %l | grep ^l',
855 # directories or links to directories,
870 # directories or links to directories,
856 'ldir ls -F -o --color %l | grep /$',
871 'ldir ls -F -o --color %l | grep /$',
857 # things which are executable
872 # things which are executable
858 'lx ls -F -o --color %l | grep ^-..x',
873 'lx ls -F -o --color %l | grep ^-..x',
859 )
874 )
860 elif os.name in ['nt','dos']:
875 elif os.name in ['nt','dos']:
861 auto_alias = ('dir dir /on', 'ls dir /on',
876 auto_alias = ('dir dir /on', 'ls dir /on',
862 'ddir dir /ad /on', 'ldir dir /ad /on',
877 'ddir dir /ad /on', 'ldir dir /ad /on',
863 'mkdir mkdir','rmdir rmdir','echo echo',
878 'mkdir mkdir','rmdir rmdir','echo echo',
864 'ren ren','cls cls','copy copy')
879 'ren ren','cls cls','copy copy')
865 else:
880 else:
866 auto_alias = ()
881 auto_alias = ()
867 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
882 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
868 # Call the actual (public) initializer
883 # Call the actual (public) initializer
869 self.init_auto_alias()
884 self.init_auto_alias()
870 # end __init__
885 # end __init__
871
886
872 def set_hook(self,name,hook):
887 def set_hook(self,name,hook):
873 """set_hook(name,hook) -> sets an internal IPython hook.
888 """set_hook(name,hook) -> sets an internal IPython hook.
874
889
875 IPython exposes some of its internal API as user-modifiable hooks. By
890 IPython exposes some of its internal API as user-modifiable hooks. By
876 resetting one of these hooks, you can modify IPython's behavior to
891 resetting one of these hooks, you can modify IPython's behavior to
877 call at runtime your own routines."""
892 call at runtime your own routines."""
878
893
879 # At some point in the future, this should validate the hook before it
894 # At some point in the future, this should validate the hook before it
880 # accepts it. Probably at least check that the hook takes the number
895 # accepts it. Probably at least check that the hook takes the number
881 # of args it's supposed to.
896 # of args it's supposed to.
882 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
897 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
883
898
884 def set_custom_exc(self,exc_tuple,handler):
899 def set_custom_exc(self,exc_tuple,handler):
885 """set_custom_exc(exc_tuple,handler)
900 """set_custom_exc(exc_tuple,handler)
886
901
887 Set a custom exception handler, which will be called if any of the
902 Set a custom exception handler, which will be called if any of the
888 exceptions in exc_tuple occur in the mainloop (specifically, in the
903 exceptions in exc_tuple occur in the mainloop (specifically, in the
889 runcode() method.
904 runcode() method.
890
905
891 Inputs:
906 Inputs:
892
907
893 - exc_tuple: a *tuple* of valid exceptions to call the defined
908 - exc_tuple: a *tuple* of valid exceptions to call the defined
894 handler for. It is very important that you use a tuple, and NOT A
909 handler for. It is very important that you use a tuple, and NOT A
895 LIST here, because of the way Python's except statement works. If
910 LIST here, because of the way Python's except statement works. If
896 you only want to trap a single exception, use a singleton tuple:
911 you only want to trap a single exception, use a singleton tuple:
897
912
898 exc_tuple == (MyCustomException,)
913 exc_tuple == (MyCustomException,)
899
914
900 - handler: this must be defined as a function with the following
915 - handler: this must be defined as a function with the following
901 basic interface: def my_handler(self,etype,value,tb).
916 basic interface: def my_handler(self,etype,value,tb).
902
917
903 This will be made into an instance method (via new.instancemethod)
918 This will be made into an instance method (via new.instancemethod)
904 of IPython itself, and it will be called if any of the exceptions
919 of IPython itself, and it will be called if any of the exceptions
905 listed in the exc_tuple are caught. If the handler is None, an
920 listed in the exc_tuple are caught. If the handler is None, an
906 internal basic one is used, which just prints basic info.
921 internal basic one is used, which just prints basic info.
907
922
908 WARNING: by putting in your own exception handler into IPython's main
923 WARNING: by putting in your own exception handler into IPython's main
909 execution loop, you run a very good chance of nasty crashes. This
924 execution loop, you run a very good chance of nasty crashes. This
910 facility should only be used if you really know what you are doing."""
925 facility should only be used if you really know what you are doing."""
911
926
912 assert type(exc_tuple)==type(()) , \
927 assert type(exc_tuple)==type(()) , \
913 "The custom exceptions must be given AS A TUPLE."
928 "The custom exceptions must be given AS A TUPLE."
914
929
915 def dummy_handler(self,etype,value,tb):
930 def dummy_handler(self,etype,value,tb):
916 print '*** Simple custom exception handler ***'
931 print '*** Simple custom exception handler ***'
917 print 'Exception type :',etype
932 print 'Exception type :',etype
918 print 'Exception value:',value
933 print 'Exception value:',value
919 print 'Traceback :',tb
934 print 'Traceback :',tb
920 print 'Source code :','\n'.join(self.buffer)
935 print 'Source code :','\n'.join(self.buffer)
921
936
922 if handler is None: handler = dummy_handler
937 if handler is None: handler = dummy_handler
923
938
924 self.CustomTB = new.instancemethod(handler,self,self.__class__)
939 self.CustomTB = new.instancemethod(handler,self,self.__class__)
925 self.custom_exceptions = exc_tuple
940 self.custom_exceptions = exc_tuple
926
941
927 def set_custom_completer(self,completer,pos=0):
942 def set_custom_completer(self,completer,pos=0):
928 """set_custom_completer(completer,pos=0)
943 """set_custom_completer(completer,pos=0)
929
944
930 Adds a new custom completer function.
945 Adds a new custom completer function.
931
946
932 The position argument (defaults to 0) is the index in the completers
947 The position argument (defaults to 0) is the index in the completers
933 list where you want the completer to be inserted."""
948 list where you want the completer to be inserted."""
934
949
935 newcomp = new.instancemethod(completer,self.Completer,
950 newcomp = new.instancemethod(completer,self.Completer,
936 self.Completer.__class__)
951 self.Completer.__class__)
937 self.Completer.matchers.insert(pos,newcomp)
952 self.Completer.matchers.insert(pos,newcomp)
938
953
939 def complete(self,text):
954 def complete(self,text):
940 """Return a sorted list of all possible completions on text.
955 """Return a sorted list of all possible completions on text.
941
956
942 Inputs:
957 Inputs:
943
958
944 - text: a string of text to be completed on.
959 - text: a string of text to be completed on.
945
960
946 This is a wrapper around the completion mechanism, similar to what
961 This is a wrapper around the completion mechanism, similar to what
947 readline does at the command line when the TAB key is hit. By
962 readline does at the command line when the TAB key is hit. By
948 exposing it as a method, it can be used by other non-readline
963 exposing it as a method, it can be used by other non-readline
949 environments (such as GUIs) for text completion.
964 environments (such as GUIs) for text completion.
950
965
951 Simple usage example:
966 Simple usage example:
952
967
953 In [1]: x = 'hello'
968 In [1]: x = 'hello'
954
969
955 In [2]: __IP.complete('x.l')
970 In [2]: __IP.complete('x.l')
956 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
971 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
957
972
958 complete = self.Completer.complete
973 complete = self.Completer.complete
959 state = 0
974 state = 0
960 # use a dict so we get unique keys, since ipyhton's multiple
975 # use a dict so we get unique keys, since ipyhton's multiple
961 # completers can return duplicates.
976 # completers can return duplicates.
962 comps = {}
977 comps = {}
963 while True:
978 while True:
964 newcomp = complete(text,state)
979 newcomp = complete(text,state)
965 if newcomp is None:
980 if newcomp is None:
966 break
981 break
967 comps[newcomp] = 1
982 comps[newcomp] = 1
968 state += 1
983 state += 1
969 outcomps = comps.keys()
984 outcomps = comps.keys()
970 outcomps.sort()
985 outcomps.sort()
971 return outcomps
986 return outcomps
972
987
973 def set_completer_frame(self, frame):
988 def set_completer_frame(self, frame):
974 if frame:
989 if frame:
975 ns = frame.f_globals.copy()
990 self.Completer.namespace = frame.f_locals
976 ns.update(frame.f_locals)
991 self.Completer.global_namespace = frame.f_globals
977 self.Completer.namespace = ns
978 else:
992 else:
979 self.Completer.namespace = self.user_ns
993 self.Completer.namespace = self.user_ns
994 self.Completer.global_namespace = self.user_global_ns
980
995
981 def post_config_initialization(self):
996 def post_config_initialization(self):
982 """Post configuration init method
997 """Post configuration init method
983
998
984 This is called after the configuration files have been processed to
999 This is called after the configuration files have been processed to
985 'finalize' the initialization."""
1000 'finalize' the initialization."""
986
1001
987 rc = self.rc
1002 rc = self.rc
988
1003
989 # Load readline proper
1004 # Load readline proper
990 if rc.readline:
1005 if rc.readline:
991 self.init_readline()
1006 self.init_readline()
992
1007
993 # Set user colors (don't do it in the constructor above so that it doesn't
1008 # Set user colors (don't do it in the constructor above so that it doesn't
994 # crash if colors option is invalid)
1009 # crash if colors option is invalid)
995 self.magic_colors(rc.colors)
1010 self.magic_colors(rc.colors)
996
1011
997 # Load user aliases
1012 # Load user aliases
998 for alias in rc.alias:
1013 for alias in rc.alias:
999 self.magic_alias(alias)
1014 self.magic_alias(alias)
1000
1015
1001 # dynamic data that survives through sessions
1016 # dynamic data that survives through sessions
1002 # XXX make the filename a config option?
1017 # XXX make the filename a config option?
1003 persist_base = 'persist'
1018 persist_base = 'persist'
1004 if rc.profile:
1019 if rc.profile:
1005 persist_base += '_%s' % rc.profile
1020 persist_base += '_%s' % rc.profile
1006 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
1021 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
1007
1022
1008 try:
1023 try:
1009 self.persist = pickle.load(file(self.persist_fname))
1024 self.persist = pickle.load(file(self.persist_fname))
1010 except:
1025 except:
1011 self.persist = {}
1026 self.persist = {}
1012
1027
1013 def init_auto_alias(self):
1028 def init_auto_alias(self):
1014 """Define some aliases automatically.
1029 """Define some aliases automatically.
1015
1030
1016 These are ALL parameter-less aliases"""
1031 These are ALL parameter-less aliases"""
1017 for alias,cmd in self.auto_alias:
1032 for alias,cmd in self.auto_alias:
1018 self.alias_table[alias] = (0,cmd)
1033 self.alias_table[alias] = (0,cmd)
1019
1034
1020 def alias_table_validate(self,verbose=0):
1035 def alias_table_validate(self,verbose=0):
1021 """Update information about the alias table.
1036 """Update information about the alias table.
1022
1037
1023 In particular, make sure no Python keywords/builtins are in it."""
1038 In particular, make sure no Python keywords/builtins are in it."""
1024
1039
1025 no_alias = self.no_alias
1040 no_alias = self.no_alias
1026 for k in self.alias_table.keys():
1041 for k in self.alias_table.keys():
1027 if k in no_alias:
1042 if k in no_alias:
1028 del self.alias_table[k]
1043 del self.alias_table[k]
1029 if verbose:
1044 if verbose:
1030 print ("Deleting alias <%s>, it's a Python "
1045 print ("Deleting alias <%s>, it's a Python "
1031 "keyword or builtin." % k)
1046 "keyword or builtin." % k)
1032
1047
1033 def set_autoindent(self,value=None):
1048 def set_autoindent(self,value=None):
1034 """Set the autoindent flag, checking for readline support.
1049 """Set the autoindent flag, checking for readline support.
1035
1050
1036 If called with no arguments, it acts as a toggle."""
1051 If called with no arguments, it acts as a toggle."""
1037
1052
1038 if not self.has_readline:
1053 if not self.has_readline:
1039 if os.name == 'posix':
1054 if os.name == 'posix':
1040 warn("The auto-indent feature requires the readline library")
1055 warn("The auto-indent feature requires the readline library")
1041 self.autoindent = 0
1056 self.autoindent = 0
1042 return
1057 return
1043 if value is None:
1058 if value is None:
1044 self.autoindent = not self.autoindent
1059 self.autoindent = not self.autoindent
1045 else:
1060 else:
1046 self.autoindent = value
1061 self.autoindent = value
1047
1062
1048 def rc_set_toggle(self,rc_field,value=None):
1063 def rc_set_toggle(self,rc_field,value=None):
1049 """Set or toggle a field in IPython's rc config. structure.
1064 """Set or toggle a field in IPython's rc config. structure.
1050
1065
1051 If called with no arguments, it acts as a toggle.
1066 If called with no arguments, it acts as a toggle.
1052
1067
1053 If called with a non-existent field, the resulting AttributeError
1068 If called with a non-existent field, the resulting AttributeError
1054 exception will propagate out."""
1069 exception will propagate out."""
1055
1070
1056 rc_val = getattr(self.rc,rc_field)
1071 rc_val = getattr(self.rc,rc_field)
1057 if value is None:
1072 if value is None:
1058 value = not rc_val
1073 value = not rc_val
1059 setattr(self.rc,rc_field,value)
1074 setattr(self.rc,rc_field,value)
1060
1075
1061 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1076 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1062 """Install the user configuration directory.
1077 """Install the user configuration directory.
1063
1078
1064 Can be called when running for the first time or to upgrade the user's
1079 Can be called when running for the first time or to upgrade the user's
1065 .ipython/ directory with the mode parameter. Valid modes are 'install'
1080 .ipython/ directory with the mode parameter. Valid modes are 'install'
1066 and 'upgrade'."""
1081 and 'upgrade'."""
1067
1082
1068 def wait():
1083 def wait():
1069 try:
1084 try:
1070 raw_input("Please press <RETURN> to start IPython.")
1085 raw_input("Please press <RETURN> to start IPython.")
1071 except EOFError:
1086 except EOFError:
1072 print >> Term.cout
1087 print >> Term.cout
1073 print '*'*70
1088 print '*'*70
1074
1089
1075 cwd = os.getcwd() # remember where we started
1090 cwd = os.getcwd() # remember where we started
1076 glb = glob.glob
1091 glb = glob.glob
1077 print '*'*70
1092 print '*'*70
1078 if mode == 'install':
1093 if mode == 'install':
1079 print \
1094 print \
1080 """Welcome to IPython. I will try to create a personal configuration directory
1095 """Welcome to IPython. I will try to create a personal configuration directory
1081 where you can customize many aspects of IPython's functionality in:\n"""
1096 where you can customize many aspects of IPython's functionality in:\n"""
1082 else:
1097 else:
1083 print 'I am going to upgrade your configuration in:'
1098 print 'I am going to upgrade your configuration in:'
1084
1099
1085 print ipythondir
1100 print ipythondir
1086
1101
1087 rcdirend = os.path.join('IPython','UserConfig')
1102 rcdirend = os.path.join('IPython','UserConfig')
1088 cfg = lambda d: os.path.join(d,rcdirend)
1103 cfg = lambda d: os.path.join(d,rcdirend)
1089 try:
1104 try:
1090 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1105 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1091 except IOError:
1106 except IOError:
1092 warning = """
1107 warning = """
1093 Installation error. IPython's directory was not found.
1108 Installation error. IPython's directory was not found.
1094
1109
1095 Check the following:
1110 Check the following:
1096
1111
1097 The ipython/IPython directory should be in a directory belonging to your
1112 The ipython/IPython directory should be in a directory belonging to your
1098 PYTHONPATH environment variable (that is, it should be in a directory
1113 PYTHONPATH environment variable (that is, it should be in a directory
1099 belonging to sys.path). You can copy it explicitly there or just link to it.
1114 belonging to sys.path). You can copy it explicitly there or just link to it.
1100
1115
1101 IPython will proceed with builtin defaults.
1116 IPython will proceed with builtin defaults.
1102 """
1117 """
1103 warn(warning)
1118 warn(warning)
1104 wait()
1119 wait()
1105 return
1120 return
1106
1121
1107 if mode == 'install':
1122 if mode == 'install':
1108 try:
1123 try:
1109 shutil.copytree(rcdir,ipythondir)
1124 shutil.copytree(rcdir,ipythondir)
1110 os.chdir(ipythondir)
1125 os.chdir(ipythondir)
1111 rc_files = glb("ipythonrc*")
1126 rc_files = glb("ipythonrc*")
1112 for rc_file in rc_files:
1127 for rc_file in rc_files:
1113 os.rename(rc_file,rc_file+rc_suffix)
1128 os.rename(rc_file,rc_file+rc_suffix)
1114 except:
1129 except:
1115 warning = """
1130 warning = """
1116
1131
1117 There was a problem with the installation:
1132 There was a problem with the installation:
1118 %s
1133 %s
1119 Try to correct it or contact the developers if you think it's a bug.
1134 Try to correct it or contact the developers if you think it's a bug.
1120 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1135 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1121 warn(warning)
1136 warn(warning)
1122 wait()
1137 wait()
1123 return
1138 return
1124
1139
1125 elif mode == 'upgrade':
1140 elif mode == 'upgrade':
1126 try:
1141 try:
1127 os.chdir(ipythondir)
1142 os.chdir(ipythondir)
1128 except:
1143 except:
1129 print """
1144 print """
1130 Can not upgrade: changing to directory %s failed. Details:
1145 Can not upgrade: changing to directory %s failed. Details:
1131 %s
1146 %s
1132 """ % (ipythondir,sys.exc_info()[1])
1147 """ % (ipythondir,sys.exc_info()[1])
1133 wait()
1148 wait()
1134 return
1149 return
1135 else:
1150 else:
1136 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1151 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1137 for new_full_path in sources:
1152 for new_full_path in sources:
1138 new_filename = os.path.basename(new_full_path)
1153 new_filename = os.path.basename(new_full_path)
1139 if new_filename.startswith('ipythonrc'):
1154 if new_filename.startswith('ipythonrc'):
1140 new_filename = new_filename + rc_suffix
1155 new_filename = new_filename + rc_suffix
1141 # The config directory should only contain files, skip any
1156 # The config directory should only contain files, skip any
1142 # directories which may be there (like CVS)
1157 # directories which may be there (like CVS)
1143 if os.path.isdir(new_full_path):
1158 if os.path.isdir(new_full_path):
1144 continue
1159 continue
1145 if os.path.exists(new_filename):
1160 if os.path.exists(new_filename):
1146 old_file = new_filename+'.old'
1161 old_file = new_filename+'.old'
1147 if os.path.exists(old_file):
1162 if os.path.exists(old_file):
1148 os.remove(old_file)
1163 os.remove(old_file)
1149 os.rename(new_filename,old_file)
1164 os.rename(new_filename,old_file)
1150 shutil.copy(new_full_path,new_filename)
1165 shutil.copy(new_full_path,new_filename)
1151 else:
1166 else:
1152 raise ValueError,'unrecognized mode for install:',`mode`
1167 raise ValueError,'unrecognized mode for install:',`mode`
1153
1168
1154 # Fix line-endings to those native to each platform in the config
1169 # Fix line-endings to those native to each platform in the config
1155 # directory.
1170 # directory.
1156 try:
1171 try:
1157 os.chdir(ipythondir)
1172 os.chdir(ipythondir)
1158 except:
1173 except:
1159 print """
1174 print """
1160 Problem: changing to directory %s failed.
1175 Problem: changing to directory %s failed.
1161 Details:
1176 Details:
1162 %s
1177 %s
1163
1178
1164 Some configuration files may have incorrect line endings. This should not
1179 Some configuration files may have incorrect line endings. This should not
1165 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1180 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1166 wait()
1181 wait()
1167 else:
1182 else:
1168 for fname in glb('ipythonrc*'):
1183 for fname in glb('ipythonrc*'):
1169 try:
1184 try:
1170 native_line_ends(fname,backup=0)
1185 native_line_ends(fname,backup=0)
1171 except IOError:
1186 except IOError:
1172 pass
1187 pass
1173
1188
1174 if mode == 'install':
1189 if mode == 'install':
1175 print """
1190 print """
1176 Successful installation!
1191 Successful installation!
1177
1192
1178 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1193 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1179 IPython manual (there are both HTML and PDF versions supplied with the
1194 IPython manual (there are both HTML and PDF versions supplied with the
1180 distribution) to make sure that your system environment is properly configured
1195 distribution) to make sure that your system environment is properly configured
1181 to take advantage of IPython's features."""
1196 to take advantage of IPython's features."""
1182 else:
1197 else:
1183 print """
1198 print """
1184 Successful upgrade!
1199 Successful upgrade!
1185
1200
1186 All files in your directory:
1201 All files in your directory:
1187 %(ipythondir)s
1202 %(ipythondir)s
1188 which would have been overwritten by the upgrade were backed up with a .old
1203 which would have been overwritten by the upgrade were backed up with a .old
1189 extension. If you had made particular customizations in those files you may
1204 extension. If you had made particular customizations in those files you may
1190 want to merge them back into the new files.""" % locals()
1205 want to merge them back into the new files.""" % locals()
1191 wait()
1206 wait()
1192 os.chdir(cwd)
1207 os.chdir(cwd)
1193 # end user_setup()
1208 # end user_setup()
1194
1209
1195 def atexit_operations(self):
1210 def atexit_operations(self):
1196 """This will be executed at the time of exit.
1211 """This will be executed at the time of exit.
1197
1212
1198 Saving of persistent data should be performed here. """
1213 Saving of persistent data should be performed here. """
1199
1214
1200 # input history
1215 # input history
1201 self.savehist()
1216 self.savehist()
1202
1217
1203 # Cleanup all tempfiles left around
1218 # Cleanup all tempfiles left around
1204 for tfile in self.tempfiles:
1219 for tfile in self.tempfiles:
1205 try:
1220 try:
1206 os.unlink(tfile)
1221 os.unlink(tfile)
1207 except OSError:
1222 except OSError:
1208 pass
1223 pass
1209
1224
1210 # save the "persistent data" catch-all dictionary
1225 # save the "persistent data" catch-all dictionary
1211 try:
1226 try:
1212 pickle.dump(self.persist, open(self.persist_fname,"w"))
1227 pickle.dump(self.persist, open(self.persist_fname,"w"))
1213 except:
1228 except:
1214 print "*** ERROR *** persistent data saving failed."
1229 print "*** ERROR *** persistent data saving failed."
1215
1230
1216 def savehist(self):
1231 def savehist(self):
1217 """Save input history to a file (via readline library)."""
1232 """Save input history to a file (via readline library)."""
1218 try:
1233 try:
1219 self.readline.write_history_file(self.histfile)
1234 self.readline.write_history_file(self.histfile)
1220 except:
1235 except:
1221 print 'Unable to save IPython command history to file: ' + \
1236 print 'Unable to save IPython command history to file: ' + \
1222 `self.histfile`
1237 `self.histfile`
1223
1238
1224 def pre_readline(self):
1239 def pre_readline(self):
1225 """readline hook to be used at the start of each line.
1240 """readline hook to be used at the start of each line.
1226
1241
1227 Currently it handles auto-indent only."""
1242 Currently it handles auto-indent only."""
1228
1243
1229 self.readline.insert_text(' '* self.readline_indent)
1244 self.readline.insert_text(' '* self.readline_indent)
1230
1245
1231 def init_readline(self):
1246 def init_readline(self):
1232 """Command history completion/saving/reloading."""
1247 """Command history completion/saving/reloading."""
1233 try:
1248 try:
1234 import readline
1249 import readline
1235 self.Completer = MagicCompleter(self,
1250 self.Completer = MagicCompleter(self,
1236 self.user_ns,
1251 self.user_ns,
1252 self.user_global_ns,
1237 self.rc.readline_omit__names,
1253 self.rc.readline_omit__names,
1238 self.alias_table)
1254 self.alias_table)
1239 except ImportError,NameError:
1255 except ImportError,NameError:
1240 # If FlexCompleter failed to import, MagicCompleter won't be
1256 # If FlexCompleter failed to import, MagicCompleter won't be
1241 # defined. This can happen because of a problem with readline
1257 # defined. This can happen because of a problem with readline
1242 self.has_readline = 0
1258 self.has_readline = 0
1243 # no point in bugging windows users with this every time:
1259 # no point in bugging windows users with this every time:
1244 if os.name == 'posix':
1260 if os.name == 'posix':
1245 warn('Readline services not available on this platform.')
1261 warn('Readline services not available on this platform.')
1246 else:
1262 else:
1247 import atexit
1263 import atexit
1248
1264
1249 # Platform-specific configuration
1265 # Platform-specific configuration
1250 if os.name == 'nt':
1266 if os.name == 'nt':
1251 # readline under Windows modifies the default exit behavior
1267 # readline under Windows modifies the default exit behavior
1252 # from being Ctrl-Z/Return to the Unix Ctrl-D one.
1268 # from being Ctrl-Z/Return to the Unix Ctrl-D one.
1253 __builtin__.exit = __builtin__.quit = \
1269 __builtin__.exit = __builtin__.quit = \
1254 ('Use Ctrl-D (i.e. EOF) to exit. '
1270 ('Use Ctrl-D (i.e. EOF) to exit. '
1255 'Use %Exit or %Quit to exit without confirmation.')
1271 'Use %Exit or %Quit to exit without confirmation.')
1256 self.readline_startup_hook = readline.set_pre_input_hook
1272 self.readline_startup_hook = readline.set_pre_input_hook
1257 else:
1273 else:
1258 self.readline_startup_hook = readline.set_startup_hook
1274 self.readline_startup_hook = readline.set_startup_hook
1259
1275
1260 # Load user's initrc file (readline config)
1276 # Load user's initrc file (readline config)
1261 inputrc_name = os.environ.get('INPUTRC')
1277 inputrc_name = os.environ.get('INPUTRC')
1262 if inputrc_name is None:
1278 if inputrc_name is None:
1263 home_dir = get_home_dir()
1279 home_dir = get_home_dir()
1264 if home_dir is not None:
1280 if home_dir is not None:
1265 inputrc_name = os.path.join(home_dir,'.inputrc')
1281 inputrc_name = os.path.join(home_dir,'.inputrc')
1266 if os.path.isfile(inputrc_name):
1282 if os.path.isfile(inputrc_name):
1267 try:
1283 try:
1268 readline.read_init_file(inputrc_name)
1284 readline.read_init_file(inputrc_name)
1269 except:
1285 except:
1270 warn('Problems reading readline initialization file <%s>'
1286 warn('Problems reading readline initialization file <%s>'
1271 % inputrc_name)
1287 % inputrc_name)
1272
1288
1273 self.has_readline = 1
1289 self.has_readline = 1
1274 self.readline = readline
1290 self.readline = readline
1275 self.readline_indent = 0 # for auto-indenting via readline
1291 self.readline_indent = 0 # for auto-indenting via readline
1276 # save this in sys so embedded copies can restore it properly
1292 # save this in sys so embedded copies can restore it properly
1277 sys.ipcompleter = self.Completer.complete
1293 sys.ipcompleter = self.Completer.complete
1278 readline.set_completer(self.Completer.complete)
1294 readline.set_completer(self.Completer.complete)
1279
1295
1280 # Configure readline according to user's prefs
1296 # Configure readline according to user's prefs
1281 for rlcommand in self.rc.readline_parse_and_bind:
1297 for rlcommand in self.rc.readline_parse_and_bind:
1282 readline.parse_and_bind(rlcommand)
1298 readline.parse_and_bind(rlcommand)
1283
1299
1284 # remove some chars from the delimiters list
1300 # remove some chars from the delimiters list
1285 delims = readline.get_completer_delims()
1301 delims = readline.get_completer_delims()
1286 delims = delims.translate(string._idmap,
1302 delims = delims.translate(string._idmap,
1287 self.rc.readline_remove_delims)
1303 self.rc.readline_remove_delims)
1288 readline.set_completer_delims(delims)
1304 readline.set_completer_delims(delims)
1289 # otherwise we end up with a monster history after a while:
1305 # otherwise we end up with a monster history after a while:
1290 readline.set_history_length(1000)
1306 readline.set_history_length(1000)
1291 try:
1307 try:
1292 #print '*** Reading readline history' # dbg
1308 #print '*** Reading readline history' # dbg
1293 readline.read_history_file(self.histfile)
1309 readline.read_history_file(self.histfile)
1294 except IOError:
1310 except IOError:
1295 pass # It doesn't exist yet.
1311 pass # It doesn't exist yet.
1296
1312
1297 atexit.register(self.atexit_operations)
1313 atexit.register(self.atexit_operations)
1298 del atexit
1314 del atexit
1299
1315
1300 # Configure auto-indent for all platforms
1316 # Configure auto-indent for all platforms
1301 self.set_autoindent(self.rc.autoindent)
1317 self.set_autoindent(self.rc.autoindent)
1302
1318
1303 def showsyntaxerror(self, filename=None):
1319 def showsyntaxerror(self, filename=None):
1304 """Display the syntax error that just occurred.
1320 """Display the syntax error that just occurred.
1305
1321
1306 This doesn't display a stack trace because there isn't one.
1322 This doesn't display a stack trace because there isn't one.
1307
1323
1308 If a filename is given, it is stuffed in the exception instead
1324 If a filename is given, it is stuffed in the exception instead
1309 of what was there before (because Python's parser always uses
1325 of what was there before (because Python's parser always uses
1310 "<string>" when reading from a string).
1326 "<string>" when reading from a string).
1311 """
1327 """
1312 type, value, sys.last_traceback = sys.exc_info()
1328 type, value, sys.last_traceback = sys.exc_info()
1313 sys.last_type = type
1329 sys.last_type = type
1314 sys.last_value = value
1330 sys.last_value = value
1315 if filename and type is SyntaxError:
1331 if filename and type is SyntaxError:
1316 # Work hard to stuff the correct filename in the exception
1332 # Work hard to stuff the correct filename in the exception
1317 try:
1333 try:
1318 msg, (dummy_filename, lineno, offset, line) = value
1334 msg, (dummy_filename, lineno, offset, line) = value
1319 except:
1335 except:
1320 # Not the format we expect; leave it alone
1336 # Not the format we expect; leave it alone
1321 pass
1337 pass
1322 else:
1338 else:
1323 # Stuff in the right filename
1339 # Stuff in the right filename
1324 try:
1340 try:
1325 # Assume SyntaxError is a class exception
1341 # Assume SyntaxError is a class exception
1326 value = SyntaxError(msg, (filename, lineno, offset, line))
1342 value = SyntaxError(msg, (filename, lineno, offset, line))
1327 except:
1343 except:
1328 # If that failed, assume SyntaxError is a string
1344 # If that failed, assume SyntaxError is a string
1329 value = msg, (filename, lineno, offset, line)
1345 value = msg, (filename, lineno, offset, line)
1330 self.SyntaxTB(type,value,[])
1346 self.SyntaxTB(type,value,[])
1331
1347
1332 def debugger(self):
1348 def debugger(self):
1333 """Call the pdb debugger."""
1349 """Call the pdb debugger."""
1334
1350
1335 if not self.rc.pdb:
1351 if not self.rc.pdb:
1336 return
1352 return
1337 pdb.pm()
1353 pdb.pm()
1338
1354
1339 def showtraceback(self,exc_tuple = None,filename=None):
1355 def showtraceback(self,exc_tuple = None,filename=None):
1340 """Display the exception that just occurred."""
1356 """Display the exception that just occurred."""
1341
1357
1342 # Though this won't be called by syntax errors in the input line,
1358 # Though this won't be called by syntax errors in the input line,
1343 # there may be SyntaxError cases whith imported code.
1359 # there may be SyntaxError cases whith imported code.
1344 if exc_tuple is None:
1360 if exc_tuple is None:
1345 type, value, tb = sys.exc_info()
1361 type, value, tb = sys.exc_info()
1346 else:
1362 else:
1347 type, value, tb = exc_tuple
1363 type, value, tb = exc_tuple
1348 if type is SyntaxError:
1364 if type is SyntaxError:
1349 self.showsyntaxerror(filename)
1365 self.showsyntaxerror(filename)
1350 else:
1366 else:
1351 sys.last_type = type
1367 sys.last_type = type
1352 sys.last_value = value
1368 sys.last_value = value
1353 sys.last_traceback = tb
1369 sys.last_traceback = tb
1354 self.InteractiveTB()
1370 self.InteractiveTB()
1355 if self.InteractiveTB.call_pdb and self.has_readline:
1371 if self.InteractiveTB.call_pdb and self.has_readline:
1356 # pdb mucks up readline, fix it back
1372 # pdb mucks up readline, fix it back
1357 self.readline.set_completer(self.Completer.complete)
1373 self.readline.set_completer(self.Completer.complete)
1358
1374
1359 def update_cache(self, line):
1375 def update_cache(self, line):
1360 """puts line into cache"""
1376 """puts line into cache"""
1361 self.inputcache.insert(0, line) # This copies the cache every time ... :-(
1377 self.inputcache.insert(0, line) # This copies the cache every time ... :-(
1362 if len(self.inputcache) >= self.CACHELENGTH:
1378 if len(self.inputcache) >= self.CACHELENGTH:
1363 self.inputcache.pop() # This not :-)
1379 self.inputcache.pop() # This not :-)
1364
1380
1365 def mainloop(self,banner=None):
1381 def mainloop(self,banner=None):
1366 """Creates the local namespace and starts the mainloop.
1382 """Creates the local namespace and starts the mainloop.
1367
1383
1368 If an optional banner argument is given, it will override the
1384 If an optional banner argument is given, it will override the
1369 internally created default banner."""
1385 internally created default banner."""
1370
1386
1371 if self.rc.c: # Emulate Python's -c option
1387 if self.rc.c: # Emulate Python's -c option
1372 self.exec_init_cmd()
1388 self.exec_init_cmd()
1373 if banner is None:
1389 if banner is None:
1374 if self.rc.banner:
1390 if self.rc.banner:
1375 banner = self.BANNER+self.banner2
1391 banner = self.BANNER+self.banner2
1376 else:
1392 else:
1377 banner = ''
1393 banner = ''
1378 self.interact(banner)
1394 self.interact(banner)
1379
1395
1380 def exec_init_cmd(self):
1396 def exec_init_cmd(self):
1381 """Execute a command given at the command line.
1397 """Execute a command given at the command line.
1382
1398
1383 This emulates Python's -c option."""
1399 This emulates Python's -c option."""
1384
1400
1385 sys.argv = ['-c']
1401 sys.argv = ['-c']
1386 self.push(self.rc.c)
1402 self.push(self.rc.c)
1387
1403
1388 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1404 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1389 """Embeds IPython into a running python program.
1405 """Embeds IPython into a running python program.
1390
1406
1391 Input:
1407 Input:
1392
1408
1393 - header: An optional header message can be specified.
1409 - header: An optional header message can be specified.
1394
1410
1395 - local_ns, global_ns: working namespaces. If given as None, the
1411 - local_ns, global_ns: working namespaces. If given as None, the
1396 IPython-initialized one is updated with __main__.__dict__, so that
1412 IPython-initialized one is updated with __main__.__dict__, so that
1397 program variables become visible but user-specific configuration
1413 program variables become visible but user-specific configuration
1398 remains possible.
1414 remains possible.
1399
1415
1400 - stack_depth: specifies how many levels in the stack to go to
1416 - stack_depth: specifies how many levels in the stack to go to
1401 looking for namespaces (when local_ns and global_ns are None). This
1417 looking for namespaces (when local_ns and global_ns are None). This
1402 allows an intermediate caller to make sure that this function gets
1418 allows an intermediate caller to make sure that this function gets
1403 the namespace from the intended level in the stack. By default (0)
1419 the namespace from the intended level in the stack. By default (0)
1404 it will get its locals and globals from the immediate caller.
1420 it will get its locals and globals from the immediate caller.
1405
1421
1406 Warning: it's possible to use this in a program which is being run by
1422 Warning: it's possible to use this in a program which is being run by
1407 IPython itself (via %run), but some funny things will happen (a few
1423 IPython itself (via %run), but some funny things will happen (a few
1408 globals get overwritten). In the future this will be cleaned up, as
1424 globals get overwritten). In the future this will be cleaned up, as
1409 there is no fundamental reason why it can't work perfectly."""
1425 there is no fundamental reason why it can't work perfectly."""
1410
1426
1411 # Get locals and globals from caller
1427 # Get locals and globals from caller
1412 if local_ns is None or global_ns is None:
1428 if local_ns is None or global_ns is None:
1413 call_frame = sys._getframe(stack_depth).f_back
1429 call_frame = sys._getframe(stack_depth).f_back
1414
1430
1415 if local_ns is None:
1431 if local_ns is None:
1416 local_ns = call_frame.f_locals
1432 local_ns = call_frame.f_locals
1417 if global_ns is None:
1433 if global_ns is None:
1418 global_ns = call_frame.f_globals
1434 global_ns = call_frame.f_globals
1419
1435
1420 # Update namespaces and fire up interpreter
1436 # Update namespaces and fire up interpreter
1421 self.user_ns = local_ns
1437 self.user_ns = local_ns
1422 self.user_global_ns = global_ns
1438 self.user_global_ns = global_ns
1423
1439
1424 # Patch for global embedding to make sure that things don't overwrite
1440 # Patch for global embedding to make sure that things don't overwrite
1425 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1441 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1426 # FIXME. Test this a bit more carefully (the if.. is new)
1442 # FIXME. Test this a bit more carefully (the if.. is new)
1427 if local_ns is None and global_ns is None:
1443 if local_ns is None and global_ns is None:
1428 self.user_global_ns.update(__main__.__dict__)
1444 self.user_global_ns.update(__main__.__dict__)
1429
1445
1446 # make sure the tab-completer has the correct frame information, so it
1447 # actually completes using the frame's locals/globals
1448 self.set_completer_frame(call_frame)
1449
1430 self.interact(header)
1450 self.interact(header)
1431
1451
1432 def interact(self, banner=None):
1452 def interact(self, banner=None):
1433 """Closely emulate the interactive Python console.
1453 """Closely emulate the interactive Python console.
1434
1454
1435 The optional banner argument specify the banner to print
1455 The optional banner argument specify the banner to print
1436 before the first interaction; by default it prints a banner
1456 before the first interaction; by default it prints a banner
1437 similar to the one printed by the real Python interpreter,
1457 similar to the one printed by the real Python interpreter,
1438 followed by the current class name in parentheses (so as not
1458 followed by the current class name in parentheses (so as not
1439 to confuse this with the real interpreter -- since it's so
1459 to confuse this with the real interpreter -- since it's so
1440 close!).
1460 close!).
1441
1461
1442 """
1462 """
1443 cprt = 'Type "copyright", "credits" or "license" for more information.'
1463 cprt = 'Type "copyright", "credits" or "license" for more information.'
1444 if banner is None:
1464 if banner is None:
1445 self.write("Python %s on %s\n%s\n(%s)\n" %
1465 self.write("Python %s on %s\n%s\n(%s)\n" %
1446 (sys.version, sys.platform, cprt,
1466 (sys.version, sys.platform, cprt,
1447 self.__class__.__name__))
1467 self.__class__.__name__))
1448 else:
1468 else:
1449 self.write(banner)
1469 self.write(banner)
1450
1470
1451 more = 0
1471 more = 0
1452
1472
1453 # Mark activity in the builtins
1473 # Mark activity in the builtins
1454 __builtin__.__dict__['__IPYTHON__active'] += 1
1474 __builtin__.__dict__['__IPYTHON__active'] += 1
1455
1475
1456 # exit_now is set by a call to %Exit or %Quit
1476 # exit_now is set by a call to %Exit or %Quit
1457 while not self.exit_now:
1477 while not self.exit_now:
1458 try:
1478 try:
1459 if more:
1479 if more:
1460 prompt = self.outputcache.prompt2
1480 prompt = self.outputcache.prompt2
1461 if self.autoindent:
1481 if self.autoindent:
1462 self.readline_startup_hook(self.pre_readline)
1482 self.readline_startup_hook(self.pre_readline)
1463 else:
1483 else:
1464 prompt = self.outputcache.prompt1
1484 prompt = self.outputcache.prompt1
1465 try:
1485 try:
1466 line = self.raw_input(prompt)
1486 line = self.raw_input(prompt)
1467 if self.autoindent:
1487 if self.autoindent:
1468 self.readline_startup_hook(None)
1488 self.readline_startup_hook(None)
1469 except EOFError:
1489 except EOFError:
1470 if self.autoindent:
1490 if self.autoindent:
1471 self.readline_startup_hook(None)
1491 self.readline_startup_hook(None)
1472 self.write("\n")
1492 self.write("\n")
1473 if self.rc.confirm_exit:
1493 if self.rc.confirm_exit:
1474 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
1494 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
1475 break
1495 break
1476 else:
1496 else:
1477 break
1497 break
1478 else:
1498 else:
1479 more = self.push(line)
1499 more = self.push(line)
1480 # Auto-indent management
1500 # Auto-indent management
1481 if self.autoindent:
1501 if self.autoindent:
1482 if line:
1502 if line:
1483 ini_spaces = re.match('^(\s+)',line)
1503 ini_spaces = re.match('^(\s+)',line)
1484 if ini_spaces:
1504 if ini_spaces:
1485 nspaces = ini_spaces.end()
1505 nspaces = ini_spaces.end()
1486 else:
1506 else:
1487 nspaces = 0
1507 nspaces = 0
1488 self.readline_indent = nspaces
1508 self.readline_indent = nspaces
1489
1509
1490 if line[-1] == ':':
1510 if line[-1] == ':':
1491 self.readline_indent += 4
1511 self.readline_indent += 4
1492 elif re.match(r'^\s+raise|^\s+return',line):
1512 elif re.match(r'^\s+raise|^\s+return',line):
1493 self.readline_indent -= 4
1513 self.readline_indent -= 4
1494 else:
1514 else:
1495 self.readline_indent = 0
1515 self.readline_indent = 0
1496
1516
1497 except KeyboardInterrupt:
1517 except KeyboardInterrupt:
1498 self.write("\nKeyboardInterrupt\n")
1518 self.write("\nKeyboardInterrupt\n")
1499 self.resetbuffer()
1519 self.resetbuffer()
1500 more = 0
1520 more = 0
1501 # keep cache in sync with the prompt counter:
1521 # keep cache in sync with the prompt counter:
1502 self.outputcache.prompt_count -= 1
1522 self.outputcache.prompt_count -= 1
1503
1523
1504 if self.autoindent:
1524 if self.autoindent:
1505 self.readline_indent = 0
1525 self.readline_indent = 0
1506
1526
1507 except bdb.BdbQuit:
1527 except bdb.BdbQuit:
1508 warn("The Python debugger has exited with a BdbQuit exception.\n"
1528 warn("The Python debugger has exited with a BdbQuit exception.\n"
1509 "Because of how pdb handles the stack, it is impossible\n"
1529 "Because of how pdb handles the stack, it is impossible\n"
1510 "for IPython to properly format this particular exception.\n"
1530 "for IPython to properly format this particular exception.\n"
1511 "IPython will resume normal operation.")
1531 "IPython will resume normal operation.")
1512
1532
1513 # We are off again...
1533 # We are off again...
1514 __builtin__.__dict__['__IPYTHON__active'] -= 1
1534 __builtin__.__dict__['__IPYTHON__active'] -= 1
1515
1535
1516 def excepthook(self, type, value, tb):
1536 def excepthook(self, type, value, tb):
1517 """One more defense for GUI apps that call sys.excepthook.
1537 """One more defense for GUI apps that call sys.excepthook.
1518
1538
1519 GUI frameworks like wxPython trap exceptions and call
1539 GUI frameworks like wxPython trap exceptions and call
1520 sys.excepthook themselves. I guess this is a feature that
1540 sys.excepthook themselves. I guess this is a feature that
1521 enables them to keep running after exceptions that would
1541 enables them to keep running after exceptions that would
1522 otherwise kill their mainloop. This is a bother for IPython
1542 otherwise kill their mainloop. This is a bother for IPython
1523 which excepts to catch all of the program exceptions with a try:
1543 which excepts to catch all of the program exceptions with a try:
1524 except: statement.
1544 except: statement.
1525
1545
1526 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1546 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1527 any app directly invokes sys.excepthook, it will look to the user like
1547 any app directly invokes sys.excepthook, it will look to the user like
1528 IPython crashed. In order to work around this, we can disable the
1548 IPython crashed. In order to work around this, we can disable the
1529 CrashHandler and replace it with this excepthook instead, which prints a
1549 CrashHandler and replace it with this excepthook instead, which prints a
1530 regular traceback using our InteractiveTB. In this fashion, apps which
1550 regular traceback using our InteractiveTB. In this fashion, apps which
1531 call sys.excepthook will generate a regular-looking exception from
1551 call sys.excepthook will generate a regular-looking exception from
1532 IPython, and the CrashHandler will only be triggered by real IPython
1552 IPython, and the CrashHandler will only be triggered by real IPython
1533 crashes.
1553 crashes.
1534
1554
1535 This hook should be used sparingly, only in places which are not likely
1555 This hook should be used sparingly, only in places which are not likely
1536 to be true IPython errors.
1556 to be true IPython errors.
1537 """
1557 """
1538
1558
1539 self.InteractiveTB(type, value, tb, tb_offset=0)
1559 self.InteractiveTB(type, value, tb, tb_offset=0)
1540 if self.InteractiveTB.call_pdb and self.has_readline:
1560 if self.InteractiveTB.call_pdb and self.has_readline:
1541 self.readline.set_completer(self.Completer.complete)
1561 self.readline.set_completer(self.Completer.complete)
1542
1562
1543 def call_alias(self,alias,rest=''):
1563 def call_alias(self,alias,rest=''):
1544 """Call an alias given its name and the rest of the line.
1564 """Call an alias given its name and the rest of the line.
1545
1565
1546 This function MUST be given a proper alias, because it doesn't make
1566 This function MUST be given a proper alias, because it doesn't make
1547 any checks when looking up into the alias table. The caller is
1567 any checks when looking up into the alias table. The caller is
1548 responsible for invoking it only with a valid alias."""
1568 responsible for invoking it only with a valid alias."""
1549
1569
1550 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1570 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1551 nargs,cmd = self.alias_table[alias]
1571 nargs,cmd = self.alias_table[alias]
1552 # Expand the %l special to be the user's input line
1572 # Expand the %l special to be the user's input line
1553 if cmd.find('%l') >= 0:
1573 if cmd.find('%l') >= 0:
1554 cmd = cmd.replace('%l',rest)
1574 cmd = cmd.replace('%l',rest)
1555 rest = ''
1575 rest = ''
1556 if nargs==0:
1576 if nargs==0:
1557 # Simple, argument-less aliases
1577 # Simple, argument-less aliases
1558 cmd = '%s %s' % (cmd,rest)
1578 cmd = '%s %s' % (cmd,rest)
1559 else:
1579 else:
1560 # Handle aliases with positional arguments
1580 # Handle aliases with positional arguments
1561 args = rest.split(None,nargs)
1581 args = rest.split(None,nargs)
1562 if len(args)< nargs:
1582 if len(args)< nargs:
1563 error('Alias <%s> requires %s arguments, %s given.' %
1583 error('Alias <%s> requires %s arguments, %s given.' %
1564 (alias,nargs,len(args)))
1584 (alias,nargs,len(args)))
1565 return
1585 return
1566 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1586 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1567 # Now call the macro, evaluating in the user's namespace
1587 # Now call the macro, evaluating in the user's namespace
1568 try:
1588 try:
1569 self.system(cmd)
1589 self.system(cmd)
1570 except:
1590 except:
1571 self.showtraceback()
1591 self.showtraceback()
1572
1592
1573 def runlines(self,lines):
1593 def runlines(self,lines):
1574 """Run a string of one or more lines of source.
1594 """Run a string of one or more lines of source.
1575
1595
1576 This method is capable of running a string containing multiple source
1596 This method is capable of running a string containing multiple source
1577 lines, as if they had been entered at the IPython prompt. Since it
1597 lines, as if they had been entered at the IPython prompt. Since it
1578 exposes IPython's processing machinery, the given strings can contain
1598 exposes IPython's processing machinery, the given strings can contain
1579 magic calls (%magic), special shell access (!cmd), etc."""
1599 magic calls (%magic), special shell access (!cmd), etc."""
1580
1600
1581 # We must start with a clean buffer, in case this is run from an
1601 # We must start with a clean buffer, in case this is run from an
1582 # interactive IPython session (via a magic, for example).
1602 # interactive IPython session (via a magic, for example).
1583 self.resetbuffer()
1603 self.resetbuffer()
1584 lines = lines.split('\n')
1604 lines = lines.split('\n')
1585 more = 0
1605 more = 0
1586 for line in lines:
1606 for line in lines:
1587 # skip blank lines so we don't mess up the prompt counter, but do
1607 # skip blank lines so we don't mess up the prompt counter, but do
1588 # NOT skip even a blank line if we are in a code block (more is
1608 # NOT skip even a blank line if we are in a code block (more is
1589 # true)
1609 # true)
1590 if line or more:
1610 if line or more:
1591 more = self.push((self.prefilter(line,more)))
1611 more = self.push((self.prefilter(line,more)))
1592 # IPython's runsource returns None if there was an error
1612 # IPython's runsource returns None if there was an error
1593 # compiling the code. This allows us to stop processing right
1613 # compiling the code. This allows us to stop processing right
1594 # away, so the user gets the error message at the right place.
1614 # away, so the user gets the error message at the right place.
1595 if more is None:
1615 if more is None:
1596 break
1616 break
1597 # final newline in case the input didn't have it, so that the code
1617 # final newline in case the input didn't have it, so that the code
1598 # actually does get executed
1618 # actually does get executed
1599 if more:
1619 if more:
1600 self.push('\n')
1620 self.push('\n')
1601
1621
1602 def runsource(self, source, filename="<input>", symbol="single"):
1622 def runsource(self, source, filename="<input>", symbol="single"):
1603 """Compile and run some source in the interpreter.
1623 """Compile and run some source in the interpreter.
1604
1624
1605 Arguments are as for compile_command().
1625 Arguments are as for compile_command().
1606
1626
1607 One several things can happen:
1627 One several things can happen:
1608
1628
1609 1) The input is incorrect; compile_command() raised an
1629 1) The input is incorrect; compile_command() raised an
1610 exception (SyntaxError or OverflowError). A syntax traceback
1630 exception (SyntaxError or OverflowError). A syntax traceback
1611 will be printed by calling the showsyntaxerror() method.
1631 will be printed by calling the showsyntaxerror() method.
1612
1632
1613 2) The input is incomplete, and more input is required;
1633 2) The input is incomplete, and more input is required;
1614 compile_command() returned None. Nothing happens.
1634 compile_command() returned None. Nothing happens.
1615
1635
1616 3) The input is complete; compile_command() returned a code
1636 3) The input is complete; compile_command() returned a code
1617 object. The code is executed by calling self.runcode() (which
1637 object. The code is executed by calling self.runcode() (which
1618 also handles run-time exceptions, except for SystemExit).
1638 also handles run-time exceptions, except for SystemExit).
1619
1639
1620 The return value is:
1640 The return value is:
1621
1641
1622 - True in case 2
1642 - True in case 2
1623
1643
1624 - False in the other cases, unless an exception is raised, where
1644 - False in the other cases, unless an exception is raised, where
1625 None is returned instead. This can be used by external callers to
1645 None is returned instead. This can be used by external callers to
1626 know whether to continue feeding input or not.
1646 know whether to continue feeding input or not.
1627
1647
1628 The return value can be used to decide whether to use sys.ps1 or
1648 The return value can be used to decide whether to use sys.ps1 or
1629 sys.ps2 to prompt the next line."""
1649 sys.ps2 to prompt the next line."""
1630
1650
1631 try:
1651 try:
1632 code = self.compile(source, filename, symbol)
1652 code = self.compile(source, filename, symbol)
1633 except (OverflowError, SyntaxError, ValueError):
1653 except (OverflowError, SyntaxError, ValueError):
1634 # Case 1
1654 # Case 1
1635 self.showsyntaxerror(filename)
1655 self.showsyntaxerror(filename)
1636 return None
1656 return None
1637
1657
1638 if code is None:
1658 if code is None:
1639 # Case 2
1659 # Case 2
1640 return True
1660 return True
1641
1661
1642 # Case 3
1662 # Case 3
1643 # We store the code object so that threaded shells and
1663 # We store the code object so that threaded shells and
1644 # custom exception handlers can access all this info if needed.
1664 # custom exception handlers can access all this info if needed.
1645 # The source corresponding to this can be obtained from the
1665 # The source corresponding to this can be obtained from the
1646 # buffer attribute as '\n'.join(self.buffer).
1666 # buffer attribute as '\n'.join(self.buffer).
1647 self.code_to_run = code
1667 self.code_to_run = code
1648 # now actually execute the code object
1668 # now actually execute the code object
1649 if self.runcode(code) == 0:
1669 if self.runcode(code) == 0:
1650 return False
1670 return False
1651 else:
1671 else:
1652 return None
1672 return None
1653
1673
1654 def runcode(self,code_obj):
1674 def runcode(self,code_obj):
1655 """Execute a code object.
1675 """Execute a code object.
1656
1676
1657 When an exception occurs, self.showtraceback() is called to display a
1677 When an exception occurs, self.showtraceback() is called to display a
1658 traceback.
1678 traceback.
1659
1679
1660 Return value: a flag indicating whether the code to be run completed
1680 Return value: a flag indicating whether the code to be run completed
1661 successfully:
1681 successfully:
1662
1682
1663 - 0: successful execution.
1683 - 0: successful execution.
1664 - 1: an error occurred.
1684 - 1: an error occurred.
1665 """
1685 """
1666
1686
1667 # Set our own excepthook in case the user code tries to call it
1687 # Set our own excepthook in case the user code tries to call it
1668 # directly, so that the IPython crash handler doesn't get triggered
1688 # directly, so that the IPython crash handler doesn't get triggered
1669 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1689 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1670 outflag = 1 # happens in more places, so it's easier as default
1690 outflag = 1 # happens in more places, so it's easier as default
1671 try:
1691 try:
1672 try:
1692 try:
1673 # Embedded instances require separate global/local namespaces
1693 # Embedded instances require separate global/local namespaces
1674 # so they can see both the surrounding (local) namespace and
1694 # so they can see both the surrounding (local) namespace and
1675 # the module-level globals when called inside another function.
1695 # the module-level globals when called inside another function.
1676 if self.embedded:
1696 if self.embedded:
1677 exec code_obj in self.user_global_ns, self.user_ns
1697 exec code_obj in self.user_global_ns, self.user_ns
1678 # Normal (non-embedded) instances should only have a single
1698 # Normal (non-embedded) instances should only have a single
1679 # namespace for user code execution, otherwise functions won't
1699 # namespace for user code execution, otherwise functions won't
1680 # see interactive top-level globals.
1700 # see interactive top-level globals.
1681 else:
1701 else:
1682 exec code_obj in self.user_ns
1702 exec code_obj in self.user_ns
1683 finally:
1703 finally:
1684 # Reset our crash handler in place
1704 # Reset our crash handler in place
1685 sys.excepthook = old_excepthook
1705 sys.excepthook = old_excepthook
1686 except SystemExit:
1706 except SystemExit:
1687 self.resetbuffer()
1707 self.resetbuffer()
1688 self.showtraceback()
1708 self.showtraceback()
1689 warn( __builtin__.exit,level=1)
1709 warn( __builtin__.exit,level=1)
1690 except self.custom_exceptions:
1710 except self.custom_exceptions:
1691 etype,value,tb = sys.exc_info()
1711 etype,value,tb = sys.exc_info()
1692 self.CustomTB(etype,value,tb)
1712 self.CustomTB(etype,value,tb)
1693 except:
1713 except:
1694 self.showtraceback()
1714 self.showtraceback()
1695 else:
1715 else:
1696 outflag = 0
1716 outflag = 0
1697 if code.softspace(sys.stdout, 0):
1717 if code.softspace(sys.stdout, 0):
1698 print
1718 print
1699 # Flush out code object which has been run (and source)
1719 # Flush out code object which has been run (and source)
1700 self.code_to_run = None
1720 self.code_to_run = None
1701 return outflag
1721 return outflag
1702
1722
1703 def raw_input(self, prompt=""):
1723 def raw_input(self, prompt=""):
1704 """Write a prompt and read a line.
1724 """Write a prompt and read a line.
1705
1725
1706 The returned line does not include the trailing newline.
1726 The returned line does not include the trailing newline.
1707 When the user enters the EOF key sequence, EOFError is raised.
1727 When the user enters the EOF key sequence, EOFError is raised.
1708
1728
1709 The base implementation uses the built-in function
1729 The base implementation uses the built-in function
1710 raw_input(); a subclass may replace this with a different
1730 raw_input(); a subclass may replace this with a different
1711 implementation.
1731 implementation.
1712 """
1732 """
1713 return self.prefilter(raw_input_original(prompt),
1733 return self.prefilter(raw_input_original(prompt),
1714 prompt==self.outputcache.prompt2)
1734 prompt==self.outputcache.prompt2)
1715
1735
1716 def split_user_input(self,line):
1736 def split_user_input(self,line):
1717 """Split user input into pre-char, function part and rest."""
1737 """Split user input into pre-char, function part and rest."""
1718
1738
1719 lsplit = self.line_split.match(line)
1739 lsplit = self.line_split.match(line)
1720 if lsplit is None: # no regexp match returns None
1740 if lsplit is None: # no regexp match returns None
1721 try:
1741 try:
1722 iFun,theRest = line.split(None,1)
1742 iFun,theRest = line.split(None,1)
1723 except ValueError:
1743 except ValueError:
1724 iFun,theRest = line,''
1744 iFun,theRest = line,''
1725 pre = re.match('^(\s*)(.*)',line).groups()[0]
1745 pre = re.match('^(\s*)(.*)',line).groups()[0]
1726 else:
1746 else:
1727 pre,iFun,theRest = lsplit.groups()
1747 pre,iFun,theRest = lsplit.groups()
1728
1748
1729 #print 'line:<%s>' % line # dbg
1749 #print 'line:<%s>' % line # dbg
1730 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1750 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1731 return pre,iFun.strip(),theRest
1751 return pre,iFun.strip(),theRest
1732
1752
1733 def _prefilter(self, line, continue_prompt):
1753 def _prefilter(self, line, continue_prompt):
1734 """Calls different preprocessors, depending on the form of line."""
1754 """Calls different preprocessors, depending on the form of line."""
1735
1755
1736 # All handlers *must* return a value, even if it's blank ('').
1756 # All handlers *must* return a value, even if it's blank ('').
1737
1757
1738 # Lines are NOT logged here. Handlers should process the line as
1758 # Lines are NOT logged here. Handlers should process the line as
1739 # needed, update the cache AND log it (so that the input cache array
1759 # needed, update the cache AND log it (so that the input cache array
1740 # stays synced).
1760 # stays synced).
1741
1761
1742 # This function is _very_ delicate, and since it's also the one which
1762 # This function is _very_ delicate, and since it's also the one which
1743 # determines IPython's response to user input, it must be as efficient
1763 # determines IPython's response to user input, it must be as efficient
1744 # as possible. For this reason it has _many_ returns in it, trying
1764 # as possible. For this reason it has _many_ returns in it, trying
1745 # always to exit as quickly as it can figure out what it needs to do.
1765 # always to exit as quickly as it can figure out what it needs to do.
1746
1766
1747 # This function is the main responsible for maintaining IPython's
1767 # This function is the main responsible for maintaining IPython's
1748 # behavior respectful of Python's semantics. So be _very_ careful if
1768 # behavior respectful of Python's semantics. So be _very_ careful if
1749 # making changes to anything here.
1769 # making changes to anything here.
1750
1770
1751 #.....................................................................
1771 #.....................................................................
1752 # Code begins
1772 # Code begins
1753
1773
1754 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1774 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1755
1775
1756 # save the line away in case we crash, so the post-mortem handler can
1776 # save the line away in case we crash, so the post-mortem handler can
1757 # record it
1777 # record it
1758 self._last_input_line = line
1778 self._last_input_line = line
1759
1779
1760 #print '***line: <%s>' % line # dbg
1780 #print '***line: <%s>' % line # dbg
1761
1781
1762 # the input history needs to track even empty lines
1782 # the input history needs to track even empty lines
1763 if not line.strip():
1783 if not line.strip():
1764 if not continue_prompt:
1784 if not continue_prompt:
1765 self.outputcache.prompt_count -= 1
1785 self.outputcache.prompt_count -= 1
1766 return self.handle_normal('',continue_prompt)
1786 return self.handle_normal('',continue_prompt)
1767
1787
1768 # print '***cont',continue_prompt # dbg
1788 # print '***cont',continue_prompt # dbg
1769 # special handlers are only allowed for single line statements
1789 # special handlers are only allowed for single line statements
1770 if continue_prompt and not self.rc.multi_line_specials:
1790 if continue_prompt and not self.rc.multi_line_specials:
1771 return self.handle_normal(line,continue_prompt)
1791 return self.handle_normal(line,continue_prompt)
1772
1792
1773 # For the rest, we need the structure of the input
1793 # For the rest, we need the structure of the input
1774 pre,iFun,theRest = self.split_user_input(line)
1794 pre,iFun,theRest = self.split_user_input(line)
1775 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1795 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1776
1796
1777 # First check for explicit escapes in the last/first character
1797 # First check for explicit escapes in the last/first character
1778 handler = None
1798 handler = None
1779 if line[-1] == self.ESC_HELP:
1799 if line[-1] == self.ESC_HELP:
1780 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1800 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1781 if handler is None:
1801 if handler is None:
1782 # look at the first character of iFun, NOT of line, so we skip
1802 # look at the first character of iFun, NOT of line, so we skip
1783 # leading whitespace in multiline input
1803 # leading whitespace in multiline input
1784 handler = self.esc_handlers.get(iFun[0:1])
1804 handler = self.esc_handlers.get(iFun[0:1])
1785 if handler is not None:
1805 if handler is not None:
1786 return handler(line,continue_prompt,pre,iFun,theRest)
1806 return handler(line,continue_prompt,pre,iFun,theRest)
1787 # Emacs ipython-mode tags certain input lines
1807 # Emacs ipython-mode tags certain input lines
1788 if line.endswith('# PYTHON-MODE'):
1808 if line.endswith('# PYTHON-MODE'):
1789 return self.handle_emacs(line,continue_prompt)
1809 return self.handle_emacs(line,continue_prompt)
1790
1810
1791 # Next, check if we can automatically execute this thing
1811 # Next, check if we can automatically execute this thing
1792
1812
1793 # Allow ! in multi-line statements if multi_line_specials is on:
1813 # Allow ! in multi-line statements if multi_line_specials is on:
1794 if continue_prompt and self.rc.multi_line_specials and \
1814 if continue_prompt and self.rc.multi_line_specials and \
1795 iFun.startswith(self.ESC_SHELL):
1815 iFun.startswith(self.ESC_SHELL):
1796 return self.handle_shell_escape(line,continue_prompt,
1816 return self.handle_shell_escape(line,continue_prompt,
1797 pre=pre,iFun=iFun,
1817 pre=pre,iFun=iFun,
1798 theRest=theRest)
1818 theRest=theRest)
1799
1819
1800 # Let's try to find if the input line is a magic fn
1820 # Let's try to find if the input line is a magic fn
1801 oinfo = None
1821 oinfo = None
1802 if hasattr(self,'magic_'+iFun):
1822 if hasattr(self,'magic_'+iFun):
1803 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1823 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1804 if oinfo['ismagic']:
1824 if oinfo['ismagic']:
1805 # Be careful not to call magics when a variable assignment is
1825 # Be careful not to call magics when a variable assignment is
1806 # being made (ls='hi', for example)
1826 # being made (ls='hi', for example)
1807 if self.rc.automagic and \
1827 if self.rc.automagic and \
1808 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1828 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1809 (self.rc.multi_line_specials or not continue_prompt):
1829 (self.rc.multi_line_specials or not continue_prompt):
1810 return self.handle_magic(line,continue_prompt,
1830 return self.handle_magic(line,continue_prompt,
1811 pre,iFun,theRest)
1831 pre,iFun,theRest)
1812 else:
1832 else:
1813 return self.handle_normal(line,continue_prompt)
1833 return self.handle_normal(line,continue_prompt)
1814
1834
1815 # If the rest of the line begins with an (in)equality, assginment or
1835 # If the rest of the line begins with an (in)equality, assginment or
1816 # function call, we should not call _ofind but simply execute it.
1836 # function call, we should not call _ofind but simply execute it.
1817 # This avoids spurious geattr() accesses on objects upon assignment.
1837 # This avoids spurious geattr() accesses on objects upon assignment.
1818 #
1838 #
1819 # It also allows users to assign to either alias or magic names true
1839 # It also allows users to assign to either alias or magic names true
1820 # python variables (the magic/alias systems always take second seat to
1840 # python variables (the magic/alias systems always take second seat to
1821 # true python code).
1841 # true python code).
1822 if theRest and theRest[0] in '!=()':
1842 if theRest and theRest[0] in '!=()':
1823 return self.handle_normal(line,continue_prompt)
1843 return self.handle_normal(line,continue_prompt)
1824
1844
1825 if oinfo is None:
1845 if oinfo is None:
1826 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1846 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1827
1847
1828 if not oinfo['found']:
1848 if not oinfo['found']:
1829 return self.handle_normal(line,continue_prompt)
1849 return self.handle_normal(line,continue_prompt)
1830 else:
1850 else:
1831 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1851 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1832 if oinfo['isalias']:
1852 if oinfo['isalias']:
1833 return self.handle_alias(line,continue_prompt,
1853 return self.handle_alias(line,continue_prompt,
1834 pre,iFun,theRest)
1854 pre,iFun,theRest)
1835
1855
1836 if self.rc.autocall and \
1856 if self.rc.autocall and \
1837 not self.re_exclude_auto.match(theRest) and \
1857 not self.re_exclude_auto.match(theRest) and \
1838 self.re_fun_name.match(iFun) and \
1858 self.re_fun_name.match(iFun) and \
1839 callable(oinfo['obj']) :
1859 callable(oinfo['obj']) :
1840 #print 'going auto' # dbg
1860 #print 'going auto' # dbg
1841 return self.handle_auto(line,continue_prompt,pre,iFun,theRest)
1861 return self.handle_auto(line,continue_prompt,pre,iFun,theRest)
1842 else:
1862 else:
1843 #print 'was callable?', callable(oinfo['obj']) # dbg
1863 #print 'was callable?', callable(oinfo['obj']) # dbg
1844 return self.handle_normal(line,continue_prompt)
1864 return self.handle_normal(line,continue_prompt)
1845
1865
1846 # If we get here, we have a normal Python line. Log and return.
1866 # If we get here, we have a normal Python line. Log and return.
1847 return self.handle_normal(line,continue_prompt)
1867 return self.handle_normal(line,continue_prompt)
1848
1868
1849 def _prefilter_dumb(self, line, continue_prompt):
1869 def _prefilter_dumb(self, line, continue_prompt):
1850 """simple prefilter function, for debugging"""
1870 """simple prefilter function, for debugging"""
1851 return self.handle_normal(line,continue_prompt)
1871 return self.handle_normal(line,continue_prompt)
1852
1872
1853 # Set the default prefilter() function (this can be user-overridden)
1873 # Set the default prefilter() function (this can be user-overridden)
1854 prefilter = _prefilter
1874 prefilter = _prefilter
1855
1875
1856 def handle_normal(self,line,continue_prompt=None,
1876 def handle_normal(self,line,continue_prompt=None,
1857 pre=None,iFun=None,theRest=None):
1877 pre=None,iFun=None,theRest=None):
1858 """Handle normal input lines. Use as a template for handlers."""
1878 """Handle normal input lines. Use as a template for handlers."""
1859
1879
1860 self.log(line,continue_prompt)
1880 self.log(line,continue_prompt)
1861 self.update_cache(line)
1881 self.update_cache(line)
1862 return line
1882 return line
1863
1883
1864 def handle_alias(self,line,continue_prompt=None,
1884 def handle_alias(self,line,continue_prompt=None,
1865 pre=None,iFun=None,theRest=None):
1885 pre=None,iFun=None,theRest=None):
1866 """Handle alias input lines. """
1886 """Handle alias input lines. """
1867
1887
1868 theRest = esc_quotes(theRest)
1888 theRest = esc_quotes(theRest)
1869 line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest)
1889 line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest)
1870 self.log(line_out,continue_prompt)
1890 self.log(line_out,continue_prompt)
1871 self.update_cache(line_out)
1891 self.update_cache(line_out)
1872 return line_out
1892 return line_out
1873
1893
1874 def handle_shell_escape(self, line, continue_prompt=None,
1894 def handle_shell_escape(self, line, continue_prompt=None,
1875 pre=None,iFun=None,theRest=None):
1895 pre=None,iFun=None,theRest=None):
1876 """Execute the line in a shell, empty return value"""
1896 """Execute the line in a shell, empty return value"""
1877
1897
1878 #print 'line in :', `line` # dbg
1898 #print 'line in :', `line` # dbg
1879 # Example of a special handler. Others follow a similar pattern.
1899 # Example of a special handler. Others follow a similar pattern.
1880 if continue_prompt: # multi-line statements
1900 if continue_prompt: # multi-line statements
1881 if iFun.startswith('!!'):
1901 if iFun.startswith('!!'):
1882 print 'SyntaxError: !! is not allowed in multiline statements'
1902 print 'SyntaxError: !! is not allowed in multiline statements'
1883 return pre
1903 return pre
1884 else:
1904 else:
1885 cmd = ("%s %s" % (iFun[1:],theRest)).replace('"','\\"')
1905 cmd = ("%s %s" % (iFun[1:],theRest)).replace('"','\\"')
1886 line_out = '%s%s.system("%s")' % (pre,self.name,cmd)
1906 line_out = '%s%s.system("%s")' % (pre,self.name,cmd)
1887 #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')'
1907 #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')'
1888 else: # single-line input
1908 else: # single-line input
1889 if line.startswith('!!'):
1909 if line.startswith('!!'):
1890 # rewrite iFun/theRest to properly hold the call to %sx and
1910 # rewrite iFun/theRest to properly hold the call to %sx and
1891 # the actual command to be executed, so handle_magic can work
1911 # the actual command to be executed, so handle_magic can work
1892 # correctly
1912 # correctly
1893 theRest = '%s %s' % (iFun[2:],theRest)
1913 theRest = '%s %s' % (iFun[2:],theRest)
1894 iFun = 'sx'
1914 iFun = 'sx'
1895 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1915 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1896 continue_prompt,pre,iFun,theRest)
1916 continue_prompt,pre,iFun,theRest)
1897 else:
1917 else:
1898 cmd = esc_quotes(line[1:])
1918 cmd = esc_quotes(line[1:])
1899 line_out = '%s.system("%s")' % (self.name,cmd)
1919 line_out = '%s.system("%s")' % (self.name,cmd)
1900 #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')'
1920 #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')'
1901 # update cache/log and return
1921 # update cache/log and return
1902 self.log(line_out,continue_prompt)
1922 self.log(line_out,continue_prompt)
1903 self.update_cache(line_out) # readline cache gets normal line
1923 self.update_cache(line_out) # readline cache gets normal line
1904 #print 'line out r:', `line_out` # dbg
1924 #print 'line out r:', `line_out` # dbg
1905 #print 'line out s:', line_out # dbg
1925 #print 'line out s:', line_out # dbg
1906 return line_out
1926 return line_out
1907
1927
1908 def handle_magic(self, line, continue_prompt=None,
1928 def handle_magic(self, line, continue_prompt=None,
1909 pre=None,iFun=None,theRest=None):
1929 pre=None,iFun=None,theRest=None):
1910 """Execute magic functions.
1930 """Execute magic functions.
1911
1931
1912 Also log them with a prepended # so the log is clean Python."""
1932 Also log them with a prepended # so the log is clean Python."""
1913
1933
1914 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1934 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1915 self.log(cmd,continue_prompt)
1935 self.log(cmd,continue_prompt)
1916 self.update_cache(line)
1936 self.update_cache(line)
1917 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1937 print 'in handle_magic, cmd=<%s>' % cmd # dbg
1918 return cmd
1938 return cmd
1919
1939
1920 def handle_auto(self, line, continue_prompt=None,
1940 def handle_auto(self, line, continue_prompt=None,
1921 pre=None,iFun=None,theRest=None):
1941 pre=None,iFun=None,theRest=None):
1922 """Hande lines which can be auto-executed, quoting if requested."""
1942 """Hande lines which can be auto-executed, quoting if requested."""
1923
1943
1924 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1944 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1925
1945
1926 # This should only be active for single-line input!
1946 # This should only be active for single-line input!
1927 if continue_prompt:
1947 if continue_prompt:
1928 return line
1948 return line
1929
1949
1930 if pre == self.ESC_QUOTE:
1950 if pre == self.ESC_QUOTE:
1931 # Auto-quote splitting on whitespace
1951 # Auto-quote splitting on whitespace
1932 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1952 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1933 elif pre == self.ESC_QUOTE2:
1953 elif pre == self.ESC_QUOTE2:
1934 # Auto-quote whole string
1954 # Auto-quote whole string
1935 newcmd = '%s("%s")' % (iFun,theRest)
1955 newcmd = '%s("%s")' % (iFun,theRest)
1936 else:
1956 else:
1937 # Auto-paren
1957 # Auto-paren
1938 if theRest[0:1] in ('=','['):
1958 if theRest[0:1] in ('=','['):
1939 # Don't autocall in these cases. They can be either
1959 # Don't autocall in these cases. They can be either
1940 # rebindings of an existing callable's name, or item access
1960 # rebindings of an existing callable's name, or item access
1941 # for an object which is BOTH callable and implements
1961 # for an object which is BOTH callable and implements
1942 # __getitem__.
1962 # __getitem__.
1943 return '%s %s' % (iFun,theRest)
1963 return '%s %s' % (iFun,theRest)
1944 if theRest.endswith(';'):
1964 if theRest.endswith(';'):
1945 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1965 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1946 else:
1966 else:
1947 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1967 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1948
1968
1949 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1969 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1950 # log what is now valid Python, not the actual user input (without the
1970 # log what is now valid Python, not the actual user input (without the
1951 # final newline)
1971 # final newline)
1952 self.log(newcmd,continue_prompt)
1972 self.log(newcmd,continue_prompt)
1953 return newcmd
1973 return newcmd
1954
1974
1955 def handle_help(self, line, continue_prompt=None,
1975 def handle_help(self, line, continue_prompt=None,
1956 pre=None,iFun=None,theRest=None):
1976 pre=None,iFun=None,theRest=None):
1957 """Try to get some help for the object.
1977 """Try to get some help for the object.
1958
1978
1959 obj? or ?obj -> basic information.
1979 obj? or ?obj -> basic information.
1960 obj?? or ??obj -> more details.
1980 obj?? or ??obj -> more details.
1961 """
1981 """
1962
1982
1963 # We need to make sure that we don't process lines which would be
1983 # We need to make sure that we don't process lines which would be
1964 # otherwise valid python, such as "x=1 # what?"
1984 # otherwise valid python, such as "x=1 # what?"
1965 try:
1985 try:
1966 code.compile_command(line)
1986 code.compile_command(line)
1967 except SyntaxError:
1987 except SyntaxError:
1968 # We should only handle as help stuff which is NOT valid syntax
1988 # We should only handle as help stuff which is NOT valid syntax
1969 if line[0]==self.ESC_HELP:
1989 if line[0]==self.ESC_HELP:
1970 line = line[1:]
1990 line = line[1:]
1971 elif line[-1]==self.ESC_HELP:
1991 elif line[-1]==self.ESC_HELP:
1972 line = line[:-1]
1992 line = line[:-1]
1973 self.log('#?'+line)
1993 self.log('#?'+line)
1974 self.update_cache(line)
1994 self.update_cache(line)
1975 if line:
1995 if line:
1976 self.magic_pinfo(line)
1996 self.magic_pinfo(line)
1977 else:
1997 else:
1978 page(self.usage,screen_lines=self.rc.screen_length)
1998 page(self.usage,screen_lines=self.rc.screen_length)
1979 return '' # Empty string is needed here!
1999 return '' # Empty string is needed here!
1980 except:
2000 except:
1981 # Pass any other exceptions through to the normal handler
2001 # Pass any other exceptions through to the normal handler
1982 return self.handle_normal(line,continue_prompt)
2002 return self.handle_normal(line,continue_prompt)
1983 else:
2003 else:
1984 # If the code compiles ok, we should handle it normally
2004 # If the code compiles ok, we should handle it normally
1985 return self.handle_normal(line,continue_prompt)
2005 return self.handle_normal(line,continue_prompt)
1986
2006
1987 def handle_emacs(self,line,continue_prompt=None,
2007 def handle_emacs(self,line,continue_prompt=None,
1988 pre=None,iFun=None,theRest=None):
2008 pre=None,iFun=None,theRest=None):
1989 """Handle input lines marked by python-mode."""
2009 """Handle input lines marked by python-mode."""
1990
2010
1991 # Currently, nothing is done. Later more functionality can be added
2011 # Currently, nothing is done. Later more functionality can be added
1992 # here if needed.
2012 # here if needed.
1993
2013
1994 # The input cache shouldn't be updated
2014 # The input cache shouldn't be updated
1995
2015
1996 return line
2016 return line
1997
2017
1998 def write(self,data):
2018 def write(self,data):
1999 """Write a string to the default output"""
2019 """Write a string to the default output"""
2000 Term.cout.write(data)
2020 Term.cout.write(data)
2001
2021
2002 def write_err(self,data):
2022 def write_err(self,data):
2003 """Write a string to the default error output"""
2023 """Write a string to the default error output"""
2004 Term.cerr.write(data)
2024 Term.cerr.write(data)
2005
2025
2006 def safe_execfile(self,fname,*where,**kw):
2026 def safe_execfile(self,fname,*where,**kw):
2007 fname = os.path.expanduser(fname)
2027 fname = os.path.expanduser(fname)
2008
2028
2009 # find things also in current directory
2029 # find things also in current directory
2010 dname = os.path.dirname(fname)
2030 dname = os.path.dirname(fname)
2011 if not sys.path.count(dname):
2031 if not sys.path.count(dname):
2012 sys.path.append(dname)
2032 sys.path.append(dname)
2013
2033
2014 try:
2034 try:
2015 xfile = open(fname)
2035 xfile = open(fname)
2016 except:
2036 except:
2017 print >> Term.cerr, \
2037 print >> Term.cerr, \
2018 'Could not open file <%s> for safe execution.' % fname
2038 'Could not open file <%s> for safe execution.' % fname
2019 return None
2039 return None
2020
2040
2021 kw.setdefault('islog',0)
2041 kw.setdefault('islog',0)
2022 kw.setdefault('quiet',1)
2042 kw.setdefault('quiet',1)
2023 kw.setdefault('exit_ignore',0)
2043 kw.setdefault('exit_ignore',0)
2024 first = xfile.readline()
2044 first = xfile.readline()
2025 _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip()
2045 _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip()
2026 xfile.close()
2046 xfile.close()
2027 # line by line execution
2047 # line by line execution
2028 if first.startswith(_LOGHEAD) or kw['islog']:
2048 if first.startswith(_LOGHEAD) or kw['islog']:
2029 print 'Loading log file <%s> one line at a time...' % fname
2049 print 'Loading log file <%s> one line at a time...' % fname
2030 if kw['quiet']:
2050 if kw['quiet']:
2031 stdout_save = sys.stdout
2051 stdout_save = sys.stdout
2032 sys.stdout = StringIO.StringIO()
2052 sys.stdout = StringIO.StringIO()
2033 try:
2053 try:
2034 globs,locs = where[0:2]
2054 globs,locs = where[0:2]
2035 except:
2055 except:
2036 try:
2056 try:
2037 globs = locs = where[0]
2057 globs = locs = where[0]
2038 except:
2058 except:
2039 globs = locs = globals()
2059 globs = locs = globals()
2040 badblocks = []
2060 badblocks = []
2041
2061
2042 # we also need to identify indented blocks of code when replaying
2062 # we also need to identify indented blocks of code when replaying
2043 # logs and put them together before passing them to an exec
2063 # logs and put them together before passing them to an exec
2044 # statement. This takes a bit of regexp and look-ahead work in the
2064 # statement. This takes a bit of regexp and look-ahead work in the
2045 # file. It's easiest if we swallow the whole thing in memory
2065 # file. It's easiest if we swallow the whole thing in memory
2046 # first, and manually walk through the lines list moving the
2066 # first, and manually walk through the lines list moving the
2047 # counter ourselves.
2067 # counter ourselves.
2048 indent_re = re.compile('\s+\S')
2068 indent_re = re.compile('\s+\S')
2049 xfile = open(fname)
2069 xfile = open(fname)
2050 filelines = xfile.readlines()
2070 filelines = xfile.readlines()
2051 xfile.close()
2071 xfile.close()
2052 nlines = len(filelines)
2072 nlines = len(filelines)
2053 lnum = 0
2073 lnum = 0
2054 while lnum < nlines:
2074 while lnum < nlines:
2055 line = filelines[lnum]
2075 line = filelines[lnum]
2056 lnum += 1
2076 lnum += 1
2057 # don't re-insert logger status info into cache
2077 # don't re-insert logger status info into cache
2058 if line.startswith('#log#'):
2078 if line.startswith('#log#'):
2059 continue
2079 continue
2060 elif line.startswith('#%s'% self.ESC_MAGIC):
2080 elif line.startswith('#%s'% self.ESC_MAGIC):
2061 self.update_cache(line[1:])
2081 self.update_cache(line[1:])
2062 line = magic2python(line)
2082 line = magic2python(line)
2063 elif line.startswith('#!'):
2083 elif line.startswith('#!'):
2064 self.update_cache(line[1:])
2084 self.update_cache(line[1:])
2065 else:
2085 else:
2066 # build a block of code (maybe a single line) for execution
2086 # build a block of code (maybe a single line) for execution
2067 block = line
2087 block = line
2068 try:
2088 try:
2069 next = filelines[lnum] # lnum has already incremented
2089 next = filelines[lnum] # lnum has already incremented
2070 except:
2090 except:
2071 next = None
2091 next = None
2072 while next and indent_re.match(next):
2092 while next and indent_re.match(next):
2073 block += next
2093 block += next
2074 lnum += 1
2094 lnum += 1
2075 try:
2095 try:
2076 next = filelines[lnum]
2096 next = filelines[lnum]
2077 except:
2097 except:
2078 next = None
2098 next = None
2079 # now execute the block of one or more lines
2099 # now execute the block of one or more lines
2080 try:
2100 try:
2081 exec block in globs,locs
2101 exec block in globs,locs
2082 self.update_cache(block.rstrip())
2102 self.update_cache(block.rstrip())
2083 except SystemExit:
2103 except SystemExit:
2084 pass
2104 pass
2085 except:
2105 except:
2086 badblocks.append(block.rstrip())
2106 badblocks.append(block.rstrip())
2087 if kw['quiet']: # restore stdout
2107 if kw['quiet']: # restore stdout
2088 sys.stdout.close()
2108 sys.stdout.close()
2089 sys.stdout = stdout_save
2109 sys.stdout = stdout_save
2090 print 'Finished replaying log file <%s>' % fname
2110 print 'Finished replaying log file <%s>' % fname
2091 if badblocks:
2111 if badblocks:
2092 print >> sys.stderr, \
2112 print >> sys.stderr, \
2093 '\nThe following lines/blocks in file <%s> reported errors:' \
2113 '\nThe following lines/blocks in file <%s> reported errors:' \
2094 % fname
2114 % fname
2095 for badline in badblocks:
2115 for badline in badblocks:
2096 print >> sys.stderr, badline
2116 print >> sys.stderr, badline
2097 else: # regular file execution
2117 else: # regular file execution
2098 try:
2118 try:
2099 execfile(fname,*where)
2119 execfile(fname,*where)
2100 except SyntaxError:
2120 except SyntaxError:
2101 etype, evalue = sys.exc_info()[0:2]
2121 etype, evalue = sys.exc_info()[0:2]
2102 self.SyntaxTB(etype,evalue,[])
2122 self.SyntaxTB(etype,evalue,[])
2103 warn('Failure executing file: <%s>' % fname)
2123 warn('Failure executing file: <%s>' % fname)
2104 except SystemExit,status:
2124 except SystemExit,status:
2105 if not kw['exit_ignore']:
2125 if not kw['exit_ignore']:
2106 self.InteractiveTB()
2126 self.InteractiveTB()
2107 warn('Failure executing file: <%s>' % fname)
2127 warn('Failure executing file: <%s>' % fname)
2108 except:
2128 except:
2109 self.InteractiveTB()
2129 self.InteractiveTB()
2110 warn('Failure executing file: <%s>' % fname)
2130 warn('Failure executing file: <%s>' % fname)
2111
2131
2112 #************************* end of file <iplib.py> *****************************
2132 #************************* end of file <iplib.py> *****************************
@@ -1,4493 +1,4516 b''
1 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/FlexCompleter.py (Completer.__init__): Added support for
4 distinct local and global namespaces in the completer API. This
5 change allows us top properly handle completion with distinct
6 scopes, including in embedded instances (this had never really
7 worked correctly).
8
9 Note: this introduces a change in the constructor for
10 MagicCompleter, as a new global_namespace parameter is now the
11 second argument (the others were bumped one position).
12
13 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
14
15 * IPython/iplib.py (embed_mainloop): fix tab-completion in
16 embedded instances (which can be done now thanks to Vivian's
17 frame-handling fixes for pdb).
18 (InteractiveShell.__init__): Fix namespace handling problem in
19 embedded instances. We were overwriting __main__ unconditionally,
20 and this should only be done for 'full' (non-embedded) IPython;
21 embedded instances must respect the caller's __main__. Thanks to
22 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
23
1 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
24 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2
25
3 * setup.py: added download_url to setup(). This registers the
26 * setup.py: added download_url to setup(). This registers the
4 download address at PyPI, which is not only useful to humans
27 download address at PyPI, which is not only useful to humans
5 browsing the site, but is also picked up by setuptools (the Eggs
28 browsing the site, but is also picked up by setuptools (the Eggs
6 machinery). Thanks to Ville and R. Kern for the info/discussion
29 machinery). Thanks to Ville and R. Kern for the info/discussion
7 on this.
30 on this.
8
31
9 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
32 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
10
33
11 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
34 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
12 This brings a lot of nice functionality to the pdb mode, which now
35 This brings a lot of nice functionality to the pdb mode, which now
13 has tab-completion, syntax highlighting, and better stack handling
36 has tab-completion, syntax highlighting, and better stack handling
14 than before. Many thanks to Vivian De Smedt
37 than before. Many thanks to Vivian De Smedt
15 <vivian-AT-vdesmedt.com> for the original patches.
38 <vivian-AT-vdesmedt.com> for the original patches.
16
39
17 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
40 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
18
41
19 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
42 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
20 sequence to consistently accept the banner argument. The
43 sequence to consistently accept the banner argument. The
21 inconsistency was tripping SAGE, thanks to Gary Zablackis
44 inconsistency was tripping SAGE, thanks to Gary Zablackis
22 <gzabl-AT-yahoo.com> for the report.
45 <gzabl-AT-yahoo.com> for the report.
23
46
24 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
47 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
25
48
26 * IPython/iplib.py (InteractiveShell.post_config_initialization):
49 * IPython/iplib.py (InteractiveShell.post_config_initialization):
27 Fix bug where a naked 'alias' call in the ipythonrc file would
50 Fix bug where a naked 'alias' call in the ipythonrc file would
28 cause a crash. Bug reported by Jorgen Stenarson.
51 cause a crash. Bug reported by Jorgen Stenarson.
29
52
30 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
53 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
31
54
32 * IPython/ipmaker.py (make_IPython): cleanups which should improve
55 * IPython/ipmaker.py (make_IPython): cleanups which should improve
33 startup time.
56 startup time.
34
57
35 * IPython/iplib.py (runcode): my globals 'fix' for embedded
58 * IPython/iplib.py (runcode): my globals 'fix' for embedded
36 instances had introduced a bug with globals in normal code. Now
59 instances had introduced a bug with globals in normal code. Now
37 it's working in all cases.
60 it's working in all cases.
38
61
39 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
62 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
40 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
63 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
41 has been introduced to set the default case sensitivity of the
64 has been introduced to set the default case sensitivity of the
42 searches. Users can still select either mode at runtime on a
65 searches. Users can still select either mode at runtime on a
43 per-search basis.
66 per-search basis.
44
67
45 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
68 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
46
69
47 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
70 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
48 attributes in wildcard searches for subclasses. Modified version
71 attributes in wildcard searches for subclasses. Modified version
49 of a patch by Jorgen.
72 of a patch by Jorgen.
50
73
51 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
74 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
52
75
53 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
76 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
54 embedded instances. I added a user_global_ns attribute to the
77 embedded instances. I added a user_global_ns attribute to the
55 InteractiveShell class to handle this.
78 InteractiveShell class to handle this.
56
79
57 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
80 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
58
81
59 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
82 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
60 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
83 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
61 (reported under win32, but may happen also in other platforms).
84 (reported under win32, but may happen also in other platforms).
62 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
85 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
63
86
64 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
87 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
65
88
66 * IPython/Magic.py (magic_psearch): new support for wildcard
89 * IPython/Magic.py (magic_psearch): new support for wildcard
67 patterns. Now, typing ?a*b will list all names which begin with a
90 patterns. Now, typing ?a*b will list all names which begin with a
68 and end in b, for example. The %psearch magic has full
91 and end in b, for example. The %psearch magic has full
69 docstrings. Many thanks to JΓΆrgen Stenarson
92 docstrings. Many thanks to JΓΆrgen Stenarson
70 <jorgen.stenarson-AT-bostream.nu>, author of the patches
93 <jorgen.stenarson-AT-bostream.nu>, author of the patches
71 implementing this functionality.
94 implementing this functionality.
72
95
73 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
96 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
74
97
75 * Manual: fixed long-standing annoyance of double-dashes (as in
98 * Manual: fixed long-standing annoyance of double-dashes (as in
76 --prefix=~, for example) being stripped in the HTML version. This
99 --prefix=~, for example) being stripped in the HTML version. This
77 is a latex2html bug, but a workaround was provided. Many thanks
100 is a latex2html bug, but a workaround was provided. Many thanks
78 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
101 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
79 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
102 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
80 rolling. This seemingly small issue had tripped a number of users
103 rolling. This seemingly small issue had tripped a number of users
81 when first installing, so I'm glad to see it gone.
104 when first installing, so I'm glad to see it gone.
82
105
83 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
106 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
84
107
85 * IPython/Extensions/numeric_formats.py: fix missing import,
108 * IPython/Extensions/numeric_formats.py: fix missing import,
86 reported by Stephen Walton.
109 reported by Stephen Walton.
87
110
88 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
111 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
89
112
90 * IPython/demo.py: finish demo module, fully documented now.
113 * IPython/demo.py: finish demo module, fully documented now.
91
114
92 * IPython/genutils.py (file_read): simple little utility to read a
115 * IPython/genutils.py (file_read): simple little utility to read a
93 file and ensure it's closed afterwards.
116 file and ensure it's closed afterwards.
94
117
95 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
118 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
96
119
97 * IPython/demo.py (Demo.__init__): added support for individually
120 * IPython/demo.py (Demo.__init__): added support for individually
98 tagging blocks for automatic execution.
121 tagging blocks for automatic execution.
99
122
100 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
123 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
101 syntax-highlighted python sources, requested by John.
124 syntax-highlighted python sources, requested by John.
102
125
103 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
126 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
104
127
105 * IPython/demo.py (Demo.again): fix bug where again() blocks after
128 * IPython/demo.py (Demo.again): fix bug where again() blocks after
106 finishing.
129 finishing.
107
130
108 * IPython/genutils.py (shlex_split): moved from Magic to here,
131 * IPython/genutils.py (shlex_split): moved from Magic to here,
109 where all 2.2 compatibility stuff lives. I needed it for demo.py.
132 where all 2.2 compatibility stuff lives. I needed it for demo.py.
110
133
111 * IPython/demo.py (Demo.__init__): added support for silent
134 * IPython/demo.py (Demo.__init__): added support for silent
112 blocks, improved marks as regexps, docstrings written.
135 blocks, improved marks as regexps, docstrings written.
113 (Demo.__init__): better docstring, added support for sys.argv.
136 (Demo.__init__): better docstring, added support for sys.argv.
114
137
115 * IPython/genutils.py (marquee): little utility used by the demo
138 * IPython/genutils.py (marquee): little utility used by the demo
116 code, handy in general.
139 code, handy in general.
117
140
118 * IPython/demo.py (Demo.__init__): new class for interactive
141 * IPython/demo.py (Demo.__init__): new class for interactive
119 demos. Not documented yet, I just wrote it in a hurry for
142 demos. Not documented yet, I just wrote it in a hurry for
120 scipy'05. Will docstring later.
143 scipy'05. Will docstring later.
121
144
122 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
145 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
123
146
124 * IPython/Shell.py (sigint_handler): Drastic simplification which
147 * IPython/Shell.py (sigint_handler): Drastic simplification which
125 also seems to make Ctrl-C work correctly across threads! This is
148 also seems to make Ctrl-C work correctly across threads! This is
126 so simple, that I can't beleive I'd missed it before. Needs more
149 so simple, that I can't beleive I'd missed it before. Needs more
127 testing, though.
150 testing, though.
128 (KBINT): Never mind, revert changes. I'm sure I'd tried something
151 (KBINT): Never mind, revert changes. I'm sure I'd tried something
129 like this before...
152 like this before...
130
153
131 * IPython/genutils.py (get_home_dir): add protection against
154 * IPython/genutils.py (get_home_dir): add protection against
132 non-dirs in win32 registry.
155 non-dirs in win32 registry.
133
156
134 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
157 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
135 bug where dict was mutated while iterating (pysh crash).
158 bug where dict was mutated while iterating (pysh crash).
136
159
137 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
160 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
138
161
139 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
162 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
140 spurious newlines added by this routine. After a report by
163 spurious newlines added by this routine. After a report by
141 F. Mantegazza.
164 F. Mantegazza.
142
165
143 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
166 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
144
167
145 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
168 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
146 calls. These were a leftover from the GTK 1.x days, and can cause
169 calls. These were a leftover from the GTK 1.x days, and can cause
147 problems in certain cases (after a report by John Hunter).
170 problems in certain cases (after a report by John Hunter).
148
171
149 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
172 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
150 os.getcwd() fails at init time. Thanks to patch from David Remahl
173 os.getcwd() fails at init time. Thanks to patch from David Remahl
151 <chmod007-AT-mac.com>.
174 <chmod007-AT-mac.com>.
152 (InteractiveShell.__init__): prevent certain special magics from
175 (InteractiveShell.__init__): prevent certain special magics from
153 being shadowed by aliases. Closes
176 being shadowed by aliases. Closes
154 http://www.scipy.net/roundup/ipython/issue41.
177 http://www.scipy.net/roundup/ipython/issue41.
155
178
156 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
179 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
157
180
158 * IPython/iplib.py (InteractiveShell.complete): Added new
181 * IPython/iplib.py (InteractiveShell.complete): Added new
159 top-level completion method to expose the completion mechanism
182 top-level completion method to expose the completion mechanism
160 beyond readline-based environments.
183 beyond readline-based environments.
161
184
162 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
185 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
163
186
164 * tools/ipsvnc (svnversion): fix svnversion capture.
187 * tools/ipsvnc (svnversion): fix svnversion capture.
165
188
166 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
189 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
167 attribute to self, which was missing. Before, it was set by a
190 attribute to self, which was missing. Before, it was set by a
168 routine which in certain cases wasn't being called, so the
191 routine which in certain cases wasn't being called, so the
169 instance could end up missing the attribute. This caused a crash.
192 instance could end up missing the attribute. This caused a crash.
170 Closes http://www.scipy.net/roundup/ipython/issue40.
193 Closes http://www.scipy.net/roundup/ipython/issue40.
171
194
172 2005-08-16 Fernando Perez <fperez@colorado.edu>
195 2005-08-16 Fernando Perez <fperez@colorado.edu>
173
196
174 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
197 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
175 contains non-string attribute. Closes
198 contains non-string attribute. Closes
176 http://www.scipy.net/roundup/ipython/issue38.
199 http://www.scipy.net/roundup/ipython/issue38.
177
200
178 2005-08-14 Fernando Perez <fperez@colorado.edu>
201 2005-08-14 Fernando Perez <fperez@colorado.edu>
179
202
180 * tools/ipsvnc: Minor improvements, to add changeset info.
203 * tools/ipsvnc: Minor improvements, to add changeset info.
181
204
182 2005-08-12 Fernando Perez <fperez@colorado.edu>
205 2005-08-12 Fernando Perez <fperez@colorado.edu>
183
206
184 * IPython/iplib.py (runsource): remove self.code_to_run_src
207 * IPython/iplib.py (runsource): remove self.code_to_run_src
185 attribute. I realized this is nothing more than
208 attribute. I realized this is nothing more than
186 '\n'.join(self.buffer), and having the same data in two different
209 '\n'.join(self.buffer), and having the same data in two different
187 places is just asking for synchronization bugs. This may impact
210 places is just asking for synchronization bugs. This may impact
188 people who have custom exception handlers, so I need to warn
211 people who have custom exception handlers, so I need to warn
189 ipython-dev about it (F. Mantegazza may use them).
212 ipython-dev about it (F. Mantegazza may use them).
190
213
191 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
214 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
192
215
193 * IPython/genutils.py: fix 2.2 compatibility (generators)
216 * IPython/genutils.py: fix 2.2 compatibility (generators)
194
217
195 2005-07-18 Fernando Perez <fperez@colorado.edu>
218 2005-07-18 Fernando Perez <fperez@colorado.edu>
196
219
197 * IPython/genutils.py (get_home_dir): fix to help users with
220 * IPython/genutils.py (get_home_dir): fix to help users with
198 invalid $HOME under win32.
221 invalid $HOME under win32.
199
222
200 2005-07-17 Fernando Perez <fperez@colorado.edu>
223 2005-07-17 Fernando Perez <fperez@colorado.edu>
201
224
202 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
225 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
203 some old hacks and clean up a bit other routines; code should be
226 some old hacks and clean up a bit other routines; code should be
204 simpler and a bit faster.
227 simpler and a bit faster.
205
228
206 * IPython/iplib.py (interact): removed some last-resort attempts
229 * IPython/iplib.py (interact): removed some last-resort attempts
207 to survive broken stdout/stderr. That code was only making it
230 to survive broken stdout/stderr. That code was only making it
208 harder to abstract out the i/o (necessary for gui integration),
231 harder to abstract out the i/o (necessary for gui integration),
209 and the crashes it could prevent were extremely rare in practice
232 and the crashes it could prevent were extremely rare in practice
210 (besides being fully user-induced in a pretty violent manner).
233 (besides being fully user-induced in a pretty violent manner).
211
234
212 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
235 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
213 Nothing major yet, but the code is simpler to read; this should
236 Nothing major yet, but the code is simpler to read; this should
214 make it easier to do more serious modifications in the future.
237 make it easier to do more serious modifications in the future.
215
238
216 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
239 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
217 which broke in .15 (thanks to a report by Ville).
240 which broke in .15 (thanks to a report by Ville).
218
241
219 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
242 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
220 be quite correct, I know next to nothing about unicode). This
243 be quite correct, I know next to nothing about unicode). This
221 will allow unicode strings to be used in prompts, amongst other
244 will allow unicode strings to be used in prompts, amongst other
222 cases. It also will prevent ipython from crashing when unicode
245 cases. It also will prevent ipython from crashing when unicode
223 shows up unexpectedly in many places. If ascii encoding fails, we
246 shows up unexpectedly in many places. If ascii encoding fails, we
224 assume utf_8. Currently the encoding is not a user-visible
247 assume utf_8. Currently the encoding is not a user-visible
225 setting, though it could be made so if there is demand for it.
248 setting, though it could be made so if there is demand for it.
226
249
227 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
250 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
228
251
229 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
252 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
230
253
231 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
254 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
232
255
233 * IPython/genutils.py: Add 2.2 compatibility here, so all other
256 * IPython/genutils.py: Add 2.2 compatibility here, so all other
234 code can work transparently for 2.2/2.3.
257 code can work transparently for 2.2/2.3.
235
258
236 2005-07-16 Fernando Perez <fperez@colorado.edu>
259 2005-07-16 Fernando Perez <fperez@colorado.edu>
237
260
238 * IPython/ultraTB.py (ExceptionColors): Make a global variable
261 * IPython/ultraTB.py (ExceptionColors): Make a global variable
239 out of the color scheme table used for coloring exception
262 out of the color scheme table used for coloring exception
240 tracebacks. This allows user code to add new schemes at runtime.
263 tracebacks. This allows user code to add new schemes at runtime.
241 This is a minimally modified version of the patch at
264 This is a minimally modified version of the patch at
242 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
265 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
243 for the contribution.
266 for the contribution.
244
267
245 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
268 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
246 slightly modified version of the patch in
269 slightly modified version of the patch in
247 http://www.scipy.net/roundup/ipython/issue34, which also allows me
270 http://www.scipy.net/roundup/ipython/issue34, which also allows me
248 to remove the previous try/except solution (which was costlier).
271 to remove the previous try/except solution (which was costlier).
249 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
272 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
250
273
251 2005-06-08 Fernando Perez <fperez@colorado.edu>
274 2005-06-08 Fernando Perez <fperez@colorado.edu>
252
275
253 * IPython/iplib.py (write/write_err): Add methods to abstract all
276 * IPython/iplib.py (write/write_err): Add methods to abstract all
254 I/O a bit more.
277 I/O a bit more.
255
278
256 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
279 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
257 warning, reported by Aric Hagberg, fix by JD Hunter.
280 warning, reported by Aric Hagberg, fix by JD Hunter.
258
281
259 2005-06-02 *** Released version 0.6.15
282 2005-06-02 *** Released version 0.6.15
260
283
261 2005-06-01 Fernando Perez <fperez@colorado.edu>
284 2005-06-01 Fernando Perez <fperez@colorado.edu>
262
285
263 * IPython/iplib.py (MagicCompleter.file_matches): Fix
286 * IPython/iplib.py (MagicCompleter.file_matches): Fix
264 tab-completion of filenames within open-quoted strings. Note that
287 tab-completion of filenames within open-quoted strings. Note that
265 this requires that in ~/.ipython/ipythonrc, users change the
288 this requires that in ~/.ipython/ipythonrc, users change the
266 readline delimiters configuration to read:
289 readline delimiters configuration to read:
267
290
268 readline_remove_delims -/~
291 readline_remove_delims -/~
269
292
270
293
271 2005-05-31 *** Released version 0.6.14
294 2005-05-31 *** Released version 0.6.14
272
295
273 2005-05-29 Fernando Perez <fperez@colorado.edu>
296 2005-05-29 Fernando Perez <fperez@colorado.edu>
274
297
275 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
298 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
276 with files not on the filesystem. Reported by Eliyahu Sandler
299 with files not on the filesystem. Reported by Eliyahu Sandler
277 <eli@gondolin.net>
300 <eli@gondolin.net>
278
301
279 2005-05-22 Fernando Perez <fperez@colorado.edu>
302 2005-05-22 Fernando Perez <fperez@colorado.edu>
280
303
281 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
304 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
282 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
305 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
283
306
284 2005-05-19 Fernando Perez <fperez@colorado.edu>
307 2005-05-19 Fernando Perez <fperez@colorado.edu>
285
308
286 * IPython/iplib.py (safe_execfile): close a file which could be
309 * IPython/iplib.py (safe_execfile): close a file which could be
287 left open (causing problems in win32, which locks open files).
310 left open (causing problems in win32, which locks open files).
288 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
311 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
289
312
290 2005-05-18 Fernando Perez <fperez@colorado.edu>
313 2005-05-18 Fernando Perez <fperez@colorado.edu>
291
314
292 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
315 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
293 keyword arguments correctly to safe_execfile().
316 keyword arguments correctly to safe_execfile().
294
317
295 2005-05-13 Fernando Perez <fperez@colorado.edu>
318 2005-05-13 Fernando Perez <fperez@colorado.edu>
296
319
297 * ipython.1: Added info about Qt to manpage, and threads warning
320 * ipython.1: Added info about Qt to manpage, and threads warning
298 to usage page (invoked with --help).
321 to usage page (invoked with --help).
299
322
300 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
323 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
301 new matcher (it goes at the end of the priority list) to do
324 new matcher (it goes at the end of the priority list) to do
302 tab-completion on named function arguments. Submitted by George
325 tab-completion on named function arguments. Submitted by George
303 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
326 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
304 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
327 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
305 for more details.
328 for more details.
306
329
307 * IPython/Magic.py (magic_run): Added new -e flag to ignore
330 * IPython/Magic.py (magic_run): Added new -e flag to ignore
308 SystemExit exceptions in the script being run. Thanks to a report
331 SystemExit exceptions in the script being run. Thanks to a report
309 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
332 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
310 producing very annoying behavior when running unit tests.
333 producing very annoying behavior when running unit tests.
311
334
312 2005-05-12 Fernando Perez <fperez@colorado.edu>
335 2005-05-12 Fernando Perez <fperez@colorado.edu>
313
336
314 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
337 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
315 which I'd broken (again) due to a changed regexp. In the process,
338 which I'd broken (again) due to a changed regexp. In the process,
316 added ';' as an escape to auto-quote the whole line without
339 added ';' as an escape to auto-quote the whole line without
317 splitting its arguments. Thanks to a report by Jerry McRae
340 splitting its arguments. Thanks to a report by Jerry McRae
318 <qrs0xyc02-AT-sneakemail.com>.
341 <qrs0xyc02-AT-sneakemail.com>.
319
342
320 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
343 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
321 possible crashes caused by a TokenError. Reported by Ed Schofield
344 possible crashes caused by a TokenError. Reported by Ed Schofield
322 <schofield-AT-ftw.at>.
345 <schofield-AT-ftw.at>.
323
346
324 2005-05-06 Fernando Perez <fperez@colorado.edu>
347 2005-05-06 Fernando Perez <fperez@colorado.edu>
325
348
326 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
349 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
327
350
328 2005-04-29 Fernando Perez <fperez@colorado.edu>
351 2005-04-29 Fernando Perez <fperez@colorado.edu>
329
352
330 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
353 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
331 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
354 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
332 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
355 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
333 which provides support for Qt interactive usage (similar to the
356 which provides support for Qt interactive usage (similar to the
334 existing one for WX and GTK). This had been often requested.
357 existing one for WX and GTK). This had been often requested.
335
358
336 2005-04-14 *** Released version 0.6.13
359 2005-04-14 *** Released version 0.6.13
337
360
338 2005-04-08 Fernando Perez <fperez@colorado.edu>
361 2005-04-08 Fernando Perez <fperez@colorado.edu>
339
362
340 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
363 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
341 from _ofind, which gets called on almost every input line. Now,
364 from _ofind, which gets called on almost every input line. Now,
342 we only try to get docstrings if they are actually going to be
365 we only try to get docstrings if they are actually going to be
343 used (the overhead of fetching unnecessary docstrings can be
366 used (the overhead of fetching unnecessary docstrings can be
344 noticeable for certain objects, such as Pyro proxies).
367 noticeable for certain objects, such as Pyro proxies).
345
368
346 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
369 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
347 for completers. For some reason I had been passing them the state
370 for completers. For some reason I had been passing them the state
348 variable, which completers never actually need, and was in
371 variable, which completers never actually need, and was in
349 conflict with the rlcompleter API. Custom completers ONLY need to
372 conflict with the rlcompleter API. Custom completers ONLY need to
350 take the text parameter.
373 take the text parameter.
351
374
352 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
375 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
353 work correctly in pysh. I've also moved all the logic which used
376 work correctly in pysh. I've also moved all the logic which used
354 to be in pysh.py here, which will prevent problems with future
377 to be in pysh.py here, which will prevent problems with future
355 upgrades. However, this time I must warn users to update their
378 upgrades. However, this time I must warn users to update their
356 pysh profile to include the line
379 pysh profile to include the line
357
380
358 import_all IPython.Extensions.InterpreterExec
381 import_all IPython.Extensions.InterpreterExec
359
382
360 because otherwise things won't work for them. They MUST also
383 because otherwise things won't work for them. They MUST also
361 delete pysh.py and the line
384 delete pysh.py and the line
362
385
363 execfile pysh.py
386 execfile pysh.py
364
387
365 from their ipythonrc-pysh.
388 from their ipythonrc-pysh.
366
389
367 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
390 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
368 robust in the face of objects whose dir() returns non-strings
391 robust in the face of objects whose dir() returns non-strings
369 (which it shouldn't, but some broken libs like ITK do). Thanks to
392 (which it shouldn't, but some broken libs like ITK do). Thanks to
370 a patch by John Hunter (implemented differently, though). Also
393 a patch by John Hunter (implemented differently, though). Also
371 minor improvements by using .extend instead of + on lists.
394 minor improvements by using .extend instead of + on lists.
372
395
373 * pysh.py:
396 * pysh.py:
374
397
375 2005-04-06 Fernando Perez <fperez@colorado.edu>
398 2005-04-06 Fernando Perez <fperez@colorado.edu>
376
399
377 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
400 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
378 by default, so that all users benefit from it. Those who don't
401 by default, so that all users benefit from it. Those who don't
379 want it can still turn it off.
402 want it can still turn it off.
380
403
381 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
404 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
382 config file, I'd forgotten about this, so users were getting it
405 config file, I'd forgotten about this, so users were getting it
383 off by default.
406 off by default.
384
407
385 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
408 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
386 consistency. Now magics can be called in multiline statements,
409 consistency. Now magics can be called in multiline statements,
387 and python variables can be expanded in magic calls via $var.
410 and python variables can be expanded in magic calls via $var.
388 This makes the magic system behave just like aliases or !system
411 This makes the magic system behave just like aliases or !system
389 calls.
412 calls.
390
413
391 2005-03-28 Fernando Perez <fperez@colorado.edu>
414 2005-03-28 Fernando Perez <fperez@colorado.edu>
392
415
393 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
416 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
394 expensive string additions for building command. Add support for
417 expensive string additions for building command. Add support for
395 trailing ';' when autocall is used.
418 trailing ';' when autocall is used.
396
419
397 2005-03-26 Fernando Perez <fperez@colorado.edu>
420 2005-03-26 Fernando Perez <fperez@colorado.edu>
398
421
399 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
422 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
400 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
423 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
401 ipython.el robust against prompts with any number of spaces
424 ipython.el robust against prompts with any number of spaces
402 (including 0) after the ':' character.
425 (including 0) after the ':' character.
403
426
404 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
427 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
405 continuation prompt, which misled users to think the line was
428 continuation prompt, which misled users to think the line was
406 already indented. Closes debian Bug#300847, reported to me by
429 already indented. Closes debian Bug#300847, reported to me by
407 Norbert Tretkowski <tretkowski-AT-inittab.de>.
430 Norbert Tretkowski <tretkowski-AT-inittab.de>.
408
431
409 2005-03-23 Fernando Perez <fperez@colorado.edu>
432 2005-03-23 Fernando Perez <fperez@colorado.edu>
410
433
411 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
434 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
412 properly aligned if they have embedded newlines.
435 properly aligned if they have embedded newlines.
413
436
414 * IPython/iplib.py (runlines): Add a public method to expose
437 * IPython/iplib.py (runlines): Add a public method to expose
415 IPython's code execution machinery, so that users can run strings
438 IPython's code execution machinery, so that users can run strings
416 as if they had been typed at the prompt interactively.
439 as if they had been typed at the prompt interactively.
417 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
440 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
418 methods which can call the system shell, but with python variable
441 methods which can call the system shell, but with python variable
419 expansion. The three such methods are: __IPYTHON__.system,
442 expansion. The three such methods are: __IPYTHON__.system,
420 .getoutput and .getoutputerror. These need to be documented in a
443 .getoutput and .getoutputerror. These need to be documented in a
421 'public API' section (to be written) of the manual.
444 'public API' section (to be written) of the manual.
422
445
423 2005-03-20 Fernando Perez <fperez@colorado.edu>
446 2005-03-20 Fernando Perez <fperez@colorado.edu>
424
447
425 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
448 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
426 for custom exception handling. This is quite powerful, and it
449 for custom exception handling. This is quite powerful, and it
427 allows for user-installable exception handlers which can trap
450 allows for user-installable exception handlers which can trap
428 custom exceptions at runtime and treat them separately from
451 custom exceptions at runtime and treat them separately from
429 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
452 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
430 Mantegazza <mantegazza-AT-ill.fr>.
453 Mantegazza <mantegazza-AT-ill.fr>.
431 (InteractiveShell.set_custom_completer): public API function to
454 (InteractiveShell.set_custom_completer): public API function to
432 add new completers at runtime.
455 add new completers at runtime.
433
456
434 2005-03-19 Fernando Perez <fperez@colorado.edu>
457 2005-03-19 Fernando Perez <fperez@colorado.edu>
435
458
436 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
459 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
437 allow objects which provide their docstrings via non-standard
460 allow objects which provide their docstrings via non-standard
438 mechanisms (like Pyro proxies) to still be inspected by ipython's
461 mechanisms (like Pyro proxies) to still be inspected by ipython's
439 ? system.
462 ? system.
440
463
441 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
464 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
442 automatic capture system. I tried quite hard to make it work
465 automatic capture system. I tried quite hard to make it work
443 reliably, and simply failed. I tried many combinations with the
466 reliably, and simply failed. I tried many combinations with the
444 subprocess module, but eventually nothing worked in all needed
467 subprocess module, but eventually nothing worked in all needed
445 cases (not blocking stdin for the child, duplicating stdout
468 cases (not blocking stdin for the child, duplicating stdout
446 without blocking, etc). The new %sc/%sx still do capture to these
469 without blocking, etc). The new %sc/%sx still do capture to these
447 magical list/string objects which make shell use much more
470 magical list/string objects which make shell use much more
448 conveninent, so not all is lost.
471 conveninent, so not all is lost.
449
472
450 XXX - FIX MANUAL for the change above!
473 XXX - FIX MANUAL for the change above!
451
474
452 (runsource): I copied code.py's runsource() into ipython to modify
475 (runsource): I copied code.py's runsource() into ipython to modify
453 it a bit. Now the code object and source to be executed are
476 it a bit. Now the code object and source to be executed are
454 stored in ipython. This makes this info accessible to third-party
477 stored in ipython. This makes this info accessible to third-party
455 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
478 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
456 Mantegazza <mantegazza-AT-ill.fr>.
479 Mantegazza <mantegazza-AT-ill.fr>.
457
480
458 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
481 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
459 history-search via readline (like C-p/C-n). I'd wanted this for a
482 history-search via readline (like C-p/C-n). I'd wanted this for a
460 long time, but only recently found out how to do it. For users
483 long time, but only recently found out how to do it. For users
461 who already have their ipythonrc files made and want this, just
484 who already have their ipythonrc files made and want this, just
462 add:
485 add:
463
486
464 readline_parse_and_bind "\e[A": history-search-backward
487 readline_parse_and_bind "\e[A": history-search-backward
465 readline_parse_and_bind "\e[B": history-search-forward
488 readline_parse_and_bind "\e[B": history-search-forward
466
489
467 2005-03-18 Fernando Perez <fperez@colorado.edu>
490 2005-03-18 Fernando Perez <fperez@colorado.edu>
468
491
469 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
492 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
470 LSString and SList classes which allow transparent conversions
493 LSString and SList classes which allow transparent conversions
471 between list mode and whitespace-separated string.
494 between list mode and whitespace-separated string.
472 (magic_r): Fix recursion problem in %r.
495 (magic_r): Fix recursion problem in %r.
473
496
474 * IPython/genutils.py (LSString): New class to be used for
497 * IPython/genutils.py (LSString): New class to be used for
475 automatic storage of the results of all alias/system calls in _o
498 automatic storage of the results of all alias/system calls in _o
476 and _e (stdout/err). These provide a .l/.list attribute which
499 and _e (stdout/err). These provide a .l/.list attribute which
477 does automatic splitting on newlines. This means that for most
500 does automatic splitting on newlines. This means that for most
478 uses, you'll never need to do capturing of output with %sc/%sx
501 uses, you'll never need to do capturing of output with %sc/%sx
479 anymore, since ipython keeps this always done for you. Note that
502 anymore, since ipython keeps this always done for you. Note that
480 only the LAST results are stored, the _o/e variables are
503 only the LAST results are stored, the _o/e variables are
481 overwritten on each call. If you need to save their contents
504 overwritten on each call. If you need to save their contents
482 further, simply bind them to any other name.
505 further, simply bind them to any other name.
483
506
484 2005-03-17 Fernando Perez <fperez@colorado.edu>
507 2005-03-17 Fernando Perez <fperez@colorado.edu>
485
508
486 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
509 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
487 prompt namespace handling.
510 prompt namespace handling.
488
511
489 2005-03-16 Fernando Perez <fperez@colorado.edu>
512 2005-03-16 Fernando Perez <fperez@colorado.edu>
490
513
491 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
514 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
492 classic prompts to be '>>> ' (final space was missing, and it
515 classic prompts to be '>>> ' (final space was missing, and it
493 trips the emacs python mode).
516 trips the emacs python mode).
494 (BasePrompt.__str__): Added safe support for dynamic prompt
517 (BasePrompt.__str__): Added safe support for dynamic prompt
495 strings. Now you can set your prompt string to be '$x', and the
518 strings. Now you can set your prompt string to be '$x', and the
496 value of x will be printed from your interactive namespace. The
519 value of x will be printed from your interactive namespace. The
497 interpolation syntax includes the full Itpl support, so
520 interpolation syntax includes the full Itpl support, so
498 ${foo()+x+bar()} is a valid prompt string now, and the function
521 ${foo()+x+bar()} is a valid prompt string now, and the function
499 calls will be made at runtime.
522 calls will be made at runtime.
500
523
501 2005-03-15 Fernando Perez <fperez@colorado.edu>
524 2005-03-15 Fernando Perez <fperez@colorado.edu>
502
525
503 * IPython/Magic.py (magic_history): renamed %hist to %history, to
526 * IPython/Magic.py (magic_history): renamed %hist to %history, to
504 avoid name clashes in pylab. %hist still works, it just forwards
527 avoid name clashes in pylab. %hist still works, it just forwards
505 the call to %history.
528 the call to %history.
506
529
507 2005-03-02 *** Released version 0.6.12
530 2005-03-02 *** Released version 0.6.12
508
531
509 2005-03-02 Fernando Perez <fperez@colorado.edu>
532 2005-03-02 Fernando Perez <fperez@colorado.edu>
510
533
511 * IPython/iplib.py (handle_magic): log magic calls properly as
534 * IPython/iplib.py (handle_magic): log magic calls properly as
512 ipmagic() function calls.
535 ipmagic() function calls.
513
536
514 * IPython/Magic.py (magic_time): Improved %time to support
537 * IPython/Magic.py (magic_time): Improved %time to support
515 statements and provide wall-clock as well as CPU time.
538 statements and provide wall-clock as well as CPU time.
516
539
517 2005-02-27 Fernando Perez <fperez@colorado.edu>
540 2005-02-27 Fernando Perez <fperez@colorado.edu>
518
541
519 * IPython/hooks.py: New hooks module, to expose user-modifiable
542 * IPython/hooks.py: New hooks module, to expose user-modifiable
520 IPython functionality in a clean manner. For now only the editor
543 IPython functionality in a clean manner. For now only the editor
521 hook is actually written, and other thigns which I intend to turn
544 hook is actually written, and other thigns which I intend to turn
522 into proper hooks aren't yet there. The display and prefilter
545 into proper hooks aren't yet there. The display and prefilter
523 stuff, for example, should be hooks. But at least now the
546 stuff, for example, should be hooks. But at least now the
524 framework is in place, and the rest can be moved here with more
547 framework is in place, and the rest can be moved here with more
525 time later. IPython had had a .hooks variable for a long time for
548 time later. IPython had had a .hooks variable for a long time for
526 this purpose, but I'd never actually used it for anything.
549 this purpose, but I'd never actually used it for anything.
527
550
528 2005-02-26 Fernando Perez <fperez@colorado.edu>
551 2005-02-26 Fernando Perez <fperez@colorado.edu>
529
552
530 * IPython/ipmaker.py (make_IPython): make the default ipython
553 * IPython/ipmaker.py (make_IPython): make the default ipython
531 directory be called _ipython under win32, to follow more the
554 directory be called _ipython under win32, to follow more the
532 naming peculiarities of that platform (where buggy software like
555 naming peculiarities of that platform (where buggy software like
533 Visual Sourcesafe breaks with .named directories). Reported by
556 Visual Sourcesafe breaks with .named directories). Reported by
534 Ville Vainio.
557 Ville Vainio.
535
558
536 2005-02-23 Fernando Perez <fperez@colorado.edu>
559 2005-02-23 Fernando Perez <fperez@colorado.edu>
537
560
538 * IPython/iplib.py (InteractiveShell.__init__): removed a few
561 * IPython/iplib.py (InteractiveShell.__init__): removed a few
539 auto_aliases for win32 which were causing problems. Users can
562 auto_aliases for win32 which were causing problems. Users can
540 define the ones they personally like.
563 define the ones they personally like.
541
564
542 2005-02-21 Fernando Perez <fperez@colorado.edu>
565 2005-02-21 Fernando Perez <fperez@colorado.edu>
543
566
544 * IPython/Magic.py (magic_time): new magic to time execution of
567 * IPython/Magic.py (magic_time): new magic to time execution of
545 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
568 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
546
569
547 2005-02-19 Fernando Perez <fperez@colorado.edu>
570 2005-02-19 Fernando Perez <fperez@colorado.edu>
548
571
549 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
572 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
550 into keys (for prompts, for example).
573 into keys (for prompts, for example).
551
574
552 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
575 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
553 prompts in case users want them. This introduces a small behavior
576 prompts in case users want them. This introduces a small behavior
554 change: ipython does not automatically add a space to all prompts
577 change: ipython does not automatically add a space to all prompts
555 anymore. To get the old prompts with a space, users should add it
578 anymore. To get the old prompts with a space, users should add it
556 manually to their ipythonrc file, so for example prompt_in1 should
579 manually to their ipythonrc file, so for example prompt_in1 should
557 now read 'In [\#]: ' instead of 'In [\#]:'.
580 now read 'In [\#]: ' instead of 'In [\#]:'.
558 (BasePrompt.__init__): New option prompts_pad_left (only in rc
581 (BasePrompt.__init__): New option prompts_pad_left (only in rc
559 file) to control left-padding of secondary prompts.
582 file) to control left-padding of secondary prompts.
560
583
561 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
584 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
562 the profiler can't be imported. Fix for Debian, which removed
585 the profiler can't be imported. Fix for Debian, which removed
563 profile.py because of License issues. I applied a slightly
586 profile.py because of License issues. I applied a slightly
564 modified version of the original Debian patch at
587 modified version of the original Debian patch at
565 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
588 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
566
589
567 2005-02-17 Fernando Perez <fperez@colorado.edu>
590 2005-02-17 Fernando Perez <fperez@colorado.edu>
568
591
569 * IPython/genutils.py (native_line_ends): Fix bug which would
592 * IPython/genutils.py (native_line_ends): Fix bug which would
570 cause improper line-ends under win32 b/c I was not opening files
593 cause improper line-ends under win32 b/c I was not opening files
571 in binary mode. Bug report and fix thanks to Ville.
594 in binary mode. Bug report and fix thanks to Ville.
572
595
573 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
596 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
574 trying to catch spurious foo[1] autocalls. My fix actually broke
597 trying to catch spurious foo[1] autocalls. My fix actually broke
575 ',/' autoquote/call with explicit escape (bad regexp).
598 ',/' autoquote/call with explicit escape (bad regexp).
576
599
577 2005-02-15 *** Released version 0.6.11
600 2005-02-15 *** Released version 0.6.11
578
601
579 2005-02-14 Fernando Perez <fperez@colorado.edu>
602 2005-02-14 Fernando Perez <fperez@colorado.edu>
580
603
581 * IPython/background_jobs.py: New background job management
604 * IPython/background_jobs.py: New background job management
582 subsystem. This is implemented via a new set of classes, and
605 subsystem. This is implemented via a new set of classes, and
583 IPython now provides a builtin 'jobs' object for background job
606 IPython now provides a builtin 'jobs' object for background job
584 execution. A convenience %bg magic serves as a lightweight
607 execution. A convenience %bg magic serves as a lightweight
585 frontend for starting the more common type of calls. This was
608 frontend for starting the more common type of calls. This was
586 inspired by discussions with B. Granger and the BackgroundCommand
609 inspired by discussions with B. Granger and the BackgroundCommand
587 class described in the book Python Scripting for Computational
610 class described in the book Python Scripting for Computational
588 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
611 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
589 (although ultimately no code from this text was used, as IPython's
612 (although ultimately no code from this text was used, as IPython's
590 system is a separate implementation).
613 system is a separate implementation).
591
614
592 * IPython/iplib.py (MagicCompleter.python_matches): add new option
615 * IPython/iplib.py (MagicCompleter.python_matches): add new option
593 to control the completion of single/double underscore names
616 to control the completion of single/double underscore names
594 separately. As documented in the example ipytonrc file, the
617 separately. As documented in the example ipytonrc file, the
595 readline_omit__names variable can now be set to 2, to omit even
618 readline_omit__names variable can now be set to 2, to omit even
596 single underscore names. Thanks to a patch by Brian Wong
619 single underscore names. Thanks to a patch by Brian Wong
597 <BrianWong-AT-AirgoNetworks.Com>.
620 <BrianWong-AT-AirgoNetworks.Com>.
598 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
621 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
599 be autocalled as foo([1]) if foo were callable. A problem for
622 be autocalled as foo([1]) if foo were callable. A problem for
600 things which are both callable and implement __getitem__.
623 things which are both callable and implement __getitem__.
601 (init_readline): Fix autoindentation for win32. Thanks to a patch
624 (init_readline): Fix autoindentation for win32. Thanks to a patch
602 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
625 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
603
626
604 2005-02-12 Fernando Perez <fperez@colorado.edu>
627 2005-02-12 Fernando Perez <fperez@colorado.edu>
605
628
606 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
629 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
607 which I had written long ago to sort out user error messages which
630 which I had written long ago to sort out user error messages which
608 may occur during startup. This seemed like a good idea initially,
631 may occur during startup. This seemed like a good idea initially,
609 but it has proven a disaster in retrospect. I don't want to
632 but it has proven a disaster in retrospect. I don't want to
610 change much code for now, so my fix is to set the internal 'debug'
633 change much code for now, so my fix is to set the internal 'debug'
611 flag to true everywhere, whose only job was precisely to control
634 flag to true everywhere, whose only job was precisely to control
612 this subsystem. This closes issue 28 (as well as avoiding all
635 this subsystem. This closes issue 28 (as well as avoiding all
613 sorts of strange hangups which occur from time to time).
636 sorts of strange hangups which occur from time to time).
614
637
615 2005-02-07 Fernando Perez <fperez@colorado.edu>
638 2005-02-07 Fernando Perez <fperez@colorado.edu>
616
639
617 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
640 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
618 previous call produced a syntax error.
641 previous call produced a syntax error.
619
642
620 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
643 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
621 classes without constructor.
644 classes without constructor.
622
645
623 2005-02-06 Fernando Perez <fperez@colorado.edu>
646 2005-02-06 Fernando Perez <fperez@colorado.edu>
624
647
625 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
648 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
626 completions with the results of each matcher, so we return results
649 completions with the results of each matcher, so we return results
627 to the user from all namespaces. This breaks with ipython
650 to the user from all namespaces. This breaks with ipython
628 tradition, but I think it's a nicer behavior. Now you get all
651 tradition, but I think it's a nicer behavior. Now you get all
629 possible completions listed, from all possible namespaces (python,
652 possible completions listed, from all possible namespaces (python,
630 filesystem, magics...) After a request by John Hunter
653 filesystem, magics...) After a request by John Hunter
631 <jdhunter-AT-nitace.bsd.uchicago.edu>.
654 <jdhunter-AT-nitace.bsd.uchicago.edu>.
632
655
633 2005-02-05 Fernando Perez <fperez@colorado.edu>
656 2005-02-05 Fernando Perez <fperez@colorado.edu>
634
657
635 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
658 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
636 the call had quote characters in it (the quotes were stripped).
659 the call had quote characters in it (the quotes were stripped).
637
660
638 2005-01-31 Fernando Perez <fperez@colorado.edu>
661 2005-01-31 Fernando Perez <fperez@colorado.edu>
639
662
640 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
663 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
641 Itpl.itpl() to make the code more robust against psyco
664 Itpl.itpl() to make the code more robust against psyco
642 optimizations.
665 optimizations.
643
666
644 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
667 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
645 of causing an exception. Quicker, cleaner.
668 of causing an exception. Quicker, cleaner.
646
669
647 2005-01-28 Fernando Perez <fperez@colorado.edu>
670 2005-01-28 Fernando Perez <fperez@colorado.edu>
648
671
649 * scripts/ipython_win_post_install.py (install): hardcode
672 * scripts/ipython_win_post_install.py (install): hardcode
650 sys.prefix+'python.exe' as the executable path. It turns out that
673 sys.prefix+'python.exe' as the executable path. It turns out that
651 during the post-installation run, sys.executable resolves to the
674 during the post-installation run, sys.executable resolves to the
652 name of the binary installer! I should report this as a distutils
675 name of the binary installer! I should report this as a distutils
653 bug, I think. I updated the .10 release with this tiny fix, to
676 bug, I think. I updated the .10 release with this tiny fix, to
654 avoid annoying the lists further.
677 avoid annoying the lists further.
655
678
656 2005-01-27 *** Released version 0.6.10
679 2005-01-27 *** Released version 0.6.10
657
680
658 2005-01-27 Fernando Perez <fperez@colorado.edu>
681 2005-01-27 Fernando Perez <fperez@colorado.edu>
659
682
660 * IPython/numutils.py (norm): Added 'inf' as optional name for
683 * IPython/numutils.py (norm): Added 'inf' as optional name for
661 L-infinity norm, included references to mathworld.com for vector
684 L-infinity norm, included references to mathworld.com for vector
662 norm definitions.
685 norm definitions.
663 (amin/amax): added amin/amax for array min/max. Similar to what
686 (amin/amax): added amin/amax for array min/max. Similar to what
664 pylab ships with after the recent reorganization of names.
687 pylab ships with after the recent reorganization of names.
665 (spike/spike_odd): removed deprecated spike/spike_odd functions.
688 (spike/spike_odd): removed deprecated spike/spike_odd functions.
666
689
667 * ipython.el: committed Alex's recent fixes and improvements.
690 * ipython.el: committed Alex's recent fixes and improvements.
668 Tested with python-mode from CVS, and it looks excellent. Since
691 Tested with python-mode from CVS, and it looks excellent. Since
669 python-mode hasn't released anything in a while, I'm temporarily
692 python-mode hasn't released anything in a while, I'm temporarily
670 putting a copy of today's CVS (v 4.70) of python-mode in:
693 putting a copy of today's CVS (v 4.70) of python-mode in:
671 http://ipython.scipy.org/tmp/python-mode.el
694 http://ipython.scipy.org/tmp/python-mode.el
672
695
673 * scripts/ipython_win_post_install.py (install): Win32 fix to use
696 * scripts/ipython_win_post_install.py (install): Win32 fix to use
674 sys.executable for the executable name, instead of assuming it's
697 sys.executable for the executable name, instead of assuming it's
675 called 'python.exe' (the post-installer would have produced broken
698 called 'python.exe' (the post-installer would have produced broken
676 setups on systems with a differently named python binary).
699 setups on systems with a differently named python binary).
677
700
678 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
701 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
679 references to os.linesep, to make the code more
702 references to os.linesep, to make the code more
680 platform-independent. This is also part of the win32 coloring
703 platform-independent. This is also part of the win32 coloring
681 fixes.
704 fixes.
682
705
683 * IPython/genutils.py (page_dumb): Remove attempts to chop long
706 * IPython/genutils.py (page_dumb): Remove attempts to chop long
684 lines, which actually cause coloring bugs because the length of
707 lines, which actually cause coloring bugs because the length of
685 the line is very difficult to correctly compute with embedded
708 the line is very difficult to correctly compute with embedded
686 escapes. This was the source of all the coloring problems under
709 escapes. This was the source of all the coloring problems under
687 Win32. I think that _finally_, Win32 users have a properly
710 Win32. I think that _finally_, Win32 users have a properly
688 working ipython in all respects. This would never have happened
711 working ipython in all respects. This would never have happened
689 if not for Gary Bishop and Viktor Ransmayr's great help and work.
712 if not for Gary Bishop and Viktor Ransmayr's great help and work.
690
713
691 2005-01-26 *** Released version 0.6.9
714 2005-01-26 *** Released version 0.6.9
692
715
693 2005-01-25 Fernando Perez <fperez@colorado.edu>
716 2005-01-25 Fernando Perez <fperez@colorado.edu>
694
717
695 * setup.py: finally, we have a true Windows installer, thanks to
718 * setup.py: finally, we have a true Windows installer, thanks to
696 the excellent work of Viktor Ransmayr
719 the excellent work of Viktor Ransmayr
697 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
720 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
698 Windows users. The setup routine is quite a bit cleaner thanks to
721 Windows users. The setup routine is quite a bit cleaner thanks to
699 this, and the post-install script uses the proper functions to
722 this, and the post-install script uses the proper functions to
700 allow a clean de-installation using the standard Windows Control
723 allow a clean de-installation using the standard Windows Control
701 Panel.
724 Panel.
702
725
703 * IPython/genutils.py (get_home_dir): changed to use the $HOME
726 * IPython/genutils.py (get_home_dir): changed to use the $HOME
704 environment variable under all OSes (including win32) if
727 environment variable under all OSes (including win32) if
705 available. This will give consistency to win32 users who have set
728 available. This will give consistency to win32 users who have set
706 this variable for any reason. If os.environ['HOME'] fails, the
729 this variable for any reason. If os.environ['HOME'] fails, the
707 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
730 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
708
731
709 2005-01-24 Fernando Perez <fperez@colorado.edu>
732 2005-01-24 Fernando Perez <fperez@colorado.edu>
710
733
711 * IPython/numutils.py (empty_like): add empty_like(), similar to
734 * IPython/numutils.py (empty_like): add empty_like(), similar to
712 zeros_like() but taking advantage of the new empty() Numeric routine.
735 zeros_like() but taking advantage of the new empty() Numeric routine.
713
736
714 2005-01-23 *** Released version 0.6.8
737 2005-01-23 *** Released version 0.6.8
715
738
716 2005-01-22 Fernando Perez <fperez@colorado.edu>
739 2005-01-22 Fernando Perez <fperez@colorado.edu>
717
740
718 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
741 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
719 automatic show() calls. After discussing things with JDH, it
742 automatic show() calls. After discussing things with JDH, it
720 turns out there are too many corner cases where this can go wrong.
743 turns out there are too many corner cases where this can go wrong.
721 It's best not to try to be 'too smart', and simply have ipython
744 It's best not to try to be 'too smart', and simply have ipython
722 reproduce as much as possible the default behavior of a normal
745 reproduce as much as possible the default behavior of a normal
723 python shell.
746 python shell.
724
747
725 * IPython/iplib.py (InteractiveShell.__init__): Modified the
748 * IPython/iplib.py (InteractiveShell.__init__): Modified the
726 line-splitting regexp and _prefilter() to avoid calling getattr()
749 line-splitting regexp and _prefilter() to avoid calling getattr()
727 on assignments. This closes
750 on assignments. This closes
728 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
751 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
729 readline uses getattr(), so a simple <TAB> keypress is still
752 readline uses getattr(), so a simple <TAB> keypress is still
730 enough to trigger getattr() calls on an object.
753 enough to trigger getattr() calls on an object.
731
754
732 2005-01-21 Fernando Perez <fperez@colorado.edu>
755 2005-01-21 Fernando Perez <fperez@colorado.edu>
733
756
734 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
757 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
735 docstring under pylab so it doesn't mask the original.
758 docstring under pylab so it doesn't mask the original.
736
759
737 2005-01-21 *** Released version 0.6.7
760 2005-01-21 *** Released version 0.6.7
738
761
739 2005-01-21 Fernando Perez <fperez@colorado.edu>
762 2005-01-21 Fernando Perez <fperez@colorado.edu>
740
763
741 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
764 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
742 signal handling for win32 users in multithreaded mode.
765 signal handling for win32 users in multithreaded mode.
743
766
744 2005-01-17 Fernando Perez <fperez@colorado.edu>
767 2005-01-17 Fernando Perez <fperez@colorado.edu>
745
768
746 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
769 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
747 instances with no __init__. After a crash report by Norbert Nemec
770 instances with no __init__. After a crash report by Norbert Nemec
748 <Norbert-AT-nemec-online.de>.
771 <Norbert-AT-nemec-online.de>.
749
772
750 2005-01-14 Fernando Perez <fperez@colorado.edu>
773 2005-01-14 Fernando Perez <fperez@colorado.edu>
751
774
752 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
775 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
753 names for verbose exceptions, when multiple dotted names and the
776 names for verbose exceptions, when multiple dotted names and the
754 'parent' object were present on the same line.
777 'parent' object were present on the same line.
755
778
756 2005-01-11 Fernando Perez <fperez@colorado.edu>
779 2005-01-11 Fernando Perez <fperez@colorado.edu>
757
780
758 * IPython/genutils.py (flag_calls): new utility to trap and flag
781 * IPython/genutils.py (flag_calls): new utility to trap and flag
759 calls in functions. I need it to clean up matplotlib support.
782 calls in functions. I need it to clean up matplotlib support.
760 Also removed some deprecated code in genutils.
783 Also removed some deprecated code in genutils.
761
784
762 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
785 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
763 that matplotlib scripts called with %run, which don't call show()
786 that matplotlib scripts called with %run, which don't call show()
764 themselves, still have their plotting windows open.
787 themselves, still have their plotting windows open.
765
788
766 2005-01-05 Fernando Perez <fperez@colorado.edu>
789 2005-01-05 Fernando Perez <fperez@colorado.edu>
767
790
768 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
791 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
769 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
792 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
770
793
771 2004-12-19 Fernando Perez <fperez@colorado.edu>
794 2004-12-19 Fernando Perez <fperez@colorado.edu>
772
795
773 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
796 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
774 parent_runcode, which was an eyesore. The same result can be
797 parent_runcode, which was an eyesore. The same result can be
775 obtained with Python's regular superclass mechanisms.
798 obtained with Python's regular superclass mechanisms.
776
799
777 2004-12-17 Fernando Perez <fperez@colorado.edu>
800 2004-12-17 Fernando Perez <fperez@colorado.edu>
778
801
779 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
802 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
780 reported by Prabhu.
803 reported by Prabhu.
781 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
804 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
782 sys.stderr) instead of explicitly calling sys.stderr. This helps
805 sys.stderr) instead of explicitly calling sys.stderr. This helps
783 maintain our I/O abstractions clean, for future GUI embeddings.
806 maintain our I/O abstractions clean, for future GUI embeddings.
784
807
785 * IPython/genutils.py (info): added new utility for sys.stderr
808 * IPython/genutils.py (info): added new utility for sys.stderr
786 unified info message handling (thin wrapper around warn()).
809 unified info message handling (thin wrapper around warn()).
787
810
788 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
811 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
789 composite (dotted) names on verbose exceptions.
812 composite (dotted) names on verbose exceptions.
790 (VerboseTB.nullrepr): harden against another kind of errors which
813 (VerboseTB.nullrepr): harden against another kind of errors which
791 Python's inspect module can trigger, and which were crashing
814 Python's inspect module can trigger, and which were crashing
792 IPython. Thanks to a report by Marco Lombardi
815 IPython. Thanks to a report by Marco Lombardi
793 <mlombard-AT-ma010192.hq.eso.org>.
816 <mlombard-AT-ma010192.hq.eso.org>.
794
817
795 2004-12-13 *** Released version 0.6.6
818 2004-12-13 *** Released version 0.6.6
796
819
797 2004-12-12 Fernando Perez <fperez@colorado.edu>
820 2004-12-12 Fernando Perez <fperez@colorado.edu>
798
821
799 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
822 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
800 generated by pygtk upon initialization if it was built without
823 generated by pygtk upon initialization if it was built without
801 threads (for matplotlib users). After a crash reported by
824 threads (for matplotlib users). After a crash reported by
802 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
825 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
803
826
804 * IPython/ipmaker.py (make_IPython): fix small bug in the
827 * IPython/ipmaker.py (make_IPython): fix small bug in the
805 import_some parameter for multiple imports.
828 import_some parameter for multiple imports.
806
829
807 * IPython/iplib.py (ipmagic): simplified the interface of
830 * IPython/iplib.py (ipmagic): simplified the interface of
808 ipmagic() to take a single string argument, just as it would be
831 ipmagic() to take a single string argument, just as it would be
809 typed at the IPython cmd line.
832 typed at the IPython cmd line.
810 (ipalias): Added new ipalias() with an interface identical to
833 (ipalias): Added new ipalias() with an interface identical to
811 ipmagic(). This completes exposing a pure python interface to the
834 ipmagic(). This completes exposing a pure python interface to the
812 alias and magic system, which can be used in loops or more complex
835 alias and magic system, which can be used in loops or more complex
813 code where IPython's automatic line mangling is not active.
836 code where IPython's automatic line mangling is not active.
814
837
815 * IPython/genutils.py (timing): changed interface of timing to
838 * IPython/genutils.py (timing): changed interface of timing to
816 simply run code once, which is the most common case. timings()
839 simply run code once, which is the most common case. timings()
817 remains unchanged, for the cases where you want multiple runs.
840 remains unchanged, for the cases where you want multiple runs.
818
841
819 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
842 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
820 bug where Python2.2 crashes with exec'ing code which does not end
843 bug where Python2.2 crashes with exec'ing code which does not end
821 in a single newline. Python 2.3 is OK, so I hadn't noticed this
844 in a single newline. Python 2.3 is OK, so I hadn't noticed this
822 before.
845 before.
823
846
824 2004-12-10 Fernando Perez <fperez@colorado.edu>
847 2004-12-10 Fernando Perez <fperez@colorado.edu>
825
848
826 * IPython/Magic.py (Magic.magic_prun): changed name of option from
849 * IPython/Magic.py (Magic.magic_prun): changed name of option from
827 -t to -T, to accomodate the new -t flag in %run (the %run and
850 -t to -T, to accomodate the new -t flag in %run (the %run and
828 %prun options are kind of intermixed, and it's not easy to change
851 %prun options are kind of intermixed, and it's not easy to change
829 this with the limitations of python's getopt).
852 this with the limitations of python's getopt).
830
853
831 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
854 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
832 the execution of scripts. It's not as fine-tuned as timeit.py,
855 the execution of scripts. It's not as fine-tuned as timeit.py,
833 but it works from inside ipython (and under 2.2, which lacks
856 but it works from inside ipython (and under 2.2, which lacks
834 timeit.py). Optionally a number of runs > 1 can be given for
857 timeit.py). Optionally a number of runs > 1 can be given for
835 timing very short-running code.
858 timing very short-running code.
836
859
837 * IPython/genutils.py (uniq_stable): new routine which returns a
860 * IPython/genutils.py (uniq_stable): new routine which returns a
838 list of unique elements in any iterable, but in stable order of
861 list of unique elements in any iterable, but in stable order of
839 appearance. I needed this for the ultraTB fixes, and it's a handy
862 appearance. I needed this for the ultraTB fixes, and it's a handy
840 utility.
863 utility.
841
864
842 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
865 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
843 dotted names in Verbose exceptions. This had been broken since
866 dotted names in Verbose exceptions. This had been broken since
844 the very start, now x.y will properly be printed in a Verbose
867 the very start, now x.y will properly be printed in a Verbose
845 traceback, instead of x being shown and y appearing always as an
868 traceback, instead of x being shown and y appearing always as an
846 'undefined global'. Getting this to work was a bit tricky,
869 'undefined global'. Getting this to work was a bit tricky,
847 because by default python tokenizers are stateless. Saved by
870 because by default python tokenizers are stateless. Saved by
848 python's ability to easily add a bit of state to an arbitrary
871 python's ability to easily add a bit of state to an arbitrary
849 function (without needing to build a full-blown callable object).
872 function (without needing to build a full-blown callable object).
850
873
851 Also big cleanup of this code, which had horrendous runtime
874 Also big cleanup of this code, which had horrendous runtime
852 lookups of zillions of attributes for colorization. Moved all
875 lookups of zillions of attributes for colorization. Moved all
853 this code into a few templates, which make it cleaner and quicker.
876 this code into a few templates, which make it cleaner and quicker.
854
877
855 Printout quality was also improved for Verbose exceptions: one
878 Printout quality was also improved for Verbose exceptions: one
856 variable per line, and memory addresses are printed (this can be
879 variable per line, and memory addresses are printed (this can be
857 quite handy in nasty debugging situations, which is what Verbose
880 quite handy in nasty debugging situations, which is what Verbose
858 is for).
881 is for).
859
882
860 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
883 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
861 the command line as scripts to be loaded by embedded instances.
884 the command line as scripts to be loaded by embedded instances.
862 Doing so has the potential for an infinite recursion if there are
885 Doing so has the potential for an infinite recursion if there are
863 exceptions thrown in the process. This fixes a strange crash
886 exceptions thrown in the process. This fixes a strange crash
864 reported by Philippe MULLER <muller-AT-irit.fr>.
887 reported by Philippe MULLER <muller-AT-irit.fr>.
865
888
866 2004-12-09 Fernando Perez <fperez@colorado.edu>
889 2004-12-09 Fernando Perez <fperez@colorado.edu>
867
890
868 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
891 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
869 to reflect new names in matplotlib, which now expose the
892 to reflect new names in matplotlib, which now expose the
870 matlab-compatible interface via a pylab module instead of the
893 matlab-compatible interface via a pylab module instead of the
871 'matlab' name. The new code is backwards compatible, so users of
894 'matlab' name. The new code is backwards compatible, so users of
872 all matplotlib versions are OK. Patch by J. Hunter.
895 all matplotlib versions are OK. Patch by J. Hunter.
873
896
874 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
897 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
875 of __init__ docstrings for instances (class docstrings are already
898 of __init__ docstrings for instances (class docstrings are already
876 automatically printed). Instances with customized docstrings
899 automatically printed). Instances with customized docstrings
877 (indep. of the class) are also recognized and all 3 separate
900 (indep. of the class) are also recognized and all 3 separate
878 docstrings are printed (instance, class, constructor). After some
901 docstrings are printed (instance, class, constructor). After some
879 comments/suggestions by J. Hunter.
902 comments/suggestions by J. Hunter.
880
903
881 2004-12-05 Fernando Perez <fperez@colorado.edu>
904 2004-12-05 Fernando Perez <fperez@colorado.edu>
882
905
883 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
906 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
884 warnings when tab-completion fails and triggers an exception.
907 warnings when tab-completion fails and triggers an exception.
885
908
886 2004-12-03 Fernando Perez <fperez@colorado.edu>
909 2004-12-03 Fernando Perez <fperez@colorado.edu>
887
910
888 * IPython/Magic.py (magic_prun): Fix bug where an exception would
911 * IPython/Magic.py (magic_prun): Fix bug where an exception would
889 be triggered when using 'run -p'. An incorrect option flag was
912 be triggered when using 'run -p'. An incorrect option flag was
890 being set ('d' instead of 'D').
913 being set ('d' instead of 'D').
891 (manpage): fix missing escaped \- sign.
914 (manpage): fix missing escaped \- sign.
892
915
893 2004-11-30 *** Released version 0.6.5
916 2004-11-30 *** Released version 0.6.5
894
917
895 2004-11-30 Fernando Perez <fperez@colorado.edu>
918 2004-11-30 Fernando Perez <fperez@colorado.edu>
896
919
897 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
920 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
898 setting with -d option.
921 setting with -d option.
899
922
900 * setup.py (docfiles): Fix problem where the doc glob I was using
923 * setup.py (docfiles): Fix problem where the doc glob I was using
901 was COMPLETELY BROKEN. It was giving the right files by pure
924 was COMPLETELY BROKEN. It was giving the right files by pure
902 accident, but failed once I tried to include ipython.el. Note:
925 accident, but failed once I tried to include ipython.el. Note:
903 glob() does NOT allow you to do exclusion on multiple endings!
926 glob() does NOT allow you to do exclusion on multiple endings!
904
927
905 2004-11-29 Fernando Perez <fperez@colorado.edu>
928 2004-11-29 Fernando Perez <fperez@colorado.edu>
906
929
907 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
930 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
908 the manpage as the source. Better formatting & consistency.
931 the manpage as the source. Better formatting & consistency.
909
932
910 * IPython/Magic.py (magic_run): Added new -d option, to run
933 * IPython/Magic.py (magic_run): Added new -d option, to run
911 scripts under the control of the python pdb debugger. Note that
934 scripts under the control of the python pdb debugger. Note that
912 this required changing the %prun option -d to -D, to avoid a clash
935 this required changing the %prun option -d to -D, to avoid a clash
913 (since %run must pass options to %prun, and getopt is too dumb to
936 (since %run must pass options to %prun, and getopt is too dumb to
914 handle options with string values with embedded spaces). Thanks
937 handle options with string values with embedded spaces). Thanks
915 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
938 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
916 (magic_who_ls): added type matching to %who and %whos, so that one
939 (magic_who_ls): added type matching to %who and %whos, so that one
917 can filter their output to only include variables of certain
940 can filter their output to only include variables of certain
918 types. Another suggestion by Matthew.
941 types. Another suggestion by Matthew.
919 (magic_whos): Added memory summaries in kb and Mb for arrays.
942 (magic_whos): Added memory summaries in kb and Mb for arrays.
920 (magic_who): Improve formatting (break lines every 9 vars).
943 (magic_who): Improve formatting (break lines every 9 vars).
921
944
922 2004-11-28 Fernando Perez <fperez@colorado.edu>
945 2004-11-28 Fernando Perez <fperez@colorado.edu>
923
946
924 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
947 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
925 cache when empty lines were present.
948 cache when empty lines were present.
926
949
927 2004-11-24 Fernando Perez <fperez@colorado.edu>
950 2004-11-24 Fernando Perez <fperez@colorado.edu>
928
951
929 * IPython/usage.py (__doc__): document the re-activated threading
952 * IPython/usage.py (__doc__): document the re-activated threading
930 options for WX and GTK.
953 options for WX and GTK.
931
954
932 2004-11-23 Fernando Perez <fperez@colorado.edu>
955 2004-11-23 Fernando Perez <fperez@colorado.edu>
933
956
934 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
957 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
935 the -wthread and -gthread options, along with a new -tk one to try
958 the -wthread and -gthread options, along with a new -tk one to try
936 and coordinate Tk threading with wx/gtk. The tk support is very
959 and coordinate Tk threading with wx/gtk. The tk support is very
937 platform dependent, since it seems to require Tcl and Tk to be
960 platform dependent, since it seems to require Tcl and Tk to be
938 built with threads (Fedora1/2 appears NOT to have it, but in
961 built with threads (Fedora1/2 appears NOT to have it, but in
939 Prabhu's Debian boxes it works OK). But even with some Tk
962 Prabhu's Debian boxes it works OK). But even with some Tk
940 limitations, this is a great improvement.
963 limitations, this is a great improvement.
941
964
942 * IPython/Prompts.py (prompt_specials_color): Added \t for time
965 * IPython/Prompts.py (prompt_specials_color): Added \t for time
943 info in user prompts. Patch by Prabhu.
966 info in user prompts. Patch by Prabhu.
944
967
945 2004-11-18 Fernando Perez <fperez@colorado.edu>
968 2004-11-18 Fernando Perez <fperez@colorado.edu>
946
969
947 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
970 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
948 EOFErrors and bail, to avoid infinite loops if a non-terminating
971 EOFErrors and bail, to avoid infinite loops if a non-terminating
949 file is fed into ipython. Patch submitted in issue 19 by user,
972 file is fed into ipython. Patch submitted in issue 19 by user,
950 many thanks.
973 many thanks.
951
974
952 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
975 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
953 autoquote/parens in continuation prompts, which can cause lots of
976 autoquote/parens in continuation prompts, which can cause lots of
954 problems. Closes roundup issue 20.
977 problems. Closes roundup issue 20.
955
978
956 2004-11-17 Fernando Perez <fperez@colorado.edu>
979 2004-11-17 Fernando Perez <fperez@colorado.edu>
957
980
958 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
981 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
959 reported as debian bug #280505. I'm not sure my local changelog
982 reported as debian bug #280505. I'm not sure my local changelog
960 entry has the proper debian format (Jack?).
983 entry has the proper debian format (Jack?).
961
984
962 2004-11-08 *** Released version 0.6.4
985 2004-11-08 *** Released version 0.6.4
963
986
964 2004-11-08 Fernando Perez <fperez@colorado.edu>
987 2004-11-08 Fernando Perez <fperez@colorado.edu>
965
988
966 * IPython/iplib.py (init_readline): Fix exit message for Windows
989 * IPython/iplib.py (init_readline): Fix exit message for Windows
967 when readline is active. Thanks to a report by Eric Jones
990 when readline is active. Thanks to a report by Eric Jones
968 <eric-AT-enthought.com>.
991 <eric-AT-enthought.com>.
969
992
970 2004-11-07 Fernando Perez <fperez@colorado.edu>
993 2004-11-07 Fernando Perez <fperez@colorado.edu>
971
994
972 * IPython/genutils.py (page): Add a trap for OSError exceptions,
995 * IPython/genutils.py (page): Add a trap for OSError exceptions,
973 sometimes seen by win2k/cygwin users.
996 sometimes seen by win2k/cygwin users.
974
997
975 2004-11-06 Fernando Perez <fperez@colorado.edu>
998 2004-11-06 Fernando Perez <fperez@colorado.edu>
976
999
977 * IPython/iplib.py (interact): Change the handling of %Exit from
1000 * IPython/iplib.py (interact): Change the handling of %Exit from
978 trying to propagate a SystemExit to an internal ipython flag.
1001 trying to propagate a SystemExit to an internal ipython flag.
979 This is less elegant than using Python's exception mechanism, but
1002 This is less elegant than using Python's exception mechanism, but
980 I can't get that to work reliably with threads, so under -pylab
1003 I can't get that to work reliably with threads, so under -pylab
981 %Exit was hanging IPython. Cross-thread exception handling is
1004 %Exit was hanging IPython. Cross-thread exception handling is
982 really a bitch. Thaks to a bug report by Stephen Walton
1005 really a bitch. Thaks to a bug report by Stephen Walton
983 <stephen.walton-AT-csun.edu>.
1006 <stephen.walton-AT-csun.edu>.
984
1007
985 2004-11-04 Fernando Perez <fperez@colorado.edu>
1008 2004-11-04 Fernando Perez <fperez@colorado.edu>
986
1009
987 * IPython/iplib.py (raw_input_original): store a pointer to the
1010 * IPython/iplib.py (raw_input_original): store a pointer to the
988 true raw_input to harden against code which can modify it
1011 true raw_input to harden against code which can modify it
989 (wx.py.PyShell does this and would otherwise crash ipython).
1012 (wx.py.PyShell does this and would otherwise crash ipython).
990 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1013 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
991
1014
992 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1015 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
993 Ctrl-C problem, which does not mess up the input line.
1016 Ctrl-C problem, which does not mess up the input line.
994
1017
995 2004-11-03 Fernando Perez <fperez@colorado.edu>
1018 2004-11-03 Fernando Perez <fperez@colorado.edu>
996
1019
997 * IPython/Release.py: Changed licensing to BSD, in all files.
1020 * IPython/Release.py: Changed licensing to BSD, in all files.
998 (name): lowercase name for tarball/RPM release.
1021 (name): lowercase name for tarball/RPM release.
999
1022
1000 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1023 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1001 use throughout ipython.
1024 use throughout ipython.
1002
1025
1003 * IPython/Magic.py (Magic._ofind): Switch to using the new
1026 * IPython/Magic.py (Magic._ofind): Switch to using the new
1004 OInspect.getdoc() function.
1027 OInspect.getdoc() function.
1005
1028
1006 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1029 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1007 of the line currently being canceled via Ctrl-C. It's extremely
1030 of the line currently being canceled via Ctrl-C. It's extremely
1008 ugly, but I don't know how to do it better (the problem is one of
1031 ugly, but I don't know how to do it better (the problem is one of
1009 handling cross-thread exceptions).
1032 handling cross-thread exceptions).
1010
1033
1011 2004-10-28 Fernando Perez <fperez@colorado.edu>
1034 2004-10-28 Fernando Perez <fperez@colorado.edu>
1012
1035
1013 * IPython/Shell.py (signal_handler): add signal handlers to trap
1036 * IPython/Shell.py (signal_handler): add signal handlers to trap
1014 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1037 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1015 report by Francesc Alted.
1038 report by Francesc Alted.
1016
1039
1017 2004-10-21 Fernando Perez <fperez@colorado.edu>
1040 2004-10-21 Fernando Perez <fperez@colorado.edu>
1018
1041
1019 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1042 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1020 to % for pysh syntax extensions.
1043 to % for pysh syntax extensions.
1021
1044
1022 2004-10-09 Fernando Perez <fperez@colorado.edu>
1045 2004-10-09 Fernando Perez <fperez@colorado.edu>
1023
1046
1024 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1047 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1025 arrays to print a more useful summary, without calling str(arr).
1048 arrays to print a more useful summary, without calling str(arr).
1026 This avoids the problem of extremely lengthy computations which
1049 This avoids the problem of extremely lengthy computations which
1027 occur if arr is large, and appear to the user as a system lockup
1050 occur if arr is large, and appear to the user as a system lockup
1028 with 100% cpu activity. After a suggestion by Kristian Sandberg
1051 with 100% cpu activity. After a suggestion by Kristian Sandberg
1029 <Kristian.Sandberg@colorado.edu>.
1052 <Kristian.Sandberg@colorado.edu>.
1030 (Magic.__init__): fix bug in global magic escapes not being
1053 (Magic.__init__): fix bug in global magic escapes not being
1031 correctly set.
1054 correctly set.
1032
1055
1033 2004-10-08 Fernando Perez <fperez@colorado.edu>
1056 2004-10-08 Fernando Perez <fperez@colorado.edu>
1034
1057
1035 * IPython/Magic.py (__license__): change to absolute imports of
1058 * IPython/Magic.py (__license__): change to absolute imports of
1036 ipython's own internal packages, to start adapting to the absolute
1059 ipython's own internal packages, to start adapting to the absolute
1037 import requirement of PEP-328.
1060 import requirement of PEP-328.
1038
1061
1039 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1062 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1040 files, and standardize author/license marks through the Release
1063 files, and standardize author/license marks through the Release
1041 module instead of having per/file stuff (except for files with
1064 module instead of having per/file stuff (except for files with
1042 particular licenses, like the MIT/PSF-licensed codes).
1065 particular licenses, like the MIT/PSF-licensed codes).
1043
1066
1044 * IPython/Debugger.py: remove dead code for python 2.1
1067 * IPython/Debugger.py: remove dead code for python 2.1
1045
1068
1046 2004-10-04 Fernando Perez <fperez@colorado.edu>
1069 2004-10-04 Fernando Perez <fperez@colorado.edu>
1047
1070
1048 * IPython/iplib.py (ipmagic): New function for accessing magics
1071 * IPython/iplib.py (ipmagic): New function for accessing magics
1049 via a normal python function call.
1072 via a normal python function call.
1050
1073
1051 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1074 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1052 from '@' to '%', to accomodate the new @decorator syntax of python
1075 from '@' to '%', to accomodate the new @decorator syntax of python
1053 2.4.
1076 2.4.
1054
1077
1055 2004-09-29 Fernando Perez <fperez@colorado.edu>
1078 2004-09-29 Fernando Perez <fperez@colorado.edu>
1056
1079
1057 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1080 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1058 matplotlib.use to prevent running scripts which try to switch
1081 matplotlib.use to prevent running scripts which try to switch
1059 interactive backends from within ipython. This will just crash
1082 interactive backends from within ipython. This will just crash
1060 the python interpreter, so we can't allow it (but a detailed error
1083 the python interpreter, so we can't allow it (but a detailed error
1061 is given to the user).
1084 is given to the user).
1062
1085
1063 2004-09-28 Fernando Perez <fperez@colorado.edu>
1086 2004-09-28 Fernando Perez <fperez@colorado.edu>
1064
1087
1065 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1088 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1066 matplotlib-related fixes so that using @run with non-matplotlib
1089 matplotlib-related fixes so that using @run with non-matplotlib
1067 scripts doesn't pop up spurious plot windows. This requires
1090 scripts doesn't pop up spurious plot windows. This requires
1068 matplotlib >= 0.63, where I had to make some changes as well.
1091 matplotlib >= 0.63, where I had to make some changes as well.
1069
1092
1070 * IPython/ipmaker.py (make_IPython): update version requirement to
1093 * IPython/ipmaker.py (make_IPython): update version requirement to
1071 python 2.2.
1094 python 2.2.
1072
1095
1073 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1096 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1074 banner arg for embedded customization.
1097 banner arg for embedded customization.
1075
1098
1076 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1099 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1077 explicit uses of __IP as the IPython's instance name. Now things
1100 explicit uses of __IP as the IPython's instance name. Now things
1078 are properly handled via the shell.name value. The actual code
1101 are properly handled via the shell.name value. The actual code
1079 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1102 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1080 is much better than before. I'll clean things completely when the
1103 is much better than before. I'll clean things completely when the
1081 magic stuff gets a real overhaul.
1104 magic stuff gets a real overhaul.
1082
1105
1083 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1106 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1084 minor changes to debian dir.
1107 minor changes to debian dir.
1085
1108
1086 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1109 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1087 pointer to the shell itself in the interactive namespace even when
1110 pointer to the shell itself in the interactive namespace even when
1088 a user-supplied dict is provided. This is needed for embedding
1111 a user-supplied dict is provided. This is needed for embedding
1089 purposes (found by tests with Michel Sanner).
1112 purposes (found by tests with Michel Sanner).
1090
1113
1091 2004-09-27 Fernando Perez <fperez@colorado.edu>
1114 2004-09-27 Fernando Perez <fperez@colorado.edu>
1092
1115
1093 * IPython/UserConfig/ipythonrc: remove []{} from
1116 * IPython/UserConfig/ipythonrc: remove []{} from
1094 readline_remove_delims, so that things like [modname.<TAB> do
1117 readline_remove_delims, so that things like [modname.<TAB> do
1095 proper completion. This disables [].TAB, but that's a less common
1118 proper completion. This disables [].TAB, but that's a less common
1096 case than module names in list comprehensions, for example.
1119 case than module names in list comprehensions, for example.
1097 Thanks to a report by Andrea Riciputi.
1120 Thanks to a report by Andrea Riciputi.
1098
1121
1099 2004-09-09 Fernando Perez <fperez@colorado.edu>
1122 2004-09-09 Fernando Perez <fperez@colorado.edu>
1100
1123
1101 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1124 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1102 blocking problems in win32 and osx. Fix by John.
1125 blocking problems in win32 and osx. Fix by John.
1103
1126
1104 2004-09-08 Fernando Perez <fperez@colorado.edu>
1127 2004-09-08 Fernando Perez <fperez@colorado.edu>
1105
1128
1106 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1129 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1107 for Win32 and OSX. Fix by John Hunter.
1130 for Win32 and OSX. Fix by John Hunter.
1108
1131
1109 2004-08-30 *** Released version 0.6.3
1132 2004-08-30 *** Released version 0.6.3
1110
1133
1111 2004-08-30 Fernando Perez <fperez@colorado.edu>
1134 2004-08-30 Fernando Perez <fperez@colorado.edu>
1112
1135
1113 * setup.py (isfile): Add manpages to list of dependent files to be
1136 * setup.py (isfile): Add manpages to list of dependent files to be
1114 updated.
1137 updated.
1115
1138
1116 2004-08-27 Fernando Perez <fperez@colorado.edu>
1139 2004-08-27 Fernando Perez <fperez@colorado.edu>
1117
1140
1118 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1141 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1119 for now. They don't really work with standalone WX/GTK code
1142 for now. They don't really work with standalone WX/GTK code
1120 (though matplotlib IS working fine with both of those backends).
1143 (though matplotlib IS working fine with both of those backends).
1121 This will neeed much more testing. I disabled most things with
1144 This will neeed much more testing. I disabled most things with
1122 comments, so turning it back on later should be pretty easy.
1145 comments, so turning it back on later should be pretty easy.
1123
1146
1124 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1147 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1125 autocalling of expressions like r'foo', by modifying the line
1148 autocalling of expressions like r'foo', by modifying the line
1126 split regexp. Closes
1149 split regexp. Closes
1127 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1150 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1128 Riley <ipythonbugs-AT-sabi.net>.
1151 Riley <ipythonbugs-AT-sabi.net>.
1129 (InteractiveShell.mainloop): honor --nobanner with banner
1152 (InteractiveShell.mainloop): honor --nobanner with banner
1130 extensions.
1153 extensions.
1131
1154
1132 * IPython/Shell.py: Significant refactoring of all classes, so
1155 * IPython/Shell.py: Significant refactoring of all classes, so
1133 that we can really support ALL matplotlib backends and threading
1156 that we can really support ALL matplotlib backends and threading
1134 models (John spotted a bug with Tk which required this). Now we
1157 models (John spotted a bug with Tk which required this). Now we
1135 should support single-threaded, WX-threads and GTK-threads, both
1158 should support single-threaded, WX-threads and GTK-threads, both
1136 for generic code and for matplotlib.
1159 for generic code and for matplotlib.
1137
1160
1138 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1161 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1139 -pylab, to simplify things for users. Will also remove the pylab
1162 -pylab, to simplify things for users. Will also remove the pylab
1140 profile, since now all of matplotlib configuration is directly
1163 profile, since now all of matplotlib configuration is directly
1141 handled here. This also reduces startup time.
1164 handled here. This also reduces startup time.
1142
1165
1143 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1166 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1144 shell wasn't being correctly called. Also in IPShellWX.
1167 shell wasn't being correctly called. Also in IPShellWX.
1145
1168
1146 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1169 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1147 fine-tune banner.
1170 fine-tune banner.
1148
1171
1149 * IPython/numutils.py (spike): Deprecate these spike functions,
1172 * IPython/numutils.py (spike): Deprecate these spike functions,
1150 delete (long deprecated) gnuplot_exec handler.
1173 delete (long deprecated) gnuplot_exec handler.
1151
1174
1152 2004-08-26 Fernando Perez <fperez@colorado.edu>
1175 2004-08-26 Fernando Perez <fperez@colorado.edu>
1153
1176
1154 * ipython.1: Update for threading options, plus some others which
1177 * ipython.1: Update for threading options, plus some others which
1155 were missing.
1178 were missing.
1156
1179
1157 * IPython/ipmaker.py (__call__): Added -wthread option for
1180 * IPython/ipmaker.py (__call__): Added -wthread option for
1158 wxpython thread handling. Make sure threading options are only
1181 wxpython thread handling. Make sure threading options are only
1159 valid at the command line.
1182 valid at the command line.
1160
1183
1161 * scripts/ipython: moved shell selection into a factory function
1184 * scripts/ipython: moved shell selection into a factory function
1162 in Shell.py, to keep the starter script to a minimum.
1185 in Shell.py, to keep the starter script to a minimum.
1163
1186
1164 2004-08-25 Fernando Perez <fperez@colorado.edu>
1187 2004-08-25 Fernando Perez <fperez@colorado.edu>
1165
1188
1166 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1189 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1167 John. Along with some recent changes he made to matplotlib, the
1190 John. Along with some recent changes he made to matplotlib, the
1168 next versions of both systems should work very well together.
1191 next versions of both systems should work very well together.
1169
1192
1170 2004-08-24 Fernando Perez <fperez@colorado.edu>
1193 2004-08-24 Fernando Perez <fperez@colorado.edu>
1171
1194
1172 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1195 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1173 tried to switch the profiling to using hotshot, but I'm getting
1196 tried to switch the profiling to using hotshot, but I'm getting
1174 strange errors from prof.runctx() there. I may be misreading the
1197 strange errors from prof.runctx() there. I may be misreading the
1175 docs, but it looks weird. For now the profiling code will
1198 docs, but it looks weird. For now the profiling code will
1176 continue to use the standard profiler.
1199 continue to use the standard profiler.
1177
1200
1178 2004-08-23 Fernando Perez <fperez@colorado.edu>
1201 2004-08-23 Fernando Perez <fperez@colorado.edu>
1179
1202
1180 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1203 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1181 threaded shell, by John Hunter. It's not quite ready yet, but
1204 threaded shell, by John Hunter. It's not quite ready yet, but
1182 close.
1205 close.
1183
1206
1184 2004-08-22 Fernando Perez <fperez@colorado.edu>
1207 2004-08-22 Fernando Perez <fperez@colorado.edu>
1185
1208
1186 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1209 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1187 in Magic and ultraTB.
1210 in Magic and ultraTB.
1188
1211
1189 * ipython.1: document threading options in manpage.
1212 * ipython.1: document threading options in manpage.
1190
1213
1191 * scripts/ipython: Changed name of -thread option to -gthread,
1214 * scripts/ipython: Changed name of -thread option to -gthread,
1192 since this is GTK specific. I want to leave the door open for a
1215 since this is GTK specific. I want to leave the door open for a
1193 -wthread option for WX, which will most likely be necessary. This
1216 -wthread option for WX, which will most likely be necessary. This
1194 change affects usage and ipmaker as well.
1217 change affects usage and ipmaker as well.
1195
1218
1196 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1219 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1197 handle the matplotlib shell issues. Code by John Hunter
1220 handle the matplotlib shell issues. Code by John Hunter
1198 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1221 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1199 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1222 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1200 broken (and disabled for end users) for now, but it puts the
1223 broken (and disabled for end users) for now, but it puts the
1201 infrastructure in place.
1224 infrastructure in place.
1202
1225
1203 2004-08-21 Fernando Perez <fperez@colorado.edu>
1226 2004-08-21 Fernando Perez <fperez@colorado.edu>
1204
1227
1205 * ipythonrc-pylab: Add matplotlib support.
1228 * ipythonrc-pylab: Add matplotlib support.
1206
1229
1207 * matplotlib_config.py: new files for matplotlib support, part of
1230 * matplotlib_config.py: new files for matplotlib support, part of
1208 the pylab profile.
1231 the pylab profile.
1209
1232
1210 * IPython/usage.py (__doc__): documented the threading options.
1233 * IPython/usage.py (__doc__): documented the threading options.
1211
1234
1212 2004-08-20 Fernando Perez <fperez@colorado.edu>
1235 2004-08-20 Fernando Perez <fperez@colorado.edu>
1213
1236
1214 * ipython: Modified the main calling routine to handle the -thread
1237 * ipython: Modified the main calling routine to handle the -thread
1215 and -mpthread options. This needs to be done as a top-level hack,
1238 and -mpthread options. This needs to be done as a top-level hack,
1216 because it determines which class to instantiate for IPython
1239 because it determines which class to instantiate for IPython
1217 itself.
1240 itself.
1218
1241
1219 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1242 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1220 classes to support multithreaded GTK operation without blocking,
1243 classes to support multithreaded GTK operation without blocking,
1221 and matplotlib with all backends. This is a lot of still very
1244 and matplotlib with all backends. This is a lot of still very
1222 experimental code, and threads are tricky. So it may still have a
1245 experimental code, and threads are tricky. So it may still have a
1223 few rough edges... This code owes a lot to
1246 few rough edges... This code owes a lot to
1224 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1247 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1225 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1248 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1226 to John Hunter for all the matplotlib work.
1249 to John Hunter for all the matplotlib work.
1227
1250
1228 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1251 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1229 options for gtk thread and matplotlib support.
1252 options for gtk thread and matplotlib support.
1230
1253
1231 2004-08-16 Fernando Perez <fperez@colorado.edu>
1254 2004-08-16 Fernando Perez <fperez@colorado.edu>
1232
1255
1233 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1256 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1234 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1257 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1235 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1258 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1236
1259
1237 2004-08-11 Fernando Perez <fperez@colorado.edu>
1260 2004-08-11 Fernando Perez <fperez@colorado.edu>
1238
1261
1239 * setup.py (isfile): Fix build so documentation gets updated for
1262 * setup.py (isfile): Fix build so documentation gets updated for
1240 rpms (it was only done for .tgz builds).
1263 rpms (it was only done for .tgz builds).
1241
1264
1242 2004-08-10 Fernando Perez <fperez@colorado.edu>
1265 2004-08-10 Fernando Perez <fperez@colorado.edu>
1243
1266
1244 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1267 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1245
1268
1246 * iplib.py : Silence syntax error exceptions in tab-completion.
1269 * iplib.py : Silence syntax error exceptions in tab-completion.
1247
1270
1248 2004-08-05 Fernando Perez <fperez@colorado.edu>
1271 2004-08-05 Fernando Perez <fperez@colorado.edu>
1249
1272
1250 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1273 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1251 'color off' mark for continuation prompts. This was causing long
1274 'color off' mark for continuation prompts. This was causing long
1252 continuation lines to mis-wrap.
1275 continuation lines to mis-wrap.
1253
1276
1254 2004-08-01 Fernando Perez <fperez@colorado.edu>
1277 2004-08-01 Fernando Perez <fperez@colorado.edu>
1255
1278
1256 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1279 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1257 for building ipython to be a parameter. All this is necessary
1280 for building ipython to be a parameter. All this is necessary
1258 right now to have a multithreaded version, but this insane
1281 right now to have a multithreaded version, but this insane
1259 non-design will be cleaned up soon. For now, it's a hack that
1282 non-design will be cleaned up soon. For now, it's a hack that
1260 works.
1283 works.
1261
1284
1262 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1285 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1263 args in various places. No bugs so far, but it's a dangerous
1286 args in various places. No bugs so far, but it's a dangerous
1264 practice.
1287 practice.
1265
1288
1266 2004-07-31 Fernando Perez <fperez@colorado.edu>
1289 2004-07-31 Fernando Perez <fperez@colorado.edu>
1267
1290
1268 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1291 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1269 fix completion of files with dots in their names under most
1292 fix completion of files with dots in their names under most
1270 profiles (pysh was OK because the completion order is different).
1293 profiles (pysh was OK because the completion order is different).
1271
1294
1272 2004-07-27 Fernando Perez <fperez@colorado.edu>
1295 2004-07-27 Fernando Perez <fperez@colorado.edu>
1273
1296
1274 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1297 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1275 keywords manually, b/c the one in keyword.py was removed in python
1298 keywords manually, b/c the one in keyword.py was removed in python
1276 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1299 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1277 This is NOT a bug under python 2.3 and earlier.
1300 This is NOT a bug under python 2.3 and earlier.
1278
1301
1279 2004-07-26 Fernando Perez <fperez@colorado.edu>
1302 2004-07-26 Fernando Perez <fperez@colorado.edu>
1280
1303
1281 * IPython/ultraTB.py (VerboseTB.text): Add another
1304 * IPython/ultraTB.py (VerboseTB.text): Add another
1282 linecache.checkcache() call to try to prevent inspect.py from
1305 linecache.checkcache() call to try to prevent inspect.py from
1283 crashing under python 2.3. I think this fixes
1306 crashing under python 2.3. I think this fixes
1284 http://www.scipy.net/roundup/ipython/issue17.
1307 http://www.scipy.net/roundup/ipython/issue17.
1285
1308
1286 2004-07-26 *** Released version 0.6.2
1309 2004-07-26 *** Released version 0.6.2
1287
1310
1288 2004-07-26 Fernando Perez <fperez@colorado.edu>
1311 2004-07-26 Fernando Perez <fperez@colorado.edu>
1289
1312
1290 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1313 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1291 fail for any number.
1314 fail for any number.
1292 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1315 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1293 empty bookmarks.
1316 empty bookmarks.
1294
1317
1295 2004-07-26 *** Released version 0.6.1
1318 2004-07-26 *** Released version 0.6.1
1296
1319
1297 2004-07-26 Fernando Perez <fperez@colorado.edu>
1320 2004-07-26 Fernando Perez <fperez@colorado.edu>
1298
1321
1299 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1322 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1300
1323
1301 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1324 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1302 escaping '()[]{}' in filenames.
1325 escaping '()[]{}' in filenames.
1303
1326
1304 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1327 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1305 Python 2.2 users who lack a proper shlex.split.
1328 Python 2.2 users who lack a proper shlex.split.
1306
1329
1307 2004-07-19 Fernando Perez <fperez@colorado.edu>
1330 2004-07-19 Fernando Perez <fperez@colorado.edu>
1308
1331
1309 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1332 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1310 for reading readline's init file. I follow the normal chain:
1333 for reading readline's init file. I follow the normal chain:
1311 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1334 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1312 report by Mike Heeter. This closes
1335 report by Mike Heeter. This closes
1313 http://www.scipy.net/roundup/ipython/issue16.
1336 http://www.scipy.net/roundup/ipython/issue16.
1314
1337
1315 2004-07-18 Fernando Perez <fperez@colorado.edu>
1338 2004-07-18 Fernando Perez <fperez@colorado.edu>
1316
1339
1317 * IPython/iplib.py (__init__): Add better handling of '\' under
1340 * IPython/iplib.py (__init__): Add better handling of '\' under
1318 Win32 for filenames. After a patch by Ville.
1341 Win32 for filenames. After a patch by Ville.
1319
1342
1320 2004-07-17 Fernando Perez <fperez@colorado.edu>
1343 2004-07-17 Fernando Perez <fperez@colorado.edu>
1321
1344
1322 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1345 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1323 autocalling would be triggered for 'foo is bar' if foo is
1346 autocalling would be triggered for 'foo is bar' if foo is
1324 callable. I also cleaned up the autocall detection code to use a
1347 callable. I also cleaned up the autocall detection code to use a
1325 regexp, which is faster. Bug reported by Alexander Schmolck.
1348 regexp, which is faster. Bug reported by Alexander Schmolck.
1326
1349
1327 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1350 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1328 '?' in them would confuse the help system. Reported by Alex
1351 '?' in them would confuse the help system. Reported by Alex
1329 Schmolck.
1352 Schmolck.
1330
1353
1331 2004-07-16 Fernando Perez <fperez@colorado.edu>
1354 2004-07-16 Fernando Perez <fperez@colorado.edu>
1332
1355
1333 * IPython/GnuplotInteractive.py (__all__): added plot2.
1356 * IPython/GnuplotInteractive.py (__all__): added plot2.
1334
1357
1335 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1358 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1336 plotting dictionaries, lists or tuples of 1d arrays.
1359 plotting dictionaries, lists or tuples of 1d arrays.
1337
1360
1338 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1361 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1339 optimizations.
1362 optimizations.
1340
1363
1341 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1364 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1342 the information which was there from Janko's original IPP code:
1365 the information which was there from Janko's original IPP code:
1343
1366
1344 03.05.99 20:53 porto.ifm.uni-kiel.de
1367 03.05.99 20:53 porto.ifm.uni-kiel.de
1345 --Started changelog.
1368 --Started changelog.
1346 --make clear do what it say it does
1369 --make clear do what it say it does
1347 --added pretty output of lines from inputcache
1370 --added pretty output of lines from inputcache
1348 --Made Logger a mixin class, simplifies handling of switches
1371 --Made Logger a mixin class, simplifies handling of switches
1349 --Added own completer class. .string<TAB> expands to last history
1372 --Added own completer class. .string<TAB> expands to last history
1350 line which starts with string. The new expansion is also present
1373 line which starts with string. The new expansion is also present
1351 with Ctrl-r from the readline library. But this shows, who this
1374 with Ctrl-r from the readline library. But this shows, who this
1352 can be done for other cases.
1375 can be done for other cases.
1353 --Added convention that all shell functions should accept a
1376 --Added convention that all shell functions should accept a
1354 parameter_string This opens the door for different behaviour for
1377 parameter_string This opens the door for different behaviour for
1355 each function. @cd is a good example of this.
1378 each function. @cd is a good example of this.
1356
1379
1357 04.05.99 12:12 porto.ifm.uni-kiel.de
1380 04.05.99 12:12 porto.ifm.uni-kiel.de
1358 --added logfile rotation
1381 --added logfile rotation
1359 --added new mainloop method which freezes first the namespace
1382 --added new mainloop method which freezes first the namespace
1360
1383
1361 07.05.99 21:24 porto.ifm.uni-kiel.de
1384 07.05.99 21:24 porto.ifm.uni-kiel.de
1362 --added the docreader classes. Now there is a help system.
1385 --added the docreader classes. Now there is a help system.
1363 -This is only a first try. Currently it's not easy to put new
1386 -This is only a first try. Currently it's not easy to put new
1364 stuff in the indices. But this is the way to go. Info would be
1387 stuff in the indices. But this is the way to go. Info would be
1365 better, but HTML is every where and not everybody has an info
1388 better, but HTML is every where and not everybody has an info
1366 system installed and it's not so easy to change html-docs to info.
1389 system installed and it's not so easy to change html-docs to info.
1367 --added global logfile option
1390 --added global logfile option
1368 --there is now a hook for object inspection method pinfo needs to
1391 --there is now a hook for object inspection method pinfo needs to
1369 be provided for this. Can be reached by two '??'.
1392 be provided for this. Can be reached by two '??'.
1370
1393
1371 08.05.99 20:51 porto.ifm.uni-kiel.de
1394 08.05.99 20:51 porto.ifm.uni-kiel.de
1372 --added a README
1395 --added a README
1373 --bug in rc file. Something has changed so functions in the rc
1396 --bug in rc file. Something has changed so functions in the rc
1374 file need to reference the shell and not self. Not clear if it's a
1397 file need to reference the shell and not self. Not clear if it's a
1375 bug or feature.
1398 bug or feature.
1376 --changed rc file for new behavior
1399 --changed rc file for new behavior
1377
1400
1378 2004-07-15 Fernando Perez <fperez@colorado.edu>
1401 2004-07-15 Fernando Perez <fperez@colorado.edu>
1379
1402
1380 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1403 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1381 cache was falling out of sync in bizarre manners when multi-line
1404 cache was falling out of sync in bizarre manners when multi-line
1382 input was present. Minor optimizations and cleanup.
1405 input was present. Minor optimizations and cleanup.
1383
1406
1384 (Logger): Remove old Changelog info for cleanup. This is the
1407 (Logger): Remove old Changelog info for cleanup. This is the
1385 information which was there from Janko's original code:
1408 information which was there from Janko's original code:
1386
1409
1387 Changes to Logger: - made the default log filename a parameter
1410 Changes to Logger: - made the default log filename a parameter
1388
1411
1389 - put a check for lines beginning with !@? in log(). Needed
1412 - put a check for lines beginning with !@? in log(). Needed
1390 (even if the handlers properly log their lines) for mid-session
1413 (even if the handlers properly log their lines) for mid-session
1391 logging activation to work properly. Without this, lines logged
1414 logging activation to work properly. Without this, lines logged
1392 in mid session, which get read from the cache, would end up
1415 in mid session, which get read from the cache, would end up
1393 'bare' (with !@? in the open) in the log. Now they are caught
1416 'bare' (with !@? in the open) in the log. Now they are caught
1394 and prepended with a #.
1417 and prepended with a #.
1395
1418
1396 * IPython/iplib.py (InteractiveShell.init_readline): added check
1419 * IPython/iplib.py (InteractiveShell.init_readline): added check
1397 in case MagicCompleter fails to be defined, so we don't crash.
1420 in case MagicCompleter fails to be defined, so we don't crash.
1398
1421
1399 2004-07-13 Fernando Perez <fperez@colorado.edu>
1422 2004-07-13 Fernando Perez <fperez@colorado.edu>
1400
1423
1401 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1424 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1402 of EPS if the requested filename ends in '.eps'.
1425 of EPS if the requested filename ends in '.eps'.
1403
1426
1404 2004-07-04 Fernando Perez <fperez@colorado.edu>
1427 2004-07-04 Fernando Perez <fperez@colorado.edu>
1405
1428
1406 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1429 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1407 escaping of quotes when calling the shell.
1430 escaping of quotes when calling the shell.
1408
1431
1409 2004-07-02 Fernando Perez <fperez@colorado.edu>
1432 2004-07-02 Fernando Perez <fperez@colorado.edu>
1410
1433
1411 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1434 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1412 gettext not working because we were clobbering '_'. Fixes
1435 gettext not working because we were clobbering '_'. Fixes
1413 http://www.scipy.net/roundup/ipython/issue6.
1436 http://www.scipy.net/roundup/ipython/issue6.
1414
1437
1415 2004-07-01 Fernando Perez <fperez@colorado.edu>
1438 2004-07-01 Fernando Perez <fperez@colorado.edu>
1416
1439
1417 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1440 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1418 into @cd. Patch by Ville.
1441 into @cd. Patch by Ville.
1419
1442
1420 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1443 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1421 new function to store things after ipmaker runs. Patch by Ville.
1444 new function to store things after ipmaker runs. Patch by Ville.
1422 Eventually this will go away once ipmaker is removed and the class
1445 Eventually this will go away once ipmaker is removed and the class
1423 gets cleaned up, but for now it's ok. Key functionality here is
1446 gets cleaned up, but for now it's ok. Key functionality here is
1424 the addition of the persistent storage mechanism, a dict for
1447 the addition of the persistent storage mechanism, a dict for
1425 keeping data across sessions (for now just bookmarks, but more can
1448 keeping data across sessions (for now just bookmarks, but more can
1426 be implemented later).
1449 be implemented later).
1427
1450
1428 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1451 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1429 persistent across sections. Patch by Ville, I modified it
1452 persistent across sections. Patch by Ville, I modified it
1430 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1453 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1431 added a '-l' option to list all bookmarks.
1454 added a '-l' option to list all bookmarks.
1432
1455
1433 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1456 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1434 center for cleanup. Registered with atexit.register(). I moved
1457 center for cleanup. Registered with atexit.register(). I moved
1435 here the old exit_cleanup(). After a patch by Ville.
1458 here the old exit_cleanup(). After a patch by Ville.
1436
1459
1437 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1460 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1438 characters in the hacked shlex_split for python 2.2.
1461 characters in the hacked shlex_split for python 2.2.
1439
1462
1440 * IPython/iplib.py (file_matches): more fixes to filenames with
1463 * IPython/iplib.py (file_matches): more fixes to filenames with
1441 whitespace in them. It's not perfect, but limitations in python's
1464 whitespace in them. It's not perfect, but limitations in python's
1442 readline make it impossible to go further.
1465 readline make it impossible to go further.
1443
1466
1444 2004-06-29 Fernando Perez <fperez@colorado.edu>
1467 2004-06-29 Fernando Perez <fperez@colorado.edu>
1445
1468
1446 * IPython/iplib.py (file_matches): escape whitespace correctly in
1469 * IPython/iplib.py (file_matches): escape whitespace correctly in
1447 filename completions. Bug reported by Ville.
1470 filename completions. Bug reported by Ville.
1448
1471
1449 2004-06-28 Fernando Perez <fperez@colorado.edu>
1472 2004-06-28 Fernando Perez <fperez@colorado.edu>
1450
1473
1451 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1474 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1452 the history file will be called 'history-PROFNAME' (or just
1475 the history file will be called 'history-PROFNAME' (or just
1453 'history' if no profile is loaded). I was getting annoyed at
1476 'history' if no profile is loaded). I was getting annoyed at
1454 getting my Numerical work history clobbered by pysh sessions.
1477 getting my Numerical work history clobbered by pysh sessions.
1455
1478
1456 * IPython/iplib.py (InteractiveShell.__init__): Internal
1479 * IPython/iplib.py (InteractiveShell.__init__): Internal
1457 getoutputerror() function so that we can honor the system_verbose
1480 getoutputerror() function so that we can honor the system_verbose
1458 flag for _all_ system calls. I also added escaping of #
1481 flag for _all_ system calls. I also added escaping of #
1459 characters here to avoid confusing Itpl.
1482 characters here to avoid confusing Itpl.
1460
1483
1461 * IPython/Magic.py (shlex_split): removed call to shell in
1484 * IPython/Magic.py (shlex_split): removed call to shell in
1462 parse_options and replaced it with shlex.split(). The annoying
1485 parse_options and replaced it with shlex.split(). The annoying
1463 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1486 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1464 to backport it from 2.3, with several frail hacks (the shlex
1487 to backport it from 2.3, with several frail hacks (the shlex
1465 module is rather limited in 2.2). Thanks to a suggestion by Ville
1488 module is rather limited in 2.2). Thanks to a suggestion by Ville
1466 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1489 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1467 problem.
1490 problem.
1468
1491
1469 (Magic.magic_system_verbose): new toggle to print the actual
1492 (Magic.magic_system_verbose): new toggle to print the actual
1470 system calls made by ipython. Mainly for debugging purposes.
1493 system calls made by ipython. Mainly for debugging purposes.
1471
1494
1472 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1495 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1473 doesn't support persistence. Reported (and fix suggested) by
1496 doesn't support persistence. Reported (and fix suggested) by
1474 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1497 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1475
1498
1476 2004-06-26 Fernando Perez <fperez@colorado.edu>
1499 2004-06-26 Fernando Perez <fperez@colorado.edu>
1477
1500
1478 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1501 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1479 continue prompts.
1502 continue prompts.
1480
1503
1481 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1504 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1482 function (basically a big docstring) and a few more things here to
1505 function (basically a big docstring) and a few more things here to
1483 speedup startup. pysh.py is now very lightweight. We want because
1506 speedup startup. pysh.py is now very lightweight. We want because
1484 it gets execfile'd, while InterpreterExec gets imported, so
1507 it gets execfile'd, while InterpreterExec gets imported, so
1485 byte-compilation saves time.
1508 byte-compilation saves time.
1486
1509
1487 2004-06-25 Fernando Perez <fperez@colorado.edu>
1510 2004-06-25 Fernando Perez <fperez@colorado.edu>
1488
1511
1489 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1512 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1490 -NUM', which was recently broken.
1513 -NUM', which was recently broken.
1491
1514
1492 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1515 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1493 in multi-line input (but not !!, which doesn't make sense there).
1516 in multi-line input (but not !!, which doesn't make sense there).
1494
1517
1495 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1518 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1496 It's just too useful, and people can turn it off in the less
1519 It's just too useful, and people can turn it off in the less
1497 common cases where it's a problem.
1520 common cases where it's a problem.
1498
1521
1499 2004-06-24 Fernando Perez <fperez@colorado.edu>
1522 2004-06-24 Fernando Perez <fperez@colorado.edu>
1500
1523
1501 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1524 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1502 special syntaxes (like alias calling) is now allied in multi-line
1525 special syntaxes (like alias calling) is now allied in multi-line
1503 input. This is still _very_ experimental, but it's necessary for
1526 input. This is still _very_ experimental, but it's necessary for
1504 efficient shell usage combining python looping syntax with system
1527 efficient shell usage combining python looping syntax with system
1505 calls. For now it's restricted to aliases, I don't think it
1528 calls. For now it's restricted to aliases, I don't think it
1506 really even makes sense to have this for magics.
1529 really even makes sense to have this for magics.
1507
1530
1508 2004-06-23 Fernando Perez <fperez@colorado.edu>
1531 2004-06-23 Fernando Perez <fperez@colorado.edu>
1509
1532
1510 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1533 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1511 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1534 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1512
1535
1513 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1536 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1514 extensions under Windows (after code sent by Gary Bishop). The
1537 extensions under Windows (after code sent by Gary Bishop). The
1515 extensions considered 'executable' are stored in IPython's rc
1538 extensions considered 'executable' are stored in IPython's rc
1516 structure as win_exec_ext.
1539 structure as win_exec_ext.
1517
1540
1518 * IPython/genutils.py (shell): new function, like system() but
1541 * IPython/genutils.py (shell): new function, like system() but
1519 without return value. Very useful for interactive shell work.
1542 without return value. Very useful for interactive shell work.
1520
1543
1521 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1544 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1522 delete aliases.
1545 delete aliases.
1523
1546
1524 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1547 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1525 sure that the alias table doesn't contain python keywords.
1548 sure that the alias table doesn't contain python keywords.
1526
1549
1527 2004-06-21 Fernando Perez <fperez@colorado.edu>
1550 2004-06-21 Fernando Perez <fperez@colorado.edu>
1528
1551
1529 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1552 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1530 non-existent items are found in $PATH. Reported by Thorsten.
1553 non-existent items are found in $PATH. Reported by Thorsten.
1531
1554
1532 2004-06-20 Fernando Perez <fperez@colorado.edu>
1555 2004-06-20 Fernando Perez <fperez@colorado.edu>
1533
1556
1534 * IPython/iplib.py (complete): modified the completer so that the
1557 * IPython/iplib.py (complete): modified the completer so that the
1535 order of priorities can be easily changed at runtime.
1558 order of priorities can be easily changed at runtime.
1536
1559
1537 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1560 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1538 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1561 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1539
1562
1540 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1563 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1541 expand Python variables prepended with $ in all system calls. The
1564 expand Python variables prepended with $ in all system calls. The
1542 same was done to InteractiveShell.handle_shell_escape. Now all
1565 same was done to InteractiveShell.handle_shell_escape. Now all
1543 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1566 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1544 expansion of python variables and expressions according to the
1567 expansion of python variables and expressions according to the
1545 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1568 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1546
1569
1547 Though PEP-215 has been rejected, a similar (but simpler) one
1570 Though PEP-215 has been rejected, a similar (but simpler) one
1548 seems like it will go into Python 2.4, PEP-292 -
1571 seems like it will go into Python 2.4, PEP-292 -
1549 http://www.python.org/peps/pep-0292.html.
1572 http://www.python.org/peps/pep-0292.html.
1550
1573
1551 I'll keep the full syntax of PEP-215, since IPython has since the
1574 I'll keep the full syntax of PEP-215, since IPython has since the
1552 start used Ka-Ping Yee's reference implementation discussed there
1575 start used Ka-Ping Yee's reference implementation discussed there
1553 (Itpl), and I actually like the powerful semantics it offers.
1576 (Itpl), and I actually like the powerful semantics it offers.
1554
1577
1555 In order to access normal shell variables, the $ has to be escaped
1578 In order to access normal shell variables, the $ has to be escaped
1556 via an extra $. For example:
1579 via an extra $. For example:
1557
1580
1558 In [7]: PATH='a python variable'
1581 In [7]: PATH='a python variable'
1559
1582
1560 In [8]: !echo $PATH
1583 In [8]: !echo $PATH
1561 a python variable
1584 a python variable
1562
1585
1563 In [9]: !echo $$PATH
1586 In [9]: !echo $$PATH
1564 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1587 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1565
1588
1566 (Magic.parse_options): escape $ so the shell doesn't evaluate
1589 (Magic.parse_options): escape $ so the shell doesn't evaluate
1567 things prematurely.
1590 things prematurely.
1568
1591
1569 * IPython/iplib.py (InteractiveShell.call_alias): added the
1592 * IPython/iplib.py (InteractiveShell.call_alias): added the
1570 ability for aliases to expand python variables via $.
1593 ability for aliases to expand python variables via $.
1571
1594
1572 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1595 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1573 system, now there's a @rehash/@rehashx pair of magics. These work
1596 system, now there's a @rehash/@rehashx pair of magics. These work
1574 like the csh rehash command, and can be invoked at any time. They
1597 like the csh rehash command, and can be invoked at any time. They
1575 build a table of aliases to everything in the user's $PATH
1598 build a table of aliases to everything in the user's $PATH
1576 (@rehash uses everything, @rehashx is slower but only adds
1599 (@rehash uses everything, @rehashx is slower but only adds
1577 executable files). With this, the pysh.py-based shell profile can
1600 executable files). With this, the pysh.py-based shell profile can
1578 now simply call rehash upon startup, and full access to all
1601 now simply call rehash upon startup, and full access to all
1579 programs in the user's path is obtained.
1602 programs in the user's path is obtained.
1580
1603
1581 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1604 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1582 functionality is now fully in place. I removed the old dynamic
1605 functionality is now fully in place. I removed the old dynamic
1583 code generation based approach, in favor of a much lighter one
1606 code generation based approach, in favor of a much lighter one
1584 based on a simple dict. The advantage is that this allows me to
1607 based on a simple dict. The advantage is that this allows me to
1585 now have thousands of aliases with negligible cost (unthinkable
1608 now have thousands of aliases with negligible cost (unthinkable
1586 with the old system).
1609 with the old system).
1587
1610
1588 2004-06-19 Fernando Perez <fperez@colorado.edu>
1611 2004-06-19 Fernando Perez <fperez@colorado.edu>
1589
1612
1590 * IPython/iplib.py (__init__): extended MagicCompleter class to
1613 * IPython/iplib.py (__init__): extended MagicCompleter class to
1591 also complete (last in priority) on user aliases.
1614 also complete (last in priority) on user aliases.
1592
1615
1593 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1616 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1594 call to eval.
1617 call to eval.
1595 (ItplNS.__init__): Added a new class which functions like Itpl,
1618 (ItplNS.__init__): Added a new class which functions like Itpl,
1596 but allows configuring the namespace for the evaluation to occur
1619 but allows configuring the namespace for the evaluation to occur
1597 in.
1620 in.
1598
1621
1599 2004-06-18 Fernando Perez <fperez@colorado.edu>
1622 2004-06-18 Fernando Perez <fperez@colorado.edu>
1600
1623
1601 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1624 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1602 better message when 'exit' or 'quit' are typed (a common newbie
1625 better message when 'exit' or 'quit' are typed (a common newbie
1603 confusion).
1626 confusion).
1604
1627
1605 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1628 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1606 check for Windows users.
1629 check for Windows users.
1607
1630
1608 * IPython/iplib.py (InteractiveShell.user_setup): removed
1631 * IPython/iplib.py (InteractiveShell.user_setup): removed
1609 disabling of colors for Windows. I'll test at runtime and issue a
1632 disabling of colors for Windows. I'll test at runtime and issue a
1610 warning if Gary's readline isn't found, as to nudge users to
1633 warning if Gary's readline isn't found, as to nudge users to
1611 download it.
1634 download it.
1612
1635
1613 2004-06-16 Fernando Perez <fperez@colorado.edu>
1636 2004-06-16 Fernando Perez <fperez@colorado.edu>
1614
1637
1615 * IPython/genutils.py (Stream.__init__): changed to print errors
1638 * IPython/genutils.py (Stream.__init__): changed to print errors
1616 to sys.stderr. I had a circular dependency here. Now it's
1639 to sys.stderr. I had a circular dependency here. Now it's
1617 possible to run ipython as IDLE's shell (consider this pre-alpha,
1640 possible to run ipython as IDLE's shell (consider this pre-alpha,
1618 since true stdout things end up in the starting terminal instead
1641 since true stdout things end up in the starting terminal instead
1619 of IDLE's out).
1642 of IDLE's out).
1620
1643
1621 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1644 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1622 users who haven't # updated their prompt_in2 definitions. Remove
1645 users who haven't # updated their prompt_in2 definitions. Remove
1623 eventually.
1646 eventually.
1624 (multiple_replace): added credit to original ASPN recipe.
1647 (multiple_replace): added credit to original ASPN recipe.
1625
1648
1626 2004-06-15 Fernando Perez <fperez@colorado.edu>
1649 2004-06-15 Fernando Perez <fperez@colorado.edu>
1627
1650
1628 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1651 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1629 list of auto-defined aliases.
1652 list of auto-defined aliases.
1630
1653
1631 2004-06-13 Fernando Perez <fperez@colorado.edu>
1654 2004-06-13 Fernando Perez <fperez@colorado.edu>
1632
1655
1633 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1656 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1634 install was really requested (so setup.py can be used for other
1657 install was really requested (so setup.py can be used for other
1635 things under Windows).
1658 things under Windows).
1636
1659
1637 2004-06-10 Fernando Perez <fperez@colorado.edu>
1660 2004-06-10 Fernando Perez <fperez@colorado.edu>
1638
1661
1639 * IPython/Logger.py (Logger.create_log): Manually remove any old
1662 * IPython/Logger.py (Logger.create_log): Manually remove any old
1640 backup, since os.remove may fail under Windows. Fixes bug
1663 backup, since os.remove may fail under Windows. Fixes bug
1641 reported by Thorsten.
1664 reported by Thorsten.
1642
1665
1643 2004-06-09 Fernando Perez <fperez@colorado.edu>
1666 2004-06-09 Fernando Perez <fperez@colorado.edu>
1644
1667
1645 * examples/example-embed.py: fixed all references to %n (replaced
1668 * examples/example-embed.py: fixed all references to %n (replaced
1646 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1669 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1647 for all examples and the manual as well.
1670 for all examples and the manual as well.
1648
1671
1649 2004-06-08 Fernando Perez <fperez@colorado.edu>
1672 2004-06-08 Fernando Perez <fperez@colorado.edu>
1650
1673
1651 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1674 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1652 alignment and color management. All 3 prompt subsystems now
1675 alignment and color management. All 3 prompt subsystems now
1653 inherit from BasePrompt.
1676 inherit from BasePrompt.
1654
1677
1655 * tools/release: updates for windows installer build and tag rpms
1678 * tools/release: updates for windows installer build and tag rpms
1656 with python version (since paths are fixed).
1679 with python version (since paths are fixed).
1657
1680
1658 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1681 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1659 which will become eventually obsolete. Also fixed the default
1682 which will become eventually obsolete. Also fixed the default
1660 prompt_in2 to use \D, so at least new users start with the correct
1683 prompt_in2 to use \D, so at least new users start with the correct
1661 defaults.
1684 defaults.
1662 WARNING: Users with existing ipythonrc files will need to apply
1685 WARNING: Users with existing ipythonrc files will need to apply
1663 this fix manually!
1686 this fix manually!
1664
1687
1665 * setup.py: make windows installer (.exe). This is finally the
1688 * setup.py: make windows installer (.exe). This is finally the
1666 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1689 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1667 which I hadn't included because it required Python 2.3 (or recent
1690 which I hadn't included because it required Python 2.3 (or recent
1668 distutils).
1691 distutils).
1669
1692
1670 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1693 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1671 usage of new '\D' escape.
1694 usage of new '\D' escape.
1672
1695
1673 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1696 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1674 lacks os.getuid())
1697 lacks os.getuid())
1675 (CachedOutput.set_colors): Added the ability to turn coloring
1698 (CachedOutput.set_colors): Added the ability to turn coloring
1676 on/off with @colors even for manually defined prompt colors. It
1699 on/off with @colors even for manually defined prompt colors. It
1677 uses a nasty global, but it works safely and via the generic color
1700 uses a nasty global, but it works safely and via the generic color
1678 handling mechanism.
1701 handling mechanism.
1679 (Prompt2.__init__): Introduced new escape '\D' for continuation
1702 (Prompt2.__init__): Introduced new escape '\D' for continuation
1680 prompts. It represents the counter ('\#') as dots.
1703 prompts. It represents the counter ('\#') as dots.
1681 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1704 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1682 need to update their ipythonrc files and replace '%n' with '\D' in
1705 need to update their ipythonrc files and replace '%n' with '\D' in
1683 their prompt_in2 settings everywhere. Sorry, but there's
1706 their prompt_in2 settings everywhere. Sorry, but there's
1684 otherwise no clean way to get all prompts to properly align. The
1707 otherwise no clean way to get all prompts to properly align. The
1685 ipythonrc shipped with IPython has been updated.
1708 ipythonrc shipped with IPython has been updated.
1686
1709
1687 2004-06-07 Fernando Perez <fperez@colorado.edu>
1710 2004-06-07 Fernando Perez <fperez@colorado.edu>
1688
1711
1689 * setup.py (isfile): Pass local_icons option to latex2html, so the
1712 * setup.py (isfile): Pass local_icons option to latex2html, so the
1690 resulting HTML file is self-contained. Thanks to
1713 resulting HTML file is self-contained. Thanks to
1691 dryice-AT-liu.com.cn for the tip.
1714 dryice-AT-liu.com.cn for the tip.
1692
1715
1693 * pysh.py: I created a new profile 'shell', which implements a
1716 * pysh.py: I created a new profile 'shell', which implements a
1694 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1717 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1695 system shell, nor will it become one anytime soon. It's mainly
1718 system shell, nor will it become one anytime soon. It's mainly
1696 meant to illustrate the use of the new flexible bash-like prompts.
1719 meant to illustrate the use of the new flexible bash-like prompts.
1697 I guess it could be used by hardy souls for true shell management,
1720 I guess it could be used by hardy souls for true shell management,
1698 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1721 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1699 profile. This uses the InterpreterExec extension provided by
1722 profile. This uses the InterpreterExec extension provided by
1700 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1723 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1701
1724
1702 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1725 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1703 auto-align itself with the length of the previous input prompt
1726 auto-align itself with the length of the previous input prompt
1704 (taking into account the invisible color escapes).
1727 (taking into account the invisible color escapes).
1705 (CachedOutput.__init__): Large restructuring of this class. Now
1728 (CachedOutput.__init__): Large restructuring of this class. Now
1706 all three prompts (primary1, primary2, output) are proper objects,
1729 all three prompts (primary1, primary2, output) are proper objects,
1707 managed by the 'parent' CachedOutput class. The code is still a
1730 managed by the 'parent' CachedOutput class. The code is still a
1708 bit hackish (all prompts share state via a pointer to the cache),
1731 bit hackish (all prompts share state via a pointer to the cache),
1709 but it's overall far cleaner than before.
1732 but it's overall far cleaner than before.
1710
1733
1711 * IPython/genutils.py (getoutputerror): modified to add verbose,
1734 * IPython/genutils.py (getoutputerror): modified to add verbose,
1712 debug and header options. This makes the interface of all getout*
1735 debug and header options. This makes the interface of all getout*
1713 functions uniform.
1736 functions uniform.
1714 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1737 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1715
1738
1716 * IPython/Magic.py (Magic.default_option): added a function to
1739 * IPython/Magic.py (Magic.default_option): added a function to
1717 allow registering default options for any magic command. This
1740 allow registering default options for any magic command. This
1718 makes it easy to have profiles which customize the magics globally
1741 makes it easy to have profiles which customize the magics globally
1719 for a certain use. The values set through this function are
1742 for a certain use. The values set through this function are
1720 picked up by the parse_options() method, which all magics should
1743 picked up by the parse_options() method, which all magics should
1721 use to parse their options.
1744 use to parse their options.
1722
1745
1723 * IPython/genutils.py (warn): modified the warnings framework to
1746 * IPython/genutils.py (warn): modified the warnings framework to
1724 use the Term I/O class. I'm trying to slowly unify all of
1747 use the Term I/O class. I'm trying to slowly unify all of
1725 IPython's I/O operations to pass through Term.
1748 IPython's I/O operations to pass through Term.
1726
1749
1727 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1750 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1728 the secondary prompt to correctly match the length of the primary
1751 the secondary prompt to correctly match the length of the primary
1729 one for any prompt. Now multi-line code will properly line up
1752 one for any prompt. Now multi-line code will properly line up
1730 even for path dependent prompts, such as the new ones available
1753 even for path dependent prompts, such as the new ones available
1731 via the prompt_specials.
1754 via the prompt_specials.
1732
1755
1733 2004-06-06 Fernando Perez <fperez@colorado.edu>
1756 2004-06-06 Fernando Perez <fperez@colorado.edu>
1734
1757
1735 * IPython/Prompts.py (prompt_specials): Added the ability to have
1758 * IPython/Prompts.py (prompt_specials): Added the ability to have
1736 bash-like special sequences in the prompts, which get
1759 bash-like special sequences in the prompts, which get
1737 automatically expanded. Things like hostname, current working
1760 automatically expanded. Things like hostname, current working
1738 directory and username are implemented already, but it's easy to
1761 directory and username are implemented already, but it's easy to
1739 add more in the future. Thanks to a patch by W.J. van der Laan
1762 add more in the future. Thanks to a patch by W.J. van der Laan
1740 <gnufnork-AT-hetdigitalegat.nl>
1763 <gnufnork-AT-hetdigitalegat.nl>
1741 (prompt_specials): Added color support for prompt strings, so
1764 (prompt_specials): Added color support for prompt strings, so
1742 users can define arbitrary color setups for their prompts.
1765 users can define arbitrary color setups for their prompts.
1743
1766
1744 2004-06-05 Fernando Perez <fperez@colorado.edu>
1767 2004-06-05 Fernando Perez <fperez@colorado.edu>
1745
1768
1746 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1769 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1747 code to load Gary Bishop's readline and configure it
1770 code to load Gary Bishop's readline and configure it
1748 automatically. Thanks to Gary for help on this.
1771 automatically. Thanks to Gary for help on this.
1749
1772
1750 2004-06-01 Fernando Perez <fperez@colorado.edu>
1773 2004-06-01 Fernando Perez <fperez@colorado.edu>
1751
1774
1752 * IPython/Logger.py (Logger.create_log): fix bug for logging
1775 * IPython/Logger.py (Logger.create_log): fix bug for logging
1753 with no filename (previous fix was incomplete).
1776 with no filename (previous fix was incomplete).
1754
1777
1755 2004-05-25 Fernando Perez <fperez@colorado.edu>
1778 2004-05-25 Fernando Perez <fperez@colorado.edu>
1756
1779
1757 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1780 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1758 parens would get passed to the shell.
1781 parens would get passed to the shell.
1759
1782
1760 2004-05-20 Fernando Perez <fperez@colorado.edu>
1783 2004-05-20 Fernando Perez <fperez@colorado.edu>
1761
1784
1762 * IPython/Magic.py (Magic.magic_prun): changed default profile
1785 * IPython/Magic.py (Magic.magic_prun): changed default profile
1763 sort order to 'time' (the more common profiling need).
1786 sort order to 'time' (the more common profiling need).
1764
1787
1765 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1788 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1766 so that source code shown is guaranteed in sync with the file on
1789 so that source code shown is guaranteed in sync with the file on
1767 disk (also changed in psource). Similar fix to the one for
1790 disk (also changed in psource). Similar fix to the one for
1768 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1791 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1769 <yann.ledu-AT-noos.fr>.
1792 <yann.ledu-AT-noos.fr>.
1770
1793
1771 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1794 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1772 with a single option would not be correctly parsed. Closes
1795 with a single option would not be correctly parsed. Closes
1773 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1796 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1774 introduced in 0.6.0 (on 2004-05-06).
1797 introduced in 0.6.0 (on 2004-05-06).
1775
1798
1776 2004-05-13 *** Released version 0.6.0
1799 2004-05-13 *** Released version 0.6.0
1777
1800
1778 2004-05-13 Fernando Perez <fperez@colorado.edu>
1801 2004-05-13 Fernando Perez <fperez@colorado.edu>
1779
1802
1780 * debian/: Added debian/ directory to CVS, so that debian support
1803 * debian/: Added debian/ directory to CVS, so that debian support
1781 is publicly accessible. The debian package is maintained by Jack
1804 is publicly accessible. The debian package is maintained by Jack
1782 Moffit <jack-AT-xiph.org>.
1805 Moffit <jack-AT-xiph.org>.
1783
1806
1784 * Documentation: included the notes about an ipython-based system
1807 * Documentation: included the notes about an ipython-based system
1785 shell (the hypothetical 'pysh') into the new_design.pdf document,
1808 shell (the hypothetical 'pysh') into the new_design.pdf document,
1786 so that these ideas get distributed to users along with the
1809 so that these ideas get distributed to users along with the
1787 official documentation.
1810 official documentation.
1788
1811
1789 2004-05-10 Fernando Perez <fperez@colorado.edu>
1812 2004-05-10 Fernando Perez <fperez@colorado.edu>
1790
1813
1791 * IPython/Logger.py (Logger.create_log): fix recently introduced
1814 * IPython/Logger.py (Logger.create_log): fix recently introduced
1792 bug (misindented line) where logstart would fail when not given an
1815 bug (misindented line) where logstart would fail when not given an
1793 explicit filename.
1816 explicit filename.
1794
1817
1795 2004-05-09 Fernando Perez <fperez@colorado.edu>
1818 2004-05-09 Fernando Perez <fperez@colorado.edu>
1796
1819
1797 * IPython/Magic.py (Magic.parse_options): skip system call when
1820 * IPython/Magic.py (Magic.parse_options): skip system call when
1798 there are no options to look for. Faster, cleaner for the common
1821 there are no options to look for. Faster, cleaner for the common
1799 case.
1822 case.
1800
1823
1801 * Documentation: many updates to the manual: describing Windows
1824 * Documentation: many updates to the manual: describing Windows
1802 support better, Gnuplot updates, credits, misc small stuff. Also
1825 support better, Gnuplot updates, credits, misc small stuff. Also
1803 updated the new_design doc a bit.
1826 updated the new_design doc a bit.
1804
1827
1805 2004-05-06 *** Released version 0.6.0.rc1
1828 2004-05-06 *** Released version 0.6.0.rc1
1806
1829
1807 2004-05-06 Fernando Perez <fperez@colorado.edu>
1830 2004-05-06 Fernando Perez <fperez@colorado.edu>
1808
1831
1809 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1832 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1810 operations to use the vastly more efficient list/''.join() method.
1833 operations to use the vastly more efficient list/''.join() method.
1811 (FormattedTB.text): Fix
1834 (FormattedTB.text): Fix
1812 http://www.scipy.net/roundup/ipython/issue12 - exception source
1835 http://www.scipy.net/roundup/ipython/issue12 - exception source
1813 extract not updated after reload. Thanks to Mike Salib
1836 extract not updated after reload. Thanks to Mike Salib
1814 <msalib-AT-mit.edu> for pinning the source of the problem.
1837 <msalib-AT-mit.edu> for pinning the source of the problem.
1815 Fortunately, the solution works inside ipython and doesn't require
1838 Fortunately, the solution works inside ipython and doesn't require
1816 any changes to python proper.
1839 any changes to python proper.
1817
1840
1818 * IPython/Magic.py (Magic.parse_options): Improved to process the
1841 * IPython/Magic.py (Magic.parse_options): Improved to process the
1819 argument list as a true shell would (by actually using the
1842 argument list as a true shell would (by actually using the
1820 underlying system shell). This way, all @magics automatically get
1843 underlying system shell). This way, all @magics automatically get
1821 shell expansion for variables. Thanks to a comment by Alex
1844 shell expansion for variables. Thanks to a comment by Alex
1822 Schmolck.
1845 Schmolck.
1823
1846
1824 2004-04-04 Fernando Perez <fperez@colorado.edu>
1847 2004-04-04 Fernando Perez <fperez@colorado.edu>
1825
1848
1826 * IPython/iplib.py (InteractiveShell.interact): Added a special
1849 * IPython/iplib.py (InteractiveShell.interact): Added a special
1827 trap for a debugger quit exception, which is basically impossible
1850 trap for a debugger quit exception, which is basically impossible
1828 to handle by normal mechanisms, given what pdb does to the stack.
1851 to handle by normal mechanisms, given what pdb does to the stack.
1829 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1852 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1830
1853
1831 2004-04-03 Fernando Perez <fperez@colorado.edu>
1854 2004-04-03 Fernando Perez <fperez@colorado.edu>
1832
1855
1833 * IPython/genutils.py (Term): Standardized the names of the Term
1856 * IPython/genutils.py (Term): Standardized the names of the Term
1834 class streams to cin/cout/cerr, following C++ naming conventions
1857 class streams to cin/cout/cerr, following C++ naming conventions
1835 (I can't use in/out/err because 'in' is not a valid attribute
1858 (I can't use in/out/err because 'in' is not a valid attribute
1836 name).
1859 name).
1837
1860
1838 * IPython/iplib.py (InteractiveShell.interact): don't increment
1861 * IPython/iplib.py (InteractiveShell.interact): don't increment
1839 the prompt if there's no user input. By Daniel 'Dang' Griffith
1862 the prompt if there's no user input. By Daniel 'Dang' Griffith
1840 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1863 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1841 Francois Pinard.
1864 Francois Pinard.
1842
1865
1843 2004-04-02 Fernando Perez <fperez@colorado.edu>
1866 2004-04-02 Fernando Perez <fperez@colorado.edu>
1844
1867
1845 * IPython/genutils.py (Stream.__init__): Modified to survive at
1868 * IPython/genutils.py (Stream.__init__): Modified to survive at
1846 least importing in contexts where stdin/out/err aren't true file
1869 least importing in contexts where stdin/out/err aren't true file
1847 objects, such as PyCrust (they lack fileno() and mode). However,
1870 objects, such as PyCrust (they lack fileno() and mode). However,
1848 the recovery facilities which rely on these things existing will
1871 the recovery facilities which rely on these things existing will
1849 not work.
1872 not work.
1850
1873
1851 2004-04-01 Fernando Perez <fperez@colorado.edu>
1874 2004-04-01 Fernando Perez <fperez@colorado.edu>
1852
1875
1853 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1876 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1854 use the new getoutputerror() function, so it properly
1877 use the new getoutputerror() function, so it properly
1855 distinguishes stdout/err.
1878 distinguishes stdout/err.
1856
1879
1857 * IPython/genutils.py (getoutputerror): added a function to
1880 * IPython/genutils.py (getoutputerror): added a function to
1858 capture separately the standard output and error of a command.
1881 capture separately the standard output and error of a command.
1859 After a comment from dang on the mailing lists. This code is
1882 After a comment from dang on the mailing lists. This code is
1860 basically a modified version of commands.getstatusoutput(), from
1883 basically a modified version of commands.getstatusoutput(), from
1861 the standard library.
1884 the standard library.
1862
1885
1863 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1886 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1864 '!!' as a special syntax (shorthand) to access @sx.
1887 '!!' as a special syntax (shorthand) to access @sx.
1865
1888
1866 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1889 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1867 command and return its output as a list split on '\n'.
1890 command and return its output as a list split on '\n'.
1868
1891
1869 2004-03-31 Fernando Perez <fperez@colorado.edu>
1892 2004-03-31 Fernando Perez <fperez@colorado.edu>
1870
1893
1871 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1894 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1872 method to dictionaries used as FakeModule instances if they lack
1895 method to dictionaries used as FakeModule instances if they lack
1873 it. At least pydoc in python2.3 breaks for runtime-defined
1896 it. At least pydoc in python2.3 breaks for runtime-defined
1874 functions without this hack. At some point I need to _really_
1897 functions without this hack. At some point I need to _really_
1875 understand what FakeModule is doing, because it's a gross hack.
1898 understand what FakeModule is doing, because it's a gross hack.
1876 But it solves Arnd's problem for now...
1899 But it solves Arnd's problem for now...
1877
1900
1878 2004-02-27 Fernando Perez <fperez@colorado.edu>
1901 2004-02-27 Fernando Perez <fperez@colorado.edu>
1879
1902
1880 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1903 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1881 mode would behave erratically. Also increased the number of
1904 mode would behave erratically. Also increased the number of
1882 possible logs in rotate mod to 999. Thanks to Rod Holland
1905 possible logs in rotate mod to 999. Thanks to Rod Holland
1883 <rhh@StructureLABS.com> for the report and fixes.
1906 <rhh@StructureLABS.com> for the report and fixes.
1884
1907
1885 2004-02-26 Fernando Perez <fperez@colorado.edu>
1908 2004-02-26 Fernando Perez <fperez@colorado.edu>
1886
1909
1887 * IPython/genutils.py (page): Check that the curses module really
1910 * IPython/genutils.py (page): Check that the curses module really
1888 has the initscr attribute before trying to use it. For some
1911 has the initscr attribute before trying to use it. For some
1889 reason, the Solaris curses module is missing this. I think this
1912 reason, the Solaris curses module is missing this. I think this
1890 should be considered a Solaris python bug, but I'm not sure.
1913 should be considered a Solaris python bug, but I'm not sure.
1891
1914
1892 2004-01-17 Fernando Perez <fperez@colorado.edu>
1915 2004-01-17 Fernando Perez <fperez@colorado.edu>
1893
1916
1894 * IPython/genutils.py (Stream.__init__): Changes to try to make
1917 * IPython/genutils.py (Stream.__init__): Changes to try to make
1895 ipython robust against stdin/out/err being closed by the user.
1918 ipython robust against stdin/out/err being closed by the user.
1896 This is 'user error' (and blocks a normal python session, at least
1919 This is 'user error' (and blocks a normal python session, at least
1897 the stdout case). However, Ipython should be able to survive such
1920 the stdout case). However, Ipython should be able to survive such
1898 instances of abuse as gracefully as possible. To simplify the
1921 instances of abuse as gracefully as possible. To simplify the
1899 coding and maintain compatibility with Gary Bishop's Term
1922 coding and maintain compatibility with Gary Bishop's Term
1900 contributions, I've made use of classmethods for this. I think
1923 contributions, I've made use of classmethods for this. I think
1901 this introduces a dependency on python 2.2.
1924 this introduces a dependency on python 2.2.
1902
1925
1903 2004-01-13 Fernando Perez <fperez@colorado.edu>
1926 2004-01-13 Fernando Perez <fperez@colorado.edu>
1904
1927
1905 * IPython/numutils.py (exp_safe): simplified the code a bit and
1928 * IPython/numutils.py (exp_safe): simplified the code a bit and
1906 removed the need for importing the kinds module altogether.
1929 removed the need for importing the kinds module altogether.
1907
1930
1908 2004-01-06 Fernando Perez <fperez@colorado.edu>
1931 2004-01-06 Fernando Perez <fperez@colorado.edu>
1909
1932
1910 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
1933 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
1911 a magic function instead, after some community feedback. No
1934 a magic function instead, after some community feedback. No
1912 special syntax will exist for it, but its name is deliberately
1935 special syntax will exist for it, but its name is deliberately
1913 very short.
1936 very short.
1914
1937
1915 2003-12-20 Fernando Perez <fperez@colorado.edu>
1938 2003-12-20 Fernando Perez <fperez@colorado.edu>
1916
1939
1917 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
1940 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
1918 new functionality, to automagically assign the result of a shell
1941 new functionality, to automagically assign the result of a shell
1919 command to a variable. I'll solicit some community feedback on
1942 command to a variable. I'll solicit some community feedback on
1920 this before making it permanent.
1943 this before making it permanent.
1921
1944
1922 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
1945 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
1923 requested about callables for which inspect couldn't obtain a
1946 requested about callables for which inspect couldn't obtain a
1924 proper argspec. Thanks to a crash report sent by Etienne
1947 proper argspec. Thanks to a crash report sent by Etienne
1925 Posthumus <etienne-AT-apple01.cs.vu.nl>.
1948 Posthumus <etienne-AT-apple01.cs.vu.nl>.
1926
1949
1927 2003-12-09 Fernando Perez <fperez@colorado.edu>
1950 2003-12-09 Fernando Perez <fperez@colorado.edu>
1928
1951
1929 * IPython/genutils.py (page): patch for the pager to work across
1952 * IPython/genutils.py (page): patch for the pager to work across
1930 various versions of Windows. By Gary Bishop.
1953 various versions of Windows. By Gary Bishop.
1931
1954
1932 2003-12-04 Fernando Perez <fperez@colorado.edu>
1955 2003-12-04 Fernando Perez <fperez@colorado.edu>
1933
1956
1934 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
1957 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
1935 Gnuplot.py version 1.7, whose internal names changed quite a bit.
1958 Gnuplot.py version 1.7, whose internal names changed quite a bit.
1936 While I tested this and it looks ok, there may still be corner
1959 While I tested this and it looks ok, there may still be corner
1937 cases I've missed.
1960 cases I've missed.
1938
1961
1939 2003-12-01 Fernando Perez <fperez@colorado.edu>
1962 2003-12-01 Fernando Perez <fperez@colorado.edu>
1940
1963
1941 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
1964 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
1942 where a line like 'p,q=1,2' would fail because the automagic
1965 where a line like 'p,q=1,2' would fail because the automagic
1943 system would be triggered for @p.
1966 system would be triggered for @p.
1944
1967
1945 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
1968 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
1946 cleanups, code unmodified.
1969 cleanups, code unmodified.
1947
1970
1948 * IPython/genutils.py (Term): added a class for IPython to handle
1971 * IPython/genutils.py (Term): added a class for IPython to handle
1949 output. In most cases it will just be a proxy for stdout/err, but
1972 output. In most cases it will just be a proxy for stdout/err, but
1950 having this allows modifications to be made for some platforms,
1973 having this allows modifications to be made for some platforms,
1951 such as handling color escapes under Windows. All of this code
1974 such as handling color escapes under Windows. All of this code
1952 was contributed by Gary Bishop, with minor modifications by me.
1975 was contributed by Gary Bishop, with minor modifications by me.
1953 The actual changes affect many files.
1976 The actual changes affect many files.
1954
1977
1955 2003-11-30 Fernando Perez <fperez@colorado.edu>
1978 2003-11-30 Fernando Perez <fperez@colorado.edu>
1956
1979
1957 * IPython/iplib.py (file_matches): new completion code, courtesy
1980 * IPython/iplib.py (file_matches): new completion code, courtesy
1958 of Jeff Collins. This enables filename completion again under
1981 of Jeff Collins. This enables filename completion again under
1959 python 2.3, which disabled it at the C level.
1982 python 2.3, which disabled it at the C level.
1960
1983
1961 2003-11-11 Fernando Perez <fperez@colorado.edu>
1984 2003-11-11 Fernando Perez <fperez@colorado.edu>
1962
1985
1963 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
1986 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
1964 for Numeric.array(map(...)), but often convenient.
1987 for Numeric.array(map(...)), but often convenient.
1965
1988
1966 2003-11-05 Fernando Perez <fperez@colorado.edu>
1989 2003-11-05 Fernando Perez <fperez@colorado.edu>
1967
1990
1968 * IPython/numutils.py (frange): Changed a call from int() to
1991 * IPython/numutils.py (frange): Changed a call from int() to
1969 int(round()) to prevent a problem reported with arange() in the
1992 int(round()) to prevent a problem reported with arange() in the
1970 numpy list.
1993 numpy list.
1971
1994
1972 2003-10-06 Fernando Perez <fperez@colorado.edu>
1995 2003-10-06 Fernando Perez <fperez@colorado.edu>
1973
1996
1974 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
1997 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
1975 prevent crashes if sys lacks an argv attribute (it happens with
1998 prevent crashes if sys lacks an argv attribute (it happens with
1976 embedded interpreters which build a bare-bones sys module).
1999 embedded interpreters which build a bare-bones sys module).
1977 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2000 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
1978
2001
1979 2003-09-24 Fernando Perez <fperez@colorado.edu>
2002 2003-09-24 Fernando Perez <fperez@colorado.edu>
1980
2003
1981 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2004 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
1982 to protect against poorly written user objects where __getattr__
2005 to protect against poorly written user objects where __getattr__
1983 raises exceptions other than AttributeError. Thanks to a bug
2006 raises exceptions other than AttributeError. Thanks to a bug
1984 report by Oliver Sander <osander-AT-gmx.de>.
2007 report by Oliver Sander <osander-AT-gmx.de>.
1985
2008
1986 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2009 * IPython/FakeModule.py (FakeModule.__repr__): this method was
1987 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2010 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
1988
2011
1989 2003-09-09 Fernando Perez <fperez@colorado.edu>
2012 2003-09-09 Fernando Perez <fperez@colorado.edu>
1990
2013
1991 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2014 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1992 unpacking a list whith a callable as first element would
2015 unpacking a list whith a callable as first element would
1993 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2016 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
1994 Collins.
2017 Collins.
1995
2018
1996 2003-08-25 *** Released version 0.5.0
2019 2003-08-25 *** Released version 0.5.0
1997
2020
1998 2003-08-22 Fernando Perez <fperez@colorado.edu>
2021 2003-08-22 Fernando Perez <fperez@colorado.edu>
1999
2022
2000 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2023 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2001 improperly defined user exceptions. Thanks to feedback from Mark
2024 improperly defined user exceptions. Thanks to feedback from Mark
2002 Russell <mrussell-AT-verio.net>.
2025 Russell <mrussell-AT-verio.net>.
2003
2026
2004 2003-08-20 Fernando Perez <fperez@colorado.edu>
2027 2003-08-20 Fernando Perez <fperez@colorado.edu>
2005
2028
2006 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2029 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2007 printing so that it would print multi-line string forms starting
2030 printing so that it would print multi-line string forms starting
2008 with a new line. This way the formatting is better respected for
2031 with a new line. This way the formatting is better respected for
2009 objects which work hard to make nice string forms.
2032 objects which work hard to make nice string forms.
2010
2033
2011 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2034 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2012 autocall would overtake data access for objects with both
2035 autocall would overtake data access for objects with both
2013 __getitem__ and __call__.
2036 __getitem__ and __call__.
2014
2037
2015 2003-08-19 *** Released version 0.5.0-rc1
2038 2003-08-19 *** Released version 0.5.0-rc1
2016
2039
2017 2003-08-19 Fernando Perez <fperez@colorado.edu>
2040 2003-08-19 Fernando Perez <fperez@colorado.edu>
2018
2041
2019 * IPython/deep_reload.py (load_tail): single tiny change here
2042 * IPython/deep_reload.py (load_tail): single tiny change here
2020 seems to fix the long-standing bug of dreload() failing to work
2043 seems to fix the long-standing bug of dreload() failing to work
2021 for dotted names. But this module is pretty tricky, so I may have
2044 for dotted names. But this module is pretty tricky, so I may have
2022 missed some subtlety. Needs more testing!.
2045 missed some subtlety. Needs more testing!.
2023
2046
2024 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2047 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2025 exceptions which have badly implemented __str__ methods.
2048 exceptions which have badly implemented __str__ methods.
2026 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2049 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2027 which I've been getting reports about from Python 2.3 users. I
2050 which I've been getting reports about from Python 2.3 users. I
2028 wish I had a simple test case to reproduce the problem, so I could
2051 wish I had a simple test case to reproduce the problem, so I could
2029 either write a cleaner workaround or file a bug report if
2052 either write a cleaner workaround or file a bug report if
2030 necessary.
2053 necessary.
2031
2054
2032 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2055 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2033 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2056 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2034 a bug report by Tjabo Kloppenburg.
2057 a bug report by Tjabo Kloppenburg.
2035
2058
2036 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2059 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2037 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2060 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2038 seems rather unstable. Thanks to a bug report by Tjabo
2061 seems rather unstable. Thanks to a bug report by Tjabo
2039 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2062 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2040
2063
2041 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2064 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2042 this out soon because of the critical fixes in the inner loop for
2065 this out soon because of the critical fixes in the inner loop for
2043 generators.
2066 generators.
2044
2067
2045 * IPython/Magic.py (Magic.getargspec): removed. This (and
2068 * IPython/Magic.py (Magic.getargspec): removed. This (and
2046 _get_def) have been obsoleted by OInspect for a long time, I
2069 _get_def) have been obsoleted by OInspect for a long time, I
2047 hadn't noticed that they were dead code.
2070 hadn't noticed that they were dead code.
2048 (Magic._ofind): restored _ofind functionality for a few literals
2071 (Magic._ofind): restored _ofind functionality for a few literals
2049 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2072 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2050 for things like "hello".capitalize?, since that would require a
2073 for things like "hello".capitalize?, since that would require a
2051 potentially dangerous eval() again.
2074 potentially dangerous eval() again.
2052
2075
2053 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2076 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2054 logic a bit more to clean up the escapes handling and minimize the
2077 logic a bit more to clean up the escapes handling and minimize the
2055 use of _ofind to only necessary cases. The interactive 'feel' of
2078 use of _ofind to only necessary cases. The interactive 'feel' of
2056 IPython should have improved quite a bit with the changes in
2079 IPython should have improved quite a bit with the changes in
2057 _prefilter and _ofind (besides being far safer than before).
2080 _prefilter and _ofind (besides being far safer than before).
2058
2081
2059 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2082 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2060 obscure, never reported). Edit would fail to find the object to
2083 obscure, never reported). Edit would fail to find the object to
2061 edit under some circumstances.
2084 edit under some circumstances.
2062 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2085 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2063 which were causing double-calling of generators. Those eval calls
2086 which were causing double-calling of generators. Those eval calls
2064 were _very_ dangerous, since code with side effects could be
2087 were _very_ dangerous, since code with side effects could be
2065 triggered. As they say, 'eval is evil'... These were the
2088 triggered. As they say, 'eval is evil'... These were the
2066 nastiest evals in IPython. Besides, _ofind is now far simpler,
2089 nastiest evals in IPython. Besides, _ofind is now far simpler,
2067 and it should also be quite a bit faster. Its use of inspect is
2090 and it should also be quite a bit faster. Its use of inspect is
2068 also safer, so perhaps some of the inspect-related crashes I've
2091 also safer, so perhaps some of the inspect-related crashes I've
2069 seen lately with Python 2.3 might be taken care of. That will
2092 seen lately with Python 2.3 might be taken care of. That will
2070 need more testing.
2093 need more testing.
2071
2094
2072 2003-08-17 Fernando Perez <fperez@colorado.edu>
2095 2003-08-17 Fernando Perez <fperez@colorado.edu>
2073
2096
2074 * IPython/iplib.py (InteractiveShell._prefilter): significant
2097 * IPython/iplib.py (InteractiveShell._prefilter): significant
2075 simplifications to the logic for handling user escapes. Faster
2098 simplifications to the logic for handling user escapes. Faster
2076 and simpler code.
2099 and simpler code.
2077
2100
2078 2003-08-14 Fernando Perez <fperez@colorado.edu>
2101 2003-08-14 Fernando Perez <fperez@colorado.edu>
2079
2102
2080 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2103 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2081 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2104 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2082 but it should be quite a bit faster. And the recursive version
2105 but it should be quite a bit faster. And the recursive version
2083 generated O(log N) intermediate storage for all rank>1 arrays,
2106 generated O(log N) intermediate storage for all rank>1 arrays,
2084 even if they were contiguous.
2107 even if they were contiguous.
2085 (l1norm): Added this function.
2108 (l1norm): Added this function.
2086 (norm): Added this function for arbitrary norms (including
2109 (norm): Added this function for arbitrary norms (including
2087 l-infinity). l1 and l2 are still special cases for convenience
2110 l-infinity). l1 and l2 are still special cases for convenience
2088 and speed.
2111 and speed.
2089
2112
2090 2003-08-03 Fernando Perez <fperez@colorado.edu>
2113 2003-08-03 Fernando Perez <fperez@colorado.edu>
2091
2114
2092 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2115 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2093 exceptions, which now raise PendingDeprecationWarnings in Python
2116 exceptions, which now raise PendingDeprecationWarnings in Python
2094 2.3. There were some in Magic and some in Gnuplot2.
2117 2.3. There were some in Magic and some in Gnuplot2.
2095
2118
2096 2003-06-30 Fernando Perez <fperez@colorado.edu>
2119 2003-06-30 Fernando Perez <fperez@colorado.edu>
2097
2120
2098 * IPython/genutils.py (page): modified to call curses only for
2121 * IPython/genutils.py (page): modified to call curses only for
2099 terminals where TERM=='xterm'. After problems under many other
2122 terminals where TERM=='xterm'. After problems under many other
2100 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2123 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2101
2124
2102 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2125 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2103 would be triggered when readline was absent. This was just an old
2126 would be triggered when readline was absent. This was just an old
2104 debugging statement I'd forgotten to take out.
2127 debugging statement I'd forgotten to take out.
2105
2128
2106 2003-06-20 Fernando Perez <fperez@colorado.edu>
2129 2003-06-20 Fernando Perez <fperez@colorado.edu>
2107
2130
2108 * IPython/genutils.py (clock): modified to return only user time
2131 * IPython/genutils.py (clock): modified to return only user time
2109 (not counting system time), after a discussion on scipy. While
2132 (not counting system time), after a discussion on scipy. While
2110 system time may be a useful quantity occasionally, it may much
2133 system time may be a useful quantity occasionally, it may much
2111 more easily be skewed by occasional swapping or other similar
2134 more easily be skewed by occasional swapping or other similar
2112 activity.
2135 activity.
2113
2136
2114 2003-06-05 Fernando Perez <fperez@colorado.edu>
2137 2003-06-05 Fernando Perez <fperez@colorado.edu>
2115
2138
2116 * IPython/numutils.py (identity): new function, for building
2139 * IPython/numutils.py (identity): new function, for building
2117 arbitrary rank Kronecker deltas (mostly backwards compatible with
2140 arbitrary rank Kronecker deltas (mostly backwards compatible with
2118 Numeric.identity)
2141 Numeric.identity)
2119
2142
2120 2003-06-03 Fernando Perez <fperez@colorado.edu>
2143 2003-06-03 Fernando Perez <fperez@colorado.edu>
2121
2144
2122 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2145 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2123 arguments passed to magics with spaces, to allow trailing '\' to
2146 arguments passed to magics with spaces, to allow trailing '\' to
2124 work normally (mainly for Windows users).
2147 work normally (mainly for Windows users).
2125
2148
2126 2003-05-29 Fernando Perez <fperez@colorado.edu>
2149 2003-05-29 Fernando Perez <fperez@colorado.edu>
2127
2150
2128 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2151 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2129 instead of pydoc.help. This fixes a bizarre behavior where
2152 instead of pydoc.help. This fixes a bizarre behavior where
2130 printing '%s' % locals() would trigger the help system. Now
2153 printing '%s' % locals() would trigger the help system. Now
2131 ipython behaves like normal python does.
2154 ipython behaves like normal python does.
2132
2155
2133 Note that if one does 'from pydoc import help', the bizarre
2156 Note that if one does 'from pydoc import help', the bizarre
2134 behavior returns, but this will also happen in normal python, so
2157 behavior returns, but this will also happen in normal python, so
2135 it's not an ipython bug anymore (it has to do with how pydoc.help
2158 it's not an ipython bug anymore (it has to do with how pydoc.help
2136 is implemented).
2159 is implemented).
2137
2160
2138 2003-05-22 Fernando Perez <fperez@colorado.edu>
2161 2003-05-22 Fernando Perez <fperez@colorado.edu>
2139
2162
2140 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2163 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2141 return [] instead of None when nothing matches, also match to end
2164 return [] instead of None when nothing matches, also match to end
2142 of line. Patch by Gary Bishop.
2165 of line. Patch by Gary Bishop.
2143
2166
2144 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2167 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2145 protection as before, for files passed on the command line. This
2168 protection as before, for files passed on the command line. This
2146 prevents the CrashHandler from kicking in if user files call into
2169 prevents the CrashHandler from kicking in if user files call into
2147 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2170 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2148 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2171 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2149
2172
2150 2003-05-20 *** Released version 0.4.0
2173 2003-05-20 *** Released version 0.4.0
2151
2174
2152 2003-05-20 Fernando Perez <fperez@colorado.edu>
2175 2003-05-20 Fernando Perez <fperez@colorado.edu>
2153
2176
2154 * setup.py: added support for manpages. It's a bit hackish b/c of
2177 * setup.py: added support for manpages. It's a bit hackish b/c of
2155 a bug in the way the bdist_rpm distutils target handles gzipped
2178 a bug in the way the bdist_rpm distutils target handles gzipped
2156 manpages, but it works. After a patch by Jack.
2179 manpages, but it works. After a patch by Jack.
2157
2180
2158 2003-05-19 Fernando Perez <fperez@colorado.edu>
2181 2003-05-19 Fernando Perez <fperez@colorado.edu>
2159
2182
2160 * IPython/numutils.py: added a mockup of the kinds module, since
2183 * IPython/numutils.py: added a mockup of the kinds module, since
2161 it was recently removed from Numeric. This way, numutils will
2184 it was recently removed from Numeric. This way, numutils will
2162 work for all users even if they are missing kinds.
2185 work for all users even if they are missing kinds.
2163
2186
2164 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2187 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2165 failure, which can occur with SWIG-wrapped extensions. After a
2188 failure, which can occur with SWIG-wrapped extensions. After a
2166 crash report from Prabhu.
2189 crash report from Prabhu.
2167
2190
2168 2003-05-16 Fernando Perez <fperez@colorado.edu>
2191 2003-05-16 Fernando Perez <fperez@colorado.edu>
2169
2192
2170 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2193 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2171 protect ipython from user code which may call directly
2194 protect ipython from user code which may call directly
2172 sys.excepthook (this looks like an ipython crash to the user, even
2195 sys.excepthook (this looks like an ipython crash to the user, even
2173 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2196 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2174 This is especially important to help users of WxWindows, but may
2197 This is especially important to help users of WxWindows, but may
2175 also be useful in other cases.
2198 also be useful in other cases.
2176
2199
2177 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2200 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2178 an optional tb_offset to be specified, and to preserve exception
2201 an optional tb_offset to be specified, and to preserve exception
2179 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2202 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2180
2203
2181 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2204 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2182
2205
2183 2003-05-15 Fernando Perez <fperez@colorado.edu>
2206 2003-05-15 Fernando Perez <fperez@colorado.edu>
2184
2207
2185 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2208 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2186 installing for a new user under Windows.
2209 installing for a new user under Windows.
2187
2210
2188 2003-05-12 Fernando Perez <fperez@colorado.edu>
2211 2003-05-12 Fernando Perez <fperez@colorado.edu>
2189
2212
2190 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2213 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2191 handler for Emacs comint-based lines. Currently it doesn't do
2214 handler for Emacs comint-based lines. Currently it doesn't do
2192 much (but importantly, it doesn't update the history cache). In
2215 much (but importantly, it doesn't update the history cache). In
2193 the future it may be expanded if Alex needs more functionality
2216 the future it may be expanded if Alex needs more functionality
2194 there.
2217 there.
2195
2218
2196 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2219 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2197 info to crash reports.
2220 info to crash reports.
2198
2221
2199 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2222 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2200 just like Python's -c. Also fixed crash with invalid -color
2223 just like Python's -c. Also fixed crash with invalid -color
2201 option value at startup. Thanks to Will French
2224 option value at startup. Thanks to Will French
2202 <wfrench-AT-bestweb.net> for the bug report.
2225 <wfrench-AT-bestweb.net> for the bug report.
2203
2226
2204 2003-05-09 Fernando Perez <fperez@colorado.edu>
2227 2003-05-09 Fernando Perez <fperez@colorado.edu>
2205
2228
2206 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2229 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2207 to EvalDict (it's a mapping, after all) and simplified its code
2230 to EvalDict (it's a mapping, after all) and simplified its code
2208 quite a bit, after a nice discussion on c.l.py where Gustavo
2231 quite a bit, after a nice discussion on c.l.py where Gustavo
2209 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2232 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2210
2233
2211 2003-04-30 Fernando Perez <fperez@colorado.edu>
2234 2003-04-30 Fernando Perez <fperez@colorado.edu>
2212
2235
2213 * IPython/genutils.py (timings_out): modified it to reduce its
2236 * IPython/genutils.py (timings_out): modified it to reduce its
2214 overhead in the common reps==1 case.
2237 overhead in the common reps==1 case.
2215
2238
2216 2003-04-29 Fernando Perez <fperez@colorado.edu>
2239 2003-04-29 Fernando Perez <fperez@colorado.edu>
2217
2240
2218 * IPython/genutils.py (timings_out): Modified to use the resource
2241 * IPython/genutils.py (timings_out): Modified to use the resource
2219 module, which avoids the wraparound problems of time.clock().
2242 module, which avoids the wraparound problems of time.clock().
2220
2243
2221 2003-04-17 *** Released version 0.2.15pre4
2244 2003-04-17 *** Released version 0.2.15pre4
2222
2245
2223 2003-04-17 Fernando Perez <fperez@colorado.edu>
2246 2003-04-17 Fernando Perez <fperez@colorado.edu>
2224
2247
2225 * setup.py (scriptfiles): Split windows-specific stuff over to a
2248 * setup.py (scriptfiles): Split windows-specific stuff over to a
2226 separate file, in an attempt to have a Windows GUI installer.
2249 separate file, in an attempt to have a Windows GUI installer.
2227 That didn't work, but part of the groundwork is done.
2250 That didn't work, but part of the groundwork is done.
2228
2251
2229 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2252 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2230 indent/unindent with 4 spaces. Particularly useful in combination
2253 indent/unindent with 4 spaces. Particularly useful in combination
2231 with the new auto-indent option.
2254 with the new auto-indent option.
2232
2255
2233 2003-04-16 Fernando Perez <fperez@colorado.edu>
2256 2003-04-16 Fernando Perez <fperez@colorado.edu>
2234
2257
2235 * IPython/Magic.py: various replacements of self.rc for
2258 * IPython/Magic.py: various replacements of self.rc for
2236 self.shell.rc. A lot more remains to be done to fully disentangle
2259 self.shell.rc. A lot more remains to be done to fully disentangle
2237 this class from the main Shell class.
2260 this class from the main Shell class.
2238
2261
2239 * IPython/GnuplotRuntime.py: added checks for mouse support so
2262 * IPython/GnuplotRuntime.py: added checks for mouse support so
2240 that we don't try to enable it if the current gnuplot doesn't
2263 that we don't try to enable it if the current gnuplot doesn't
2241 really support it. Also added checks so that we don't try to
2264 really support it. Also added checks so that we don't try to
2242 enable persist under Windows (where Gnuplot doesn't recognize the
2265 enable persist under Windows (where Gnuplot doesn't recognize the
2243 option).
2266 option).
2244
2267
2245 * IPython/iplib.py (InteractiveShell.interact): Added optional
2268 * IPython/iplib.py (InteractiveShell.interact): Added optional
2246 auto-indenting code, after a patch by King C. Shu
2269 auto-indenting code, after a patch by King C. Shu
2247 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2270 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2248 get along well with pasting indented code. If I ever figure out
2271 get along well with pasting indented code. If I ever figure out
2249 how to make that part go well, it will become on by default.
2272 how to make that part go well, it will become on by default.
2250
2273
2251 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2274 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2252 crash ipython if there was an unmatched '%' in the user's prompt
2275 crash ipython if there was an unmatched '%' in the user's prompt
2253 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2276 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2254
2277
2255 * IPython/iplib.py (InteractiveShell.interact): removed the
2278 * IPython/iplib.py (InteractiveShell.interact): removed the
2256 ability to ask the user whether he wants to crash or not at the
2279 ability to ask the user whether he wants to crash or not at the
2257 'last line' exception handler. Calling functions at that point
2280 'last line' exception handler. Calling functions at that point
2258 changes the stack, and the error reports would have incorrect
2281 changes the stack, and the error reports would have incorrect
2259 tracebacks.
2282 tracebacks.
2260
2283
2261 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2284 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2262 pass through a peger a pretty-printed form of any object. After a
2285 pass through a peger a pretty-printed form of any object. After a
2263 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2286 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2264
2287
2265 2003-04-14 Fernando Perez <fperez@colorado.edu>
2288 2003-04-14 Fernando Perez <fperez@colorado.edu>
2266
2289
2267 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2290 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2268 all files in ~ would be modified at first install (instead of
2291 all files in ~ would be modified at first install (instead of
2269 ~/.ipython). This could be potentially disastrous, as the
2292 ~/.ipython). This could be potentially disastrous, as the
2270 modification (make line-endings native) could damage binary files.
2293 modification (make line-endings native) could damage binary files.
2271
2294
2272 2003-04-10 Fernando Perez <fperez@colorado.edu>
2295 2003-04-10 Fernando Perez <fperez@colorado.edu>
2273
2296
2274 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2297 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2275 handle only lines which are invalid python. This now means that
2298 handle only lines which are invalid python. This now means that
2276 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2299 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2277 for the bug report.
2300 for the bug report.
2278
2301
2279 2003-04-01 Fernando Perez <fperez@colorado.edu>
2302 2003-04-01 Fernando Perez <fperez@colorado.edu>
2280
2303
2281 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2304 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2282 where failing to set sys.last_traceback would crash pdb.pm().
2305 where failing to set sys.last_traceback would crash pdb.pm().
2283 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2306 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2284 report.
2307 report.
2285
2308
2286 2003-03-25 Fernando Perez <fperez@colorado.edu>
2309 2003-03-25 Fernando Perez <fperez@colorado.edu>
2287
2310
2288 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2311 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2289 before printing it (it had a lot of spurious blank lines at the
2312 before printing it (it had a lot of spurious blank lines at the
2290 end).
2313 end).
2291
2314
2292 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2315 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2293 output would be sent 21 times! Obviously people don't use this
2316 output would be sent 21 times! Obviously people don't use this
2294 too often, or I would have heard about it.
2317 too often, or I would have heard about it.
2295
2318
2296 2003-03-24 Fernando Perez <fperez@colorado.edu>
2319 2003-03-24 Fernando Perez <fperez@colorado.edu>
2297
2320
2298 * setup.py (scriptfiles): renamed the data_files parameter from
2321 * setup.py (scriptfiles): renamed the data_files parameter from
2299 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2322 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2300 for the patch.
2323 for the patch.
2301
2324
2302 2003-03-20 Fernando Perez <fperez@colorado.edu>
2325 2003-03-20 Fernando Perez <fperez@colorado.edu>
2303
2326
2304 * IPython/genutils.py (error): added error() and fatal()
2327 * IPython/genutils.py (error): added error() and fatal()
2305 functions.
2328 functions.
2306
2329
2307 2003-03-18 *** Released version 0.2.15pre3
2330 2003-03-18 *** Released version 0.2.15pre3
2308
2331
2309 2003-03-18 Fernando Perez <fperez@colorado.edu>
2332 2003-03-18 Fernando Perez <fperez@colorado.edu>
2310
2333
2311 * setupext/install_data_ext.py
2334 * setupext/install_data_ext.py
2312 (install_data_ext.initialize_options): Class contributed by Jack
2335 (install_data_ext.initialize_options): Class contributed by Jack
2313 Moffit for fixing the old distutils hack. He is sending this to
2336 Moffit for fixing the old distutils hack. He is sending this to
2314 the distutils folks so in the future we may not need it as a
2337 the distutils folks so in the future we may not need it as a
2315 private fix.
2338 private fix.
2316
2339
2317 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2340 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2318 changes for Debian packaging. See his patch for full details.
2341 changes for Debian packaging. See his patch for full details.
2319 The old distutils hack of making the ipythonrc* files carry a
2342 The old distutils hack of making the ipythonrc* files carry a
2320 bogus .py extension is gone, at last. Examples were moved to a
2343 bogus .py extension is gone, at last. Examples were moved to a
2321 separate subdir under doc/, and the separate executable scripts
2344 separate subdir under doc/, and the separate executable scripts
2322 now live in their own directory. Overall a great cleanup. The
2345 now live in their own directory. Overall a great cleanup. The
2323 manual was updated to use the new files, and setup.py has been
2346 manual was updated to use the new files, and setup.py has been
2324 fixed for this setup.
2347 fixed for this setup.
2325
2348
2326 * IPython/PyColorize.py (Parser.usage): made non-executable and
2349 * IPython/PyColorize.py (Parser.usage): made non-executable and
2327 created a pycolor wrapper around it to be included as a script.
2350 created a pycolor wrapper around it to be included as a script.
2328
2351
2329 2003-03-12 *** Released version 0.2.15pre2
2352 2003-03-12 *** Released version 0.2.15pre2
2330
2353
2331 2003-03-12 Fernando Perez <fperez@colorado.edu>
2354 2003-03-12 Fernando Perez <fperez@colorado.edu>
2332
2355
2333 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2356 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2334 long-standing problem with garbage characters in some terminals.
2357 long-standing problem with garbage characters in some terminals.
2335 The issue was really that the \001 and \002 escapes must _only_ be
2358 The issue was really that the \001 and \002 escapes must _only_ be
2336 passed to input prompts (which call readline), but _never_ to
2359 passed to input prompts (which call readline), but _never_ to
2337 normal text to be printed on screen. I changed ColorANSI to have
2360 normal text to be printed on screen. I changed ColorANSI to have
2338 two classes: TermColors and InputTermColors, each with the
2361 two classes: TermColors and InputTermColors, each with the
2339 appropriate escapes for input prompts or normal text. The code in
2362 appropriate escapes for input prompts or normal text. The code in
2340 Prompts.py got slightly more complicated, but this very old and
2363 Prompts.py got slightly more complicated, but this very old and
2341 annoying bug is finally fixed.
2364 annoying bug is finally fixed.
2342
2365
2343 All the credit for nailing down the real origin of this problem
2366 All the credit for nailing down the real origin of this problem
2344 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2367 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2345 *Many* thanks to him for spending quite a bit of effort on this.
2368 *Many* thanks to him for spending quite a bit of effort on this.
2346
2369
2347 2003-03-05 *** Released version 0.2.15pre1
2370 2003-03-05 *** Released version 0.2.15pre1
2348
2371
2349 2003-03-03 Fernando Perez <fperez@colorado.edu>
2372 2003-03-03 Fernando Perez <fperez@colorado.edu>
2350
2373
2351 * IPython/FakeModule.py: Moved the former _FakeModule to a
2374 * IPython/FakeModule.py: Moved the former _FakeModule to a
2352 separate file, because it's also needed by Magic (to fix a similar
2375 separate file, because it's also needed by Magic (to fix a similar
2353 pickle-related issue in @run).
2376 pickle-related issue in @run).
2354
2377
2355 2003-03-02 Fernando Perez <fperez@colorado.edu>
2378 2003-03-02 Fernando Perez <fperez@colorado.edu>
2356
2379
2357 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2380 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2358 the autocall option at runtime.
2381 the autocall option at runtime.
2359 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2382 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2360 across Magic.py to start separating Magic from InteractiveShell.
2383 across Magic.py to start separating Magic from InteractiveShell.
2361 (Magic._ofind): Fixed to return proper namespace for dotted
2384 (Magic._ofind): Fixed to return proper namespace for dotted
2362 names. Before, a dotted name would always return 'not currently
2385 names. Before, a dotted name would always return 'not currently
2363 defined', because it would find the 'parent'. s.x would be found,
2386 defined', because it would find the 'parent'. s.x would be found,
2364 but since 'x' isn't defined by itself, it would get confused.
2387 but since 'x' isn't defined by itself, it would get confused.
2365 (Magic.magic_run): Fixed pickling problems reported by Ralf
2388 (Magic.magic_run): Fixed pickling problems reported by Ralf
2366 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2389 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2367 that I'd used when Mike Heeter reported similar issues at the
2390 that I'd used when Mike Heeter reported similar issues at the
2368 top-level, but now for @run. It boils down to injecting the
2391 top-level, but now for @run. It boils down to injecting the
2369 namespace where code is being executed with something that looks
2392 namespace where code is being executed with something that looks
2370 enough like a module to fool pickle.dump(). Since a pickle stores
2393 enough like a module to fool pickle.dump(). Since a pickle stores
2371 a named reference to the importing module, we need this for
2394 a named reference to the importing module, we need this for
2372 pickles to save something sensible.
2395 pickles to save something sensible.
2373
2396
2374 * IPython/ipmaker.py (make_IPython): added an autocall option.
2397 * IPython/ipmaker.py (make_IPython): added an autocall option.
2375
2398
2376 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2399 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2377 the auto-eval code. Now autocalling is an option, and the code is
2400 the auto-eval code. Now autocalling is an option, and the code is
2378 also vastly safer. There is no more eval() involved at all.
2401 also vastly safer. There is no more eval() involved at all.
2379
2402
2380 2003-03-01 Fernando Perez <fperez@colorado.edu>
2403 2003-03-01 Fernando Perez <fperez@colorado.edu>
2381
2404
2382 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2405 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2383 dict with named keys instead of a tuple.
2406 dict with named keys instead of a tuple.
2384
2407
2385 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2408 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2386
2409
2387 * setup.py (make_shortcut): Fixed message about directories
2410 * setup.py (make_shortcut): Fixed message about directories
2388 created during Windows installation (the directories were ok, just
2411 created during Windows installation (the directories were ok, just
2389 the printed message was misleading). Thanks to Chris Liechti
2412 the printed message was misleading). Thanks to Chris Liechti
2390 <cliechti-AT-gmx.net> for the heads up.
2413 <cliechti-AT-gmx.net> for the heads up.
2391
2414
2392 2003-02-21 Fernando Perez <fperez@colorado.edu>
2415 2003-02-21 Fernando Perez <fperez@colorado.edu>
2393
2416
2394 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2417 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2395 of ValueError exception when checking for auto-execution. This
2418 of ValueError exception when checking for auto-execution. This
2396 one is raised by things like Numeric arrays arr.flat when the
2419 one is raised by things like Numeric arrays arr.flat when the
2397 array is non-contiguous.
2420 array is non-contiguous.
2398
2421
2399 2003-01-31 Fernando Perez <fperez@colorado.edu>
2422 2003-01-31 Fernando Perez <fperez@colorado.edu>
2400
2423
2401 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2424 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2402 not return any value at all (even though the command would get
2425 not return any value at all (even though the command would get
2403 executed).
2426 executed).
2404 (xsys): Flush stdout right after printing the command to ensure
2427 (xsys): Flush stdout right after printing the command to ensure
2405 proper ordering of commands and command output in the total
2428 proper ordering of commands and command output in the total
2406 output.
2429 output.
2407 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2430 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2408 system/getoutput as defaults. The old ones are kept for
2431 system/getoutput as defaults. The old ones are kept for
2409 compatibility reasons, so no code which uses this library needs
2432 compatibility reasons, so no code which uses this library needs
2410 changing.
2433 changing.
2411
2434
2412 2003-01-27 *** Released version 0.2.14
2435 2003-01-27 *** Released version 0.2.14
2413
2436
2414 2003-01-25 Fernando Perez <fperez@colorado.edu>
2437 2003-01-25 Fernando Perez <fperez@colorado.edu>
2415
2438
2416 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2439 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2417 functions defined in previous edit sessions could not be re-edited
2440 functions defined in previous edit sessions could not be re-edited
2418 (because the temp files were immediately removed). Now temp files
2441 (because the temp files were immediately removed). Now temp files
2419 are removed only at IPython's exit.
2442 are removed only at IPython's exit.
2420 (Magic.magic_run): Improved @run to perform shell-like expansions
2443 (Magic.magic_run): Improved @run to perform shell-like expansions
2421 on its arguments (~users and $VARS). With this, @run becomes more
2444 on its arguments (~users and $VARS). With this, @run becomes more
2422 like a normal command-line.
2445 like a normal command-line.
2423
2446
2424 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2447 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2425 bugs related to embedding and cleaned up that code. A fairly
2448 bugs related to embedding and cleaned up that code. A fairly
2426 important one was the impossibility to access the global namespace
2449 important one was the impossibility to access the global namespace
2427 through the embedded IPython (only local variables were visible).
2450 through the embedded IPython (only local variables were visible).
2428
2451
2429 2003-01-14 Fernando Perez <fperez@colorado.edu>
2452 2003-01-14 Fernando Perez <fperez@colorado.edu>
2430
2453
2431 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2454 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2432 auto-calling to be a bit more conservative. Now it doesn't get
2455 auto-calling to be a bit more conservative. Now it doesn't get
2433 triggered if any of '!=()<>' are in the rest of the input line, to
2456 triggered if any of '!=()<>' are in the rest of the input line, to
2434 allow comparing callables. Thanks to Alex for the heads up.
2457 allow comparing callables. Thanks to Alex for the heads up.
2435
2458
2436 2003-01-07 Fernando Perez <fperez@colorado.edu>
2459 2003-01-07 Fernando Perez <fperez@colorado.edu>
2437
2460
2438 * IPython/genutils.py (page): fixed estimation of the number of
2461 * IPython/genutils.py (page): fixed estimation of the number of
2439 lines in a string to be paged to simply count newlines. This
2462 lines in a string to be paged to simply count newlines. This
2440 prevents over-guessing due to embedded escape sequences. A better
2463 prevents over-guessing due to embedded escape sequences. A better
2441 long-term solution would involve stripping out the control chars
2464 long-term solution would involve stripping out the control chars
2442 for the count, but it's potentially so expensive I just don't
2465 for the count, but it's potentially so expensive I just don't
2443 think it's worth doing.
2466 think it's worth doing.
2444
2467
2445 2002-12-19 *** Released version 0.2.14pre50
2468 2002-12-19 *** Released version 0.2.14pre50
2446
2469
2447 2002-12-19 Fernando Perez <fperez@colorado.edu>
2470 2002-12-19 Fernando Perez <fperez@colorado.edu>
2448
2471
2449 * tools/release (version): Changed release scripts to inform
2472 * tools/release (version): Changed release scripts to inform
2450 Andrea and build a NEWS file with a list of recent changes.
2473 Andrea and build a NEWS file with a list of recent changes.
2451
2474
2452 * IPython/ColorANSI.py (__all__): changed terminal detection
2475 * IPython/ColorANSI.py (__all__): changed terminal detection
2453 code. Seems to work better for xterms without breaking
2476 code. Seems to work better for xterms without breaking
2454 konsole. Will need more testing to determine if WinXP and Mac OSX
2477 konsole. Will need more testing to determine if WinXP and Mac OSX
2455 also work ok.
2478 also work ok.
2456
2479
2457 2002-12-18 *** Released version 0.2.14pre49
2480 2002-12-18 *** Released version 0.2.14pre49
2458
2481
2459 2002-12-18 Fernando Perez <fperez@colorado.edu>
2482 2002-12-18 Fernando Perez <fperez@colorado.edu>
2460
2483
2461 * Docs: added new info about Mac OSX, from Andrea.
2484 * Docs: added new info about Mac OSX, from Andrea.
2462
2485
2463 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2486 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2464 allow direct plotting of python strings whose format is the same
2487 allow direct plotting of python strings whose format is the same
2465 of gnuplot data files.
2488 of gnuplot data files.
2466
2489
2467 2002-12-16 Fernando Perez <fperez@colorado.edu>
2490 2002-12-16 Fernando Perez <fperez@colorado.edu>
2468
2491
2469 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2492 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2470 value of exit question to be acknowledged.
2493 value of exit question to be acknowledged.
2471
2494
2472 2002-12-03 Fernando Perez <fperez@colorado.edu>
2495 2002-12-03 Fernando Perez <fperez@colorado.edu>
2473
2496
2474 * IPython/ipmaker.py: removed generators, which had been added
2497 * IPython/ipmaker.py: removed generators, which had been added
2475 by mistake in an earlier debugging run. This was causing trouble
2498 by mistake in an earlier debugging run. This was causing trouble
2476 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2499 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2477 for pointing this out.
2500 for pointing this out.
2478
2501
2479 2002-11-17 Fernando Perez <fperez@colorado.edu>
2502 2002-11-17 Fernando Perez <fperez@colorado.edu>
2480
2503
2481 * Manual: updated the Gnuplot section.
2504 * Manual: updated the Gnuplot section.
2482
2505
2483 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2506 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2484 a much better split of what goes in Runtime and what goes in
2507 a much better split of what goes in Runtime and what goes in
2485 Interactive.
2508 Interactive.
2486
2509
2487 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2510 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2488 being imported from iplib.
2511 being imported from iplib.
2489
2512
2490 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2513 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2491 for command-passing. Now the global Gnuplot instance is called
2514 for command-passing. Now the global Gnuplot instance is called
2492 'gp' instead of 'g', which was really a far too fragile and
2515 'gp' instead of 'g', which was really a far too fragile and
2493 common name.
2516 common name.
2494
2517
2495 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2518 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2496 bounding boxes generated by Gnuplot for square plots.
2519 bounding boxes generated by Gnuplot for square plots.
2497
2520
2498 * IPython/genutils.py (popkey): new function added. I should
2521 * IPython/genutils.py (popkey): new function added. I should
2499 suggest this on c.l.py as a dict method, it seems useful.
2522 suggest this on c.l.py as a dict method, it seems useful.
2500
2523
2501 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2524 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2502 to transparently handle PostScript generation. MUCH better than
2525 to transparently handle PostScript generation. MUCH better than
2503 the previous plot_eps/replot_eps (which I removed now). The code
2526 the previous plot_eps/replot_eps (which I removed now). The code
2504 is also fairly clean and well documented now (including
2527 is also fairly clean and well documented now (including
2505 docstrings).
2528 docstrings).
2506
2529
2507 2002-11-13 Fernando Perez <fperez@colorado.edu>
2530 2002-11-13 Fernando Perez <fperez@colorado.edu>
2508
2531
2509 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2532 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2510 (inconsistent with options).
2533 (inconsistent with options).
2511
2534
2512 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2535 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2513 manually disabled, I don't know why. Fixed it.
2536 manually disabled, I don't know why. Fixed it.
2514 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2537 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2515 eps output.
2538 eps output.
2516
2539
2517 2002-11-12 Fernando Perez <fperez@colorado.edu>
2540 2002-11-12 Fernando Perez <fperez@colorado.edu>
2518
2541
2519 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2542 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2520 don't propagate up to caller. Fixes crash reported by François
2543 don't propagate up to caller. Fixes crash reported by François
2521 Pinard.
2544 Pinard.
2522
2545
2523 2002-11-09 Fernando Perez <fperez@colorado.edu>
2546 2002-11-09 Fernando Perez <fperez@colorado.edu>
2524
2547
2525 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2548 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2526 history file for new users.
2549 history file for new users.
2527 (make_IPython): fixed bug where initial install would leave the
2550 (make_IPython): fixed bug where initial install would leave the
2528 user running in the .ipython dir.
2551 user running in the .ipython dir.
2529 (make_IPython): fixed bug where config dir .ipython would be
2552 (make_IPython): fixed bug where config dir .ipython would be
2530 created regardless of the given -ipythondir option. Thanks to Cory
2553 created regardless of the given -ipythondir option. Thanks to Cory
2531 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2554 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2532
2555
2533 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2556 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2534 type confirmations. Will need to use it in all of IPython's code
2557 type confirmations. Will need to use it in all of IPython's code
2535 consistently.
2558 consistently.
2536
2559
2537 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2560 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2538 context to print 31 lines instead of the default 5. This will make
2561 context to print 31 lines instead of the default 5. This will make
2539 the crash reports extremely detailed in case the problem is in
2562 the crash reports extremely detailed in case the problem is in
2540 libraries I don't have access to.
2563 libraries I don't have access to.
2541
2564
2542 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2565 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2543 line of defense' code to still crash, but giving users fair
2566 line of defense' code to still crash, but giving users fair
2544 warning. I don't want internal errors to go unreported: if there's
2567 warning. I don't want internal errors to go unreported: if there's
2545 an internal problem, IPython should crash and generate a full
2568 an internal problem, IPython should crash and generate a full
2546 report.
2569 report.
2547
2570
2548 2002-11-08 Fernando Perez <fperez@colorado.edu>
2571 2002-11-08 Fernando Perez <fperez@colorado.edu>
2549
2572
2550 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2573 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2551 otherwise uncaught exceptions which can appear if people set
2574 otherwise uncaught exceptions which can appear if people set
2552 sys.stdout to something badly broken. Thanks to a crash report
2575 sys.stdout to something badly broken. Thanks to a crash report
2553 from henni-AT-mail.brainbot.com.
2576 from henni-AT-mail.brainbot.com.
2554
2577
2555 2002-11-04 Fernando Perez <fperez@colorado.edu>
2578 2002-11-04 Fernando Perez <fperez@colorado.edu>
2556
2579
2557 * IPython/iplib.py (InteractiveShell.interact): added
2580 * IPython/iplib.py (InteractiveShell.interact): added
2558 __IPYTHON__active to the builtins. It's a flag which goes on when
2581 __IPYTHON__active to the builtins. It's a flag which goes on when
2559 the interaction starts and goes off again when it stops. This
2582 the interaction starts and goes off again when it stops. This
2560 allows embedding code to detect being inside IPython. Before this
2583 allows embedding code to detect being inside IPython. Before this
2561 was done via __IPYTHON__, but that only shows that an IPython
2584 was done via __IPYTHON__, but that only shows that an IPython
2562 instance has been created.
2585 instance has been created.
2563
2586
2564 * IPython/Magic.py (Magic.magic_env): I realized that in a
2587 * IPython/Magic.py (Magic.magic_env): I realized that in a
2565 UserDict, instance.data holds the data as a normal dict. So I
2588 UserDict, instance.data holds the data as a normal dict. So I
2566 modified @env to return os.environ.data instead of rebuilding a
2589 modified @env to return os.environ.data instead of rebuilding a
2567 dict by hand.
2590 dict by hand.
2568
2591
2569 2002-11-02 Fernando Perez <fperez@colorado.edu>
2592 2002-11-02 Fernando Perez <fperez@colorado.edu>
2570
2593
2571 * IPython/genutils.py (warn): changed so that level 1 prints no
2594 * IPython/genutils.py (warn): changed so that level 1 prints no
2572 header. Level 2 is now the default (with 'WARNING' header, as
2595 header. Level 2 is now the default (with 'WARNING' header, as
2573 before). I think I tracked all places where changes were needed in
2596 before). I think I tracked all places where changes were needed in
2574 IPython, but outside code using the old level numbering may have
2597 IPython, but outside code using the old level numbering may have
2575 broken.
2598 broken.
2576
2599
2577 * IPython/iplib.py (InteractiveShell.runcode): added this to
2600 * IPython/iplib.py (InteractiveShell.runcode): added this to
2578 handle the tracebacks in SystemExit traps correctly. The previous
2601 handle the tracebacks in SystemExit traps correctly. The previous
2579 code (through interact) was printing more of the stack than
2602 code (through interact) was printing more of the stack than
2580 necessary, showing IPython internal code to the user.
2603 necessary, showing IPython internal code to the user.
2581
2604
2582 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2605 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2583 default. Now that the default at the confirmation prompt is yes,
2606 default. Now that the default at the confirmation prompt is yes,
2584 it's not so intrusive. François' argument that ipython sessions
2607 it's not so intrusive. François' argument that ipython sessions
2585 tend to be complex enough not to lose them from an accidental C-d,
2608 tend to be complex enough not to lose them from an accidental C-d,
2586 is a valid one.
2609 is a valid one.
2587
2610
2588 * IPython/iplib.py (InteractiveShell.interact): added a
2611 * IPython/iplib.py (InteractiveShell.interact): added a
2589 showtraceback() call to the SystemExit trap, and modified the exit
2612 showtraceback() call to the SystemExit trap, and modified the exit
2590 confirmation to have yes as the default.
2613 confirmation to have yes as the default.
2591
2614
2592 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2615 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2593 this file. It's been gone from the code for a long time, this was
2616 this file. It's been gone from the code for a long time, this was
2594 simply leftover junk.
2617 simply leftover junk.
2595
2618
2596 2002-11-01 Fernando Perez <fperez@colorado.edu>
2619 2002-11-01 Fernando Perez <fperez@colorado.edu>
2597
2620
2598 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2621 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2599 added. If set, IPython now traps EOF and asks for
2622 added. If set, IPython now traps EOF and asks for
2600 confirmation. After a request by François Pinard.
2623 confirmation. After a request by François Pinard.
2601
2624
2602 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2625 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2603 of @abort, and with a new (better) mechanism for handling the
2626 of @abort, and with a new (better) mechanism for handling the
2604 exceptions.
2627 exceptions.
2605
2628
2606 2002-10-27 Fernando Perez <fperez@colorado.edu>
2629 2002-10-27 Fernando Perez <fperez@colorado.edu>
2607
2630
2608 * IPython/usage.py (__doc__): updated the --help information and
2631 * IPython/usage.py (__doc__): updated the --help information and
2609 the ipythonrc file to indicate that -log generates
2632 the ipythonrc file to indicate that -log generates
2610 ./ipython.log. Also fixed the corresponding info in @logstart.
2633 ./ipython.log. Also fixed the corresponding info in @logstart.
2611 This and several other fixes in the manuals thanks to reports by
2634 This and several other fixes in the manuals thanks to reports by
2612 François Pinard <pinard-AT-iro.umontreal.ca>.
2635 François Pinard <pinard-AT-iro.umontreal.ca>.
2613
2636
2614 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2637 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2615 refer to @logstart (instead of @log, which doesn't exist).
2638 refer to @logstart (instead of @log, which doesn't exist).
2616
2639
2617 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2640 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2618 AttributeError crash. Thanks to Christopher Armstrong
2641 AttributeError crash. Thanks to Christopher Armstrong
2619 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2642 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2620 introduced recently (in 0.2.14pre37) with the fix to the eval
2643 introduced recently (in 0.2.14pre37) with the fix to the eval
2621 problem mentioned below.
2644 problem mentioned below.
2622
2645
2623 2002-10-17 Fernando Perez <fperez@colorado.edu>
2646 2002-10-17 Fernando Perez <fperez@colorado.edu>
2624
2647
2625 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2648 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2626 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2649 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2627
2650
2628 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2651 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2629 this function to fix a problem reported by Alex Schmolck. He saw
2652 this function to fix a problem reported by Alex Schmolck. He saw
2630 it with list comprehensions and generators, which were getting
2653 it with list comprehensions and generators, which were getting
2631 called twice. The real problem was an 'eval' call in testing for
2654 called twice. The real problem was an 'eval' call in testing for
2632 automagic which was evaluating the input line silently.
2655 automagic which was evaluating the input line silently.
2633
2656
2634 This is a potentially very nasty bug, if the input has side
2657 This is a potentially very nasty bug, if the input has side
2635 effects which must not be repeated. The code is much cleaner now,
2658 effects which must not be repeated. The code is much cleaner now,
2636 without any blanket 'except' left and with a regexp test for
2659 without any blanket 'except' left and with a regexp test for
2637 actual function names.
2660 actual function names.
2638
2661
2639 But an eval remains, which I'm not fully comfortable with. I just
2662 But an eval remains, which I'm not fully comfortable with. I just
2640 don't know how to find out if an expression could be a callable in
2663 don't know how to find out if an expression could be a callable in
2641 the user's namespace without doing an eval on the string. However
2664 the user's namespace without doing an eval on the string. However
2642 that string is now much more strictly checked so that no code
2665 that string is now much more strictly checked so that no code
2643 slips by, so the eval should only happen for things that can
2666 slips by, so the eval should only happen for things that can
2644 really be only function/method names.
2667 really be only function/method names.
2645
2668
2646 2002-10-15 Fernando Perez <fperez@colorado.edu>
2669 2002-10-15 Fernando Perez <fperez@colorado.edu>
2647
2670
2648 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2671 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2649 OSX information to main manual, removed README_Mac_OSX file from
2672 OSX information to main manual, removed README_Mac_OSX file from
2650 distribution. Also updated credits for recent additions.
2673 distribution. Also updated credits for recent additions.
2651
2674
2652 2002-10-10 Fernando Perez <fperez@colorado.edu>
2675 2002-10-10 Fernando Perez <fperez@colorado.edu>
2653
2676
2654 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2677 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2655 terminal-related issues. Many thanks to Andrea Riciputi
2678 terminal-related issues. Many thanks to Andrea Riciputi
2656 <andrea.riciputi-AT-libero.it> for writing it.
2679 <andrea.riciputi-AT-libero.it> for writing it.
2657
2680
2658 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2681 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2659 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2682 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2660
2683
2661 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2684 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2662 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2685 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2663 <syver-en-AT-online.no> who both submitted patches for this problem.
2686 <syver-en-AT-online.no> who both submitted patches for this problem.
2664
2687
2665 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2688 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2666 global embedding to make sure that things don't overwrite user
2689 global embedding to make sure that things don't overwrite user
2667 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2690 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2668
2691
2669 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2692 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2670 compatibility. Thanks to Hayden Callow
2693 compatibility. Thanks to Hayden Callow
2671 <h.callow-AT-elec.canterbury.ac.nz>
2694 <h.callow-AT-elec.canterbury.ac.nz>
2672
2695
2673 2002-10-04 Fernando Perez <fperez@colorado.edu>
2696 2002-10-04 Fernando Perez <fperez@colorado.edu>
2674
2697
2675 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2698 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2676 Gnuplot.File objects.
2699 Gnuplot.File objects.
2677
2700
2678 2002-07-23 Fernando Perez <fperez@colorado.edu>
2701 2002-07-23 Fernando Perez <fperez@colorado.edu>
2679
2702
2680 * IPython/genutils.py (timing): Added timings() and timing() for
2703 * IPython/genutils.py (timing): Added timings() and timing() for
2681 quick access to the most commonly needed data, the execution
2704 quick access to the most commonly needed data, the execution
2682 times. Old timing() renamed to timings_out().
2705 times. Old timing() renamed to timings_out().
2683
2706
2684 2002-07-18 Fernando Perez <fperez@colorado.edu>
2707 2002-07-18 Fernando Perez <fperez@colorado.edu>
2685
2708
2686 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2709 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2687 bug with nested instances disrupting the parent's tab completion.
2710 bug with nested instances disrupting the parent's tab completion.
2688
2711
2689 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2712 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2690 all_completions code to begin the emacs integration.
2713 all_completions code to begin the emacs integration.
2691
2714
2692 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2715 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2693 argument to allow titling individual arrays when plotting.
2716 argument to allow titling individual arrays when plotting.
2694
2717
2695 2002-07-15 Fernando Perez <fperez@colorado.edu>
2718 2002-07-15 Fernando Perez <fperez@colorado.edu>
2696
2719
2697 * setup.py (make_shortcut): changed to retrieve the value of
2720 * setup.py (make_shortcut): changed to retrieve the value of
2698 'Program Files' directory from the registry (this value changes in
2721 'Program Files' directory from the registry (this value changes in
2699 non-english versions of Windows). Thanks to Thomas Fanslau
2722 non-english versions of Windows). Thanks to Thomas Fanslau
2700 <tfanslau-AT-gmx.de> for the report.
2723 <tfanslau-AT-gmx.de> for the report.
2701
2724
2702 2002-07-10 Fernando Perez <fperez@colorado.edu>
2725 2002-07-10 Fernando Perez <fperez@colorado.edu>
2703
2726
2704 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2727 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2705 a bug in pdb, which crashes if a line with only whitespace is
2728 a bug in pdb, which crashes if a line with only whitespace is
2706 entered. Bug report submitted to sourceforge.
2729 entered. Bug report submitted to sourceforge.
2707
2730
2708 2002-07-09 Fernando Perez <fperez@colorado.edu>
2731 2002-07-09 Fernando Perez <fperez@colorado.edu>
2709
2732
2710 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2733 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2711 reporting exceptions (it's a bug in inspect.py, I just set a
2734 reporting exceptions (it's a bug in inspect.py, I just set a
2712 workaround).
2735 workaround).
2713
2736
2714 2002-07-08 Fernando Perez <fperez@colorado.edu>
2737 2002-07-08 Fernando Perez <fperez@colorado.edu>
2715
2738
2716 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2739 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2717 __IPYTHON__ in __builtins__ to show up in user_ns.
2740 __IPYTHON__ in __builtins__ to show up in user_ns.
2718
2741
2719 2002-07-03 Fernando Perez <fperez@colorado.edu>
2742 2002-07-03 Fernando Perez <fperez@colorado.edu>
2720
2743
2721 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2744 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2722 name from @gp_set_instance to @gp_set_default.
2745 name from @gp_set_instance to @gp_set_default.
2723
2746
2724 * IPython/ipmaker.py (make_IPython): default editor value set to
2747 * IPython/ipmaker.py (make_IPython): default editor value set to
2725 '0' (a string), to match the rc file. Otherwise will crash when
2748 '0' (a string), to match the rc file. Otherwise will crash when
2726 .strip() is called on it.
2749 .strip() is called on it.
2727
2750
2728
2751
2729 2002-06-28 Fernando Perez <fperez@colorado.edu>
2752 2002-06-28 Fernando Perez <fperez@colorado.edu>
2730
2753
2731 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2754 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2732 of files in current directory when a file is executed via
2755 of files in current directory when a file is executed via
2733 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2756 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2734
2757
2735 * setup.py (manfiles): fix for rpm builds, submitted by RA
2758 * setup.py (manfiles): fix for rpm builds, submitted by RA
2736 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2759 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2737
2760
2738 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2761 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2739 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2762 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2740 string!). A. Schmolck caught this one.
2763 string!). A. Schmolck caught this one.
2741
2764
2742 2002-06-27 Fernando Perez <fperez@colorado.edu>
2765 2002-06-27 Fernando Perez <fperez@colorado.edu>
2743
2766
2744 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2767 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2745 defined files at the cmd line. __name__ wasn't being set to
2768 defined files at the cmd line. __name__ wasn't being set to
2746 __main__.
2769 __main__.
2747
2770
2748 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2771 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2749 regular lists and tuples besides Numeric arrays.
2772 regular lists and tuples besides Numeric arrays.
2750
2773
2751 * IPython/Prompts.py (CachedOutput.__call__): Added output
2774 * IPython/Prompts.py (CachedOutput.__call__): Added output
2752 supression for input ending with ';'. Similar to Mathematica and
2775 supression for input ending with ';'. Similar to Mathematica and
2753 Matlab. The _* vars and Out[] list are still updated, just like
2776 Matlab. The _* vars and Out[] list are still updated, just like
2754 Mathematica behaves.
2777 Mathematica behaves.
2755
2778
2756 2002-06-25 Fernando Perez <fperez@colorado.edu>
2779 2002-06-25 Fernando Perez <fperez@colorado.edu>
2757
2780
2758 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2781 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2759 .ini extensions for profiels under Windows.
2782 .ini extensions for profiels under Windows.
2760
2783
2761 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2784 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2762 string form. Fix contributed by Alexander Schmolck
2785 string form. Fix contributed by Alexander Schmolck
2763 <a.schmolck-AT-gmx.net>
2786 <a.schmolck-AT-gmx.net>
2764
2787
2765 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2788 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2766 pre-configured Gnuplot instance.
2789 pre-configured Gnuplot instance.
2767
2790
2768 2002-06-21 Fernando Perez <fperez@colorado.edu>
2791 2002-06-21 Fernando Perez <fperez@colorado.edu>
2769
2792
2770 * IPython/numutils.py (exp_safe): new function, works around the
2793 * IPython/numutils.py (exp_safe): new function, works around the
2771 underflow problems in Numeric.
2794 underflow problems in Numeric.
2772 (log2): New fn. Safe log in base 2: returns exact integer answer
2795 (log2): New fn. Safe log in base 2: returns exact integer answer
2773 for exact integer powers of 2.
2796 for exact integer powers of 2.
2774
2797
2775 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2798 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2776 properly.
2799 properly.
2777
2800
2778 2002-06-20 Fernando Perez <fperez@colorado.edu>
2801 2002-06-20 Fernando Perez <fperez@colorado.edu>
2779
2802
2780 * IPython/genutils.py (timing): new function like
2803 * IPython/genutils.py (timing): new function like
2781 Mathematica's. Similar to time_test, but returns more info.
2804 Mathematica's. Similar to time_test, but returns more info.
2782
2805
2783 2002-06-18 Fernando Perez <fperez@colorado.edu>
2806 2002-06-18 Fernando Perez <fperez@colorado.edu>
2784
2807
2785 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2808 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2786 according to Mike Heeter's suggestions.
2809 according to Mike Heeter's suggestions.
2787
2810
2788 2002-06-16 Fernando Perez <fperez@colorado.edu>
2811 2002-06-16 Fernando Perez <fperez@colorado.edu>
2789
2812
2790 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2813 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2791 system. GnuplotMagic is gone as a user-directory option. New files
2814 system. GnuplotMagic is gone as a user-directory option. New files
2792 make it easier to use all the gnuplot stuff both from external
2815 make it easier to use all the gnuplot stuff both from external
2793 programs as well as from IPython. Had to rewrite part of
2816 programs as well as from IPython. Had to rewrite part of
2794 hardcopy() b/c of a strange bug: often the ps files simply don't
2817 hardcopy() b/c of a strange bug: often the ps files simply don't
2795 get created, and require a repeat of the command (often several
2818 get created, and require a repeat of the command (often several
2796 times).
2819 times).
2797
2820
2798 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2821 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2799 resolve output channel at call time, so that if sys.stderr has
2822 resolve output channel at call time, so that if sys.stderr has
2800 been redirected by user this gets honored.
2823 been redirected by user this gets honored.
2801
2824
2802 2002-06-13 Fernando Perez <fperez@colorado.edu>
2825 2002-06-13 Fernando Perez <fperez@colorado.edu>
2803
2826
2804 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2827 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2805 IPShell. Kept a copy with the old names to avoid breaking people's
2828 IPShell. Kept a copy with the old names to avoid breaking people's
2806 embedded code.
2829 embedded code.
2807
2830
2808 * IPython/ipython: simplified it to the bare minimum after
2831 * IPython/ipython: simplified it to the bare minimum after
2809 Holger's suggestions. Added info about how to use it in
2832 Holger's suggestions. Added info about how to use it in
2810 PYTHONSTARTUP.
2833 PYTHONSTARTUP.
2811
2834
2812 * IPython/Shell.py (IPythonShell): changed the options passing
2835 * IPython/Shell.py (IPythonShell): changed the options passing
2813 from a string with funky %s replacements to a straight list. Maybe
2836 from a string with funky %s replacements to a straight list. Maybe
2814 a bit more typing, but it follows sys.argv conventions, so there's
2837 a bit more typing, but it follows sys.argv conventions, so there's
2815 less special-casing to remember.
2838 less special-casing to remember.
2816
2839
2817 2002-06-12 Fernando Perez <fperez@colorado.edu>
2840 2002-06-12 Fernando Perez <fperez@colorado.edu>
2818
2841
2819 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2842 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2820 command. Thanks to a suggestion by Mike Heeter.
2843 command. Thanks to a suggestion by Mike Heeter.
2821 (Magic.magic_pfile): added behavior to look at filenames if given
2844 (Magic.magic_pfile): added behavior to look at filenames if given
2822 arg is not a defined object.
2845 arg is not a defined object.
2823 (Magic.magic_save): New @save function to save code snippets. Also
2846 (Magic.magic_save): New @save function to save code snippets. Also
2824 a Mike Heeter idea.
2847 a Mike Heeter idea.
2825
2848
2826 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2849 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2827 plot() and replot(). Much more convenient now, especially for
2850 plot() and replot(). Much more convenient now, especially for
2828 interactive use.
2851 interactive use.
2829
2852
2830 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2853 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2831 filenames.
2854 filenames.
2832
2855
2833 2002-06-02 Fernando Perez <fperez@colorado.edu>
2856 2002-06-02 Fernando Perez <fperez@colorado.edu>
2834
2857
2835 * IPython/Struct.py (Struct.__init__): modified to admit
2858 * IPython/Struct.py (Struct.__init__): modified to admit
2836 initialization via another struct.
2859 initialization via another struct.
2837
2860
2838 * IPython/genutils.py (SystemExec.__init__): New stateful
2861 * IPython/genutils.py (SystemExec.__init__): New stateful
2839 interface to xsys and bq. Useful for writing system scripts.
2862 interface to xsys and bq. Useful for writing system scripts.
2840
2863
2841 2002-05-30 Fernando Perez <fperez@colorado.edu>
2864 2002-05-30 Fernando Perez <fperez@colorado.edu>
2842
2865
2843 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2866 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2844 documents. This will make the user download smaller (it's getting
2867 documents. This will make the user download smaller (it's getting
2845 too big).
2868 too big).
2846
2869
2847 2002-05-29 Fernando Perez <fperez@colorado.edu>
2870 2002-05-29 Fernando Perez <fperez@colorado.edu>
2848
2871
2849 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2872 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2850 fix problems with shelve and pickle. Seems to work, but I don't
2873 fix problems with shelve and pickle. Seems to work, but I don't
2851 know if corner cases break it. Thanks to Mike Heeter
2874 know if corner cases break it. Thanks to Mike Heeter
2852 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2875 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2853
2876
2854 2002-05-24 Fernando Perez <fperez@colorado.edu>
2877 2002-05-24 Fernando Perez <fperez@colorado.edu>
2855
2878
2856 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2879 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2857 macros having broken.
2880 macros having broken.
2858
2881
2859 2002-05-21 Fernando Perez <fperez@colorado.edu>
2882 2002-05-21 Fernando Perez <fperez@colorado.edu>
2860
2883
2861 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2884 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2862 introduced logging bug: all history before logging started was
2885 introduced logging bug: all history before logging started was
2863 being written one character per line! This came from the redesign
2886 being written one character per line! This came from the redesign
2864 of the input history as a special list which slices to strings,
2887 of the input history as a special list which slices to strings,
2865 not to lists.
2888 not to lists.
2866
2889
2867 2002-05-20 Fernando Perez <fperez@colorado.edu>
2890 2002-05-20 Fernando Perez <fperez@colorado.edu>
2868
2891
2869 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2892 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2870 be an attribute of all classes in this module. The design of these
2893 be an attribute of all classes in this module. The design of these
2871 classes needs some serious overhauling.
2894 classes needs some serious overhauling.
2872
2895
2873 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2896 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2874 which was ignoring '_' in option names.
2897 which was ignoring '_' in option names.
2875
2898
2876 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2899 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2877 'Verbose_novars' to 'Context' and made it the new default. It's a
2900 'Verbose_novars' to 'Context' and made it the new default. It's a
2878 bit more readable and also safer than verbose.
2901 bit more readable and also safer than verbose.
2879
2902
2880 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2903 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2881 triple-quoted strings.
2904 triple-quoted strings.
2882
2905
2883 * IPython/OInspect.py (__all__): new module exposing the object
2906 * IPython/OInspect.py (__all__): new module exposing the object
2884 introspection facilities. Now the corresponding magics are dummy
2907 introspection facilities. Now the corresponding magics are dummy
2885 wrappers around this. Having this module will make it much easier
2908 wrappers around this. Having this module will make it much easier
2886 to put these functions into our modified pdb.
2909 to put these functions into our modified pdb.
2887 This new object inspector system uses the new colorizing module,
2910 This new object inspector system uses the new colorizing module,
2888 so source code and other things are nicely syntax highlighted.
2911 so source code and other things are nicely syntax highlighted.
2889
2912
2890 2002-05-18 Fernando Perez <fperez@colorado.edu>
2913 2002-05-18 Fernando Perez <fperez@colorado.edu>
2891
2914
2892 * IPython/ColorANSI.py: Split the coloring tools into a separate
2915 * IPython/ColorANSI.py: Split the coloring tools into a separate
2893 module so I can use them in other code easier (they were part of
2916 module so I can use them in other code easier (they were part of
2894 ultraTB).
2917 ultraTB).
2895
2918
2896 2002-05-17 Fernando Perez <fperez@colorado.edu>
2919 2002-05-17 Fernando Perez <fperez@colorado.edu>
2897
2920
2898 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2921 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2899 fixed it to set the global 'g' also to the called instance, as
2922 fixed it to set the global 'g' also to the called instance, as
2900 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2923 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2901 user's 'g' variables).
2924 user's 'g' variables).
2902
2925
2903 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2926 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2904 global variables (aliases to _ih,_oh) so that users which expect
2927 global variables (aliases to _ih,_oh) so that users which expect
2905 In[5] or Out[7] to work aren't unpleasantly surprised.
2928 In[5] or Out[7] to work aren't unpleasantly surprised.
2906 (InputList.__getslice__): new class to allow executing slices of
2929 (InputList.__getslice__): new class to allow executing slices of
2907 input history directly. Very simple class, complements the use of
2930 input history directly. Very simple class, complements the use of
2908 macros.
2931 macros.
2909
2932
2910 2002-05-16 Fernando Perez <fperez@colorado.edu>
2933 2002-05-16 Fernando Perez <fperez@colorado.edu>
2911
2934
2912 * setup.py (docdirbase): make doc directory be just doc/IPython
2935 * setup.py (docdirbase): make doc directory be just doc/IPython
2913 without version numbers, it will reduce clutter for users.
2936 without version numbers, it will reduce clutter for users.
2914
2937
2915 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
2938 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
2916 execfile call to prevent possible memory leak. See for details:
2939 execfile call to prevent possible memory leak. See for details:
2917 http://mail.python.org/pipermail/python-list/2002-February/088476.html
2940 http://mail.python.org/pipermail/python-list/2002-February/088476.html
2918
2941
2919 2002-05-15 Fernando Perez <fperez@colorado.edu>
2942 2002-05-15 Fernando Perez <fperez@colorado.edu>
2920
2943
2921 * IPython/Magic.py (Magic.magic_psource): made the object
2944 * IPython/Magic.py (Magic.magic_psource): made the object
2922 introspection names be more standard: pdoc, pdef, pfile and
2945 introspection names be more standard: pdoc, pdef, pfile and
2923 psource. They all print/page their output, and it makes
2946 psource. They all print/page their output, and it makes
2924 remembering them easier. Kept old names for compatibility as
2947 remembering them easier. Kept old names for compatibility as
2925 aliases.
2948 aliases.
2926
2949
2927 2002-05-14 Fernando Perez <fperez@colorado.edu>
2950 2002-05-14 Fernando Perez <fperez@colorado.edu>
2928
2951
2929 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
2952 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
2930 what the mouse problem was. The trick is to use gnuplot with temp
2953 what the mouse problem was. The trick is to use gnuplot with temp
2931 files and NOT with pipes (for data communication), because having
2954 files and NOT with pipes (for data communication), because having
2932 both pipes and the mouse on is bad news.
2955 both pipes and the mouse on is bad news.
2933
2956
2934 2002-05-13 Fernando Perez <fperez@colorado.edu>
2957 2002-05-13 Fernando Perez <fperez@colorado.edu>
2935
2958
2936 * IPython/Magic.py (Magic._ofind): fixed namespace order search
2959 * IPython/Magic.py (Magic._ofind): fixed namespace order search
2937 bug. Information would be reported about builtins even when
2960 bug. Information would be reported about builtins even when
2938 user-defined functions overrode them.
2961 user-defined functions overrode them.
2939
2962
2940 2002-05-11 Fernando Perez <fperez@colorado.edu>
2963 2002-05-11 Fernando Perez <fperez@colorado.edu>
2941
2964
2942 * IPython/__init__.py (__all__): removed FlexCompleter from
2965 * IPython/__init__.py (__all__): removed FlexCompleter from
2943 __all__ so that things don't fail in platforms without readline.
2966 __all__ so that things don't fail in platforms without readline.
2944
2967
2945 2002-05-10 Fernando Perez <fperez@colorado.edu>
2968 2002-05-10 Fernando Perez <fperez@colorado.edu>
2946
2969
2947 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
2970 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
2948 it requires Numeric, effectively making Numeric a dependency for
2971 it requires Numeric, effectively making Numeric a dependency for
2949 IPython.
2972 IPython.
2950
2973
2951 * Released 0.2.13
2974 * Released 0.2.13
2952
2975
2953 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
2976 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
2954 profiler interface. Now all the major options from the profiler
2977 profiler interface. Now all the major options from the profiler
2955 module are directly supported in IPython, both for single
2978 module are directly supported in IPython, both for single
2956 expressions (@prun) and for full programs (@run -p).
2979 expressions (@prun) and for full programs (@run -p).
2957
2980
2958 2002-05-09 Fernando Perez <fperez@colorado.edu>
2981 2002-05-09 Fernando Perez <fperez@colorado.edu>
2959
2982
2960 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
2983 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
2961 magic properly formatted for screen.
2984 magic properly formatted for screen.
2962
2985
2963 * setup.py (make_shortcut): Changed things to put pdf version in
2986 * setup.py (make_shortcut): Changed things to put pdf version in
2964 doc/ instead of doc/manual (had to change lyxport a bit).
2987 doc/ instead of doc/manual (had to change lyxport a bit).
2965
2988
2966 * IPython/Magic.py (Profile.string_stats): made profile runs go
2989 * IPython/Magic.py (Profile.string_stats): made profile runs go
2967 through pager (they are long and a pager allows searching, saving,
2990 through pager (they are long and a pager allows searching, saving,
2968 etc.)
2991 etc.)
2969
2992
2970 2002-05-08 Fernando Perez <fperez@colorado.edu>
2993 2002-05-08 Fernando Perez <fperez@colorado.edu>
2971
2994
2972 * Released 0.2.12
2995 * Released 0.2.12
2973
2996
2974 2002-05-06 Fernando Perez <fperez@colorado.edu>
2997 2002-05-06 Fernando Perez <fperez@colorado.edu>
2975
2998
2976 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
2999 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
2977 introduced); 'hist n1 n2' was broken.
3000 introduced); 'hist n1 n2' was broken.
2978 (Magic.magic_pdb): added optional on/off arguments to @pdb
3001 (Magic.magic_pdb): added optional on/off arguments to @pdb
2979 (Magic.magic_run): added option -i to @run, which executes code in
3002 (Magic.magic_run): added option -i to @run, which executes code in
2980 the IPython namespace instead of a clean one. Also added @irun as
3003 the IPython namespace instead of a clean one. Also added @irun as
2981 an alias to @run -i.
3004 an alias to @run -i.
2982
3005
2983 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3006 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2984 fixed (it didn't really do anything, the namespaces were wrong).
3007 fixed (it didn't really do anything, the namespaces were wrong).
2985
3008
2986 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3009 * IPython/Debugger.py (__init__): Added workaround for python 2.1
2987
3010
2988 * IPython/__init__.py (__all__): Fixed package namespace, now
3011 * IPython/__init__.py (__all__): Fixed package namespace, now
2989 'import IPython' does give access to IPython.<all> as
3012 'import IPython' does give access to IPython.<all> as
2990 expected. Also renamed __release__ to Release.
3013 expected. Also renamed __release__ to Release.
2991
3014
2992 * IPython/Debugger.py (__license__): created new Pdb class which
3015 * IPython/Debugger.py (__license__): created new Pdb class which
2993 functions like a drop-in for the normal pdb.Pdb but does NOT
3016 functions like a drop-in for the normal pdb.Pdb but does NOT
2994 import readline by default. This way it doesn't muck up IPython's
3017 import readline by default. This way it doesn't muck up IPython's
2995 readline handling, and now tab-completion finally works in the
3018 readline handling, and now tab-completion finally works in the
2996 debugger -- sort of. It completes things globally visible, but the
3019 debugger -- sort of. It completes things globally visible, but the
2997 completer doesn't track the stack as pdb walks it. That's a bit
3020 completer doesn't track the stack as pdb walks it. That's a bit
2998 tricky, and I'll have to implement it later.
3021 tricky, and I'll have to implement it later.
2999
3022
3000 2002-05-05 Fernando Perez <fperez@colorado.edu>
3023 2002-05-05 Fernando Perez <fperez@colorado.edu>
3001
3024
3002 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3025 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3003 magic docstrings when printed via ? (explicit \'s were being
3026 magic docstrings when printed via ? (explicit \'s were being
3004 printed).
3027 printed).
3005
3028
3006 * IPython/ipmaker.py (make_IPython): fixed namespace
3029 * IPython/ipmaker.py (make_IPython): fixed namespace
3007 identification bug. Now variables loaded via logs or command-line
3030 identification bug. Now variables loaded via logs or command-line
3008 files are recognized in the interactive namespace by @who.
3031 files are recognized in the interactive namespace by @who.
3009
3032
3010 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3033 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3011 log replay system stemming from the string form of Structs.
3034 log replay system stemming from the string form of Structs.
3012
3035
3013 * IPython/Magic.py (Macro.__init__): improved macros to properly
3036 * IPython/Magic.py (Macro.__init__): improved macros to properly
3014 handle magic commands in them.
3037 handle magic commands in them.
3015 (Magic.magic_logstart): usernames are now expanded so 'logstart
3038 (Magic.magic_logstart): usernames are now expanded so 'logstart
3016 ~/mylog' now works.
3039 ~/mylog' now works.
3017
3040
3018 * IPython/iplib.py (complete): fixed bug where paths starting with
3041 * IPython/iplib.py (complete): fixed bug where paths starting with
3019 '/' would be completed as magic names.
3042 '/' would be completed as magic names.
3020
3043
3021 2002-05-04 Fernando Perez <fperez@colorado.edu>
3044 2002-05-04 Fernando Perez <fperez@colorado.edu>
3022
3045
3023 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3046 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3024 allow running full programs under the profiler's control.
3047 allow running full programs under the profiler's control.
3025
3048
3026 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3049 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3027 mode to report exceptions verbosely but without formatting
3050 mode to report exceptions verbosely but without formatting
3028 variables. This addresses the issue of ipython 'freezing' (it's
3051 variables. This addresses the issue of ipython 'freezing' (it's
3029 not frozen, but caught in an expensive formatting loop) when huge
3052 not frozen, but caught in an expensive formatting loop) when huge
3030 variables are in the context of an exception.
3053 variables are in the context of an exception.
3031 (VerboseTB.text): Added '--->' markers at line where exception was
3054 (VerboseTB.text): Added '--->' markers at line where exception was
3032 triggered. Much clearer to read, especially in NoColor modes.
3055 triggered. Much clearer to read, especially in NoColor modes.
3033
3056
3034 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3057 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3035 implemented in reverse when changing to the new parse_options().
3058 implemented in reverse when changing to the new parse_options().
3036
3059
3037 2002-05-03 Fernando Perez <fperez@colorado.edu>
3060 2002-05-03 Fernando Perez <fperez@colorado.edu>
3038
3061
3039 * IPython/Magic.py (Magic.parse_options): new function so that
3062 * IPython/Magic.py (Magic.parse_options): new function so that
3040 magics can parse options easier.
3063 magics can parse options easier.
3041 (Magic.magic_prun): new function similar to profile.run(),
3064 (Magic.magic_prun): new function similar to profile.run(),
3042 suggested by Chris Hart.
3065 suggested by Chris Hart.
3043 (Magic.magic_cd): fixed behavior so that it only changes if
3066 (Magic.magic_cd): fixed behavior so that it only changes if
3044 directory actually is in history.
3067 directory actually is in history.
3045
3068
3046 * IPython/usage.py (__doc__): added information about potential
3069 * IPython/usage.py (__doc__): added information about potential
3047 slowness of Verbose exception mode when there are huge data
3070 slowness of Verbose exception mode when there are huge data
3048 structures to be formatted (thanks to Archie Paulson).
3071 structures to be formatted (thanks to Archie Paulson).
3049
3072
3050 * IPython/ipmaker.py (make_IPython): Changed default logging
3073 * IPython/ipmaker.py (make_IPython): Changed default logging
3051 (when simply called with -log) to use curr_dir/ipython.log in
3074 (when simply called with -log) to use curr_dir/ipython.log in
3052 rotate mode. Fixed crash which was occuring with -log before
3075 rotate mode. Fixed crash which was occuring with -log before
3053 (thanks to Jim Boyle).
3076 (thanks to Jim Boyle).
3054
3077
3055 2002-05-01 Fernando Perez <fperez@colorado.edu>
3078 2002-05-01 Fernando Perez <fperez@colorado.edu>
3056
3079
3057 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3080 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3058 was nasty -- though somewhat of a corner case).
3081 was nasty -- though somewhat of a corner case).
3059
3082
3060 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3083 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3061 text (was a bug).
3084 text (was a bug).
3062
3085
3063 2002-04-30 Fernando Perez <fperez@colorado.edu>
3086 2002-04-30 Fernando Perez <fperez@colorado.edu>
3064
3087
3065 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3088 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3066 a print after ^D or ^C from the user so that the In[] prompt
3089 a print after ^D or ^C from the user so that the In[] prompt
3067 doesn't over-run the gnuplot one.
3090 doesn't over-run the gnuplot one.
3068
3091
3069 2002-04-29 Fernando Perez <fperez@colorado.edu>
3092 2002-04-29 Fernando Perez <fperez@colorado.edu>
3070
3093
3071 * Released 0.2.10
3094 * Released 0.2.10
3072
3095
3073 * IPython/__release__.py (version): get date dynamically.
3096 * IPython/__release__.py (version): get date dynamically.
3074
3097
3075 * Misc. documentation updates thanks to Arnd's comments. Also ran
3098 * Misc. documentation updates thanks to Arnd's comments. Also ran
3076 a full spellcheck on the manual (hadn't been done in a while).
3099 a full spellcheck on the manual (hadn't been done in a while).
3077
3100
3078 2002-04-27 Fernando Perez <fperez@colorado.edu>
3101 2002-04-27 Fernando Perez <fperez@colorado.edu>
3079
3102
3080 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3103 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3081 starting a log in mid-session would reset the input history list.
3104 starting a log in mid-session would reset the input history list.
3082
3105
3083 2002-04-26 Fernando Perez <fperez@colorado.edu>
3106 2002-04-26 Fernando Perez <fperez@colorado.edu>
3084
3107
3085 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3108 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3086 all files were being included in an update. Now anything in
3109 all files were being included in an update. Now anything in
3087 UserConfig that matches [A-Za-z]*.py will go (this excludes
3110 UserConfig that matches [A-Za-z]*.py will go (this excludes
3088 __init__.py)
3111 __init__.py)
3089
3112
3090 2002-04-25 Fernando Perez <fperez@colorado.edu>
3113 2002-04-25 Fernando Perez <fperez@colorado.edu>
3091
3114
3092 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3115 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3093 to __builtins__ so that any form of embedded or imported code can
3116 to __builtins__ so that any form of embedded or imported code can
3094 test for being inside IPython.
3117 test for being inside IPython.
3095
3118
3096 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3119 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3097 changed to GnuplotMagic because it's now an importable module,
3120 changed to GnuplotMagic because it's now an importable module,
3098 this makes the name follow that of the standard Gnuplot module.
3121 this makes the name follow that of the standard Gnuplot module.
3099 GnuplotMagic can now be loaded at any time in mid-session.
3122 GnuplotMagic can now be loaded at any time in mid-session.
3100
3123
3101 2002-04-24 Fernando Perez <fperez@colorado.edu>
3124 2002-04-24 Fernando Perez <fperez@colorado.edu>
3102
3125
3103 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3126 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3104 the globals (IPython has its own namespace) and the
3127 the globals (IPython has its own namespace) and the
3105 PhysicalQuantity stuff is much better anyway.
3128 PhysicalQuantity stuff is much better anyway.
3106
3129
3107 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3130 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3108 embedding example to standard user directory for
3131 embedding example to standard user directory for
3109 distribution. Also put it in the manual.
3132 distribution. Also put it in the manual.
3110
3133
3111 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3134 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3112 instance as first argument (so it doesn't rely on some obscure
3135 instance as first argument (so it doesn't rely on some obscure
3113 hidden global).
3136 hidden global).
3114
3137
3115 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3138 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3116 delimiters. While it prevents ().TAB from working, it allows
3139 delimiters. While it prevents ().TAB from working, it allows
3117 completions in open (... expressions. This is by far a more common
3140 completions in open (... expressions. This is by far a more common
3118 case.
3141 case.
3119
3142
3120 2002-04-23 Fernando Perez <fperez@colorado.edu>
3143 2002-04-23 Fernando Perez <fperez@colorado.edu>
3121
3144
3122 * IPython/Extensions/InterpreterPasteInput.py: new
3145 * IPython/Extensions/InterpreterPasteInput.py: new
3123 syntax-processing module for pasting lines with >>> or ... at the
3146 syntax-processing module for pasting lines with >>> or ... at the
3124 start.
3147 start.
3125
3148
3126 * IPython/Extensions/PhysicalQ_Interactive.py
3149 * IPython/Extensions/PhysicalQ_Interactive.py
3127 (PhysicalQuantityInteractive.__int__): fixed to work with either
3150 (PhysicalQuantityInteractive.__int__): fixed to work with either
3128 Numeric or math.
3151 Numeric or math.
3129
3152
3130 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3153 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3131 provided profiles. Now we have:
3154 provided profiles. Now we have:
3132 -math -> math module as * and cmath with its own namespace.
3155 -math -> math module as * and cmath with its own namespace.
3133 -numeric -> Numeric as *, plus gnuplot & grace
3156 -numeric -> Numeric as *, plus gnuplot & grace
3134 -physics -> same as before
3157 -physics -> same as before
3135
3158
3136 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3159 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3137 user-defined magics wouldn't be found by @magic if they were
3160 user-defined magics wouldn't be found by @magic if they were
3138 defined as class methods. Also cleaned up the namespace search
3161 defined as class methods. Also cleaned up the namespace search
3139 logic and the string building (to use %s instead of many repeated
3162 logic and the string building (to use %s instead of many repeated
3140 string adds).
3163 string adds).
3141
3164
3142 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3165 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3143 of user-defined magics to operate with class methods (cleaner, in
3166 of user-defined magics to operate with class methods (cleaner, in
3144 line with the gnuplot code).
3167 line with the gnuplot code).
3145
3168
3146 2002-04-22 Fernando Perez <fperez@colorado.edu>
3169 2002-04-22 Fernando Perez <fperez@colorado.edu>
3147
3170
3148 * setup.py: updated dependency list so that manual is updated when
3171 * setup.py: updated dependency list so that manual is updated when
3149 all included files change.
3172 all included files change.
3150
3173
3151 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3174 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3152 the delimiter removal option (the fix is ugly right now).
3175 the delimiter removal option (the fix is ugly right now).
3153
3176
3154 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3177 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3155 all of the math profile (quicker loading, no conflict between
3178 all of the math profile (quicker loading, no conflict between
3156 g-9.8 and g-gnuplot).
3179 g-9.8 and g-gnuplot).
3157
3180
3158 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3181 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3159 name of post-mortem files to IPython_crash_report.txt.
3182 name of post-mortem files to IPython_crash_report.txt.
3160
3183
3161 * Cleanup/update of the docs. Added all the new readline info and
3184 * Cleanup/update of the docs. Added all the new readline info and
3162 formatted all lists as 'real lists'.
3185 formatted all lists as 'real lists'.
3163
3186
3164 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3187 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3165 tab-completion options, since the full readline parse_and_bind is
3188 tab-completion options, since the full readline parse_and_bind is
3166 now accessible.
3189 now accessible.
3167
3190
3168 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3191 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3169 handling of readline options. Now users can specify any string to
3192 handling of readline options. Now users can specify any string to
3170 be passed to parse_and_bind(), as well as the delimiters to be
3193 be passed to parse_and_bind(), as well as the delimiters to be
3171 removed.
3194 removed.
3172 (InteractiveShell.__init__): Added __name__ to the global
3195 (InteractiveShell.__init__): Added __name__ to the global
3173 namespace so that things like Itpl which rely on its existence
3196 namespace so that things like Itpl which rely on its existence
3174 don't crash.
3197 don't crash.
3175 (InteractiveShell._prefilter): Defined the default with a _ so
3198 (InteractiveShell._prefilter): Defined the default with a _ so
3176 that prefilter() is easier to override, while the default one
3199 that prefilter() is easier to override, while the default one
3177 remains available.
3200 remains available.
3178
3201
3179 2002-04-18 Fernando Perez <fperez@colorado.edu>
3202 2002-04-18 Fernando Perez <fperez@colorado.edu>
3180
3203
3181 * Added information about pdb in the docs.
3204 * Added information about pdb in the docs.
3182
3205
3183 2002-04-17 Fernando Perez <fperez@colorado.edu>
3206 2002-04-17 Fernando Perez <fperez@colorado.edu>
3184
3207
3185 * IPython/ipmaker.py (make_IPython): added rc_override option to
3208 * IPython/ipmaker.py (make_IPython): added rc_override option to
3186 allow passing config options at creation time which may override
3209 allow passing config options at creation time which may override
3187 anything set in the config files or command line. This is
3210 anything set in the config files or command line. This is
3188 particularly useful for configuring embedded instances.
3211 particularly useful for configuring embedded instances.
3189
3212
3190 2002-04-15 Fernando Perez <fperez@colorado.edu>
3213 2002-04-15 Fernando Perez <fperez@colorado.edu>
3191
3214
3192 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3215 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3193 crash embedded instances because of the input cache falling out of
3216 crash embedded instances because of the input cache falling out of
3194 sync with the output counter.
3217 sync with the output counter.
3195
3218
3196 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3219 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3197 mode which calls pdb after an uncaught exception in IPython itself.
3220 mode which calls pdb after an uncaught exception in IPython itself.
3198
3221
3199 2002-04-14 Fernando Perez <fperez@colorado.edu>
3222 2002-04-14 Fernando Perez <fperez@colorado.edu>
3200
3223
3201 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3224 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3202 readline, fix it back after each call.
3225 readline, fix it back after each call.
3203
3226
3204 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3227 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3205 method to force all access via __call__(), which guarantees that
3228 method to force all access via __call__(), which guarantees that
3206 traceback references are properly deleted.
3229 traceback references are properly deleted.
3207
3230
3208 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3231 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3209 improve printing when pprint is in use.
3232 improve printing when pprint is in use.
3210
3233
3211 2002-04-13 Fernando Perez <fperez@colorado.edu>
3234 2002-04-13 Fernando Perez <fperez@colorado.edu>
3212
3235
3213 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3236 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3214 exceptions aren't caught anymore. If the user triggers one, he
3237 exceptions aren't caught anymore. If the user triggers one, he
3215 should know why he's doing it and it should go all the way up,
3238 should know why he's doing it and it should go all the way up,
3216 just like any other exception. So now @abort will fully kill the
3239 just like any other exception. So now @abort will fully kill the
3217 embedded interpreter and the embedding code (unless that happens
3240 embedded interpreter and the embedding code (unless that happens
3218 to catch SystemExit).
3241 to catch SystemExit).
3219
3242
3220 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3243 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3221 and a debugger() method to invoke the interactive pdb debugger
3244 and a debugger() method to invoke the interactive pdb debugger
3222 after printing exception information. Also added the corresponding
3245 after printing exception information. Also added the corresponding
3223 -pdb option and @pdb magic to control this feature, and updated
3246 -pdb option and @pdb magic to control this feature, and updated
3224 the docs. After a suggestion from Christopher Hart
3247 the docs. After a suggestion from Christopher Hart
3225 (hart-AT-caltech.edu).
3248 (hart-AT-caltech.edu).
3226
3249
3227 2002-04-12 Fernando Perez <fperez@colorado.edu>
3250 2002-04-12 Fernando Perez <fperez@colorado.edu>
3228
3251
3229 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3252 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3230 the exception handlers defined by the user (not the CrashHandler)
3253 the exception handlers defined by the user (not the CrashHandler)
3231 so that user exceptions don't trigger an ipython bug report.
3254 so that user exceptions don't trigger an ipython bug report.
3232
3255
3233 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3256 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3234 configurable (it should have always been so).
3257 configurable (it should have always been so).
3235
3258
3236 2002-03-26 Fernando Perez <fperez@colorado.edu>
3259 2002-03-26 Fernando Perez <fperez@colorado.edu>
3237
3260
3238 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3261 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3239 and there to fix embedding namespace issues. This should all be
3262 and there to fix embedding namespace issues. This should all be
3240 done in a more elegant way.
3263 done in a more elegant way.
3241
3264
3242 2002-03-25 Fernando Perez <fperez@colorado.edu>
3265 2002-03-25 Fernando Perez <fperez@colorado.edu>
3243
3266
3244 * IPython/genutils.py (get_home_dir): Try to make it work under
3267 * IPython/genutils.py (get_home_dir): Try to make it work under
3245 win9x also.
3268 win9x also.
3246
3269
3247 2002-03-20 Fernando Perez <fperez@colorado.edu>
3270 2002-03-20 Fernando Perez <fperez@colorado.edu>
3248
3271
3249 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3272 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3250 sys.displayhook untouched upon __init__.
3273 sys.displayhook untouched upon __init__.
3251
3274
3252 2002-03-19 Fernando Perez <fperez@colorado.edu>
3275 2002-03-19 Fernando Perez <fperez@colorado.edu>
3253
3276
3254 * Released 0.2.9 (for embedding bug, basically).
3277 * Released 0.2.9 (for embedding bug, basically).
3255
3278
3256 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3279 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3257 exceptions so that enclosing shell's state can be restored.
3280 exceptions so that enclosing shell's state can be restored.
3258
3281
3259 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3282 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3260 naming conventions in the .ipython/ dir.
3283 naming conventions in the .ipython/ dir.
3261
3284
3262 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3285 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3263 from delimiters list so filenames with - in them get expanded.
3286 from delimiters list so filenames with - in them get expanded.
3264
3287
3265 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3288 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3266 sys.displayhook not being properly restored after an embedded call.
3289 sys.displayhook not being properly restored after an embedded call.
3267
3290
3268 2002-03-18 Fernando Perez <fperez@colorado.edu>
3291 2002-03-18 Fernando Perez <fperez@colorado.edu>
3269
3292
3270 * Released 0.2.8
3293 * Released 0.2.8
3271
3294
3272 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3295 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3273 some files weren't being included in a -upgrade.
3296 some files weren't being included in a -upgrade.
3274 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3297 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3275 on' so that the first tab completes.
3298 on' so that the first tab completes.
3276 (InteractiveShell.handle_magic): fixed bug with spaces around
3299 (InteractiveShell.handle_magic): fixed bug with spaces around
3277 quotes breaking many magic commands.
3300 quotes breaking many magic commands.
3278
3301
3279 * setup.py: added note about ignoring the syntax error messages at
3302 * setup.py: added note about ignoring the syntax error messages at
3280 installation.
3303 installation.
3281
3304
3282 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3305 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3283 streamlining the gnuplot interface, now there's only one magic @gp.
3306 streamlining the gnuplot interface, now there's only one magic @gp.
3284
3307
3285 2002-03-17 Fernando Perez <fperez@colorado.edu>
3308 2002-03-17 Fernando Perez <fperez@colorado.edu>
3286
3309
3287 * IPython/UserConfig/magic_gnuplot.py: new name for the
3310 * IPython/UserConfig/magic_gnuplot.py: new name for the
3288 example-magic_pm.py file. Much enhanced system, now with a shell
3311 example-magic_pm.py file. Much enhanced system, now with a shell
3289 for communicating directly with gnuplot, one command at a time.
3312 for communicating directly with gnuplot, one command at a time.
3290
3313
3291 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3314 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3292 setting __name__=='__main__'.
3315 setting __name__=='__main__'.
3293
3316
3294 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3317 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3295 mini-shell for accessing gnuplot from inside ipython. Should
3318 mini-shell for accessing gnuplot from inside ipython. Should
3296 extend it later for grace access too. Inspired by Arnd's
3319 extend it later for grace access too. Inspired by Arnd's
3297 suggestion.
3320 suggestion.
3298
3321
3299 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3322 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3300 calling magic functions with () in their arguments. Thanks to Arnd
3323 calling magic functions with () in their arguments. Thanks to Arnd
3301 Baecker for pointing this to me.
3324 Baecker for pointing this to me.
3302
3325
3303 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3326 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3304 infinitely for integer or complex arrays (only worked with floats).
3327 infinitely for integer or complex arrays (only worked with floats).
3305
3328
3306 2002-03-16 Fernando Perez <fperez@colorado.edu>
3329 2002-03-16 Fernando Perez <fperez@colorado.edu>
3307
3330
3308 * setup.py: Merged setup and setup_windows into a single script
3331 * setup.py: Merged setup and setup_windows into a single script
3309 which properly handles things for windows users.
3332 which properly handles things for windows users.
3310
3333
3311 2002-03-15 Fernando Perez <fperez@colorado.edu>
3334 2002-03-15 Fernando Perez <fperez@colorado.edu>
3312
3335
3313 * Big change to the manual: now the magics are all automatically
3336 * Big change to the manual: now the magics are all automatically
3314 documented. This information is generated from their docstrings
3337 documented. This information is generated from their docstrings
3315 and put in a latex file included by the manual lyx file. This way
3338 and put in a latex file included by the manual lyx file. This way
3316 we get always up to date information for the magics. The manual
3339 we get always up to date information for the magics. The manual
3317 now also has proper version information, also auto-synced.
3340 now also has proper version information, also auto-synced.
3318
3341
3319 For this to work, an undocumented --magic_docstrings option was added.
3342 For this to work, an undocumented --magic_docstrings option was added.
3320
3343
3321 2002-03-13 Fernando Perez <fperez@colorado.edu>
3344 2002-03-13 Fernando Perez <fperez@colorado.edu>
3322
3345
3323 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3346 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3324 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3347 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3325
3348
3326 2002-03-12 Fernando Perez <fperez@colorado.edu>
3349 2002-03-12 Fernando Perez <fperez@colorado.edu>
3327
3350
3328 * IPython/ultraTB.py (TermColors): changed color escapes again to
3351 * IPython/ultraTB.py (TermColors): changed color escapes again to
3329 fix the (old, reintroduced) line-wrapping bug. Basically, if
3352 fix the (old, reintroduced) line-wrapping bug. Basically, if
3330 \001..\002 aren't given in the color escapes, lines get wrapped
3353 \001..\002 aren't given in the color escapes, lines get wrapped
3331 weirdly. But giving those screws up old xterms and emacs terms. So
3354 weirdly. But giving those screws up old xterms and emacs terms. So
3332 I added some logic for emacs terms to be ok, but I can't identify old
3355 I added some logic for emacs terms to be ok, but I can't identify old
3333 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3356 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3334
3357
3335 2002-03-10 Fernando Perez <fperez@colorado.edu>
3358 2002-03-10 Fernando Perez <fperez@colorado.edu>
3336
3359
3337 * IPython/usage.py (__doc__): Various documentation cleanups and
3360 * IPython/usage.py (__doc__): Various documentation cleanups and
3338 updates, both in usage docstrings and in the manual.
3361 updates, both in usage docstrings and in the manual.
3339
3362
3340 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3363 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3341 handling of caching. Set minimum acceptabe value for having a
3364 handling of caching. Set minimum acceptabe value for having a
3342 cache at 20 values.
3365 cache at 20 values.
3343
3366
3344 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3367 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3345 install_first_time function to a method, renamed it and added an
3368 install_first_time function to a method, renamed it and added an
3346 'upgrade' mode. Now people can update their config directory with
3369 'upgrade' mode. Now people can update their config directory with
3347 a simple command line switch (-upgrade, also new).
3370 a simple command line switch (-upgrade, also new).
3348
3371
3349 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3372 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3350 @file (convenient for automagic users under Python >= 2.2).
3373 @file (convenient for automagic users under Python >= 2.2).
3351 Removed @files (it seemed more like a plural than an abbrev. of
3374 Removed @files (it seemed more like a plural than an abbrev. of
3352 'file show').
3375 'file show').
3353
3376
3354 * IPython/iplib.py (install_first_time): Fixed crash if there were
3377 * IPython/iplib.py (install_first_time): Fixed crash if there were
3355 backup files ('~') in .ipython/ install directory.
3378 backup files ('~') in .ipython/ install directory.
3356
3379
3357 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3380 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3358 system. Things look fine, but these changes are fairly
3381 system. Things look fine, but these changes are fairly
3359 intrusive. Test them for a few days.
3382 intrusive. Test them for a few days.
3360
3383
3361 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3384 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3362 the prompts system. Now all in/out prompt strings are user
3385 the prompts system. Now all in/out prompt strings are user
3363 controllable. This is particularly useful for embedding, as one
3386 controllable. This is particularly useful for embedding, as one
3364 can tag embedded instances with particular prompts.
3387 can tag embedded instances with particular prompts.
3365
3388
3366 Also removed global use of sys.ps1/2, which now allows nested
3389 Also removed global use of sys.ps1/2, which now allows nested
3367 embeddings without any problems. Added command-line options for
3390 embeddings without any problems. Added command-line options for
3368 the prompt strings.
3391 the prompt strings.
3369
3392
3370 2002-03-08 Fernando Perez <fperez@colorado.edu>
3393 2002-03-08 Fernando Perez <fperez@colorado.edu>
3371
3394
3372 * IPython/UserConfig/example-embed-short.py (ipshell): added
3395 * IPython/UserConfig/example-embed-short.py (ipshell): added
3373 example file with the bare minimum code for embedding.
3396 example file with the bare minimum code for embedding.
3374
3397
3375 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3398 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3376 functionality for the embeddable shell to be activated/deactivated
3399 functionality for the embeddable shell to be activated/deactivated
3377 either globally or at each call.
3400 either globally or at each call.
3378
3401
3379 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3402 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3380 rewriting the prompt with '--->' for auto-inputs with proper
3403 rewriting the prompt with '--->' for auto-inputs with proper
3381 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3404 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3382 this is handled by the prompts class itself, as it should.
3405 this is handled by the prompts class itself, as it should.
3383
3406
3384 2002-03-05 Fernando Perez <fperez@colorado.edu>
3407 2002-03-05 Fernando Perez <fperez@colorado.edu>
3385
3408
3386 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3409 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3387 @logstart to avoid name clashes with the math log function.
3410 @logstart to avoid name clashes with the math log function.
3388
3411
3389 * Big updates to X/Emacs section of the manual.
3412 * Big updates to X/Emacs section of the manual.
3390
3413
3391 * Removed ipython_emacs. Milan explained to me how to pass
3414 * Removed ipython_emacs. Milan explained to me how to pass
3392 arguments to ipython through Emacs. Some day I'm going to end up
3415 arguments to ipython through Emacs. Some day I'm going to end up
3393 learning some lisp...
3416 learning some lisp...
3394
3417
3395 2002-03-04 Fernando Perez <fperez@colorado.edu>
3418 2002-03-04 Fernando Perez <fperez@colorado.edu>
3396
3419
3397 * IPython/ipython_emacs: Created script to be used as the
3420 * IPython/ipython_emacs: Created script to be used as the
3398 py-python-command Emacs variable so we can pass IPython
3421 py-python-command Emacs variable so we can pass IPython
3399 parameters. I can't figure out how to tell Emacs directly to pass
3422 parameters. I can't figure out how to tell Emacs directly to pass
3400 parameters to IPython, so a dummy shell script will do it.
3423 parameters to IPython, so a dummy shell script will do it.
3401
3424
3402 Other enhancements made for things to work better under Emacs'
3425 Other enhancements made for things to work better under Emacs'
3403 various types of terminals. Many thanks to Milan Zamazal
3426 various types of terminals. Many thanks to Milan Zamazal
3404 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3427 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3405
3428
3406 2002-03-01 Fernando Perez <fperez@colorado.edu>
3429 2002-03-01 Fernando Perez <fperez@colorado.edu>
3407
3430
3408 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3431 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3409 that loading of readline is now optional. This gives better
3432 that loading of readline is now optional. This gives better
3410 control to emacs users.
3433 control to emacs users.
3411
3434
3412 * IPython/ultraTB.py (__date__): Modified color escape sequences
3435 * IPython/ultraTB.py (__date__): Modified color escape sequences
3413 and now things work fine under xterm and in Emacs' term buffers
3436 and now things work fine under xterm and in Emacs' term buffers
3414 (though not shell ones). Well, in emacs you get colors, but all
3437 (though not shell ones). Well, in emacs you get colors, but all
3415 seem to be 'light' colors (no difference between dark and light
3438 seem to be 'light' colors (no difference between dark and light
3416 ones). But the garbage chars are gone, and also in xterms. It
3439 ones). But the garbage chars are gone, and also in xterms. It
3417 seems that now I'm using 'cleaner' ansi sequences.
3440 seems that now I'm using 'cleaner' ansi sequences.
3418
3441
3419 2002-02-21 Fernando Perez <fperez@colorado.edu>
3442 2002-02-21 Fernando Perez <fperez@colorado.edu>
3420
3443
3421 * Released 0.2.7 (mainly to publish the scoping fix).
3444 * Released 0.2.7 (mainly to publish the scoping fix).
3422
3445
3423 * IPython/Logger.py (Logger.logstate): added. A corresponding
3446 * IPython/Logger.py (Logger.logstate): added. A corresponding
3424 @logstate magic was created.
3447 @logstate magic was created.
3425
3448
3426 * IPython/Magic.py: fixed nested scoping problem under Python
3449 * IPython/Magic.py: fixed nested scoping problem under Python
3427 2.1.x (automagic wasn't working).
3450 2.1.x (automagic wasn't working).
3428
3451
3429 2002-02-20 Fernando Perez <fperez@colorado.edu>
3452 2002-02-20 Fernando Perez <fperez@colorado.edu>
3430
3453
3431 * Released 0.2.6.
3454 * Released 0.2.6.
3432
3455
3433 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3456 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3434 option so that logs can come out without any headers at all.
3457 option so that logs can come out without any headers at all.
3435
3458
3436 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3459 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3437 SciPy.
3460 SciPy.
3438
3461
3439 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3462 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3440 that embedded IPython calls don't require vars() to be explicitly
3463 that embedded IPython calls don't require vars() to be explicitly
3441 passed. Now they are extracted from the caller's frame (code
3464 passed. Now they are extracted from the caller's frame (code
3442 snatched from Eric Jones' weave). Added better documentation to
3465 snatched from Eric Jones' weave). Added better documentation to
3443 the section on embedding and the example file.
3466 the section on embedding and the example file.
3444
3467
3445 * IPython/genutils.py (page): Changed so that under emacs, it just
3468 * IPython/genutils.py (page): Changed so that under emacs, it just
3446 prints the string. You can then page up and down in the emacs
3469 prints the string. You can then page up and down in the emacs
3447 buffer itself. This is how the builtin help() works.
3470 buffer itself. This is how the builtin help() works.
3448
3471
3449 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3472 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3450 macro scoping: macros need to be executed in the user's namespace
3473 macro scoping: macros need to be executed in the user's namespace
3451 to work as if they had been typed by the user.
3474 to work as if they had been typed by the user.
3452
3475
3453 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3476 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3454 execute automatically (no need to type 'exec...'). They then
3477 execute automatically (no need to type 'exec...'). They then
3455 behave like 'true macros'. The printing system was also modified
3478 behave like 'true macros'. The printing system was also modified
3456 for this to work.
3479 for this to work.
3457
3480
3458 2002-02-19 Fernando Perez <fperez@colorado.edu>
3481 2002-02-19 Fernando Perez <fperez@colorado.edu>
3459
3482
3460 * IPython/genutils.py (page_file): new function for paging files
3483 * IPython/genutils.py (page_file): new function for paging files
3461 in an OS-independent way. Also necessary for file viewing to work
3484 in an OS-independent way. Also necessary for file viewing to work
3462 well inside Emacs buffers.
3485 well inside Emacs buffers.
3463 (page): Added checks for being in an emacs buffer.
3486 (page): Added checks for being in an emacs buffer.
3464 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3487 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3465 same bug in iplib.
3488 same bug in iplib.
3466
3489
3467 2002-02-18 Fernando Perez <fperez@colorado.edu>
3490 2002-02-18 Fernando Perez <fperez@colorado.edu>
3468
3491
3469 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3492 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3470 of readline so that IPython can work inside an Emacs buffer.
3493 of readline so that IPython can work inside an Emacs buffer.
3471
3494
3472 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3495 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3473 method signatures (they weren't really bugs, but it looks cleaner
3496 method signatures (they weren't really bugs, but it looks cleaner
3474 and keeps PyChecker happy).
3497 and keeps PyChecker happy).
3475
3498
3476 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3499 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3477 for implementing various user-defined hooks. Currently only
3500 for implementing various user-defined hooks. Currently only
3478 display is done.
3501 display is done.
3479
3502
3480 * IPython/Prompts.py (CachedOutput._display): changed display
3503 * IPython/Prompts.py (CachedOutput._display): changed display
3481 functions so that they can be dynamically changed by users easily.
3504 functions so that they can be dynamically changed by users easily.
3482
3505
3483 * IPython/Extensions/numeric_formats.py (num_display): added an
3506 * IPython/Extensions/numeric_formats.py (num_display): added an
3484 extension for printing NumPy arrays in flexible manners. It
3507 extension for printing NumPy arrays in flexible manners. It
3485 doesn't do anything yet, but all the structure is in
3508 doesn't do anything yet, but all the structure is in
3486 place. Ultimately the plan is to implement output format control
3509 place. Ultimately the plan is to implement output format control
3487 like in Octave.
3510 like in Octave.
3488
3511
3489 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3512 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3490 methods are found at run-time by all the automatic machinery.
3513 methods are found at run-time by all the automatic machinery.
3491
3514
3492 2002-02-17 Fernando Perez <fperez@colorado.edu>
3515 2002-02-17 Fernando Perez <fperez@colorado.edu>
3493
3516
3494 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3517 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3495 whole file a little.
3518 whole file a little.
3496
3519
3497 * ToDo: closed this document. Now there's a new_design.lyx
3520 * ToDo: closed this document. Now there's a new_design.lyx
3498 document for all new ideas. Added making a pdf of it for the
3521 document for all new ideas. Added making a pdf of it for the
3499 end-user distro.
3522 end-user distro.
3500
3523
3501 * IPython/Logger.py (Logger.switch_log): Created this to replace
3524 * IPython/Logger.py (Logger.switch_log): Created this to replace
3502 logon() and logoff(). It also fixes a nasty crash reported by
3525 logon() and logoff(). It also fixes a nasty crash reported by
3503 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3526 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3504
3527
3505 * IPython/iplib.py (complete): got auto-completion to work with
3528 * IPython/iplib.py (complete): got auto-completion to work with
3506 automagic (I had wanted this for a long time).
3529 automagic (I had wanted this for a long time).
3507
3530
3508 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3531 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3509 to @file, since file() is now a builtin and clashes with automagic
3532 to @file, since file() is now a builtin and clashes with automagic
3510 for @file.
3533 for @file.
3511
3534
3512 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3535 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3513 of this was previously in iplib, which had grown to more than 2000
3536 of this was previously in iplib, which had grown to more than 2000
3514 lines, way too long. No new functionality, but it makes managing
3537 lines, way too long. No new functionality, but it makes managing
3515 the code a bit easier.
3538 the code a bit easier.
3516
3539
3517 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3540 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3518 information to crash reports.
3541 information to crash reports.
3519
3542
3520 2002-02-12 Fernando Perez <fperez@colorado.edu>
3543 2002-02-12 Fernando Perez <fperez@colorado.edu>
3521
3544
3522 * Released 0.2.5.
3545 * Released 0.2.5.
3523
3546
3524 2002-02-11 Fernando Perez <fperez@colorado.edu>
3547 2002-02-11 Fernando Perez <fperez@colorado.edu>
3525
3548
3526 * Wrote a relatively complete Windows installer. It puts
3549 * Wrote a relatively complete Windows installer. It puts
3527 everything in place, creates Start Menu entries and fixes the
3550 everything in place, creates Start Menu entries and fixes the
3528 color issues. Nothing fancy, but it works.
3551 color issues. Nothing fancy, but it works.
3529
3552
3530 2002-02-10 Fernando Perez <fperez@colorado.edu>
3553 2002-02-10 Fernando Perez <fperez@colorado.edu>
3531
3554
3532 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3555 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3533 os.path.expanduser() call so that we can type @run ~/myfile.py and
3556 os.path.expanduser() call so that we can type @run ~/myfile.py and
3534 have thigs work as expected.
3557 have thigs work as expected.
3535
3558
3536 * IPython/genutils.py (page): fixed exception handling so things
3559 * IPython/genutils.py (page): fixed exception handling so things
3537 work both in Unix and Windows correctly. Quitting a pager triggers
3560 work both in Unix and Windows correctly. Quitting a pager triggers
3538 an IOError/broken pipe in Unix, and in windows not finding a pager
3561 an IOError/broken pipe in Unix, and in windows not finding a pager
3539 is also an IOError, so I had to actually look at the return value
3562 is also an IOError, so I had to actually look at the return value
3540 of the exception, not just the exception itself. Should be ok now.
3563 of the exception, not just the exception itself. Should be ok now.
3541
3564
3542 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3565 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3543 modified to allow case-insensitive color scheme changes.
3566 modified to allow case-insensitive color scheme changes.
3544
3567
3545 2002-02-09 Fernando Perez <fperez@colorado.edu>
3568 2002-02-09 Fernando Perez <fperez@colorado.edu>
3546
3569
3547 * IPython/genutils.py (native_line_ends): new function to leave
3570 * IPython/genutils.py (native_line_ends): new function to leave
3548 user config files with os-native line-endings.
3571 user config files with os-native line-endings.
3549
3572
3550 * README and manual updates.
3573 * README and manual updates.
3551
3574
3552 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3575 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3553 instead of StringType to catch Unicode strings.
3576 instead of StringType to catch Unicode strings.
3554
3577
3555 * IPython/genutils.py (filefind): fixed bug for paths with
3578 * IPython/genutils.py (filefind): fixed bug for paths with
3556 embedded spaces (very common in Windows).
3579 embedded spaces (very common in Windows).
3557
3580
3558 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3581 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3559 files under Windows, so that they get automatically associated
3582 files under Windows, so that they get automatically associated
3560 with a text editor. Windows makes it a pain to handle
3583 with a text editor. Windows makes it a pain to handle
3561 extension-less files.
3584 extension-less files.
3562
3585
3563 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3586 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3564 warning about readline only occur for Posix. In Windows there's no
3587 warning about readline only occur for Posix. In Windows there's no
3565 way to get readline, so why bother with the warning.
3588 way to get readline, so why bother with the warning.
3566
3589
3567 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3590 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3568 for __str__ instead of dir(self), since dir() changed in 2.2.
3591 for __str__ instead of dir(self), since dir() changed in 2.2.
3569
3592
3570 * Ported to Windows! Tested on XP, I suspect it should work fine
3593 * Ported to Windows! Tested on XP, I suspect it should work fine
3571 on NT/2000, but I don't think it will work on 98 et al. That
3594 on NT/2000, but I don't think it will work on 98 et al. That
3572 series of Windows is such a piece of junk anyway that I won't try
3595 series of Windows is such a piece of junk anyway that I won't try
3573 porting it there. The XP port was straightforward, showed a few
3596 porting it there. The XP port was straightforward, showed a few
3574 bugs here and there (fixed all), in particular some string
3597 bugs here and there (fixed all), in particular some string
3575 handling stuff which required considering Unicode strings (which
3598 handling stuff which required considering Unicode strings (which
3576 Windows uses). This is good, but hasn't been too tested :) No
3599 Windows uses). This is good, but hasn't been too tested :) No
3577 fancy installer yet, I'll put a note in the manual so people at
3600 fancy installer yet, I'll put a note in the manual so people at
3578 least make manually a shortcut.
3601 least make manually a shortcut.
3579
3602
3580 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3603 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3581 into a single one, "colors". This now controls both prompt and
3604 into a single one, "colors". This now controls both prompt and
3582 exception color schemes, and can be changed both at startup
3605 exception color schemes, and can be changed both at startup
3583 (either via command-line switches or via ipythonrc files) and at
3606 (either via command-line switches or via ipythonrc files) and at
3584 runtime, with @colors.
3607 runtime, with @colors.
3585 (Magic.magic_run): renamed @prun to @run and removed the old
3608 (Magic.magic_run): renamed @prun to @run and removed the old
3586 @run. The two were too similar to warrant keeping both.
3609 @run. The two were too similar to warrant keeping both.
3587
3610
3588 2002-02-03 Fernando Perez <fperez@colorado.edu>
3611 2002-02-03 Fernando Perez <fperez@colorado.edu>
3589
3612
3590 * IPython/iplib.py (install_first_time): Added comment on how to
3613 * IPython/iplib.py (install_first_time): Added comment on how to
3591 configure the color options for first-time users. Put a <return>
3614 configure the color options for first-time users. Put a <return>
3592 request at the end so that small-terminal users get a chance to
3615 request at the end so that small-terminal users get a chance to
3593 read the startup info.
3616 read the startup info.
3594
3617
3595 2002-01-23 Fernando Perez <fperez@colorado.edu>
3618 2002-01-23 Fernando Perez <fperez@colorado.edu>
3596
3619
3597 * IPython/iplib.py (CachedOutput.update): Changed output memory
3620 * IPython/iplib.py (CachedOutput.update): Changed output memory
3598 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3621 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3599 input history we still use _i. Did this b/c these variable are
3622 input history we still use _i. Did this b/c these variable are
3600 very commonly used in interactive work, so the less we need to
3623 very commonly used in interactive work, so the less we need to
3601 type the better off we are.
3624 type the better off we are.
3602 (Magic.magic_prun): updated @prun to better handle the namespaces
3625 (Magic.magic_prun): updated @prun to better handle the namespaces
3603 the file will run in, including a fix for __name__ not being set
3626 the file will run in, including a fix for __name__ not being set
3604 before.
3627 before.
3605
3628
3606 2002-01-20 Fernando Perez <fperez@colorado.edu>
3629 2002-01-20 Fernando Perez <fperez@colorado.edu>
3607
3630
3608 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3631 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3609 extra garbage for Python 2.2. Need to look more carefully into
3632 extra garbage for Python 2.2. Need to look more carefully into
3610 this later.
3633 this later.
3611
3634
3612 2002-01-19 Fernando Perez <fperez@colorado.edu>
3635 2002-01-19 Fernando Perez <fperez@colorado.edu>
3613
3636
3614 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3637 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3615 display SyntaxError exceptions properly formatted when they occur
3638 display SyntaxError exceptions properly formatted when they occur
3616 (they can be triggered by imported code).
3639 (they can be triggered by imported code).
3617
3640
3618 2002-01-18 Fernando Perez <fperez@colorado.edu>
3641 2002-01-18 Fernando Perez <fperez@colorado.edu>
3619
3642
3620 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3643 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3621 SyntaxError exceptions are reported nicely formatted, instead of
3644 SyntaxError exceptions are reported nicely formatted, instead of
3622 spitting out only offset information as before.
3645 spitting out only offset information as before.
3623 (Magic.magic_prun): Added the @prun function for executing
3646 (Magic.magic_prun): Added the @prun function for executing
3624 programs with command line args inside IPython.
3647 programs with command line args inside IPython.
3625
3648
3626 2002-01-16 Fernando Perez <fperez@colorado.edu>
3649 2002-01-16 Fernando Perez <fperez@colorado.edu>
3627
3650
3628 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3651 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3629 to *not* include the last item given in a range. This brings their
3652 to *not* include the last item given in a range. This brings their
3630 behavior in line with Python's slicing:
3653 behavior in line with Python's slicing:
3631 a[n1:n2] -> a[n1]...a[n2-1]
3654 a[n1:n2] -> a[n1]...a[n2-1]
3632 It may be a bit less convenient, but I prefer to stick to Python's
3655 It may be a bit less convenient, but I prefer to stick to Python's
3633 conventions *everywhere*, so users never have to wonder.
3656 conventions *everywhere*, so users never have to wonder.
3634 (Magic.magic_macro): Added @macro function to ease the creation of
3657 (Magic.magic_macro): Added @macro function to ease the creation of
3635 macros.
3658 macros.
3636
3659
3637 2002-01-05 Fernando Perez <fperez@colorado.edu>
3660 2002-01-05 Fernando Perez <fperez@colorado.edu>
3638
3661
3639 * Released 0.2.4.
3662 * Released 0.2.4.
3640
3663
3641 * IPython/iplib.py (Magic.magic_pdef):
3664 * IPython/iplib.py (Magic.magic_pdef):
3642 (InteractiveShell.safe_execfile): report magic lines and error
3665 (InteractiveShell.safe_execfile): report magic lines and error
3643 lines without line numbers so one can easily copy/paste them for
3666 lines without line numbers so one can easily copy/paste them for
3644 re-execution.
3667 re-execution.
3645
3668
3646 * Updated manual with recent changes.
3669 * Updated manual with recent changes.
3647
3670
3648 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3671 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3649 docstring printing when class? is called. Very handy for knowing
3672 docstring printing when class? is called. Very handy for knowing
3650 how to create class instances (as long as __init__ is well
3673 how to create class instances (as long as __init__ is well
3651 documented, of course :)
3674 documented, of course :)
3652 (Magic.magic_doc): print both class and constructor docstrings.
3675 (Magic.magic_doc): print both class and constructor docstrings.
3653 (Magic.magic_pdef): give constructor info if passed a class and
3676 (Magic.magic_pdef): give constructor info if passed a class and
3654 __call__ info for callable object instances.
3677 __call__ info for callable object instances.
3655
3678
3656 2002-01-04 Fernando Perez <fperez@colorado.edu>
3679 2002-01-04 Fernando Perez <fperez@colorado.edu>
3657
3680
3658 * Made deep_reload() off by default. It doesn't always work
3681 * Made deep_reload() off by default. It doesn't always work
3659 exactly as intended, so it's probably safer to have it off. It's
3682 exactly as intended, so it's probably safer to have it off. It's
3660 still available as dreload() anyway, so nothing is lost.
3683 still available as dreload() anyway, so nothing is lost.
3661
3684
3662 2002-01-02 Fernando Perez <fperez@colorado.edu>
3685 2002-01-02 Fernando Perez <fperez@colorado.edu>
3663
3686
3664 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3687 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3665 so I wanted an updated release).
3688 so I wanted an updated release).
3666
3689
3667 2001-12-27 Fernando Perez <fperez@colorado.edu>
3690 2001-12-27 Fernando Perez <fperez@colorado.edu>
3668
3691
3669 * IPython/iplib.py (InteractiveShell.interact): Added the original
3692 * IPython/iplib.py (InteractiveShell.interact): Added the original
3670 code from 'code.py' for this module in order to change the
3693 code from 'code.py' for this module in order to change the
3671 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3694 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3672 the history cache would break when the user hit Ctrl-C, and
3695 the history cache would break when the user hit Ctrl-C, and
3673 interact() offers no way to add any hooks to it.
3696 interact() offers no way to add any hooks to it.
3674
3697
3675 2001-12-23 Fernando Perez <fperez@colorado.edu>
3698 2001-12-23 Fernando Perez <fperez@colorado.edu>
3676
3699
3677 * setup.py: added check for 'MANIFEST' before trying to remove
3700 * setup.py: added check for 'MANIFEST' before trying to remove
3678 it. Thanks to Sean Reifschneider.
3701 it. Thanks to Sean Reifschneider.
3679
3702
3680 2001-12-22 Fernando Perez <fperez@colorado.edu>
3703 2001-12-22 Fernando Perez <fperez@colorado.edu>
3681
3704
3682 * Released 0.2.2.
3705 * Released 0.2.2.
3683
3706
3684 * Finished (reasonably) writing the manual. Later will add the
3707 * Finished (reasonably) writing the manual. Later will add the
3685 python-standard navigation stylesheets, but for the time being
3708 python-standard navigation stylesheets, but for the time being
3686 it's fairly complete. Distribution will include html and pdf
3709 it's fairly complete. Distribution will include html and pdf
3687 versions.
3710 versions.
3688
3711
3689 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3712 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3690 (MayaVi author).
3713 (MayaVi author).
3691
3714
3692 2001-12-21 Fernando Perez <fperez@colorado.edu>
3715 2001-12-21 Fernando Perez <fperez@colorado.edu>
3693
3716
3694 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3717 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3695 good public release, I think (with the manual and the distutils
3718 good public release, I think (with the manual and the distutils
3696 installer). The manual can use some work, but that can go
3719 installer). The manual can use some work, but that can go
3697 slowly. Otherwise I think it's quite nice for end users. Next
3720 slowly. Otherwise I think it's quite nice for end users. Next
3698 summer, rewrite the guts of it...
3721 summer, rewrite the guts of it...
3699
3722
3700 * Changed format of ipythonrc files to use whitespace as the
3723 * Changed format of ipythonrc files to use whitespace as the
3701 separator instead of an explicit '='. Cleaner.
3724 separator instead of an explicit '='. Cleaner.
3702
3725
3703 2001-12-20 Fernando Perez <fperez@colorado.edu>
3726 2001-12-20 Fernando Perez <fperez@colorado.edu>
3704
3727
3705 * Started a manual in LyX. For now it's just a quick merge of the
3728 * Started a manual in LyX. For now it's just a quick merge of the
3706 various internal docstrings and READMEs. Later it may grow into a
3729 various internal docstrings and READMEs. Later it may grow into a
3707 nice, full-blown manual.
3730 nice, full-blown manual.
3708
3731
3709 * Set up a distutils based installer. Installation should now be
3732 * Set up a distutils based installer. Installation should now be
3710 trivially simple for end-users.
3733 trivially simple for end-users.
3711
3734
3712 2001-12-11 Fernando Perez <fperez@colorado.edu>
3735 2001-12-11 Fernando Perez <fperez@colorado.edu>
3713
3736
3714 * Released 0.2.0. First public release, announced it at
3737 * Released 0.2.0. First public release, announced it at
3715 comp.lang.python. From now on, just bugfixes...
3738 comp.lang.python. From now on, just bugfixes...
3716
3739
3717 * Went through all the files, set copyright/license notices and
3740 * Went through all the files, set copyright/license notices and
3718 cleaned up things. Ready for release.
3741 cleaned up things. Ready for release.
3719
3742
3720 2001-12-10 Fernando Perez <fperez@colorado.edu>
3743 2001-12-10 Fernando Perez <fperez@colorado.edu>
3721
3744
3722 * Changed the first-time installer not to use tarfiles. It's more
3745 * Changed the first-time installer not to use tarfiles. It's more
3723 robust now and less unix-dependent. Also makes it easier for
3746 robust now and less unix-dependent. Also makes it easier for
3724 people to later upgrade versions.
3747 people to later upgrade versions.
3725
3748
3726 * Changed @exit to @abort to reflect the fact that it's pretty
3749 * Changed @exit to @abort to reflect the fact that it's pretty
3727 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3750 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3728 becomes significant only when IPyhton is embedded: in that case,
3751 becomes significant only when IPyhton is embedded: in that case,
3729 C-D closes IPython only, but @abort kills the enclosing program
3752 C-D closes IPython only, but @abort kills the enclosing program
3730 too (unless it had called IPython inside a try catching
3753 too (unless it had called IPython inside a try catching
3731 SystemExit).
3754 SystemExit).
3732
3755
3733 * Created Shell module which exposes the actuall IPython Shell
3756 * Created Shell module which exposes the actuall IPython Shell
3734 classes, currently the normal and the embeddable one. This at
3757 classes, currently the normal and the embeddable one. This at
3735 least offers a stable interface we won't need to change when
3758 least offers a stable interface we won't need to change when
3736 (later) the internals are rewritten. That rewrite will be confined
3759 (later) the internals are rewritten. That rewrite will be confined
3737 to iplib and ipmaker, but the Shell interface should remain as is.
3760 to iplib and ipmaker, but the Shell interface should remain as is.
3738
3761
3739 * Added embed module which offers an embeddable IPShell object,
3762 * Added embed module which offers an embeddable IPShell object,
3740 useful to fire up IPython *inside* a running program. Great for
3763 useful to fire up IPython *inside* a running program. Great for
3741 debugging or dynamical data analysis.
3764 debugging or dynamical data analysis.
3742
3765
3743 2001-12-08 Fernando Perez <fperez@colorado.edu>
3766 2001-12-08 Fernando Perez <fperez@colorado.edu>
3744
3767
3745 * Fixed small bug preventing seeing info from methods of defined
3768 * Fixed small bug preventing seeing info from methods of defined
3746 objects (incorrect namespace in _ofind()).
3769 objects (incorrect namespace in _ofind()).
3747
3770
3748 * Documentation cleanup. Moved the main usage docstrings to a
3771 * Documentation cleanup. Moved the main usage docstrings to a
3749 separate file, usage.py (cleaner to maintain, and hopefully in the
3772 separate file, usage.py (cleaner to maintain, and hopefully in the
3750 future some perlpod-like way of producing interactive, man and
3773 future some perlpod-like way of producing interactive, man and
3751 html docs out of it will be found).
3774 html docs out of it will be found).
3752
3775
3753 * Added @profile to see your profile at any time.
3776 * Added @profile to see your profile at any time.
3754
3777
3755 * Added @p as an alias for 'print'. It's especially convenient if
3778 * Added @p as an alias for 'print'. It's especially convenient if
3756 using automagic ('p x' prints x).
3779 using automagic ('p x' prints x).
3757
3780
3758 * Small cleanups and fixes after a pychecker run.
3781 * Small cleanups and fixes after a pychecker run.
3759
3782
3760 * Changed the @cd command to handle @cd - and @cd -<n> for
3783 * Changed the @cd command to handle @cd - and @cd -<n> for
3761 visiting any directory in _dh.
3784 visiting any directory in _dh.
3762
3785
3763 * Introduced _dh, a history of visited directories. @dhist prints
3786 * Introduced _dh, a history of visited directories. @dhist prints
3764 it out with numbers.
3787 it out with numbers.
3765
3788
3766 2001-12-07 Fernando Perez <fperez@colorado.edu>
3789 2001-12-07 Fernando Perez <fperez@colorado.edu>
3767
3790
3768 * Released 0.1.22
3791 * Released 0.1.22
3769
3792
3770 * Made initialization a bit more robust against invalid color
3793 * Made initialization a bit more robust against invalid color
3771 options in user input (exit, not traceback-crash).
3794 options in user input (exit, not traceback-crash).
3772
3795
3773 * Changed the bug crash reporter to write the report only in the
3796 * Changed the bug crash reporter to write the report only in the
3774 user's .ipython directory. That way IPython won't litter people's
3797 user's .ipython directory. That way IPython won't litter people's
3775 hard disks with crash files all over the place. Also print on
3798 hard disks with crash files all over the place. Also print on
3776 screen the necessary mail command.
3799 screen the necessary mail command.
3777
3800
3778 * With the new ultraTB, implemented LightBG color scheme for light
3801 * With the new ultraTB, implemented LightBG color scheme for light
3779 background terminals. A lot of people like white backgrounds, so I
3802 background terminals. A lot of people like white backgrounds, so I
3780 guess we should at least give them something readable.
3803 guess we should at least give them something readable.
3781
3804
3782 2001-12-06 Fernando Perez <fperez@colorado.edu>
3805 2001-12-06 Fernando Perez <fperez@colorado.edu>
3783
3806
3784 * Modified the structure of ultraTB. Now there's a proper class
3807 * Modified the structure of ultraTB. Now there's a proper class
3785 for tables of color schemes which allow adding schemes easily and
3808 for tables of color schemes which allow adding schemes easily and
3786 switching the active scheme without creating a new instance every
3809 switching the active scheme without creating a new instance every
3787 time (which was ridiculous). The syntax for creating new schemes
3810 time (which was ridiculous). The syntax for creating new schemes
3788 is also cleaner. I think ultraTB is finally done, with a clean
3811 is also cleaner. I think ultraTB is finally done, with a clean
3789 class structure. Names are also much cleaner (now there's proper
3812 class structure. Names are also much cleaner (now there's proper
3790 color tables, no need for every variable to also have 'color' in
3813 color tables, no need for every variable to also have 'color' in
3791 its name).
3814 its name).
3792
3815
3793 * Broke down genutils into separate files. Now genutils only
3816 * Broke down genutils into separate files. Now genutils only
3794 contains utility functions, and classes have been moved to their
3817 contains utility functions, and classes have been moved to their
3795 own files (they had enough independent functionality to warrant
3818 own files (they had enough independent functionality to warrant
3796 it): ConfigLoader, OutputTrap, Struct.
3819 it): ConfigLoader, OutputTrap, Struct.
3797
3820
3798 2001-12-05 Fernando Perez <fperez@colorado.edu>
3821 2001-12-05 Fernando Perez <fperez@colorado.edu>
3799
3822
3800 * IPython turns 21! Released version 0.1.21, as a candidate for
3823 * IPython turns 21! Released version 0.1.21, as a candidate for
3801 public consumption. If all goes well, release in a few days.
3824 public consumption. If all goes well, release in a few days.
3802
3825
3803 * Fixed path bug (files in Extensions/ directory wouldn't be found
3826 * Fixed path bug (files in Extensions/ directory wouldn't be found
3804 unless IPython/ was explicitly in sys.path).
3827 unless IPython/ was explicitly in sys.path).
3805
3828
3806 * Extended the FlexCompleter class as MagicCompleter to allow
3829 * Extended the FlexCompleter class as MagicCompleter to allow
3807 completion of @-starting lines.
3830 completion of @-starting lines.
3808
3831
3809 * Created __release__.py file as a central repository for release
3832 * Created __release__.py file as a central repository for release
3810 info that other files can read from.
3833 info that other files can read from.
3811
3834
3812 * Fixed small bug in logging: when logging was turned on in
3835 * Fixed small bug in logging: when logging was turned on in
3813 mid-session, old lines with special meanings (!@?) were being
3836 mid-session, old lines with special meanings (!@?) were being
3814 logged without the prepended comment, which is necessary since
3837 logged without the prepended comment, which is necessary since
3815 they are not truly valid python syntax. This should make session
3838 they are not truly valid python syntax. This should make session
3816 restores produce less errors.
3839 restores produce less errors.
3817
3840
3818 * The namespace cleanup forced me to make a FlexCompleter class
3841 * The namespace cleanup forced me to make a FlexCompleter class
3819 which is nothing but a ripoff of rlcompleter, but with selectable
3842 which is nothing but a ripoff of rlcompleter, but with selectable
3820 namespace (rlcompleter only works in __main__.__dict__). I'll try
3843 namespace (rlcompleter only works in __main__.__dict__). I'll try
3821 to submit a note to the authors to see if this change can be
3844 to submit a note to the authors to see if this change can be
3822 incorporated in future rlcompleter releases (Dec.6: done)
3845 incorporated in future rlcompleter releases (Dec.6: done)
3823
3846
3824 * More fixes to namespace handling. It was a mess! Now all
3847 * More fixes to namespace handling. It was a mess! Now all
3825 explicit references to __main__.__dict__ are gone (except when
3848 explicit references to __main__.__dict__ are gone (except when
3826 really needed) and everything is handled through the namespace
3849 really needed) and everything is handled through the namespace
3827 dicts in the IPython instance. We seem to be getting somewhere
3850 dicts in the IPython instance. We seem to be getting somewhere
3828 with this, finally...
3851 with this, finally...
3829
3852
3830 * Small documentation updates.
3853 * Small documentation updates.
3831
3854
3832 * Created the Extensions directory under IPython (with an
3855 * Created the Extensions directory under IPython (with an
3833 __init__.py). Put the PhysicalQ stuff there. This directory should
3856 __init__.py). Put the PhysicalQ stuff there. This directory should
3834 be used for all special-purpose extensions.
3857 be used for all special-purpose extensions.
3835
3858
3836 * File renaming:
3859 * File renaming:
3837 ipythonlib --> ipmaker
3860 ipythonlib --> ipmaker
3838 ipplib --> iplib
3861 ipplib --> iplib
3839 This makes a bit more sense in terms of what these files actually do.
3862 This makes a bit more sense in terms of what these files actually do.
3840
3863
3841 * Moved all the classes and functions in ipythonlib to ipplib, so
3864 * Moved all the classes and functions in ipythonlib to ipplib, so
3842 now ipythonlib only has make_IPython(). This will ease up its
3865 now ipythonlib only has make_IPython(). This will ease up its
3843 splitting in smaller functional chunks later.
3866 splitting in smaller functional chunks later.
3844
3867
3845 * Cleaned up (done, I think) output of @whos. Better column
3868 * Cleaned up (done, I think) output of @whos. Better column
3846 formatting, and now shows str(var) for as much as it can, which is
3869 formatting, and now shows str(var) for as much as it can, which is
3847 typically what one gets with a 'print var'.
3870 typically what one gets with a 'print var'.
3848
3871
3849 2001-12-04 Fernando Perez <fperez@colorado.edu>
3872 2001-12-04 Fernando Perez <fperez@colorado.edu>
3850
3873
3851 * Fixed namespace problems. Now builtin/IPyhton/user names get
3874 * Fixed namespace problems. Now builtin/IPyhton/user names get
3852 properly reported in their namespace. Internal namespace handling
3875 properly reported in their namespace. Internal namespace handling
3853 is finally getting decent (not perfect yet, but much better than
3876 is finally getting decent (not perfect yet, but much better than
3854 the ad-hoc mess we had).
3877 the ad-hoc mess we had).
3855
3878
3856 * Removed -exit option. If people just want to run a python
3879 * Removed -exit option. If people just want to run a python
3857 script, that's what the normal interpreter is for. Less
3880 script, that's what the normal interpreter is for. Less
3858 unnecessary options, less chances for bugs.
3881 unnecessary options, less chances for bugs.
3859
3882
3860 * Added a crash handler which generates a complete post-mortem if
3883 * Added a crash handler which generates a complete post-mortem if
3861 IPython crashes. This will help a lot in tracking bugs down the
3884 IPython crashes. This will help a lot in tracking bugs down the
3862 road.
3885 road.
3863
3886
3864 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3887 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3865 which were boud to functions being reassigned would bypass the
3888 which were boud to functions being reassigned would bypass the
3866 logger, breaking the sync of _il with the prompt counter. This
3889 logger, breaking the sync of _il with the prompt counter. This
3867 would then crash IPython later when a new line was logged.
3890 would then crash IPython later when a new line was logged.
3868
3891
3869 2001-12-02 Fernando Perez <fperez@colorado.edu>
3892 2001-12-02 Fernando Perez <fperez@colorado.edu>
3870
3893
3871 * Made IPython a package. This means people don't have to clutter
3894 * Made IPython a package. This means people don't have to clutter
3872 their sys.path with yet another directory. Changed the INSTALL
3895 their sys.path with yet another directory. Changed the INSTALL
3873 file accordingly.
3896 file accordingly.
3874
3897
3875 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3898 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3876 sorts its output (so @who shows it sorted) and @whos formats the
3899 sorts its output (so @who shows it sorted) and @whos formats the
3877 table according to the width of the first column. Nicer, easier to
3900 table according to the width of the first column. Nicer, easier to
3878 read. Todo: write a generic table_format() which takes a list of
3901 read. Todo: write a generic table_format() which takes a list of
3879 lists and prints it nicely formatted, with optional row/column
3902 lists and prints it nicely formatted, with optional row/column
3880 separators and proper padding and justification.
3903 separators and proper padding and justification.
3881
3904
3882 * Released 0.1.20
3905 * Released 0.1.20
3883
3906
3884 * Fixed bug in @log which would reverse the inputcache list (a
3907 * Fixed bug in @log which would reverse the inputcache list (a
3885 copy operation was missing).
3908 copy operation was missing).
3886
3909
3887 * Code cleanup. @config was changed to use page(). Better, since
3910 * Code cleanup. @config was changed to use page(). Better, since
3888 its output is always quite long.
3911 its output is always quite long.
3889
3912
3890 * Itpl is back as a dependency. I was having too many problems
3913 * Itpl is back as a dependency. I was having too many problems
3891 getting the parametric aliases to work reliably, and it's just
3914 getting the parametric aliases to work reliably, and it's just
3892 easier to code weird string operations with it than playing %()s
3915 easier to code weird string operations with it than playing %()s
3893 games. It's only ~6k, so I don't think it's too big a deal.
3916 games. It's only ~6k, so I don't think it's too big a deal.
3894
3917
3895 * Found (and fixed) a very nasty bug with history. !lines weren't
3918 * Found (and fixed) a very nasty bug with history. !lines weren't
3896 getting cached, and the out of sync caches would crash
3919 getting cached, and the out of sync caches would crash
3897 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3920 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3898 division of labor a bit better. Bug fixed, cleaner structure.
3921 division of labor a bit better. Bug fixed, cleaner structure.
3899
3922
3900 2001-12-01 Fernando Perez <fperez@colorado.edu>
3923 2001-12-01 Fernando Perez <fperez@colorado.edu>
3901
3924
3902 * Released 0.1.19
3925 * Released 0.1.19
3903
3926
3904 * Added option -n to @hist to prevent line number printing. Much
3927 * Added option -n to @hist to prevent line number printing. Much
3905 easier to copy/paste code this way.
3928 easier to copy/paste code this way.
3906
3929
3907 * Created global _il to hold the input list. Allows easy
3930 * Created global _il to hold the input list. Allows easy
3908 re-execution of blocks of code by slicing it (inspired by Janko's
3931 re-execution of blocks of code by slicing it (inspired by Janko's
3909 comment on 'macros').
3932 comment on 'macros').
3910
3933
3911 * Small fixes and doc updates.
3934 * Small fixes and doc updates.
3912
3935
3913 * Rewrote @history function (was @h). Renamed it to @hist, @h is
3936 * Rewrote @history function (was @h). Renamed it to @hist, @h is
3914 much too fragile with automagic. Handles properly multi-line
3937 much too fragile with automagic. Handles properly multi-line
3915 statements and takes parameters.
3938 statements and takes parameters.
3916
3939
3917 2001-11-30 Fernando Perez <fperez@colorado.edu>
3940 2001-11-30 Fernando Perez <fperez@colorado.edu>
3918
3941
3919 * Version 0.1.18 released.
3942 * Version 0.1.18 released.
3920
3943
3921 * Fixed nasty namespace bug in initial module imports.
3944 * Fixed nasty namespace bug in initial module imports.
3922
3945
3923 * Added copyright/license notes to all code files (except
3946 * Added copyright/license notes to all code files (except
3924 DPyGetOpt). For the time being, LGPL. That could change.
3947 DPyGetOpt). For the time being, LGPL. That could change.
3925
3948
3926 * Rewrote a much nicer README, updated INSTALL, cleaned up
3949 * Rewrote a much nicer README, updated INSTALL, cleaned up
3927 ipythonrc-* samples.
3950 ipythonrc-* samples.
3928
3951
3929 * Overall code/documentation cleanup. Basically ready for
3952 * Overall code/documentation cleanup. Basically ready for
3930 release. Only remaining thing: licence decision (LGPL?).
3953 release. Only remaining thing: licence decision (LGPL?).
3931
3954
3932 * Converted load_config to a class, ConfigLoader. Now recursion
3955 * Converted load_config to a class, ConfigLoader. Now recursion
3933 control is better organized. Doesn't include the same file twice.
3956 control is better organized. Doesn't include the same file twice.
3934
3957
3935 2001-11-29 Fernando Perez <fperez@colorado.edu>
3958 2001-11-29 Fernando Perez <fperez@colorado.edu>
3936
3959
3937 * Got input history working. Changed output history variables from
3960 * Got input history working. Changed output history variables from
3938 _p to _o so that _i is for input and _o for output. Just cleaner
3961 _p to _o so that _i is for input and _o for output. Just cleaner
3939 convention.
3962 convention.
3940
3963
3941 * Implemented parametric aliases. This pretty much allows the
3964 * Implemented parametric aliases. This pretty much allows the
3942 alias system to offer full-blown shell convenience, I think.
3965 alias system to offer full-blown shell convenience, I think.
3943
3966
3944 * Version 0.1.17 released, 0.1.18 opened.
3967 * Version 0.1.17 released, 0.1.18 opened.
3945
3968
3946 * dot_ipython/ipythonrc (alias): added documentation.
3969 * dot_ipython/ipythonrc (alias): added documentation.
3947 (xcolor): Fixed small bug (xcolors -> xcolor)
3970 (xcolor): Fixed small bug (xcolors -> xcolor)
3948
3971
3949 * Changed the alias system. Now alias is a magic command to define
3972 * Changed the alias system. Now alias is a magic command to define
3950 aliases just like the shell. Rationale: the builtin magics should
3973 aliases just like the shell. Rationale: the builtin magics should
3951 be there for things deeply connected to IPython's
3974 be there for things deeply connected to IPython's
3952 architecture. And this is a much lighter system for what I think
3975 architecture. And this is a much lighter system for what I think
3953 is the really important feature: allowing users to define quickly
3976 is the really important feature: allowing users to define quickly
3954 magics that will do shell things for them, so they can customize
3977 magics that will do shell things for them, so they can customize
3955 IPython easily to match their work habits. If someone is really
3978 IPython easily to match their work habits. If someone is really
3956 desperate to have another name for a builtin alias, they can
3979 desperate to have another name for a builtin alias, they can
3957 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
3980 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
3958 works.
3981 works.
3959
3982
3960 2001-11-28 Fernando Perez <fperez@colorado.edu>
3983 2001-11-28 Fernando Perez <fperez@colorado.edu>
3961
3984
3962 * Changed @file so that it opens the source file at the proper
3985 * Changed @file so that it opens the source file at the proper
3963 line. Since it uses less, if your EDITOR environment is
3986 line. Since it uses less, if your EDITOR environment is
3964 configured, typing v will immediately open your editor of choice
3987 configured, typing v will immediately open your editor of choice
3965 right at the line where the object is defined. Not as quick as
3988 right at the line where the object is defined. Not as quick as
3966 having a direct @edit command, but for all intents and purposes it
3989 having a direct @edit command, but for all intents and purposes it
3967 works. And I don't have to worry about writing @edit to deal with
3990 works. And I don't have to worry about writing @edit to deal with
3968 all the editors, less does that.
3991 all the editors, less does that.
3969
3992
3970 * Version 0.1.16 released, 0.1.17 opened.
3993 * Version 0.1.16 released, 0.1.17 opened.
3971
3994
3972 * Fixed some nasty bugs in the page/page_dumb combo that could
3995 * Fixed some nasty bugs in the page/page_dumb combo that could
3973 crash IPython.
3996 crash IPython.
3974
3997
3975 2001-11-27 Fernando Perez <fperez@colorado.edu>
3998 2001-11-27 Fernando Perez <fperez@colorado.edu>
3976
3999
3977 * Version 0.1.15 released, 0.1.16 opened.
4000 * Version 0.1.15 released, 0.1.16 opened.
3978
4001
3979 * Finally got ? and ?? to work for undefined things: now it's
4002 * Finally got ? and ?? to work for undefined things: now it's
3980 possible to type {}.get? and get information about the get method
4003 possible to type {}.get? and get information about the get method
3981 of dicts, or os.path? even if only os is defined (so technically
4004 of dicts, or os.path? even if only os is defined (so technically
3982 os.path isn't). Works at any level. For example, after import os,
4005 os.path isn't). Works at any level. For example, after import os,
3983 os?, os.path?, os.path.abspath? all work. This is great, took some
4006 os?, os.path?, os.path.abspath? all work. This is great, took some
3984 work in _ofind.
4007 work in _ofind.
3985
4008
3986 * Fixed more bugs with logging. The sanest way to do it was to add
4009 * Fixed more bugs with logging. The sanest way to do it was to add
3987 to @log a 'mode' parameter. Killed two in one shot (this mode
4010 to @log a 'mode' parameter. Killed two in one shot (this mode
3988 option was a request of Janko's). I think it's finally clean
4011 option was a request of Janko's). I think it's finally clean
3989 (famous last words).
4012 (famous last words).
3990
4013
3991 * Added a page_dumb() pager which does a decent job of paging on
4014 * Added a page_dumb() pager which does a decent job of paging on
3992 screen, if better things (like less) aren't available. One less
4015 screen, if better things (like less) aren't available. One less
3993 unix dependency (someday maybe somebody will port this to
4016 unix dependency (someday maybe somebody will port this to
3994 windows).
4017 windows).
3995
4018
3996 * Fixed problem in magic_log: would lock of logging out if log
4019 * Fixed problem in magic_log: would lock of logging out if log
3997 creation failed (because it would still think it had succeeded).
4020 creation failed (because it would still think it had succeeded).
3998
4021
3999 * Improved the page() function using curses to auto-detect screen
4022 * Improved the page() function using curses to auto-detect screen
4000 size. Now it can make a much better decision on whether to print
4023 size. Now it can make a much better decision on whether to print
4001 or page a string. Option screen_length was modified: a value 0
4024 or page a string. Option screen_length was modified: a value 0
4002 means auto-detect, and that's the default now.
4025 means auto-detect, and that's the default now.
4003
4026
4004 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4027 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4005 go out. I'll test it for a few days, then talk to Janko about
4028 go out. I'll test it for a few days, then talk to Janko about
4006 licences and announce it.
4029 licences and announce it.
4007
4030
4008 * Fixed the length of the auto-generated ---> prompt which appears
4031 * Fixed the length of the auto-generated ---> prompt which appears
4009 for auto-parens and auto-quotes. Getting this right isn't trivial,
4032 for auto-parens and auto-quotes. Getting this right isn't trivial,
4010 with all the color escapes, different prompt types and optional
4033 with all the color escapes, different prompt types and optional
4011 separators. But it seems to be working in all the combinations.
4034 separators. But it seems to be working in all the combinations.
4012
4035
4013 2001-11-26 Fernando Perez <fperez@colorado.edu>
4036 2001-11-26 Fernando Perez <fperez@colorado.edu>
4014
4037
4015 * Wrote a regexp filter to get option types from the option names
4038 * Wrote a regexp filter to get option types from the option names
4016 string. This eliminates the need to manually keep two duplicate
4039 string. This eliminates the need to manually keep two duplicate
4017 lists.
4040 lists.
4018
4041
4019 * Removed the unneeded check_option_names. Now options are handled
4042 * Removed the unneeded check_option_names. Now options are handled
4020 in a much saner manner and it's easy to visually check that things
4043 in a much saner manner and it's easy to visually check that things
4021 are ok.
4044 are ok.
4022
4045
4023 * Updated version numbers on all files I modified to carry a
4046 * Updated version numbers on all files I modified to carry a
4024 notice so Janko and Nathan have clear version markers.
4047 notice so Janko and Nathan have clear version markers.
4025
4048
4026 * Updated docstring for ultraTB with my changes. I should send
4049 * Updated docstring for ultraTB with my changes. I should send
4027 this to Nathan.
4050 this to Nathan.
4028
4051
4029 * Lots of small fixes. Ran everything through pychecker again.
4052 * Lots of small fixes. Ran everything through pychecker again.
4030
4053
4031 * Made loading of deep_reload an cmd line option. If it's not too
4054 * Made loading of deep_reload an cmd line option. If it's not too
4032 kosher, now people can just disable it. With -nodeep_reload it's
4055 kosher, now people can just disable it. With -nodeep_reload it's
4033 still available as dreload(), it just won't overwrite reload().
4056 still available as dreload(), it just won't overwrite reload().
4034
4057
4035 * Moved many options to the no| form (-opt and -noopt
4058 * Moved many options to the no| form (-opt and -noopt
4036 accepted). Cleaner.
4059 accepted). Cleaner.
4037
4060
4038 * Changed magic_log so that if called with no parameters, it uses
4061 * Changed magic_log so that if called with no parameters, it uses
4039 'rotate' mode. That way auto-generated logs aren't automatically
4062 'rotate' mode. That way auto-generated logs aren't automatically
4040 over-written. For normal logs, now a backup is made if it exists
4063 over-written. For normal logs, now a backup is made if it exists
4041 (only 1 level of backups). A new 'backup' mode was added to the
4064 (only 1 level of backups). A new 'backup' mode was added to the
4042 Logger class to support this. This was a request by Janko.
4065 Logger class to support this. This was a request by Janko.
4043
4066
4044 * Added @logoff/@logon to stop/restart an active log.
4067 * Added @logoff/@logon to stop/restart an active log.
4045
4068
4046 * Fixed a lot of bugs in log saving/replay. It was pretty
4069 * Fixed a lot of bugs in log saving/replay. It was pretty
4047 broken. Now special lines (!@,/) appear properly in the command
4070 broken. Now special lines (!@,/) appear properly in the command
4048 history after a log replay.
4071 history after a log replay.
4049
4072
4050 * Tried and failed to implement full session saving via pickle. My
4073 * Tried and failed to implement full session saving via pickle. My
4051 idea was to pickle __main__.__dict__, but modules can't be
4074 idea was to pickle __main__.__dict__, but modules can't be
4052 pickled. This would be a better alternative to replaying logs, but
4075 pickled. This would be a better alternative to replaying logs, but
4053 seems quite tricky to get to work. Changed -session to be called
4076 seems quite tricky to get to work. Changed -session to be called
4054 -logplay, which more accurately reflects what it does. And if we
4077 -logplay, which more accurately reflects what it does. And if we
4055 ever get real session saving working, -session is now available.
4078 ever get real session saving working, -session is now available.
4056
4079
4057 * Implemented color schemes for prompts also. As for tracebacks,
4080 * Implemented color schemes for prompts also. As for tracebacks,
4058 currently only NoColor and Linux are supported. But now the
4081 currently only NoColor and Linux are supported. But now the
4059 infrastructure is in place, based on a generic ColorScheme
4082 infrastructure is in place, based on a generic ColorScheme
4060 class. So writing and activating new schemes both for the prompts
4083 class. So writing and activating new schemes both for the prompts
4061 and the tracebacks should be straightforward.
4084 and the tracebacks should be straightforward.
4062
4085
4063 * Version 0.1.13 released, 0.1.14 opened.
4086 * Version 0.1.13 released, 0.1.14 opened.
4064
4087
4065 * Changed handling of options for output cache. Now counter is
4088 * Changed handling of options for output cache. Now counter is
4066 hardwired starting at 1 and one specifies the maximum number of
4089 hardwired starting at 1 and one specifies the maximum number of
4067 entries *in the outcache* (not the max prompt counter). This is
4090 entries *in the outcache* (not the max prompt counter). This is
4068 much better, since many statements won't increase the cache
4091 much better, since many statements won't increase the cache
4069 count. It also eliminated some confusing options, now there's only
4092 count. It also eliminated some confusing options, now there's only
4070 one: cache_size.
4093 one: cache_size.
4071
4094
4072 * Added 'alias' magic function and magic_alias option in the
4095 * Added 'alias' magic function and magic_alias option in the
4073 ipythonrc file. Now the user can easily define whatever names he
4096 ipythonrc file. Now the user can easily define whatever names he
4074 wants for the magic functions without having to play weird
4097 wants for the magic functions without having to play weird
4075 namespace games. This gives IPython a real shell-like feel.
4098 namespace games. This gives IPython a real shell-like feel.
4076
4099
4077 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4100 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4078 @ or not).
4101 @ or not).
4079
4102
4080 This was one of the last remaining 'visible' bugs (that I know
4103 This was one of the last remaining 'visible' bugs (that I know
4081 of). I think if I can clean up the session loading so it works
4104 of). I think if I can clean up the session loading so it works
4082 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4105 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4083 about licensing).
4106 about licensing).
4084
4107
4085 2001-11-25 Fernando Perez <fperez@colorado.edu>
4108 2001-11-25 Fernando Perez <fperez@colorado.edu>
4086
4109
4087 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4110 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4088 there's a cleaner distinction between what ? and ?? show.
4111 there's a cleaner distinction between what ? and ?? show.
4089
4112
4090 * Added screen_length option. Now the user can define his own
4113 * Added screen_length option. Now the user can define his own
4091 screen size for page() operations.
4114 screen size for page() operations.
4092
4115
4093 * Implemented magic shell-like functions with automatic code
4116 * Implemented magic shell-like functions with automatic code
4094 generation. Now adding another function is just a matter of adding
4117 generation. Now adding another function is just a matter of adding
4095 an entry to a dict, and the function is dynamically generated at
4118 an entry to a dict, and the function is dynamically generated at
4096 run-time. Python has some really cool features!
4119 run-time. Python has some really cool features!
4097
4120
4098 * Renamed many options to cleanup conventions a little. Now all
4121 * Renamed many options to cleanup conventions a little. Now all
4099 are lowercase, and only underscores where needed. Also in the code
4122 are lowercase, and only underscores where needed. Also in the code
4100 option name tables are clearer.
4123 option name tables are clearer.
4101
4124
4102 * Changed prompts a little. Now input is 'In [n]:' instead of
4125 * Changed prompts a little. Now input is 'In [n]:' instead of
4103 'In[n]:='. This allows it the numbers to be aligned with the
4126 'In[n]:='. This allows it the numbers to be aligned with the
4104 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4127 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4105 Python (it was a Mathematica thing). The '...' continuation prompt
4128 Python (it was a Mathematica thing). The '...' continuation prompt
4106 was also changed a little to align better.
4129 was also changed a little to align better.
4107
4130
4108 * Fixed bug when flushing output cache. Not all _p<n> variables
4131 * Fixed bug when flushing output cache. Not all _p<n> variables
4109 exist, so their deletion needs to be wrapped in a try:
4132 exist, so their deletion needs to be wrapped in a try:
4110
4133
4111 * Figured out how to properly use inspect.formatargspec() (it
4134 * Figured out how to properly use inspect.formatargspec() (it
4112 requires the args preceded by *). So I removed all the code from
4135 requires the args preceded by *). So I removed all the code from
4113 _get_pdef in Magic, which was just replicating that.
4136 _get_pdef in Magic, which was just replicating that.
4114
4137
4115 * Added test to prefilter to allow redefining magic function names
4138 * Added test to prefilter to allow redefining magic function names
4116 as variables. This is ok, since the @ form is always available,
4139 as variables. This is ok, since the @ form is always available,
4117 but whe should allow the user to define a variable called 'ls' if
4140 but whe should allow the user to define a variable called 'ls' if
4118 he needs it.
4141 he needs it.
4119
4142
4120 * Moved the ToDo information from README into a separate ToDo.
4143 * Moved the ToDo information from README into a separate ToDo.
4121
4144
4122 * General code cleanup and small bugfixes. I think it's close to a
4145 * General code cleanup and small bugfixes. I think it's close to a
4123 state where it can be released, obviously with a big 'beta'
4146 state where it can be released, obviously with a big 'beta'
4124 warning on it.
4147 warning on it.
4125
4148
4126 * Got the magic function split to work. Now all magics are defined
4149 * Got the magic function split to work. Now all magics are defined
4127 in a separate class. It just organizes things a bit, and now
4150 in a separate class. It just organizes things a bit, and now
4128 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4151 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4129 was too long).
4152 was too long).
4130
4153
4131 * Changed @clear to @reset to avoid potential confusions with
4154 * Changed @clear to @reset to avoid potential confusions with
4132 the shell command clear. Also renamed @cl to @clear, which does
4155 the shell command clear. Also renamed @cl to @clear, which does
4133 exactly what people expect it to from their shell experience.
4156 exactly what people expect it to from their shell experience.
4134
4157
4135 Added a check to the @reset command (since it's so
4158 Added a check to the @reset command (since it's so
4136 destructive, it's probably a good idea to ask for confirmation).
4159 destructive, it's probably a good idea to ask for confirmation).
4137 But now reset only works for full namespace resetting. Since the
4160 But now reset only works for full namespace resetting. Since the
4138 del keyword is already there for deleting a few specific
4161 del keyword is already there for deleting a few specific
4139 variables, I don't see the point of having a redundant magic
4162 variables, I don't see the point of having a redundant magic
4140 function for the same task.
4163 function for the same task.
4141
4164
4142 2001-11-24 Fernando Perez <fperez@colorado.edu>
4165 2001-11-24 Fernando Perez <fperez@colorado.edu>
4143
4166
4144 * Updated the builtin docs (esp. the ? ones).
4167 * Updated the builtin docs (esp. the ? ones).
4145
4168
4146 * Ran all the code through pychecker. Not terribly impressed with
4169 * Ran all the code through pychecker. Not terribly impressed with
4147 it: lots of spurious warnings and didn't really find anything of
4170 it: lots of spurious warnings and didn't really find anything of
4148 substance (just a few modules being imported and not used).
4171 substance (just a few modules being imported and not used).
4149
4172
4150 * Implemented the new ultraTB functionality into IPython. New
4173 * Implemented the new ultraTB functionality into IPython. New
4151 option: xcolors. This chooses color scheme. xmode now only selects
4174 option: xcolors. This chooses color scheme. xmode now only selects
4152 between Plain and Verbose. Better orthogonality.
4175 between Plain and Verbose. Better orthogonality.
4153
4176
4154 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4177 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4155 mode and color scheme for the exception handlers. Now it's
4178 mode and color scheme for the exception handlers. Now it's
4156 possible to have the verbose traceback with no coloring.
4179 possible to have the verbose traceback with no coloring.
4157
4180
4158 2001-11-23 Fernando Perez <fperez@colorado.edu>
4181 2001-11-23 Fernando Perez <fperez@colorado.edu>
4159
4182
4160 * Version 0.1.12 released, 0.1.13 opened.
4183 * Version 0.1.12 released, 0.1.13 opened.
4161
4184
4162 * Removed option to set auto-quote and auto-paren escapes by
4185 * Removed option to set auto-quote and auto-paren escapes by
4163 user. The chances of breaking valid syntax are just too high. If
4186 user. The chances of breaking valid syntax are just too high. If
4164 someone *really* wants, they can always dig into the code.
4187 someone *really* wants, they can always dig into the code.
4165
4188
4166 * Made prompt separators configurable.
4189 * Made prompt separators configurable.
4167
4190
4168 2001-11-22 Fernando Perez <fperez@colorado.edu>
4191 2001-11-22 Fernando Perez <fperez@colorado.edu>
4169
4192
4170 * Small bugfixes in many places.
4193 * Small bugfixes in many places.
4171
4194
4172 * Removed the MyCompleter class from ipplib. It seemed redundant
4195 * Removed the MyCompleter class from ipplib. It seemed redundant
4173 with the C-p,C-n history search functionality. Less code to
4196 with the C-p,C-n history search functionality. Less code to
4174 maintain.
4197 maintain.
4175
4198
4176 * Moved all the original ipython.py code into ipythonlib.py. Right
4199 * Moved all the original ipython.py code into ipythonlib.py. Right
4177 now it's just one big dump into a function called make_IPython, so
4200 now it's just one big dump into a function called make_IPython, so
4178 no real modularity has been gained. But at least it makes the
4201 no real modularity has been gained. But at least it makes the
4179 wrapper script tiny, and since ipythonlib is a module, it gets
4202 wrapper script tiny, and since ipythonlib is a module, it gets
4180 compiled and startup is much faster.
4203 compiled and startup is much faster.
4181
4204
4182 This is a reasobably 'deep' change, so we should test it for a
4205 This is a reasobably 'deep' change, so we should test it for a
4183 while without messing too much more with the code.
4206 while without messing too much more with the code.
4184
4207
4185 2001-11-21 Fernando Perez <fperez@colorado.edu>
4208 2001-11-21 Fernando Perez <fperez@colorado.edu>
4186
4209
4187 * Version 0.1.11 released, 0.1.12 opened for further work.
4210 * Version 0.1.11 released, 0.1.12 opened for further work.
4188
4211
4189 * Removed dependency on Itpl. It was only needed in one place. It
4212 * Removed dependency on Itpl. It was only needed in one place. It
4190 would be nice if this became part of python, though. It makes life
4213 would be nice if this became part of python, though. It makes life
4191 *a lot* easier in some cases.
4214 *a lot* easier in some cases.
4192
4215
4193 * Simplified the prefilter code a bit. Now all handlers are
4216 * Simplified the prefilter code a bit. Now all handlers are
4194 expected to explicitly return a value (at least a blank string).
4217 expected to explicitly return a value (at least a blank string).
4195
4218
4196 * Heavy edits in ipplib. Removed the help system altogether. Now
4219 * Heavy edits in ipplib. Removed the help system altogether. Now
4197 obj?/?? is used for inspecting objects, a magic @doc prints
4220 obj?/?? is used for inspecting objects, a magic @doc prints
4198 docstrings, and full-blown Python help is accessed via the 'help'
4221 docstrings, and full-blown Python help is accessed via the 'help'
4199 keyword. This cleans up a lot of code (less to maintain) and does
4222 keyword. This cleans up a lot of code (less to maintain) and does
4200 the job. Since 'help' is now a standard Python component, might as
4223 the job. Since 'help' is now a standard Python component, might as
4201 well use it and remove duplicate functionality.
4224 well use it and remove duplicate functionality.
4202
4225
4203 Also removed the option to use ipplib as a standalone program. By
4226 Also removed the option to use ipplib as a standalone program. By
4204 now it's too dependent on other parts of IPython to function alone.
4227 now it's too dependent on other parts of IPython to function alone.
4205
4228
4206 * Fixed bug in genutils.pager. It would crash if the pager was
4229 * Fixed bug in genutils.pager. It would crash if the pager was
4207 exited immediately after opening (broken pipe).
4230 exited immediately after opening (broken pipe).
4208
4231
4209 * Trimmed down the VerboseTB reporting a little. The header is
4232 * Trimmed down the VerboseTB reporting a little. The header is
4210 much shorter now and the repeated exception arguments at the end
4233 much shorter now and the repeated exception arguments at the end
4211 have been removed. For interactive use the old header seemed a bit
4234 have been removed. For interactive use the old header seemed a bit
4212 excessive.
4235 excessive.
4213
4236
4214 * Fixed small bug in output of @whos for variables with multi-word
4237 * Fixed small bug in output of @whos for variables with multi-word
4215 types (only first word was displayed).
4238 types (only first word was displayed).
4216
4239
4217 2001-11-17 Fernando Perez <fperez@colorado.edu>
4240 2001-11-17 Fernando Perez <fperez@colorado.edu>
4218
4241
4219 * Version 0.1.10 released, 0.1.11 opened for further work.
4242 * Version 0.1.10 released, 0.1.11 opened for further work.
4220
4243
4221 * Modified dirs and friends. dirs now *returns* the stack (not
4244 * Modified dirs and friends. dirs now *returns* the stack (not
4222 prints), so one can manipulate it as a variable. Convenient to
4245 prints), so one can manipulate it as a variable. Convenient to
4223 travel along many directories.
4246 travel along many directories.
4224
4247
4225 * Fixed bug in magic_pdef: would only work with functions with
4248 * Fixed bug in magic_pdef: would only work with functions with
4226 arguments with default values.
4249 arguments with default values.
4227
4250
4228 2001-11-14 Fernando Perez <fperez@colorado.edu>
4251 2001-11-14 Fernando Perez <fperez@colorado.edu>
4229
4252
4230 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4253 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4231 example with IPython. Various other minor fixes and cleanups.
4254 example with IPython. Various other minor fixes and cleanups.
4232
4255
4233 * Version 0.1.9 released, 0.1.10 opened for further work.
4256 * Version 0.1.9 released, 0.1.10 opened for further work.
4234
4257
4235 * Added sys.path to the list of directories searched in the
4258 * Added sys.path to the list of directories searched in the
4236 execfile= option. It used to be the current directory and the
4259 execfile= option. It used to be the current directory and the
4237 user's IPYTHONDIR only.
4260 user's IPYTHONDIR only.
4238
4261
4239 2001-11-13 Fernando Perez <fperez@colorado.edu>
4262 2001-11-13 Fernando Perez <fperez@colorado.edu>
4240
4263
4241 * Reinstated the raw_input/prefilter separation that Janko had
4264 * Reinstated the raw_input/prefilter separation that Janko had
4242 initially. This gives a more convenient setup for extending the
4265 initially. This gives a more convenient setup for extending the
4243 pre-processor from the outside: raw_input always gets a string,
4266 pre-processor from the outside: raw_input always gets a string,
4244 and prefilter has to process it. We can then redefine prefilter
4267 and prefilter has to process it. We can then redefine prefilter
4245 from the outside and implement extensions for special
4268 from the outside and implement extensions for special
4246 purposes.
4269 purposes.
4247
4270
4248 Today I got one for inputting PhysicalQuantity objects
4271 Today I got one for inputting PhysicalQuantity objects
4249 (from Scientific) without needing any function calls at
4272 (from Scientific) without needing any function calls at
4250 all. Extremely convenient, and it's all done as a user-level
4273 all. Extremely convenient, and it's all done as a user-level
4251 extension (no IPython code was touched). Now instead of:
4274 extension (no IPython code was touched). Now instead of:
4252 a = PhysicalQuantity(4.2,'m/s**2')
4275 a = PhysicalQuantity(4.2,'m/s**2')
4253 one can simply say
4276 one can simply say
4254 a = 4.2 m/s**2
4277 a = 4.2 m/s**2
4255 or even
4278 or even
4256 a = 4.2 m/s^2
4279 a = 4.2 m/s^2
4257
4280
4258 I use this, but it's also a proof of concept: IPython really is
4281 I use this, but it's also a proof of concept: IPython really is
4259 fully user-extensible, even at the level of the parsing of the
4282 fully user-extensible, even at the level of the parsing of the
4260 command line. It's not trivial, but it's perfectly doable.
4283 command line. It's not trivial, but it's perfectly doable.
4261
4284
4262 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4285 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4263 the problem of modules being loaded in the inverse order in which
4286 the problem of modules being loaded in the inverse order in which
4264 they were defined in
4287 they were defined in
4265
4288
4266 * Version 0.1.8 released, 0.1.9 opened for further work.
4289 * Version 0.1.8 released, 0.1.9 opened for further work.
4267
4290
4268 * Added magics pdef, source and file. They respectively show the
4291 * Added magics pdef, source and file. They respectively show the
4269 definition line ('prototype' in C), source code and full python
4292 definition line ('prototype' in C), source code and full python
4270 file for any callable object. The object inspector oinfo uses
4293 file for any callable object. The object inspector oinfo uses
4271 these to show the same information.
4294 these to show the same information.
4272
4295
4273 * Version 0.1.7 released, 0.1.8 opened for further work.
4296 * Version 0.1.7 released, 0.1.8 opened for further work.
4274
4297
4275 * Separated all the magic functions into a class called Magic. The
4298 * Separated all the magic functions into a class called Magic. The
4276 InteractiveShell class was becoming too big for Xemacs to handle
4299 InteractiveShell class was becoming too big for Xemacs to handle
4277 (de-indenting a line would lock it up for 10 seconds while it
4300 (de-indenting a line would lock it up for 10 seconds while it
4278 backtracked on the whole class!)
4301 backtracked on the whole class!)
4279
4302
4280 FIXME: didn't work. It can be done, but right now namespaces are
4303 FIXME: didn't work. It can be done, but right now namespaces are
4281 all messed up. Do it later (reverted it for now, so at least
4304 all messed up. Do it later (reverted it for now, so at least
4282 everything works as before).
4305 everything works as before).
4283
4306
4284 * Got the object introspection system (magic_oinfo) working! I
4307 * Got the object introspection system (magic_oinfo) working! I
4285 think this is pretty much ready for release to Janko, so he can
4308 think this is pretty much ready for release to Janko, so he can
4286 test it for a while and then announce it. Pretty much 100% of what
4309 test it for a while and then announce it. Pretty much 100% of what
4287 I wanted for the 'phase 1' release is ready. Happy, tired.
4310 I wanted for the 'phase 1' release is ready. Happy, tired.
4288
4311
4289 2001-11-12 Fernando Perez <fperez@colorado.edu>
4312 2001-11-12 Fernando Perez <fperez@colorado.edu>
4290
4313
4291 * Version 0.1.6 released, 0.1.7 opened for further work.
4314 * Version 0.1.6 released, 0.1.7 opened for further work.
4292
4315
4293 * Fixed bug in printing: it used to test for truth before
4316 * Fixed bug in printing: it used to test for truth before
4294 printing, so 0 wouldn't print. Now checks for None.
4317 printing, so 0 wouldn't print. Now checks for None.
4295
4318
4296 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4319 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4297 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4320 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4298 reaches by hand into the outputcache. Think of a better way to do
4321 reaches by hand into the outputcache. Think of a better way to do
4299 this later.
4322 this later.
4300
4323
4301 * Various small fixes thanks to Nathan's comments.
4324 * Various small fixes thanks to Nathan's comments.
4302
4325
4303 * Changed magic_pprint to magic_Pprint. This way it doesn't
4326 * Changed magic_pprint to magic_Pprint. This way it doesn't
4304 collide with pprint() and the name is consistent with the command
4327 collide with pprint() and the name is consistent with the command
4305 line option.
4328 line option.
4306
4329
4307 * Changed prompt counter behavior to be fully like
4330 * Changed prompt counter behavior to be fully like
4308 Mathematica's. That is, even input that doesn't return a result
4331 Mathematica's. That is, even input that doesn't return a result
4309 raises the prompt counter. The old behavior was kind of confusing
4332 raises the prompt counter. The old behavior was kind of confusing
4310 (getting the same prompt number several times if the operation
4333 (getting the same prompt number several times if the operation
4311 didn't return a result).
4334 didn't return a result).
4312
4335
4313 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4336 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4314
4337
4315 * Fixed -Classic mode (wasn't working anymore).
4338 * Fixed -Classic mode (wasn't working anymore).
4316
4339
4317 * Added colored prompts using Nathan's new code. Colors are
4340 * Added colored prompts using Nathan's new code. Colors are
4318 currently hardwired, they can be user-configurable. For
4341 currently hardwired, they can be user-configurable. For
4319 developers, they can be chosen in file ipythonlib.py, at the
4342 developers, they can be chosen in file ipythonlib.py, at the
4320 beginning of the CachedOutput class def.
4343 beginning of the CachedOutput class def.
4321
4344
4322 2001-11-11 Fernando Perez <fperez@colorado.edu>
4345 2001-11-11 Fernando Perez <fperez@colorado.edu>
4323
4346
4324 * Version 0.1.5 released, 0.1.6 opened for further work.
4347 * Version 0.1.5 released, 0.1.6 opened for further work.
4325
4348
4326 * Changed magic_env to *return* the environment as a dict (not to
4349 * Changed magic_env to *return* the environment as a dict (not to
4327 print it). This way it prints, but it can also be processed.
4350 print it). This way it prints, but it can also be processed.
4328
4351
4329 * Added Verbose exception reporting to interactive
4352 * Added Verbose exception reporting to interactive
4330 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4353 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4331 traceback. Had to make some changes to the ultraTB file. This is
4354 traceback. Had to make some changes to the ultraTB file. This is
4332 probably the last 'big' thing in my mental todo list. This ties
4355 probably the last 'big' thing in my mental todo list. This ties
4333 in with the next entry:
4356 in with the next entry:
4334
4357
4335 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4358 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4336 has to specify is Plain, Color or Verbose for all exception
4359 has to specify is Plain, Color or Verbose for all exception
4337 handling.
4360 handling.
4338
4361
4339 * Removed ShellServices option. All this can really be done via
4362 * Removed ShellServices option. All this can really be done via
4340 the magic system. It's easier to extend, cleaner and has automatic
4363 the magic system. It's easier to extend, cleaner and has automatic
4341 namespace protection and documentation.
4364 namespace protection and documentation.
4342
4365
4343 2001-11-09 Fernando Perez <fperez@colorado.edu>
4366 2001-11-09 Fernando Perez <fperez@colorado.edu>
4344
4367
4345 * Fixed bug in output cache flushing (missing parameter to
4368 * Fixed bug in output cache flushing (missing parameter to
4346 __init__). Other small bugs fixed (found using pychecker).
4369 __init__). Other small bugs fixed (found using pychecker).
4347
4370
4348 * Version 0.1.4 opened for bugfixing.
4371 * Version 0.1.4 opened for bugfixing.
4349
4372
4350 2001-11-07 Fernando Perez <fperez@colorado.edu>
4373 2001-11-07 Fernando Perez <fperez@colorado.edu>
4351
4374
4352 * Version 0.1.3 released, mainly because of the raw_input bug.
4375 * Version 0.1.3 released, mainly because of the raw_input bug.
4353
4376
4354 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4377 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4355 and when testing for whether things were callable, a call could
4378 and when testing for whether things were callable, a call could
4356 actually be made to certain functions. They would get called again
4379 actually be made to certain functions. They would get called again
4357 once 'really' executed, with a resulting double call. A disaster
4380 once 'really' executed, with a resulting double call. A disaster
4358 in many cases (list.reverse() would never work!).
4381 in many cases (list.reverse() would never work!).
4359
4382
4360 * Removed prefilter() function, moved its code to raw_input (which
4383 * Removed prefilter() function, moved its code to raw_input (which
4361 after all was just a near-empty caller for prefilter). This saves
4384 after all was just a near-empty caller for prefilter). This saves
4362 a function call on every prompt, and simplifies the class a tiny bit.
4385 a function call on every prompt, and simplifies the class a tiny bit.
4363
4386
4364 * Fix _ip to __ip name in magic example file.
4387 * Fix _ip to __ip name in magic example file.
4365
4388
4366 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4389 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4367 work with non-gnu versions of tar.
4390 work with non-gnu versions of tar.
4368
4391
4369 2001-11-06 Fernando Perez <fperez@colorado.edu>
4392 2001-11-06 Fernando Perez <fperez@colorado.edu>
4370
4393
4371 * Version 0.1.2. Just to keep track of the recent changes.
4394 * Version 0.1.2. Just to keep track of the recent changes.
4372
4395
4373 * Fixed nasty bug in output prompt routine. It used to check 'if
4396 * Fixed nasty bug in output prompt routine. It used to check 'if
4374 arg != None...'. Problem is, this fails if arg implements a
4397 arg != None...'. Problem is, this fails if arg implements a
4375 special comparison (__cmp__) which disallows comparing to
4398 special comparison (__cmp__) which disallows comparing to
4376 None. Found it when trying to use the PhysicalQuantity module from
4399 None. Found it when trying to use the PhysicalQuantity module from
4377 ScientificPython.
4400 ScientificPython.
4378
4401
4379 2001-11-05 Fernando Perez <fperez@colorado.edu>
4402 2001-11-05 Fernando Perez <fperez@colorado.edu>
4380
4403
4381 * Also added dirs. Now the pushd/popd/dirs family functions
4404 * Also added dirs. Now the pushd/popd/dirs family functions
4382 basically like the shell, with the added convenience of going home
4405 basically like the shell, with the added convenience of going home
4383 when called with no args.
4406 when called with no args.
4384
4407
4385 * pushd/popd slightly modified to mimic shell behavior more
4408 * pushd/popd slightly modified to mimic shell behavior more
4386 closely.
4409 closely.
4387
4410
4388 * Added env,pushd,popd from ShellServices as magic functions. I
4411 * Added env,pushd,popd from ShellServices as magic functions. I
4389 think the cleanest will be to port all desired functions from
4412 think the cleanest will be to port all desired functions from
4390 ShellServices as magics and remove ShellServices altogether. This
4413 ShellServices as magics and remove ShellServices altogether. This
4391 will provide a single, clean way of adding functionality
4414 will provide a single, clean way of adding functionality
4392 (shell-type or otherwise) to IP.
4415 (shell-type or otherwise) to IP.
4393
4416
4394 2001-11-04 Fernando Perez <fperez@colorado.edu>
4417 2001-11-04 Fernando Perez <fperez@colorado.edu>
4395
4418
4396 * Added .ipython/ directory to sys.path. This way users can keep
4419 * Added .ipython/ directory to sys.path. This way users can keep
4397 customizations there and access them via import.
4420 customizations there and access them via import.
4398
4421
4399 2001-11-03 Fernando Perez <fperez@colorado.edu>
4422 2001-11-03 Fernando Perez <fperez@colorado.edu>
4400
4423
4401 * Opened version 0.1.1 for new changes.
4424 * Opened version 0.1.1 for new changes.
4402
4425
4403 * Changed version number to 0.1.0: first 'public' release, sent to
4426 * Changed version number to 0.1.0: first 'public' release, sent to
4404 Nathan and Janko.
4427 Nathan and Janko.
4405
4428
4406 * Lots of small fixes and tweaks.
4429 * Lots of small fixes and tweaks.
4407
4430
4408 * Minor changes to whos format. Now strings are shown, snipped if
4431 * Minor changes to whos format. Now strings are shown, snipped if
4409 too long.
4432 too long.
4410
4433
4411 * Changed ShellServices to work on __main__ so they show up in @who
4434 * Changed ShellServices to work on __main__ so they show up in @who
4412
4435
4413 * Help also works with ? at the end of a line:
4436 * Help also works with ? at the end of a line:
4414 ?sin and sin?
4437 ?sin and sin?
4415 both produce the same effect. This is nice, as often I use the
4438 both produce the same effect. This is nice, as often I use the
4416 tab-complete to find the name of a method, but I used to then have
4439 tab-complete to find the name of a method, but I used to then have
4417 to go to the beginning of the line to put a ? if I wanted more
4440 to go to the beginning of the line to put a ? if I wanted more
4418 info. Now I can just add the ? and hit return. Convenient.
4441 info. Now I can just add the ? and hit return. Convenient.
4419
4442
4420 2001-11-02 Fernando Perez <fperez@colorado.edu>
4443 2001-11-02 Fernando Perez <fperez@colorado.edu>
4421
4444
4422 * Python version check (>=2.1) added.
4445 * Python version check (>=2.1) added.
4423
4446
4424 * Added LazyPython documentation. At this point the docs are quite
4447 * Added LazyPython documentation. At this point the docs are quite
4425 a mess. A cleanup is in order.
4448 a mess. A cleanup is in order.
4426
4449
4427 * Auto-installer created. For some bizarre reason, the zipfiles
4450 * Auto-installer created. For some bizarre reason, the zipfiles
4428 module isn't working on my system. So I made a tar version
4451 module isn't working on my system. So I made a tar version
4429 (hopefully the command line options in various systems won't kill
4452 (hopefully the command line options in various systems won't kill
4430 me).
4453 me).
4431
4454
4432 * Fixes to Struct in genutils. Now all dictionary-like methods are
4455 * Fixes to Struct in genutils. Now all dictionary-like methods are
4433 protected (reasonably).
4456 protected (reasonably).
4434
4457
4435 * Added pager function to genutils and changed ? to print usage
4458 * Added pager function to genutils and changed ? to print usage
4436 note through it (it was too long).
4459 note through it (it was too long).
4437
4460
4438 * Added the LazyPython functionality. Works great! I changed the
4461 * Added the LazyPython functionality. Works great! I changed the
4439 auto-quote escape to ';', it's on home row and next to '. But
4462 auto-quote escape to ';', it's on home row and next to '. But
4440 both auto-quote and auto-paren (still /) escapes are command-line
4463 both auto-quote and auto-paren (still /) escapes are command-line
4441 parameters.
4464 parameters.
4442
4465
4443
4466
4444 2001-11-01 Fernando Perez <fperez@colorado.edu>
4467 2001-11-01 Fernando Perez <fperez@colorado.edu>
4445
4468
4446 * Version changed to 0.0.7. Fairly large change: configuration now
4469 * Version changed to 0.0.7. Fairly large change: configuration now
4447 is all stored in a directory, by default .ipython. There, all
4470 is all stored in a directory, by default .ipython. There, all
4448 config files have normal looking names (not .names)
4471 config files have normal looking names (not .names)
4449
4472
4450 * Version 0.0.6 Released first to Lucas and Archie as a test
4473 * Version 0.0.6 Released first to Lucas and Archie as a test
4451 run. Since it's the first 'semi-public' release, change version to
4474 run. Since it's the first 'semi-public' release, change version to
4452 > 0.0.6 for any changes now.
4475 > 0.0.6 for any changes now.
4453
4476
4454 * Stuff I had put in the ipplib.py changelog:
4477 * Stuff I had put in the ipplib.py changelog:
4455
4478
4456 Changes to InteractiveShell:
4479 Changes to InteractiveShell:
4457
4480
4458 - Made the usage message a parameter.
4481 - Made the usage message a parameter.
4459
4482
4460 - Require the name of the shell variable to be given. It's a bit
4483 - Require the name of the shell variable to be given. It's a bit
4461 of a hack, but allows the name 'shell' not to be hardwire in the
4484 of a hack, but allows the name 'shell' not to be hardwire in the
4462 magic (@) handler, which is problematic b/c it requires
4485 magic (@) handler, which is problematic b/c it requires
4463 polluting the global namespace with 'shell'. This in turn is
4486 polluting the global namespace with 'shell'. This in turn is
4464 fragile: if a user redefines a variable called shell, things
4487 fragile: if a user redefines a variable called shell, things
4465 break.
4488 break.
4466
4489
4467 - magic @: all functions available through @ need to be defined
4490 - magic @: all functions available through @ need to be defined
4468 as magic_<name>, even though they can be called simply as
4491 as magic_<name>, even though they can be called simply as
4469 @<name>. This allows the special command @magic to gather
4492 @<name>. This allows the special command @magic to gather
4470 information automatically about all existing magic functions,
4493 information automatically about all existing magic functions,
4471 even if they are run-time user extensions, by parsing the shell
4494 even if they are run-time user extensions, by parsing the shell
4472 instance __dict__ looking for special magic_ names.
4495 instance __dict__ looking for special magic_ names.
4473
4496
4474 - mainloop: added *two* local namespace parameters. This allows
4497 - mainloop: added *two* local namespace parameters. This allows
4475 the class to differentiate between parameters which were there
4498 the class to differentiate between parameters which were there
4476 before and after command line initialization was processed. This
4499 before and after command line initialization was processed. This
4477 way, later @who can show things loaded at startup by the
4500 way, later @who can show things loaded at startup by the
4478 user. This trick was necessary to make session saving/reloading
4501 user. This trick was necessary to make session saving/reloading
4479 really work: ideally after saving/exiting/reloading a session,
4502 really work: ideally after saving/exiting/reloading a session,
4480 *everythin* should look the same, including the output of @who. I
4503 *everythin* should look the same, including the output of @who. I
4481 was only able to make this work with this double namespace
4504 was only able to make this work with this double namespace
4482 trick.
4505 trick.
4483
4506
4484 - added a header to the logfile which allows (almost) full
4507 - added a header to the logfile which allows (almost) full
4485 session restoring.
4508 session restoring.
4486
4509
4487 - prepend lines beginning with @ or !, with a and log
4510 - prepend lines beginning with @ or !, with a and log
4488 them. Why? !lines: may be useful to know what you did @lines:
4511 them. Why? !lines: may be useful to know what you did @lines:
4489 they may affect session state. So when restoring a session, at
4512 they may affect session state. So when restoring a session, at
4490 least inform the user of their presence. I couldn't quite get
4513 least inform the user of their presence. I couldn't quite get
4491 them to properly re-execute, but at least the user is warned.
4514 them to properly re-execute, but at least the user is warned.
4492
4515
4493 * Started ChangeLog.
4516 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now