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
42d19e6a
Kaydet (Commit)
42d19e6a
authored
Ara 24, 2008
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
pretend exceptions don't exist a while longer
üst
54686e3c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
28 deletions
+6
-28
controlflow.rst
Doc/tutorial/controlflow.rst
+6
-28
No files found.
Doc/tutorial/controlflow.rst
Dosyayı görüntüle @
42d19e6a
...
@@ -169,42 +169,20 @@ required syntactically but the program requires no action. For example::
...
@@ -169,42 +169,20 @@ required syntactically but the program requires no action. For example::
... pass # Busy-wait for keyboard interrupt (Ctrl+C)
... pass # Busy-wait for keyboard interrupt (Ctrl+C)
...
...
This is commonly used for creating minimal classes such as exceptions, or
This is commonly used for creating minimal classes::
for ignoring unwanted exceptions::
>>> class
ParserError(Exception)
:
>>> class
MyEmptyClass
:
... pass
... pass
...
...
>>> try:
... import audioop
... except ImportError:
... pass
...
Another place :keyword:`pass` can be used is as a place-holder for a function or
Another place :keyword:`pass` can be used is as a place-holder for a function or
conditional body when you are working on new code, allowing you to keep
conditional body when you are working on new code, allowing you to keep thinking
thinking at a more abstract level. However, as :keyword:`pass` is silently
at a more abstract level. The :keyword:`pass` is silently ignored::
ignored, a better choice may be to raise a :exc:`NotImplementedError`
exception::
>>> def initlog(*args):
>>> def initlog(*args):
... raise NotImplementedError # Open logfile if not already open
... pass # Remember to implement this!
... if not logfp:
... raise NotImplementedError # Set up dummy log back-end
... raise NotImplementedError('Call log initialization handler')
...
...
If :keyword:`pass` were used here and you later ran tests, they may fail
without indicating why. Using :exc:`NotImplementedError` causes this code
to raise an exception, telling you exactly where the incomplete code
is. Note the two calling styles of the exceptions above.
The first style, with no message but with an accompanying comment,
lets you easily leave the comment when you remove the exception,
which ideally would be a good description for
the block of code the exception is a placeholder for. However, the
third example, providing a message for the exception, will produce
a more useful traceback.
.. _tut-functions:
.. _tut-functions:
Defining Functions
Defining Functions
...
...
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