Go to the documentation of this file.00001
00002 import sys
00003 import os
00004 import readline
00005 import atexit
00006
00007 import ctypes
00008
00009 def interactive_inspect_mode():
00010
00011 flagPtr = ctypes.cast(ctypes.pythonapi.Py_InteractiveFlag,
00012 ctypes.POINTER(ctypes.c_int))
00013 return flagPtr.contents.value > 0 or bool(os.environ.get("PYTHONINSPECT",False))
00014
00015
00016 if __name__ == '__main__':
00017
00018
00019
00020
00021
00022 historyPath = os.path.expanduser("~/.pyhistory")
00023
00024
00025 def save_history(historyPath=historyPath):
00026 import readline
00027 readline.write_history_file(historyPath)
00028 if os.path.exists(historyPath):
00029 readline.read_history_file(historyPath)
00030
00031
00032 atexit.register(save_history)
00033 readline.parse_and_bind("set show-all-if-ambiguous on")
00034 readline.parse_and_bind("tab: complete")
00035 if os.path.exists (historyPath) :
00036 readline.read_history_file(historyPath)
00037 readline.set_history_length(-1)
00038
00039 if not interactive_inspect_mode():
00040 print "python -i `which interactivePythonTest.py` "
00041
00042