- くだすれPython(超初心者用) その27©2ch.net
768 :デフォルトの名無しさん[sage]:2015/10/30(金) 12:37:33.93 ID:LbGz8JT9 - ただ、%pasteを使って対話シェルにペーストしたものを%saveでpyファイル化すると、
そこに出来たpyファイルの中身は、get_ipython().magic(u'paste')みたいに なって、後に使えないような問題が生じていました。 そこで、その理由を調べてみると、 ttp://stackoverflow.com/questions/29968038/how-to-save-an-ipython-session-if-i-used-magic-paste-magic-save-doesnt-wor という英文のサイトに、How to save an ipython session if i used magic %paste ? (magic %save doesn't work) Of course, I would like the pasted code to be saved instead.Any ideas? という同じトラブルの質問がなされていた。
| - くだすれPython(超初心者用) その27©2ch.net
769 :デフォルトの名無しさん[sage]:2015/10/30(金) 12:38:03.64 ID:LbGz8JT9 - その解答の一つにあったのは、
It is only saving the commands you type at the prompt, and the command you entered was paste, which the magic converts to get_ipython().magic(u'paste '). While the first behavior may not be a bug (even if it's not particularly helpful), this editing behavior definitely seems like one. %pasteでIPythonの対話シェルにペーストしたものを%saveでpyファイル化したものは、 get_ipython().magic(u'paste')になるのがデフォルトの仕様です、ユーザーが コマンドを実行した箇所の%paste=(u'paste ')の部分しかファイル化されない仕様になってます。と、 書いてある感じ。%pasteを使わないで、普通にコードをコピペ・ペースト出来たものは、%saveで普通に pyファイル化されている感じでした。
|
|