IPython
패키지에 생각보다 유용한 옵션들이 많은데, 여기에 한번 정리해보았다. ipython --help
로 모든 옵션을 볼 수 있다.import
from other directories다른 directory에 있는 모듈에서 함수, 클래스 등을 import 하려는 경우
>>> import sys
>>> module_path = "해당 디렉토리의 절대 경로"
>>> sys.path.append(module_path)
처음에 실행할 때부터 특정 파일에 저장하고싶을 경우
ipython --logfile {filename}
{filename}
에 명령어 로그를 저장한다. (파이썬 스크립트로 저장된다).py
) 형태로 옮기거나 할 경우에 쉽게 복붙할 수 있다. %logstop
> %logstart -{o|r|t|q}
-o
: output logging-r
: raw input log-t
: timestamping-q
: (뭔지 아직 잘 모르겠다)ipython --logappend {filename}
{filename}
에 명령어 로그를 추가한다.
ipython
으로 신나게 코딩하다가 갑자기 export 하고싶어질 경우
*%{magic}
: 쉘 안에서 실행하는 'built-in magic commands'
%history [-l] [-f] [-o]
이전 명령어 히스토리를 저장
-l
: 최근 n개의 line을 저장
-f
: 저장할 파일 이름
-o
: ouput도 함께 저장
또는 직접 저장할 line을 아래처럼 명명
Line 4, current session
4-6
Lines 4-6, current session
243/1-5
Lines 1-5, session 243
~2/7
Line 7, session 2 before current
~8/1-~6/5
From the first line of 8 sessions ago, to the fifth line of 6 sessions ago.
Multiple ranges can be entered, separated by spaces