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
5ef9d9fd
Kaydet (Commit)
5ef9d9fd
authored
Nis 23, 2006
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Update contextlib documentation to use the same terminology as the module implementation
üst
84faa857
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
libcontextlib.tex
Doc/lib/libcontextlib.tex
+8
-7
No files found.
Doc/lib/libcontextlib.tex
Dosyayı görüntüle @
5ef9d9fd
...
...
@@ -49,8 +49,9 @@ occurred. Thus, you can use a
the error (if any), or ensure that some cleanup takes place.
Note that you can use
\code
{
@contextmanager
}
to define a context
manager's
\method
{__
context
__}
method. This is usually more convenient
than creating another class just to serve as a context. For example:
object's
\method
{__
context
__}
method. This is usually more convenient
than creating another class just to serve as a context manager.
For example:
\begin{verbatim}
from
__
future
__
import with
_
statement
...
...
@@ -97,10 +98,10 @@ with A as X:
do
_
something()
\end{verbatim}
Note that if
one of the nested contexts'
\method
{__
exit
__
()
}
method
Note that if
the
\method
{__
exit
__
()
}
method of one of the nested context managers
raises an exception, any previous exception state will be lost; the new
exception will be passed to the
outer contexts'
\method
{__
exit
__
()
}
method(s), if any
. In general,
\method
{__
exit
__
()
}
methods should avoid
exception will be passed to the
\method
{__
exit
__
()
}
methods of any remaining
outer context managers
. In general,
\method
{__
exit
__
()
}
methods should avoid
raising exceptions, and in particular they should not re-raise a
passed-in exception.
\end{funcdesc}
...
...
@@ -127,9 +128,9 @@ from __future__ import with_statement
from contextlib import closing
import codecs
with closing(
codecs.open("foo", encoding="utf8"
)) as f:
with closing(
urllib.urlopen('http://www.python.org'
)) as f:
for line in f:
print line
.encode("latin1")
print line
\end{verbatim}
without needing to explicitly close
\code
{
f
}
. Even if an error occurs,
...
...
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