← Back to team overview

yade-users team mailing list archive

Re: [Question #270774]: redirecting output of yade.timing.stats()

 

Question #270774 on Yade changed:
https://answers.launchpad.net/yade/+question/270774

    Status: Open => Answered

Jan Stránský proposed the following answer:
You can redirect python output using sys.stdout (btw. the very first google
link "python redirect output"):

###############################
from yade import timing
import sys
sys.stdout = open('/tmp/timing.txt','w')
timing.stats()
###############################

or also returning original stdout back:

###############################
from yade import timing
import sys

print 'whatever'
f = open('/tmp/timing.txt','w')
sys.stdout = f
print 'whatever2'
timing.stats()
sys.stdout = sys.__stdout__
f.close()
print 'whatever3'
###############################

cheers
Jan


2015-08-26 19:16 GMT+02:00 ipemath
<question270774@xxxxxxxxxxxxxxxxxxxxx>:

> Question #270774 on Yade changed:
> https://answers.launchpad.net/yade/+question/270774
>
>     Status: Answered => Open
>
> ipemath is still having a problem:
> I use O.exitNoBacktrace() at the end of the script to return the control
> to terminal. If  I use "yade script.py > out.txt" I wont get the control
> bacck to terminal
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to     : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp
>

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.