Printing and clearing output window.

Recently I started to work on some maya startup scripts and wanted to print out some info in Maya’s Output Window.

So I thought a simple

Would do the trick. However it doesnt.

Turns out maya stores the stdout connection of the Output Window in the private __stdout__.

So in order to print to the output window use:

Now after a few lines of testing I wanted to clear out the Output Window which turns out to be quite hacky.

So after some searching I found that someone uploaded a useful script that does exactly this:

It does look very intrusive into the windows file system so I guess using this for linux or mac is out of the question.