uu.py - get result of uuencode() in a string
Fred L. Drake
fdrake at cnri.reston.va.us
Wed Jul 21 10:51:42 EDT 1999
Richard van de Stadt writes:
> Is it possible to get the output of the uuencode() function
> into a string, instead of a file or stdout?
The output file can be a StringIO instance; a convenience function
to handle this could be written as (untested):
------------------------------------------------------------------------
import StringIO
import uu
def uu2string(data, mode=None):
outfile = StringIO.StringIO()
infile = StringIO.StringIO(data)
uu.decode(infile, outfile, mode)
return outfile.getvalue()
------------------------------------------------------------------------
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
Corporation for National Research Initiatives
More information about the Python-list
mailing list