STDOUT to StringIO

F

Fredrik

I know that I can redirect my standard output to a file like this:

STDOUT.reopen(File.open(filename,'w'))

But then, why can't I redirect it to a string like this? :

output = StringIo_Open('','w')
STDOUT.reopen(output)
TypeError: can't convert StringIO into String

Can somebody see what I am doing wrong?

Thanks a lot!
Fredrik
 
R

Ryan Davis

I know that I can redirect my standard output to a file like this:

STDOUT.reopen(File.open(filename,'w'))

But then, why can't I redirect it to a string like this? :

output = StringIo_Open('','w')
STDOUT.reopen(output)

Can somebody see what I am doing wrong?
=> "blah\n"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top