Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #54771

Re: Convert namedtuple to dictionary

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 <python@mrabarnett.plus.com>
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 <python@mrabarnett.plus.com>
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> <mailman.325.1380152379.18130.python-list@python.org> <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.331.1380158148.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


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?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Convert namedtuple to dictionary tripsvt@gmail.com - 2013-09-25 15:45 -0700
  Re: Convert namedtuple to dictionary Tim Chase <python.list@tim.thechases.com> - 2013-09-25 18:41 -0500
    Re: Convert namedtuple to dictionary Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-26 01:08 +0000
      Re: Convert namedtuple to dictionary MRAB <python@mrabarnett.plus.com> - 2013-09-26 02:15 +0100
      Re: Convert namedtuple to dictionary Terry Reedy <tjreedy@udel.edu> - 2013-09-25 21:45 -0400
      Re: Convert namedtuple to dictionary Tim Chase <python.list@tim.thechases.com> - 2013-09-26 06:51 -0500
  Re: Convert namedtuple to dictionary MRAB <python@mrabarnett.plus.com> - 2013-09-26 00:52 +0100
  Re: Convert namedtuple to dictionary Ned Batchelder <ned@nedbatchelder.com> - 2013-09-25 20:15 -0400
  Re: Convert namedtuple to dictionary Steven D'Aprano <steve@pearwood.info> - 2013-09-26 03:48 +0000
  Re: Convert namedtuple to dictionary Peter Otten <__peter__@web.de> - 2013-09-26 08:47 +0200

csiph-web