Late-binding of function defaults (was Re: What is a function parameter =[] for?)

Ian Kelly ian.g.kelly at gmail.com
Wed Nov 25 22:01:43 EST 2015


On Wed, Nov 25, 2015 at 5:52 PM, Random832 <random832 at fastmail.com> wrote:
> On 2015年11月25日, Ben Finney <ben+python at benfinney.id.au> wrote:
>> That is, the ‘2’ in ‘cartesian_point = (2, 3)’ means something different
>> than in ‘cartesian_point = (3, 2)’.
>>>> Whereas the ‘2’ in ‘test_scores = [2, 3]’ means exactly the same as in
>> ‘test_scores = [3, 2]’.
>>>> If each position in the sequence gives the value there a different
>> menaning, use a tuple; if not, use a list.
>> I don't think that's really right. The absence of first-class
> multisets in python does mean that lists get "abused" for that
> purpose, but I don't think that means that there's no legitimate
> use-case for a list (i.e. a mutable sequence in which position is
> significant).
>> The difference between a tuple and a list is that one is mutable
> and the other is not. The difference you are describing is
> between a list and a multiset (or a tuple and an immutable
> multiset).

I think that Ben was actually trying to make a distinction between
heterogeneity and homogeneity of the contents, not a distinction of
whether the collection was ordered or not. You can of course have a
homogeneous collection for which order is still important, e.g. a
batting line-up.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /