[IronPython] Hosting question

Slide slide.o.mix at gmail.com
Fri Jul 28 13:38:24 CEST 2006


On 7/27/06, Ryan Dawson <rdawson at exchange.microsoft.com> wrote:
> Hmm, I suspect this has something to do with your handling of the stream.  Below is a little pure IronPython snippet that I'm using to test.
>
> If you'd like to post your code for PythonOutputStream I'd be happy to take a look.  Hope this helps...
>
> from IronPython.Hosting import PythonEngine
> from System.IO import MemoryStream
> from System.IO import StreamReader
> from System.Text import ASCIIEncoding
>
> class MyStream(MemoryStream):
>         def Write(self,buffer,offset,count):
>                         super(MyStream,self).Write(buffer,offset,count)
>                         print 'Writing "%s"' % ASCIIEncoding().GetString(buffer,offset,count)
>
> s = MyStream()
>
> pe = PythonEngine()
> pe.SetStandardOutput(s)
>
> pe.Execute("print 3")
>
> s.Position=0
> text = StreamReader(s).ReadToEnd()
> print 'Final text = "%s"' % text
>
> #######################
> Output when run:
> Writing "3"
> Writing "
> "
> Final text = "3
> "
>


*sheepish* It was some of my other code that was causing the
problem...thanks for the help!



More information about the Ironpython-users mailing list