By using eval() we can get back the object. In above code my_data2 is an string object, using this we can create our original set object.
print(type(eval(my_data2)))
Output
<class 'set'>
Using str()
Our built in function str() also returns the string from the object but here we get the 'informal' or nicely printable string representation of an object. Such returned string may not work with eval().
However repr() is typically used for debugging, so it is important that the representation is information-rich and unambiguous. See this example.