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
790c3c13
Kaydet (Commit)
790c3c13
authored
Nis 26, 2006
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix an error in the last contextlib.closing example
üst
9cc3b1cc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
libcontextlib.tex
Doc/lib/libcontextlib.tex
+3
-3
No files found.
Doc/lib/libcontextlib.tex
Dosyayı görüntüle @
790c3c13
...
@@ -149,8 +149,7 @@ occurs, \code{page.close()} will be called when the \keyword{with}
...
@@ -149,8 +149,7 @@ occurs, \code{page.close()} will be called when the \keyword{with}
block is exited.
block is exited.
Context managers with a close method can use this context factory
Context managers with a close method can use this context factory
directly without needing to implement their own
to easily implement their own
\method
{__
context
__
()
}
method.
\method
{__
context
__
()
}
method.
\begin{verbatim}
\begin{verbatim}
from
__
future
__
import with
_
statement
from
__
future
__
import with
_
statement
from contextlib import closing
from contextlib import closing
...
@@ -158,7 +157,8 @@ from contextlib import closing
...
@@ -158,7 +157,8 @@ from contextlib import closing
class MyClass:
class MyClass:
def close(self):
def close(self):
print "Closing", self
print "Closing", self
__
context
__
= closing
def
__
context
__
(self):
return closing(self)
>>> with MyClass() as x:
>>> with MyClass() as x:
... print "Hello from", x
... print "Hello from", x
...
...
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