What is a function parameter =[] for?

Ian Kelly ian.g.kelly at gmail.com
Wed Nov 25 17:38:27 EST 2015


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:
>> On Wed, Nov 25, 2015 at 11:27 AM, Antoon Pardon
>> <antoon.pardon at rece.vub.ac.be> wrote:
>>> I don't know what you are talking about. The first thing I have argued
>>> is that () is a literal. Then I have expaned that to that something
>>> like (3, 5, 8) is a literal. I never argued that tuple expressions
>>> in general are literals. And one way I supported my point was with the
>>> following quote from the python language reference.
>>>
>>>   Literals are notations for constant values of some built-in types.
>>>
>>> And I think that the things I argued were literals, were in fact
>>> constant values of some built-in type.
>>
>> 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?



More information about the Python-list mailing list