What is a function parameter =[] for?

Antoon Pardon antoon.pardon at rece.vub.ac.be
Wed Nov 25 16:05:30 EST 2015


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.

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

Same reasoning.

> 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.

And how does that make a difference?

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

Not in general no. It doesn't imply that not any tuple display notation
is a literal notation.

Expression may be constant but need not be, that is no reason to claim
that anything that is an expression can't be a literal.

-- 
Antoon.



More information about the Python-list mailing list