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


Groups > comp.lang.python > #88039

Re: Supply condition in function call

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'mentioned,': 0.07; 'undefined': 0.09; 'cc:addr:python-list': 0.11; '>that': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'namedtuple': 0.16; 'simpson': 0.16; 'supplied': 0.16; 'to:addr:web.de': 0.16; 'tuple': 0.16; 'unwarranted': 0.16; 'varnames': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'necessary.': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'order.': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'but': 0.35; 'introducing': 0.36; 'charset:us-ascii': 0.36; 'list.': 0.37; 'needed': 0.38; 'fact': 0.38; 'content-disposition:inline': 0.62; 'field': 0.63; 'actually,': 0.84; 'otten': 0.84; 'received:192.168.15': 0.84; 'vars': 0.91
Date Thu, 26 Mar 2015 21:06:29 +1100
From Cameron Simpson <cs@zip.com.au>
To Peter Otten <__peter__@web.de>
Cc python-list@python.org
Subject Re: Supply condition in function call
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Disposition inline
In-Reply-To <mf0i1g$hl6$1@ger.gmane.org>
User-Agent Mutt/1.5.23 (2014-03-12)
References <mf0i1g$hl6$1@ger.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
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.192.1427364402.10327.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1427364402 news.xs4all.nl 2963 [2001:888:2000:d::a6]:60376
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:88039

Show key headers only | View raw


On 26Mar2015 10:03, Peter Otten <__peter__@web.de> wrote:
>Cameron Simpson wrote:
>>       vars = locals()
>>       varnames = list(vars.keys())
>
>That leaves varnames in undefined order. Consider
>
>varnames = sorted(vars)

Actually, not necessary.

I started with sorted, but it is irrelevant, so I backed off to "list" to avoid 
introducing an unwarranted implication, in fact precisely the implicaion you 
are making.

The only requirement, which I mentioned, is that the values used to initialise 
the namedtuple are supplied in the same order as the tuple field names, so all 
that is needed is to suck the .keys() out once and use them in the same order 
when we construct the namedtuple. Hence just a list.

Cheers,
Cameron Simpson <cs@zip.com.au>

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


Thread

Re: Supply condition in function call Cameron Simpson <cs@zip.com.au> - 2015-03-26 21:06 +1100

csiph-web