i want to know how to assign the output of print to a variable.
so if
mystring = \"a=\\\'12\\\'\"
then
print mys
Redirect stdout
and capture its output in an object?
import sys
# a simple class with a write method
class WritableObject:
def __init__(self):
self.content = []
def write(self, string):
self.content.append(string)
# example with redirection of sys.stdout
foo = WritableObject() # a writable object
sys.stdout = foo # redirection
print "one, two, three, four" # some writing
And then just take the "output" from foo.content
and do what you want with it.
Please disregard if I have misunderstood your requirement.