(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/module-linecache.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/module-traceback.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/module-traceback.html| ]]
|
Python Library Reference
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/contents.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/modindex.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/genindex.html| ]]
|
Next: 3.7 linecache Up: 3.6 traceback Previous: 3.6 traceback
3.6.1 Traceback Example
This simple example implements a basic read-eval-print loop, similar to (but less useful than) the standard Python interactive interpreter loop. For a more complete implementation of the interpreter loop, refer to the code module.
import sys, traceback
def run_user_code(envdir):
source = raw_input(">>> ")
try:
exec source in envdir
except:
print "Exception in user code:"
print '-'*60
traceback.print_exc(file=sys.stdout)
print '-'*60
envdir = {}
while 1:
run_user_code(envdir)
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/module-linecache.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/module-traceback.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/module-traceback.html| ]]
|
Python Library Reference
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/contents.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/modindex.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/genindex.html| ]]
|
Next: 3.7 linecache Up: 3.6 traceback Previous: 3.6 traceback
Send comments on this document to python-docs@python.org.