Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
b98a8ba1
Kaydet (Commit)
b98a8ba1
authored
May 23, 2004
tarafından
Skip Montanaro
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add example that uses readline.readline().
üst
0dc23101
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
libreadline.tex
Doc/lib/libreadline.tex
+33
-0
No files found.
Doc/lib/libreadline.tex
Dosyayı görüntüle @
b98a8ba1
...
...
@@ -159,3 +159,36 @@ atexit.register(readline.write_history_file, histfile)
del os, histfile
\end{verbatim}
The following example extends the
\class
{
code.InteractiveConsole
}
class to
support command line editing and history save/restore.
\begin{verbatim}
import code
import readline
import atexit
import os
class HistoryConsole(code.InteractiveConsole):
def
__
init
__
(self, locals=None, filename="<console>",
histfile=os.path.expanduser("~/.console-history")):
code.InteractiveConsole.
__
init
__
(self)
self.init
_
history(histfile)
def init
_
history(self, histfile):
readline.parse
_
and
_
bind("tab: complete")
if hasattr(readline, "read
_
history
_
file"):
try:
readline.read
_
history
_
file(histfile)
except IOError:
pass
atexit.register(self.save
_
history, histfile)
def raw
_
input(self, prompt=""):
line = readline.readline(prompt)
if line:
readline.add
_
history(line)
return line
def save
_
history(self, histfile):
readline.write
_
history
_
file(histfile)
\end{verbatim}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment