What is a function parameter =[] for?

Antoon Pardon antoon.pardon at rece.vub.ac.be
Thu Nov 26 03:15:09 EST 2015


Op 25-11-15 om 23:38 schreef Ian Kelly:
> On Wed, Nov 25, 2015 at 2:05 PM, Antoon Pardon
> <antoon.pardon at rece.vub.ac.be> wrote:
>> Op 25-11-15 om 21:39 schreef Ian Kelly:
>>
>>> I believe that sentence from the docs is using "some" to mean "not
>>> all", whereas you are apparently using it to mean "any".
>>>
>>> frozenset([1,2,3]) constructs a constant value of a built-in type.
>>> Would you consider that a literal?
>> I am inclined to say yes, because a sufficient intelligent compilor
>> can compute the value and store it do be retrieved and bound to a
>> target when needed.
> I'm curious then what you think of this:
>
> from collections import namedtuple
>
> class Point(namedtuple("Point", "x y")): pass
>
> Point(17, 12)
>
> Still a constant, but not a built-in type. Would you consider that a literal?

I think I would answer no to that. In this case we have a user class. So
the compilor has no intrinsic knowledge of the structure of this type.
So the language has no choice but to construct the object at the moment
of execution.

-- 
Antoon.




More information about the Python-list mailing list