Show More
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.' | |||||
6 |
|
6 | |||
7 | This file contains all the classes and helper functions specific to IPython. |
|
7 | This file contains all the classes and helper functions specific to IPython. | |
8 |
|
8 | |||
9 |
$Id: iplib.py 178 |
|
9 | $Id: iplib.py 1788 2006-09-27 07:15:44Z fperez $ | |
10 | """ |
|
10 | """ | |
11 |
|
11 | |||
12 | #***************************************************************************** |
|
12 | #***************************************************************************** | |
@@ -126,6 +126,23 b' class Bunch: pass' | |||||
126 |
|
126 | |||
127 | class Undefined: pass |
|
127 | class Undefined: pass | |
128 |
|
128 | |||
|
129 | class Quitter(object): | |||
|
130 | """Simple class to handle exit, similar to Python 2.5's. | |||
|
131 | ||||
|
132 | It handles exiting in an ipython-safe manner, which the one in Python 2.5 | |||
|
133 | doesn't do (obviously, since it doesn't know about ipython).""" | |||
|
134 | ||||
|
135 | def __init__(self,shell,name): | |||
|
136 | self.shell = shell | |||
|
137 | self.name = name | |||
|
138 | ||||
|
139 | def __repr__(self): | |||
|
140 | return 'Type %s() to exit.' % self.name | |||
|
141 | __str__ = __repr__ | |||
|
142 | ||||
|
143 | def __call__(self): | |||
|
144 | self.shell.exit() | |||
|
145 | ||||
129 | class InputList(list): |
|
146 | class InputList(list): | |
130 | """Class to store user input. |
|
147 | """Class to store user input. | |
131 |
|
148 | |||
@@ -220,11 +237,10 b' class InteractiveShell(object,Magic):' | |||||
220 | self.filename = '<ipython console>' |
|
237 | self.filename = '<ipython console>' | |
221 |
|
238 | |||
222 | # Install our own quitter instead of the builtins. For python2.3-2.4, |
|
239 | # Install our own quitter instead of the builtins. For python2.3-2.4, | |
223 |
# this brings in behavior |
|
240 | # this brings in behavior like 2.5, and for 2.5 it's identical. | |
224 | # identical to Python's official behavior (except we lack the message, |
|
241 | __builtin__.exit = Quitter(self,'exit') | |
225 | # but with autocall the need for that is much less). |
|
242 | __builtin__.quit = Quitter(self,'quit') | |
226 | __builtin__.exit = __builtin__.quit = self.exit |
|
243 | ||
227 |
|
||||
228 | # Make an empty namespace, which extension writers can rely on both |
|
244 | # Make an empty namespace, which extension writers can rely on both | |
229 | # existing and NEVER being used by ipython itself. This gives them a |
|
245 | # existing and NEVER being used by ipython itself. This gives them a | |
230 | # convenient location for storing additional information and state |
|
246 | # convenient location for storing additional information and state |
General Comments 0
You need to be logged in to leave comments.
Login now