[Ironpython-users] Separating return values from printed values?

Doug Blank doug.blank at gmail.com
Thu Sep 20 18:15:04 CEST 2012


On Thu, Sep 20, 2012 at 11:48 AM, Keith Rome <rome at wintellect.com> wrote:
> That should be fine. My example was the simplest way possible to spin up a script, so I didn't bother with an explicit scope. But that doesn't change anything really. Also if you re-use the same engine many times, you only really need to wire up the custom output writer once - after initial engine creation.
>
> You can also make the TextWriter slightly smarter and ensure that it only colorizes text that comes from the print function. There isn't a straightforward way to do that, but you can cheat and check the call stack. As long as your code is full-trust then this shouldn't be an issue.
>
> This version might be a little more suitable and complete after seeing your example. I still had to make some assumptions about how your Execute is being handled, but this should at least be fairly close:
>

Wow, Keith! That is amazing, and amazing that you wrote this for us!

I'll give it a try... looks a little sketching diving into the
stack... but this is useful for other uses perhaps also...

Whole lotta thanks!

-Doug


More information about the Ironpython-users mailing list