Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Semantics of collection types (was: Late-binding of function defaults (was Re: What is a function parameter =[] for?)) Date: Thu, 26 Nov 2015 16:04:39 +1100 Lines: 39 Message-ID: References: <87d1v5emhl.fsf@elektro.pacujo.net> <564e6a62$0$1620$c3e8da3$5496439d@news.astraweb.com> <56556DF8.1080407@rece.vub.ac.be> <878u5mns8z.fsf@elektro.pacujo.net> <858u5lc0r7.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de 28Sg5T1GyapZRhTtB0YSygEy1QoM0weoil1L3HViEX3Q== Cancel-Lock: sha1:+GktztaQ7u3bFZAA6d80SPP+QJY= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'difference,': 0.07; 'semantic': 0.07; 'mutable': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'semantics': 0.09; 'to)': 0.09; 'tuple': 0.09; 'python.': 0.11; 'wed,': 0.15; '(2,': 0.16; '(3,': 0.16; '460': 0.16; '[2,': 0.16; 'distinction': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'space;': 0.16; 'tuple;': 0.16; 'wrote:': 0.16; 'exists': 0.18; '2015': 0.20; 'not,': 0.22; 'saying': 0.22; '(by': 0.22; 'trying': 0.22; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'earlier': 0.27; 'expanding': 0.27; 'not.': 0.27; 'right.': 0.27; 'sequence': 0.27; 'behaviour': 0.29; 'types.': 0.29; "i'm": 0.30; 'point': 0.33; 'ordered': 0.33; 'except': 0.34; 'list': 0.34; 'advice': 0.35; 'gives': 0.35; 'nov': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'lines': 0.36; 'to:addr:python- list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'received:org': 0.37; 'list.': 0.37; 'difference': 0.38; 'thank': 0.38; 'means': 0.39; 'data': 0.39; "didn't": 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'collection': 0.60; 'replying': 0.61; 'different': 0.63; 'our': 0.64; 'you.': 0.64; 'between': 0.65; '8bit%:21': 0.70; 'skip:\xe2 10': 0.70; '\xe2\x80\x93': 0.72; '_o__)': 0.84; 'enforced': 0.84; 'received:125': 0.84; 'contents,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99527 Ian Kelly writes: > On Wed, Nov 25, 2015 at 5:52 PM, Random832 wrote: > > On 2015-11-25, Ben Finney 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. I was expanding on (by replying to) earlier advice about expressing semantics in our choice of data types. > > The difference between a tuple and a list is that one is mutable > > and the other is not. That is a difference enforced in the behaviour of the types, yes. I didn't talk about behaviour, but about meaning. I'm saying that the behavioural difference conveniently lines up with a semantic difference, even to the point of the meaning of “tuple” that pre-dates Python. > 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. That's right, thank you. -- \ “Nothing exists except atoms and empty space; everything else | `\ is opinion.” —Democritus, c. 460 BCE – 370 BCE | _o__) | Ben Finney