Hello,
I would like to do the following:
import StringIO, uu
my_data = StringIO.StringIO() # this is a file-like object
uu.encode(in_file, my_data)
# do stuff with my data (send over network)
uu.decode(my_data, out_file) # here I finally write to disk
The above code works. However, if I implement the previous step as a property in an object:
@property
def content(self):
out = StringIO.StringIO()
uu.decode(self._content, out)
return out.getvalue()
@content.setter
def content(self, value):
self._content = StringIO.StringIO()
with open('value', 'rb') as stream:
uu.encode(stream, self._content)
but when I do it like that, self._content
is empty (None
, to be precise). Any ideas?