# Useful things to have
from __future__ import division
from math import *
-import sys, os, re, math
+import math
+import os
+import re
+import sys
+
+import array
+import cgi
+from datetime import datetime, timedelta
+import hashlib
+import json
+import random
+import re
+import socket
+import struct
+import subprocess
+import tempfile
+import time
+import traceback
+import urllib
+
+# Not available in Python3
+try:
+ import StringIO
+ import urllib2
+ import urlparse
+except ImportError:
+ pass
# Readline completion of everything :)
import rlcompleter, readline, atexit
-defaultCompleter = rlcompleter.Completer()
+default_completer = rlcompleter.Completer()
-historyPath = os.path.expanduser("~/.pyhistory")
+history_path = os.path.expanduser("~/.python_history")
-def myCompleter(text, state):
- if text.strip() == "" and state == 0:
- return text + "\t"
- else:
- return defaultCompleter.complete(text, state)
+def my_completer(text, state):
+ if text.strip() == "":
+ if state == 0:
+ return text + "\t"
+ else:
+ return None
+ else:
+ return default_completer.complete(text, state)
-def save_history(historyPath=historyPath):
+def save_history(history_path=history_path):
import readline
- readline.write_history_file(historyPath)
+ readline.write_history_file(history_path)
-readline.set_completer(myCompleter)
+readline.set_completer(my_completer)
readline.parse_and_bind("tab: complete")
-if os.path.exists(historyPath):
- readline.read_history_file(historyPath)
+if os.path.exists(history_path):
+ readline.read_history_file(history_path)
atexit.register(save_history)