Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'trailing': 0.09; 'underscore': 0.09; 'wrote': 0.14; "wouldn't": 0.14; '"private"': 0.16; 'attribute.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'namedtuple': 0.16; 'subject:Convert': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'header:User-Agent:1': 0.23; 'documented': 0.24; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'chase': 0.31; "d'aprano": 0.31; 'sep': 0.31; 'steven': 0.31; 'tuples': 0.31; 'url:python': 0.33; 'sense': 0.34; 'but': 0.35; 'url:org': 0.36; 'starting': 0.37; 'url:library': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'field': 0.63; 'more': 0.64; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'private.': 0.84; 'reply-to:addr:python.org': 0.84; '2013': 0.98 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=MqNrtQqe c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=0kkAYlmtguIA:10 a=uPasbX5kAJEA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=HgPT_0boHaYA:10 a=wDFzZookhFYZW9XGC40A:9 a=wPNLvfGTeEIA:10 a=PiR3IboA0J8A:10 X-AUTH: mrabarnett:2500 Date: Thu, 26 Sep 2013 02:15:50 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Convert namedtuple to dictionary References: <635a3b46-3150-409f-8a9d-002af18fb734@googlegroups.com> <52438924$0$30000$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <52438924$0$30000$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380158148 news.xs4all.nl 15891 [2001:888:2000:d::a6]:39677 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54771 On 26/09/2013 02:08, Steven D'Aprano wrote: > On Wed, 25 Sep 2013 18:41:25 -0500, Tim Chase wrote about namedtuple: > >> While it uses the "private" member-variable "_fields", you can do > > It's not actually private! > > namedtuple is documented as an exception to the rule that methods > starting with a single leading underscore are private. Named tuples > define three public methods and one data attribute. In order to avoid > clashing with field names, they start with a single underscore, but they > are documented as public: > > _make > _asdict > _replace > _fields > > > http://docs.python.org/2/library/collections.html#namedtuple-factory-function-for-tuples-with-named-fields > Wouldn't it have made more sense to have a trailing underscore instead?