Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88097
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.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.024 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'explicitly': 0.05; 'python': 0.11; 'btw:': 0.16; 'clashes': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'hmm.': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'namedtuple': 0.16; 'simpson': 0.16; 'tuple': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'header:User-Agent:1': 0.23; 'all:': 0.24; 'cheers,': 0.24; 'right.': 0.26; 'skip:v 30': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; '(which': 0.31; 'usually': 0.31; 'probably': 0.32; 'something': 0.35; 'opposed': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'first': 0.61; 'content- disposition:inline': 0.62; 'name': 0.63; 'subject': 0.69; 'published': 0.71; 'otten': 0.84; 'received:192.168.15': 0.84; 'remark': 0.84 |
| Date | Fri, 27 Mar 2015 08:37:34 +1100 |
| From | Cameron Simpson <cs@zip.com.au> |
| To | 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 | <mf0nhv$e9r$1@ger.gmane.org> |
| User-Agent | Mutt/1.5.23 (2014-03-12) |
| References | <mf0nhv$e9r$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.217.1427405859.10327.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1427405859 news.xs4all.nl 2972 [2001:888:2000:d::a6]:35915 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:88097 |
Show key headers only | View raw
On 26Mar2015 11:37, Peter Otten <__peter__@web.de> wrote:
>You are right. [...]
>
>By the way, in this case you don't need the list at all:
>
>def vartuple(vars):
> return namedtuple("locals", vars)._make(vars.values())
Hmm. Neat. I had not realised that was available.
You'd need "vars.keys()", not "vars", for the first use of "vars", BTW:
return namedtuple("locals", vars.keys())._make(vars.values())
A remark for the OP: a method name like "_make" would normally be something you
would avoid as it is Python convenion that _* names are "private", which in
Python usually means subject to arbitrary change and probably not documented;
internal implementation mechanisms as opposed to published interfaces.
However, in namedtuple the word "_make" is chosen specificly to avoid clashes
with the "named" tuple values (which would normally not start with "_"), and it
is explicitly documented.
Thanks Peter!
Cheers,
Cameron Simpson <cs@zip.com.au>
Nothing is impossible for the man who doesn't have to do it.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Supply condition in function call Cameron Simpson <cs@zip.com.au> - 2015-03-27 08:37 +1100
csiph-web