* Added wpylib.interactive_tools.printstr class to facilitate logging of

print-ed output in interactive python sessions.
This commit is contained in:
Wirawan Purwanto
2012-05-17 12:29:30 -04:00
parent 5c72506135
commit 140b3b699c

View File

@@ -155,3 +155,21 @@ def init_interactive(use_readline=True, global_ns=None):
return True
#print "_-helo"
class printstr:
"""A hack to record printout in a logged interactive python session
(I had logged ipython in mind, but other similar framework can use
this as well).
We intentionally use __repr__ to print the string.
Usage:
printstr(<python object>)
"""
def __init__(self, obj):
self.str = str(obj)
def __str__(self):
return self.str
def __repr__(self):
return self.str