9
IPythonのロギング機能に出力と入力を含める方法はありますか?IPython出力をログに記録しますか?
これは、ログファイルが現在のようになります。
#!/usr/bin/env python
# 2012-08-06.py
# IPython automatic logging file
# 12:02
# =================================
print "test"
私は1つの以上の行が表示したいのです:私はそれが必要とされていると仮定しているため
#!/usr/bin/env python
# 2012-08-06.py
# IPython automatic logging file
# 12:02
# =================================
print "test"
# test
(#
です機能を無効にするため)
これはIPythonノートブックを使用しても可能ですが、少なくとも1台のマシンではこれが必要ですipython 0.10.2を編集しました。
編集:これを設定ファイル内で自動的に設定する方法を知りたいと思います。今、私のconfigが
from time import strftime
import os
logfilename = strftime('ipython_log_%Y-%m-%d')+".py"
logfilepath = "%s/%s" % (os.getcwd(),logfilename)
file_handle = open(logfilepath,'a')
file_handle.write('########################################################\n')
out_str = '# Started Logging At: '+ strftime('%Y-%m-%d %H:%M:%S\n')
file_handle.write(out_str)
file_handle.write('########################################################\n')
file_handle.close()
c.TerminalInteractiveShell.logappend = logfilepath
c.TerminalInteractiveShell.logstart = True
のように見えるがc.TerminalInteractiveShell.log_output = True
を指定すると、持っていない%logstart
ため-o
オプションあります
解決策は、ここに記載されているように、スタートアップスクリプトでこれを行うように見えます。http://wiki.ipython.org/Cookbook/DatedLog(これはhttp://stackoverflow.com/questions/11836612で提供された解決策でした。/where-how-in-context-is-ipythons-configuration-file-executed?lq = 1) – keflavich