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
9dca5eaf
Kaydet (Commit)
9dca5eaf
authored
Şub 15, 2007
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make functools.wraps() docs a bit clearer.
üst
13a98287
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
libfunctools.tex
Doc/lib/libfunctools.tex
+11
-6
No files found.
Doc/lib/libfunctools.tex
Dosyayı görüntüle @
9dca5eaf
...
@@ -53,15 +53,16 @@ two:
...
@@ -53,15 +53,16 @@ two:
\begin{funcdesc}
{
update
_
wrapper
}
\begin{funcdesc}
{
update
_
wrapper
}
{
wrapper, wrapped
\optional
{
, assigned
}
\optional
{
, updated
}}
{
wrapper, wrapped
\optional
{
, assigned
}
\optional
{
, updated
}}
Update a
wrapper function to look like the wrapped function. The optional
Update a
\var
{
wrapper
}
function to look like the
\var
{
wrapped
}
function.
arguments are tuples to specify which attributes of the original
The optional
arguments are tuples to specify which attributes of the original
function are assigned directly to the matching attributes on the wrapper
function are assigned directly to the matching attributes on the wrapper
function and which attributes of the wrapper function are updated with
function and which attributes of the wrapper function are updated with
the corresponding attributes from the original function. The default
the corresponding attributes from the original function. The default
values for these arguments are the module level constants
values for these arguments are the module level constants
\var
{
WRAPPER
_
ASSIGNMENTS
}
(which assigns to the wrapper function's name,
\var
{
WRAPPER
_
ASSIGNMENTS
}
(which assigns to the wrapper function's
module and documentation string) and
\var
{
WRAPPER
_
UPDATES
}
(which
\var
{__
name
__}
,
\var
{__
module
__}
and
\var
{__
doc
__}
, the documentation string)
updates the wrapper function's instance dictionary).
and
\var
{
WRAPPER
_
UPDATES
}
(which updates the wrapper function's
\var
{__
dict
__}
,
i.e. the instance dictionary).
The main intended use for this function is in decorator functions
The main intended use for this function is in decorator functions
which wrap the decorated function and return the wrapper. If the
which wrap the decorated function and return the wrapper. If the
...
@@ -85,6 +86,7 @@ as a function decorator when defining a wrapper function. For example:
...
@@ -85,6 +86,7 @@ as a function decorator when defining a wrapper function. For example:
...
...
>>> @my
_
decorator
>>> @my
_
decorator
... def example():
... def example():
... """Docstring"""
... print 'Called example function'
... print 'Called example function'
...
...
>>> example()
>>> example()
...
@@ -92,9 +94,12 @@ as a function decorator when defining a wrapper function. For example:
...
@@ -92,9 +94,12 @@ as a function decorator when defining a wrapper function. For example:
Called example function
Called example function
>>> example.
__
name
__
>>> example.
__
name
__
'example'
'example'
>>> example.
__
doc
__
'Docstring'
\end{verbatim}
\end{verbatim}
Without the use of this decorator factory, the name of the example
Without the use of this decorator factory, the name of the example
function would have been
\code
{
'wrapper'
}
.
function would have been
\code
{
'wrapper'
}
, and the docstring of the
original
\function
{
example()
}
would have been lost.
\end{funcdesc}
\end{funcdesc}
...
...
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