2015-02-06 15 views

답변

2

이 기본 시작에서 명령 세트 정의하려면, 당신은 당신의 ~/.ipython 디렉토리에 templete입니다에 ipy_user_conf.py 파일을 명령을 추가해야합니다.
이 모듈은 IPython 시작 중에 가져옵니다. 그래서 당신은 쉽게 수행 할 수 있습니다 수입 모듈, 확장, 변경 옵션을 구성 마법 명령을 정의, 다음 등 IPython 네임 스페이스에
을 변수와 함수를 넣어 샘플 ipy_user_conf.py됩니다 : 자세한 내용은

# Most of your config files and extensions will probably start 
# with this import 

import IPython.ipapi 
ip = IPython.ipapi.get() 

# You probably want to uncomment this if you did %upgrade -nolegacy 
# import ipy_defaults 

import os 

def main(): 

    #ip.dbg.debugmode = True 
    ip.dbg.debug_stack() 

    # uncomment if you want to get ipython -p sh behaviour 
    # without having to use command line switches 
    import ipy_profile_sh 
    import jobctrl 

    # Configure your favourite editor? 
    # Good idea e.g. for %edit os.path.isfile 

    #import ipy_editors 

    # Choose one of these: 

    #ipy_editors.scite() 
    #ipy_editors.scite('c:/opt/scite/scite.exe') 
    #ipy_editors.komodo() 
    #ipy_editors.idle() 
    # ... or many others, try 'ipy_editors??' after import to see them 

    # Or roll your own: 
    #ipy_editors.install_editor("c:/opt/jed +$line $file") 


    o = ip.options 
    # An example on how to set options 
    #o.autocall = 1 
    o.system_verbose = 0 

    #import_all("os sys") 
    #execf('~/_ipython/ns.py') 


    # -- prompt 
    # A different, more compact set of prompts from the default ones, that 
    # always show your current location in the filesystem: 

    #o.prompt_in1 = r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Normal\n\C_Green|\#>' 
    #o.prompt_in2 = r'.\D: ' 
    #o.prompt_out = r'[\#] ' 

    # Try one of these color settings if you can't read the text easily 
    # autoexec is a list of IPython commands to execute on startup 
    #o.autoexec.append('%colors LightBG') 
    #o.autoexec.append('%colors NoColor') 
    o.autoexec.append('%colors Linux') 


# some config helper functions you can use 
def import_all(modules): 
    """ Usage: import_all("os sys") """ 
    for m in modules.split(): 
     ip.ex("from %s import *" % m) 

def execf(fname): 
    """ Execute a file in user namespace """ 
    ip.ex('execfile("%s")' % os.path.expanduser(fname)) 

main() 

는, 링크 : Customization of IPython을 참조하십시오.

알고 싶었던 바입니다.

+1

감사합니다. 당신의 대답은 제가 찾고있는 것이 아닙니다. 링크 된 문서는 ipython의 아주 오래된 버전 용이며 ipython을 시작할 때 실행되는 명령을 설정하는 방법을 설명합니다. 그러나 내가 찾고있는 것은 새로 생성 된 모든 노트에 맞춤 초기화 셀을 추가하는 방법입니다. 이것은 동일하게 보일 수도 있지만 예를 들어 노트북을 공유하려는 경우가 아닙니다. – user9886