How do I add tab completion to the Python shell?

后端 未结 9 865
甜味超标
甜味超标 2020-11-30 16:41

When starting a django application using python manage.py shell, I get an InteractiveConsole shell - I can use tab completion, etc.

Python 2.5.1         


        
9条回答
  •  一生所求
    2020-11-30 17:20

    I may have found a way to do it.

    Create a file .pythonrc

    # ~/.pythonrc
    # enable syntax completion
    try:
        import readline
    except ImportError:
        print("Module readline not available.")
    else:
        import rlcompleter
        readline.parse_and_bind("tab: complete")
    

    then in your .bashrc file, add

    export PYTHONSTARTUP=~/.pythonrc
    

    That seems to work.

提交回复
热议问题