##// END OF EJS Templates
Turn quit/exit into magics instead of special-cased strings
fperez -
Show More
@@ -1,7 +1,7 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 960 2005-12-28 06:51:01Z fperez $"""
4 $Id: Magic.py 962 2005-12-28 18:04:59Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -1988,6 +1988,19 b' Defaulting color scheme to \'NoColor\'"""'
1988 1988 print 'Pretty printing has been turned', \
1989 1989 ['OFF','ON'][self.shell.outputcache.Pprint]
1990 1990
1991 def magic_exit(self, parameter_s=''):
1992 """Exit IPython, confirming if configured to do so.
1993
1994 You can configure whether IPython asks for confirmation upon exit by
1995 setting the confirm_exit flag in the ipythonrc file."""
1996
1997 self.shell.exit()
1998
1999 def magic_quit(self, parameter_s=''):
2000 """Exit IPython, confirming if configured to do so (like %exit)"""
2001
2002 self.shell.exit()
2003
1991 2004 def magic_Exit(self, parameter_s=''):
1992 2005 """Exit IPython without confirmation."""
1993 2006
@@ -6,7 +6,7 b' Requires Python 2.1 or newer.'
6 6
7 7 This file contains all the classes and helper functions specific to IPython.
8 8
9 $Id: iplib.py 960 2005-12-28 06:51:01Z fperez $
9 $Id: iplib.py 962 2005-12-28 18:04:59Z fperez $
10 10 """
11 11
12 12 #*****************************************************************************
@@ -191,8 +191,6 b' def softspace(file, newvalue):'
191 191 # Local use exceptions
192 192 class SpaceInInput(exceptions.Exception): pass
193 193
194 class IPythonExit(exceptions.Exception): pass
195
196 194 #****************************************************************************
197 195 # Local use classes
198 196 class Bunch: pass
@@ -1256,8 +1254,6 b' want to merge them back into the new files.""" % locals()'
1256 1254 self.readline_startup_hook(None)
1257 1255 self.write("\n")
1258 1256 self.exit()
1259 except IPythonExit:
1260 self.exit()
1261 1257 else:
1262 1258 more = self.push(line)
1263 1259 # Auto-indent management
@@ -1655,8 +1651,6 b' want to merge them back into the new files.""" % locals()'
1655 1651 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1656 1652
1657 1653 if not oinfo['found']:
1658 if iFun in ('quit','exit'):
1659 raise IPythonExit
1660 1654 return self.handle_normal(line,continue_prompt)
1661 1655 else:
1662 1656 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
@@ -1,3 +1,10 b''
1 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
4 of the previous special-casing of input in the eval loop. I think
5 this is cleaner, as they really are commands and shouldn't have
6 a special role in the middle of the core code.
7
1 8 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
2 9
3 10 * IPython/iplib.py (edit_syntax_error): added support for
@@ -935,15 +935,22 b' It automatically resolved all dependencies (python24, readline, py-readline).'
935 935 Windows instructions
936 936 \layout Standard
937 937
938 While you can use IPython under Windows with only a stock Python installation,
939 there is one extension,
940 \family typewriter
941 readline
942 \family default
943 , which will make the whole experience a lot more pleasant.
944 It is almost a requirement, since IPython will complain in its absence
945 (though it will function).
946
938 Some of IPython's very useful features are:
939 \layout Itemize
940
941 Integrated readline support (Tab-based file, object and attribute completion,
942 input history across sessions, editable command line, etc.)
943 \layout Itemize
944
945 Coloring of prompts, code and tracebacks.
946 \layout Standard
947
948 These, by default, are only available under Unix-like operating systems.
949 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
950 from them.
951 His readline library implements both GNU readline functionality and color
952 support, so that IPython under Windows XP/2k can be as friendly and powerful
953 as under Unix-like environments.
947 954 \layout Standard
948 955
949 956 The
@@ -1012,74 +1019,6 b' Warning about a broken readline-like library:'
1012 1019 which for all purposes is (at least as of version 1.6) terminally broken.
1013 1020 \layout Subsubsection
1014 1021
1015 Gary Bishop's readline and color support for Windows
1016 \layout Standard
1017
1018 Some of IPython's very useful features are:
1019 \layout Itemize
1020
1021 Integrated readline support (Tab-based file, object and attribute completion,
1022 input history across sessions, editable command line, etc.)
1023 \layout Itemize
1024
1025 Coloring of prompts, code and tracebacks.
1026 \layout Standard
1027
1028 These, by default, are only available under Unix-like operating systems.
1029 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
1030 from them.
1031 His readline library implements both GNU readline functionality and color
1032 support, so that IPython under Windows XP/2k can be as friendly and powerful
1033 as under Unix-like environments.
1034 \layout Standard
1035
1036 You can find Gary's tools at
1037 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
1038
1039 \end_inset
1040
1041 ; Gary's
1042 \family typewriter
1043 readline
1044 \family default
1045 requires in turn the
1046 \family typewriter
1047 ctypes
1048 \family default
1049 library by Thomas Heller, available at
1050 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1051
1052 \end_inset
1053
1054 , and Mark Hammond's
1055 \family typewriter
1056 PyWin32
1057 \family default
1058 from
1059 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
1060
1061 \end_inset
1062
1063 (
1064 \family typewriter
1065 PyWin32
1066 \family default
1067 is great for anything Windows-related anyway, so you might as well get
1068 it).
1069 \layout Standard
1070
1071 Under MS\SpecialChar ~
1072 Windows, IPython will complain if it can not find this
1073 \family typewriter
1074 readline
1075 \family default
1076 library at startup and any time the
1077 \family typewriter
1078 %colors
1079 \family default
1080 command is issued, so you can consider it to be a quasi-requirement.
1081 \layout Subsubsection
1082
1083 1022 Installation procedure
1084 1023 \layout Standard
1085 1024
@@ -2393,6 +2332,46 b' Use the IPython.demo.Demo class to load any Python script as an interactive'
2393 2332 for more.
2394 2333 \layout Standard
2395 2334
2335
2336 \series bold
2337 Effective logging:
2338 \series default
2339 a very useful suggestion sent in by Robert Kern follows
2340 \layout Standard
2341
2342 I recently happened on a nifty way to keep tidy per-project log files.
2343 I made a profile for my project (which is called "parkfield").
2344 \layout LyX-Code
2345
2346 include ipythonrc
2347 \layout LyX-Code
2348
2349 logfile '' # cancel earlier logfile invocation
2350 \layout LyX-Code
2351
2352 execute import time
2353 \layout LyX-Code
2354
2355 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2356 \layout LyX-Code
2357
2358 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2359 \layout Standard
2360
2361 I also added a shell alias for convenience:
2362 \layout LyX-Code
2363
2364 alias parkfield="ipython -pylab -profile parkfield"
2365 \layout Standard
2366
2367 Now I have a nice little directory with everything I ever type in, organized
2368 by project and date.
2369 \layout Standard
2370
2371
2372 \series bold
2373 Contribute your own:
2374 \series default
2396 2375 If you have your own favorite tip on using IPython efficiently for a certain
2397 2376 task (especially things which can't be done in the normal Python interpreter),
2398 2377 don't hesitate to send it!
@@ -9158,8 +9137,12 b' Smedt'
9158 9137 \layout List
9159 9138 \labelwidthstring 00.00.0000
9160 9139
9161 Scott (email unknown) Support for automatic editor invocation on syntax
9162 errors (see
9140 Scott\SpecialChar ~
9141 Tsai
9142 \family typewriter
9143 <scottt958-AT-yahoo.com.tw>
9144 \family default
9145 Support for automatic editor invocation on syntax errors (see
9163 9146 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9164 9147
9165 9148 \end_inset
General Comments 0
You need to be logged in to leave comments. Login now