What is a function parameter =[] for?

Ian Kelly ian.g.kelly at gmail.com
Wed Nov 25 15:39:44 EST 2015


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?

How about tuple(1, 2+3, abs(-19))? Still a constant value of a built-in type.

I think the most important word in the definition you quoted is
actually "notation". It says it right there: literals are not
"constant values", but notations for *expressing* constant values.

The tuple display notation expresses values that may be constant but
need not be. Therefore it's not a literal notation.



More information about the Python-list mailing list