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
2225add2
Kaydet (Commit)
2225add2
authored
Nis 01, 2002
tarafından
Jeremy Hylton
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Given lambda its own section, instead of burying it in boolean operators.
üst
53ed917d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
30 deletions
+7
-30
ref5.tex
Doc/ref/ref5.tex
+7
-30
No files found.
Doc/ref/ref5.tex
Dosyayı görüntüle @
2225add2
...
...
@@ -955,11 +955,16 @@ invent a value anyway, it does not bother to return a value of the
same type as its argument, so e.g.,
\code
{
not 'foo'
}
yields
\code
{
0
}
,
not
\code
{
''
}
.)
\section
{
Lambdas
\label
{
lambdas
}}
\indexii
{
lambda
}{
expression
}
\indexii
{
lambda
}{
form
}
\indexii
{
anonmymous
}{
function
}
Lambda forms (lambda expressions) have the same syntactic position as
expressions. They are a shorthand to create anonymous functions; the
expression
\code
{
lambda
\var
{
arguments
}
:
\var
{
expression
}}
yields a function object
that behaves virtually identical to one
defined
with
yields a function object
. The unnamed object behaves like a function
object define
with
\begin{verbatim}
def name(arguments):
...
...
@@ -969,34 +974,6 @@ def name(arguments):
See section
\ref
{
function
}
for the syntax of parameter lists. Note
that functions created with lambda forms cannot contain statements.
\label
{
lambda
}
\indexii
{
lambda
}{
expression
}
\indexii
{
lambda
}{
form
}
\indexii
{
anonmymous
}{
function
}
\strong
{
Programmer's note:
}
Prior to Python 2.1, a lambda form defined
inside a function has no access to names defined in the function's
namespace. This is because Python had only two scopes: local and
global. A common work-around was to use default argument values to
pass selected variables into the lambda's namespace, e.g.:
\begin{verbatim}
def make
_
incrementor(increment):
return lambda x, n=increment: x+n
\end{verbatim}
As of Python 2.1, nested scopes were introduced, and this work-around
has not been necessary. Python 2.1 supports nested scopes in modules
which include the statement
\samp
{
from
__
future
__
import
nested
_
scopes
}
, and more recent versions of Python enable nested
scopes by default. This version works starting with Python 2.1:
\begin{verbatim}
from
__
future
__
import nested
_
scopes
def make
_
incrementor(increment):
return lambda x: x+increment
\end{verbatim}
\section
{
Expression lists
\label
{
exprlists
}}
\indexii
{
expression
}{
list
}
...
...
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