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
7d4f8fda
Kaydet (Commit)
7d4f8fda
authored
Eyl 04, 2009
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#6777: dont discourage usage of Exception.args or promote usage of Exception.message.
üst
601ee7f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
17 deletions
+14
-17
errors.rst
Doc/tutorial/errors.rst
+14
-17
No files found.
Doc/tutorial/errors.rst
Dosyayı görüntüle @
7d4f8fda
...
...
@@ -165,14 +165,11 @@ exception type.
The except clause may specify a variable after the exception name (or tuple).
The variable is bound to an exception instance with the arguments stored in
``instance.args``. For convenience, the exception instance defines
:meth:`__
getitem__` and :meth:`__str__` so the arguments can be accessed or
printed directly without having to
reference ``.args``.
:meth:`__
str__` so the arguments can be printed directly without having to
reference ``.args``.
But use of ``.args`` is discouraged. Instead, the preferred use is to pass a
single argument to an exception (which can be a tuple if multiple arguments are
needed) and have it bound to the ``message`` attribute. One may also
instantiate an exception first before raising it and add any attributes to it as
desired. ::
One may also instantiate an exception first before raising it and add any
attributes to it as desired. ::
>>> try:
... raise Exception('spam', 'eggs')
...
...
@@ -288,28 +285,28 @@ to create specific exception classes for different error conditions::
"""Exception raised for errors in the input.
Attributes:
expr
ession
-- input expression in which the error occurred
m
essage
-- explanation of the error
expr -- input expression in which the error occurred
m
sg
-- explanation of the error
"""
def __init__(self, expr
ession, message
):
self.expr
ession = expression
self.m
essage = message
def __init__(self, expr
, msg
):
self.expr
= expr
self.m
sg = msg
class TransitionError(Error):
"""Raised when an operation attempts a state transition that's not
allowed.
Attributes:
prev
ious
-- state at beginning of transition
prev -- state at beginning of transition
next -- attempted new state
m
essage
-- explanation of why the specific transition is not allowed
m
sg
-- explanation of why the specific transition is not allowed
"""
def __init__(self, prev
ious, next, message
):
self.prev
ious = previous
def __init__(self, prev
, next, msg
):
self.prev
= prev
self.next = next
self.m
essage = message
self.m
sg = msg
Most exceptions are defined with names that end in "Error," similar to the
naming of the standard exceptions.
...
...
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