[twill] StringIO?

John Mudd johnbmudd at gmail.com
Tue Mar 21 13:20:17 PST 2006


Um, I'm able to capture the output as a string.  I was hoping calling
the truncate() method would reset the StringIO() thing.  Doesn't
though.  It just accumulates.  I must be way off base by now.

Looking for StringIO docs.  Standard Python doesn't help much. 
Looking...  Fredrik Lundh examples.  Is this where StringIO came from?
 Seems like it could be useful, in rare cases.

Is this really necessary?  Why not just return the output as a string
by default?  Let me decide if I want to print it.  Leave the
auto-print to twill-sh only.  Just like Python, print result in
interactive mode.  Return result in scripts.

John



import StringIO
print dir(StringIO)


output = StringIO.StringIO()
twill.set_output(output)

b = twill.get_browser()

b.go('http://www.xxxxxxxxxx.com/webmail')
print 'output=%s' % output.getvalue()
output.truncate()

b.showforms()
print 'output=%s' % output.getvalue()
output.truncate()

print 'dir(output)=%s' % dir(output)



More information about the twill mailing list