Aug-08-2020, 06:59 PM
I want to convert a string "<... object at POINTER>" to an object.
Python version: 3.7.4
The reason:
I want to make a something like a global static variable, but I don't know how do it with the program that's using Python as a script, that's why I convert my object to string then I'm able to store it to the program because it only accepts string, and when I run the script again, I can reuse the object from the stored string. Now you see that it's something like a static object, but I don't know how to do that.
Python version: 3.7.4
class MyClass: def Test(self): print("Hello!") c = MyClass() s = str(c) print("The value of the string s is", s) c0 = convert_str_to_object(s) # This is undefined but how to fix this? c0.Test() # This should print "Hello!"
Output:The value of the string s is <__main__.MyClass object at 0x0000019C9A340908>
Hello! (This should appears)
I want to convert the string s back to an object, but how?The reason:
I want to make a something like a global static variable, but I don't know how do it with the program that's using Python as a script, that's why I convert my object to string then I'm able to store it to the program because it only accepts string, and when I run the script again, I can reuse the object from the stored string. Now you see that it's something like a static object, but I don't know how to do that.