Hi,

Sorry for the late reply, totally missed this!

To run it, I’ll need to give you a little backstory. Whenever you use print
"something", you are essentially calling sys.stdout.write("something" +
"\n") which means “write to standard out with a new-line”, where “standard
out” generally refers to a terminal.

By replacing sys.stdout with the object above, print will instead refer to
that class when attempting to write to “standard out”, which will in this
case append some additional information before doing so.

The sys.__stdout__ is an extra variable kept per default by Python and
refers to the original sys.stdout, in case you overwrite it like we are
here. We use it to refer back to where printing would happen normally;
which again is generally the terminal. But this time, it will have that
extra piece of information coming along with it.

My intent was for you to replace sys.stdout before running any other code,
so as to make the rest of your code print its information with
line-numbers, so that you could locate exactly where those printed lines
where coming from; assuming that it is print statements which was causing
them.

Does that help?

Best,
Marcus
​

On 17 November 2014 05:07, likage <[email protected]> wrote:

>
> Hey Marcus,
>
> Just wanted to ask how do i run the code? Within my own code or append my
> file into this code of yours?
>
> Cheers!
>
>
>
>
> On Friday, November 14, 2014 3:52:09 PM UTC+8, Marcus Ottosson wrote:
>>
>> This will append line number and filename to each print statement, maybe
>> it can help you figure out where it’s coming from.
>> https://gist.github.com/mottosso/7261394e511bc6206ede
>>
>> (Though I’m having trouble figuring out why it repeats the appended
>> information, I expected flushing to handle it, but it did not)
>> ​
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/3f5f5c0e-1ca0-40d0-a4a8-5e25c6c9b0b6%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/3f5f5c0e-1ca0-40d0-a4a8-5e25c6c9b0b6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Marcus Ottosson*
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAAzzCmywNE8t6VXGY5fzRM9sAZ5noLW%2B1vTXVcSeEFzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to