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
8823972c
Kaydet (Commit)
8823972c
authored
Agu 19, 1996
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Documented class exceptions.
üst
305ed11a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
6 deletions
+46
-6
ref4.tex
Doc/ref/ref4.tex
+23
-3
ref4.tex
Doc/ref4.tex
+23
-3
No files found.
Doc/ref/ref4.tex
Dosyayı görüntüle @
8823972c
...
...
@@ -169,13 +169,33 @@ code from the top).
When an exception is not handled at all, the interpreter terminates
execution of the program, or returns to its interactive main loop.
Exceptions are identified by string objects. Two different string
objects with the same value identify different exceptions.
Exceptions are identified by string objects or class instances. Two
different string objects with the same value identify different
exceptions. An exception can be raised with a class instance. Such
exceptions are caught by specifying an except clause that has the
class name (or a base class) as the condition.
When an exception is raised, an object (maybe
\verb
@
None
@
) is passed
as the exception's ``parameter''; this object does not affect the
selection of an exception handler, but is passed to the selected
exception handler as additional information.
exception handler as additional information. For exceptions raised
with a class instance, the instance is passed as the ``parameter''.
For example:
\begin{verbatim}
>>> class Error:
... def
__
init
__
(self, msg): self.msg = msg
...
>>> class SpecificError(Error): pass
...
>>> try:
... raise SpecificError('broken')
... except Error, obj:
... print obj.msg
...
broken
\end{verbatim}
See also the description of the
\verb
@
try
@
and
\verb
@
raise
@
statements.
Doc/ref4.tex
Dosyayı görüntüle @
8823972c
...
...
@@ -169,13 +169,33 @@ code from the top).
When an exception is not handled at all, the interpreter terminates
execution of the program, or returns to its interactive main loop.
Exceptions are identified by string objects. Two different string
objects with the same value identify different exceptions.
Exceptions are identified by string objects or class instances. Two
different string objects with the same value identify different
exceptions. An exception can be raised with a class instance. Such
exceptions are caught by specifying an except clause that has the
class name (or a base class) as the condition.
When an exception is raised, an object (maybe
\verb
@
None
@
) is passed
as the exception's ``parameter''; this object does not affect the
selection of an exception handler, but is passed to the selected
exception handler as additional information.
exception handler as additional information. For exceptions raised
with a class instance, the instance is passed as the ``parameter''.
For example:
\begin{verbatim}
>>> class Error:
... def
__
init
__
(self, msg): self.msg = msg
...
>>> class SpecificError(Error): pass
...
>>> try:
... raise SpecificError('broken')
... except Error, obj:
... print obj.msg
...
broken
\end{verbatim}
See also the description of the
\verb
@
try
@
and
\verb
@
raise
@
statements.
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