import cloudpickle
class A:
def __init__(self, i: int):
self.i = i
def a_method(self, sentence: str) -> str:
b: str = sentence * self.i
return b
a = A(i=2)
with open("mypickle", "wb") as f:
cloudpickle.dump(a, f)
Would it be possible to retrieve the source code as a string of the a_method as :
'def a_method(self, sentence: str) -> str:\n b: str = sentence * self.i\n return b\n'
The class instance is pickled by value and I don't have a reference to the original class definition.
Given the following pickle (python3.8)
Would it be possible to retrieve the source code as a string of the
a_method
as :'def a_method(self, sentence: str) -> str:\n b: str = sentence * self.i\n return b\n'
The class instance is pickled by value and I don't have a reference to the original class definition.