i want to know how to assign the output of print to a variable.
so if
mystring = \"a=\\\'12\\\'\"
then
print mys
You can call __str__ and __repr__ on python objects to get their string representations (there's a tiny difference between them, so consult the docs). That's actually done by print internally.
__str__
__repr__
print