I am new to python. I have a few questions coming from an armature!

Paul Rudin paul.nospam at rudin.co.uk
Tue Aug 16 02:25:44 EDT 2016


sohcahtoa82 at gmail.com writes:

> On Monday, August 15, 2016 at 8:07:32 AM UTC-7, alister wrote:
>> On Mon, 15 Aug 2016 07:00:47 -0700, Sickfit92 wrote:
>> 
>> > 1. How long did it take you guys to master the language or, let me put
>> > it this way to completely get the hang and start writing code?
>> > 
> <snip>
>> Some concepts took more time than others before I had the "Light bulb" 
>> moment, Comprehensions & decorators being the most notable although 
>> Lambda still escapes me, fortunately these can all be unrolled into 
>> larger functions so are not essential in the early stages
>> 
> <snip>
>
> What helped me understand Lambdas is figuring out that they're really just a $1,000 term for a $5 concept.
>
> A lambda is just a single-line function without a name (Unless you assign it to one).  A syntactic shortcut.
>
> def square_plus_one(x):
>     return x ** 2 + 1
>
> squared_plus_one_list = map(square_plus_one, some_list)
>
> is equivalent to:
>
> squared_plus_one_list = map(lambda x: x**2 + 1, some_list)

I realise that this is about understanding lambda, but it's worth noting
in passing that we tend to write this sort of thing as:

squared_plus_one_list = [x**2 + 1 for x in some_list]




More information about the Python-list mailing list