Could someone explain the purpose of a lambda and decorator? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

Could someone explain the purpose of a lambda and decorator?

1st Oct 2016, 1:32 PM
Avery
Avery - avatar
2 Respuestas
+ 8
a decorator alters the behaviour of a function (and indicates to a reader that it does so through the decorator) the lambda allows to define an anonymous function, i.e. it allows to work with a function that does not have a "def... " block. this allows for more readable code when it is a very small function that you only call once (for example).
2nd Oct 2016, 8:35 AM
David Gablinger
David Gablinger - avatar
+ 1
Here is an explanation of the decorator usage: https://code.sololearn.com/cD09ijlIS6Ev/?ref=app
7th Jun 2018, 1:58 AM
Denys Yeromenko
Denys Yeromenko - avatar