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
ce28e2c2
Kaydet (Commit)
ce28e2c2
authored
Eki 06, 2013
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge with 3.3
üst
3db684ff
de5aff1b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
+18
-11
controlflow.rst
Doc/tutorial/controlflow.rst
+18
-11
No files found.
Doc/tutorial/controlflow.rst
Dosyayı görüntüle @
ce28e2c2
...
...
@@ -583,17 +583,16 @@ In the same fashion, dictionaries can deliver keyword arguments with the ``**``\
.. _tut-lambda:
Lambda Forms
------------
By popular demand, a few features commonly found in functional programming
languages like Lisp have been added to Python. With the :keyword:`lambda`
keyword, small anonymous functions can be created. Here's a function that
returns the sum of its two arguments: ``lambda a, b: a+b``. Lambda forms can be
used wherever function objects are required. They are syntactically restricted
to a single expression. Semantically, they are just syntactic sugar for a
normal function definition. Like nested function definitions, lambda forms can
reference variables from the containing scope::
Lambda Expressions
------------------
Small anonymous functions can be created with the :keyword:`lambda` keyword.
This function returns the sum of its two arguments: ``lambda a, b: a+b``.
Lambda forms can be used wherever function objects are required. They are
syntactically restricted to a single expression. Semantically, they are just
syntactic sugar for a normal function definition. Like nested function
definitions, lambda functions can reference variables from the containing
scope::
>>> def make_incrementor(n):
... return lambda x: x + n
...
...
@@ -604,6 +603,14 @@ reference variables from the containing scope::
>>> f(1)
43
The above example uses a lambda expression to return a function. Another use
is to pass a small function as an argument::
>>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
>>> pairs.sort(key=lambda pair: pair[1])
>>> pairs
[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]
.. _tut-docstrings:
...
...
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