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

print-ed output in interactive python sessions.
master
Wirawan Purwanto 13 years ago
parent 5c72506135
commit 140b3b699c
  1. 18
      interactive_tools.py

@ -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

Loading…
Cancel
Save