I want to encode a file using uu.encode() method and use the encoded text in the script. For this I have to write that output to a file, by default uu.encode(input_file, output_file) requires the output file name so that it can write the encoded text to that file, then read the file to store in a variable.
But I don't want to do this and store the encoded text directly into a variable. Is it possible?
Here is the typical usage of uu.encode:
import uu
uu.encode("myfile.exe", "encoded_exe.txt")
I tried some stupid moves like this, which took me nowhere.
>>> data = uu.encode("M8510-8681-2015-09-29-220157.flv", sys.stdout.read())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: File not open for reading
>>>
This is not a must-requirement for me, but want to learn a thing or two using this opportunity.