Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 15 Online
OpenStudy (anonymous):

is it possible to un string something? for instance if str(Circle(2)) returns 'Circle(2)'. Is there a way to get it back to Circle(2) ?

OpenStudy (anonymous):

Assuming Circle(2) is a function call, str(Circle(2)) will modify the return value of Circle(2) to the string type. Suppose Circle(2) returns an int, you can say int( str( Circle(2) ) ) and it will return an int. If Circle(2) returns an user defined type, I think str(Circle(2)) is undefined? Unless you modify __str__, right? I will try that.

OpenStudy (anonymous):

I shouldn't say undefined. It's just an error, IIRC.

OpenStudy (anonymous):

you are right. Actually I was using a .format function that really did return 'Circle(2)' which if it wasnt a string would have meaning. but alas I could not find an unString function, loosely speaking that is.

OpenStudy (anonymous):

is this what you meant?? line 22 gets the objects using the string http://pastebin.com/PWqEM3FB

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!