मैं इंटरैक्टिव अजगर सत्र अनुकूलित करने के लिए मानक युक्तियों का उपयोग कैसे अजगर 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 तो कर्सर की स्थिति को गलत तरीके से गणना की गई थी और पाठ को गलत तरीके से प्रदर्शित किया गया था (यूपी दबाकर) आह्वान ।
बैश आदमी पेज में इस समस्या का उल्लेख किया और विशेष मार्कर द्वारा तय:
\[ 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 ** कंसोल? मेरा समाधान django इंटरैक्टिव सत्र में पूरा करने में सक्षम बनाता है, इस उद्देश्य के लिए bpython का उपयोग कैसे करें? – gavenkoa
@gavenkoa [core.managment.commands.shell] पर देख रहे हैं (https://code.djangoproject.com/browser/django/trunk/django/core/management/commands/shell.py), मुझे लगता है कि अगर 'ipython 'विफल रहता है,' bpython' का उपयोग किया जाता है। यदि आपने दोनों स्थापित किए हैं, तो आप अभी भी उस फ़ाइल को संपादित कर सकते हैं और 'shells' वर्ग विशेषता को पुन: व्यवस्थित कर सकते हैं ताकि' ipython' से पहले 'bpython' का प्रयास किया जा सके। – jcollado
knowladge साझा करने के लिए धन्यवाद – gavenkoa