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
90981e0e
Kaydet (Commit)
90981e0e
authored
Eki 07, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add Jeff Epler's interact() function. Note that it is broken.
(It should probably be withdrawn :-( )
üst
d5484fb7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
code.py
Lib/code.py
+52
-0
No files found.
Lib/code.py
Dosyayı görüntüle @
90981e0e
# XXX This is broken with class exceptions
"""Utilities dealing with code objects."""
def
compile_command
(
source
,
filename
=
"<input>"
,
symbol
=
"single"
):
...
...
@@ -50,3 +52,53 @@ def compile_command(source, filename="<input>", symbol="single"):
return
code
if
not
code1
and
err1
==
err2
:
raise
SyntaxError
,
err1
def
interact
(
banner
=
None
,
readfunc
=
raw_input
,
local
=
None
):
# Due to Jeff Epler, with changes by Guido:
"""Closely emulate the interactive Python console."""
try
:
import
readline
# Enable GNU readline if available
except
:
pass
local
=
local
or
{}
import
sys
,
string
,
traceback
sys
.
ps1
=
'>>> '
sys
.
ps2
=
'... '
if
banner
:
print
banner
else
:
print
"Python Interactive Console"
,
sys
.
version
print
sys
.
copyright
buf
=
[]
while
1
:
if
buf
:
prompt
=
sys
.
ps2
else
:
prompt
=
sys
.
ps1
try
:
line
=
readfunc
(
prompt
)
except
KeyboardInterrupt
:
print
"
\n
KeyboardInterrupt"
buf
=
[]
continue
except
EOFError
:
break
buf
.
append
(
line
)
try
:
x
=
compile_command
(
string
.
join
(
buf
,
"
\n
"
))
except
SyntaxError
:
traceback
.
print_exc
(
0
)
buf
=
[]
continue
if
x
==
None
:
continue
else
:
try
:
exec
x
in
local
except
:
exc_type
,
exc_value
,
exc_traceback
=
\
sys
.
exc_type
,
sys
.
exc_value
,
\
sys
.
exc_traceback
l
=
len
(
traceback
.
extract_tb
(
sys
.
exc_traceback
))
try
:
1
/
0
except
:
m
=
len
(
traceback
.
extract_tb
(
sys
.
exc_traceback
))
traceback
.
print_exception
(
exc_type
,
exc_value
,
exc_traceback
,
l
-
m
)
buf
=
[]
if
__name__
==
'__main__'
:
interact
()
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