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
e9af284e
Kaydet (Commit)
e9af284e
authored
Agu 17, 2007
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
No need to define raw_input(), input() does the same.
üst
ed44a1a6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
21 deletions
+3
-21
controlflow.rst
Doc/tutorial/controlflow.rst
+2
-14
errors.rst
Doc/tutorial/errors.rst
+1
-7
No files found.
Doc/tutorial/controlflow.rst
Dosyayı görüntüle @
e9af284e
...
@@ -16,13 +16,7 @@ control flow statements known from other languages, with some twists.
...
@@ -16,13 +16,7 @@ control flow statements known from other languages, with some twists.
Perhaps the most well-known statement type is the :keyword:`if` statement. For
Perhaps the most well-known statement type is the :keyword:`if` statement. For
example::
example::
>>> def raw_input(prompt):
>>> x = int(input("Please enter an integer: "))
... import sys
... sys.stdout.write(prompt)
... sys.stdout.flush()
... return sys.stdin.readline()
...
>>> x = int(raw_input("Please enter an integer: "))
>>> if x < 0:
>>> if x < 0:
... x = 0
... x = 0
... print 'Negative changed to zero'
... print 'Negative changed to zero'
...
@@ -298,15 +292,9 @@ The most useful form is to specify a default value for one or more arguments.
...
@@ -298,15 +292,9 @@ The most useful form is to specify a default value for one or more arguments.
This creates a function that can be called with fewer arguments than it is
This creates a function that can be called with fewer arguments than it is
defined to allow. For example::
defined to allow. For example::
def raw_input(prompt):
import sys
sys.stdout.write(prompt)
sys.stdout.flush()
return sys.stdin.readline()
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
while True:
while True:
ok =
raw_
input(prompt)
ok = input(prompt)
if ok in ('y', 'ye', 'yes'): return True
if ok in ('y', 'ye', 'yes'): return True
if ok in ('n', 'no', 'nop', 'nope'): return False
if ok in ('n', 'no', 'nop', 'nope'): return False
retries = retries - 1
retries = retries - 1
...
...
Doc/tutorial/errors.rst
Dosyayı görüntüle @
e9af284e
...
@@ -85,15 +85,9 @@ entered, but allows the user to interrupt the program (using :kbd:`Control-C` or
...
@@ -85,15 +85,9 @@ entered, but allows the user to interrupt the program (using :kbd:`Control-C` or
whatever the operating system supports); note that a user-generated interruption
whatever the operating system supports); note that a user-generated interruption
is signalled by raising the :exc:`KeyboardInterrupt` exception. ::
is signalled by raising the :exc:`KeyboardInterrupt` exception. ::
>>> def raw_input(prompt):
... import sys
... sys.stdout.write(prompt)
... sys.stdout.flush()
... return sys.stdin.readline()
...
>>> while True:
>>> while True:
... try:
... try:
... x = int(
raw_
input("Please enter a number: "))
... x = int(input("Please enter a number: "))
... break
... break
... except ValueError:
... except ValueError:
... print "Oops! That was no valid number. Try again..."
... print "Oops! That was no valid number. Try again..."
...
...
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