-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.pythonrc.py
37 lines (34 loc) · 1.1 KB
/
.pythonrc.py
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
tylerDebug = 0
if tylerDebug: import pdb
try: import sys
except ImportError: print "Module sys not available."
try: import re
except ImportError: print "Module re not available."
try: import inspect
except ImportError: print "Module inspect not available"
if not re.search('ipython$',sys.argv[0]):
try: import readline
except ImportError: print "Module readline not available."
else:
try: import rlcompleter
except ImportError: print "Module rlcompleter not available."
else: readline.parse_and_bind("tab: complete")
def getdef(function, withDoc=False):
attr = inspect.getargspec(function)
defstring = function.__name__+'('
if attr.defaults is None:
diff = len(attr.args)
else:
diff = len(attr.args) - len(attr.defaults)
for i,arg in enumerate(attr.args):
try:
if i - diff < 0: #@ ...then the argument doesn't have a default
defstring += arg+', '
elif arg is not attr.args[-1]:
defstring += arg+'='+str(attr.defaults[i-diff])+', '
else:
defstring += arg+'='+str(attr.defaults[i-diff])
except IndexError: pass
defstring += ')'
print defstring
if withDoc: print function.__doc__