내가 대화 형 파이썬 세션을 사용자 정의하는 표준 팁을 사용하는 경우 파이썬의 readline의 열 계산을 해결하는 방법을 봐 : 색상을 사용 프롬프트
$ cat ~/.bashrc export PYTHONSTARTUP=~/.pystartup $ cat ~/.pystartup import os import sys import atexit import readline import rlcompleter historyPath = os.path.expanduser("~/.pyhistory") def save_history(historyPath=historyPath): import readline readline.write_history_file(historyPath) if os.path.exists(historyPath): readline.read_history_file(historyPath) term_with_colors = ['xterm', 'xterm-color', 'xterm-256color', 'linux', 'screen', 'screen-256color', 'screen-bce'] if os.environ.get('TERM') in term_with_colors: green='\033[32m' red='\033[31m' reset='\033[0m' sys.ps1 = red + '>>> ' + reset sys.ps2 = green + '... ' + reset del term_with_colors atexit.register(save_history) del os, sys, atexit, readline, rlcompleter, save_history, historyPath이 지금은 상황에 맞는 완성 및 색상 프롬프트를 얻을.
문제는 컬러 프롬프트에서 온 - 나는 역사 검색 뒤로 커서 위치가 잘못 계산 및 텍스트가 잘못 표시 그래서, ACOUNT 터미널 이스케이프 시퀀스에 걸릴 readline에 대화 형 파이썬 세션에서 (UP을 을 눌러)를 호출 할 때 . 배쉬 man 페이지에서
이 문제는 특수 마커 언급 고정 :\[ begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt \] end a sequence of non-printing characters
어떻게하라는 메시지가 파이썬이 문제를 해결하려면?
+1. bpython은 좋은 것입니다! 어때요 django **./manage.py ** console? 내 솔루션은 또한 장고 대화 형 세션에서 완성을 가능케하는데,이 목적을 위해 bpython을 사용하는 방법은 무엇입니까? – gavenkoa
@gavenkoa [core.managment.commands.shell] (https://code.djangoproject.com/browser/django/trunk/django/core/management/commands/shell.py)에서 보았을 때,'ipython '실패하면'bpython'이 사용됩니다. 둘 다 설치했다면, 여전히'ipython' 전에'bpython'을 시도하도록'shells' 클래스 속성을 재정렬하고 파일을 편집 할 수 있습니다. – jcollado
knowladge 공유 주셔서 감사합니다. – gavenkoa