-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonstartup
More file actions
38 lines (31 loc) · 860 Bytes
/
pythonstartup
File metadata and controls
38 lines (31 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- encoding: utf-8 -*-
import atexit
import builtins
import datetime
import json
import math
import os
import re
import readline
import rlcompleter
import sys
from pprint import PrettyPrinter, pprint
# Pretty Print
builtins.print = PrettyPrinter(depth=5, width=80, compact=True).pprint
def pretty_display(value):
if value is not None:
_ = pprint.pformat(value, width=80)
print(_)
sys._getframe().f_globals["_"] = value
sys.displayhook = pretty_display
# Histroy
histfile = os.path.join(os.environ["HOME"], ".python_history")
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
# TAB Completion
readline.parse_and_bind("tab: complete")
readline.parse_and_bind("set show-all-if-ambiguous on")
readline.parse_and_bind("set completion-ignore-case on")