Currently, I am trying to code a program in Python. I am struggling to make my system be able to decode str of classes:
E.g:
class test:
def __init__(self, coin):
self.coin = coin
print(test(5))
>>> <__main__.test object at 0x00D20B10>
I would want to be able to convert the string to a class, then assign it to a variable so I can:
x = eval("<__main__.test object at 0x00D20B10>")
print(x.coin)
>>> 5
My error:
Traceback (most recent call last):
print(eval("<__main__.test object at 0x00D20B10>"))
File "<string>", line 1
<__main__.test object at 0x00D20B10>
^
SyntaxError: invalid syntax
How can I achieve that?