Resume after exception
Skip Montanaro
skip at pobox.com
Tue Jun 14 08:41:18 EDT 2005
>> Is it possible to have an 'except' case which passes control back to
>> the point after the exception occurred?
Peter> Basically no, although I could imagine some gross hack with the
Peter> frame info and some bytecode hacks that effect a "goto".
Someone (I forget who) posted an autoload module (appended) awhile ago for
Python that does a reasonable job of recovery in the case of
use-before-import. I modified it slightly and use it on my laptop.
Examples:
% python
Python 2.5a0 (#77, May 14 2005, 14:47:06)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1671)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> time.time()
found time in xmlrpclib module
1118752288.5277729
>>> datetime.datetime.now()
found datetime in xmlrpclib module
datetime.datetime(2005, 6, 14, 7, 31, 43, 136432)
>>> math.sin(7)
autoloading math
0.65698659871878906
Note that it's far from perfect (to wit: the weird fact that "time" and
"datetime" are found in the xmlrpclib module).
Skip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/octet-stream
Size: 1637 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050614/68e30c50/attachment.obj>
More information about the Python-list
mailing list