Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.038 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'immutable': 0.09; 'instances.': 0.09; 'tuple': 0.09; 'cc:addr:python-list': 0.10; '(rather': 0.16; 'benjamin': 0.16; 'cc:name:python list': 0.16; 'hashable': 0.16; 'immutable,': 0.16; 'namedtuple': 0.16; 'namedtuples': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'supposed': 0.21; 'tuples': 0.22; 'cc:2**0': 0.23; 'seems': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'interface': 0.27; 'received:209.85.212': 0.28; 'though.': 0.29; 'objects': 0.29; 'expect': 0.31; 'could': 0.32; 'instances': 0.33; 'values.': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'really': 0.36; 'itself': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'things': 0.38; 'little': 0.39; 'john': 0.60; 'places': 0.61; 'provide': 0.62; 'different': 0.63; 'said:': 0.65; 'hoping': 0.72; '2013': 0.84; 'anywhere.': 0.84; 'oscar': 0.84; 'reid': 0.84; 'replacements': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=tRLkwKReYOXv303RKhimCOXXjXF5tgykKS23BLF8HMA=; b=btokj8sCUvMT4lQOYa3qAmvkOvozBz52LAOVTBgdnjbA3BA5UIb23OvfzPNcOq0Fa6 wfDPoxcgzlKQVj0Ty2hh1nRK0ioqhNnu9fj/NkrXFZDSI6zwpv5+qcMZ/BCaKofLipvT LlDXtto3BliMe58YVTuhswGm5XV9ygTfgtQaKp+2j3+ZuwAYRv6ALofJQldgY5awBfVX VNQx4kI7jXvp0UvkgjERHMS43SiDVfIS9xZJSsidgRRoeTYtYJMI24LXXp+suUqzvhYl DYh2k5gUMhpoMg2ZHiL+nV0Mla6y7eFWPm8Q9eaME5Rv01JsK+dvzNltCd1QcTKnEXsk aLwQ== X-Received: by 10.52.20.177 with SMTP id o17mr14152380vde.17.1361196743851; Mon, 18 Feb 2013 06:12:23 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <512231CA.8070108@gmail.com> References: <7a40a426-baa9-46f8-8f9d-59ba32b044f3@googlegroups.com> <512231CA.8070108@gmail.com> From: Oscar Benjamin Date: Mon, 18 Feb 2013 14:12:03 +0000 Subject: Re: Differences creating tuples and collections.namedtuples To: John Reid Content-Type: text/plain; charset=ISO-8859-1 Cc: Python List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361197214 news.xs4all.nl 6960 [2001:888:2000:d::a6]:49410 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39095 On 18 February 2013 13:51, John Reid wrote: > On 18/02/13 12:03, Oscar Benjamin wrote: >> On 18 February 2013 11:47, John Reid wrote: >>> Hi, >>> >>> I was hoping namedtuples could be used as replacements for tuples in all instances. >> namedtuples are not really intended to serves as tuples anywhere. They >> are intended to provide lightweight, immutable, hashable objects with >> *named* (rather than numbered) values. > > If they are not supposed to be tuples then calling them namedtuples and > inheriting from tuple seems a little odd. You can use namedtuple instances in places that expect tuples. Inheriting from tuples enables them to be all the things I said: lightweight, immutable and hashable. The type object itself has a different interface for the constructor, though. Oscar