What is a function parameter =[] for?

Antoon Pardon antoon.pardon at rece.vub.ac.be
Tue Nov 24 10:03:47 EST 2015


Op 24-11-15 om 15:34 schreef Chris Angelico:
> On Wed, Nov 25, 2015 at 1:24 AM, Antoon Pardon
> <antoon.pardon at rece.vub.ac.be> wrote:
>>> Start thinking of it as a constructor call rather than a literal, and
>>> you'll get past most of the confusion.
>>
>> That doesn't change the fact it does look like a literal and not like
>> a constructor.
> 
> Then explain how this is a literal:
> 
> squares = [x*x for x in range(int(input("How far? ")))]

So are you saying

  () isn't a literal

because

  (x * x for x in range(int(input("How far? ")))) isn't a literal?

-- 
Antoon.



More information about the Python-list mailing list