What is a function parameter =[] for?

Random832 random832 at fastmail.com
Tue Nov 24 11:28:58 EST 2015


On 2015-11-24, Chris Angelico <rosuav at gmail.com> wrote:
> 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.
>
> Neither of them is a literal, even though one of them isn't even
> constructing a list. Tuples may be constant, but they still don't have
> a literal form.

How do you define "literal form"? I define it as any syntax that
can participate in ast.literal_eval (And I consider [...] to be a
literal form regardless of whether the ... values are literals or
not). I don't think "Start thinking of it as a constructor call
rather than a literal" is helpful, since it just hides one's
confusion about what a literal is.

The Python documentation itself seems to assume that "literal"
should only be used for things that are a single token, though I
have no idea where this thinking comes from.




More information about the Python-list mailing list