Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #3982
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.straub-nv.de!noris.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| From | Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: Argument of the bool function |
| Date | Mon, 25 Apr 2011 16:29:34 +0200 |
| Organization | A newly installed InterNetNews server |
| Message-ID | <ip40gf$i0o$1@r03.glglgl.eu> (permalink) |
| References | <4d9f374b$0$12803$426a34cc@news.free.fr> <mailman.154.1302280920.9059.python-list@python.org> <4da1a8b5$0$23679$426a74cc@news.free.fr> <mailman.190.1302440567.9059.python-list@python.org> <inslea$p6d$1@speranza.aioe.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| User-Agent | Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8 |
| In-Reply-To | <inslea$p6d$1@speranza.aioe.org> |
| Lines | 54 |
| NNTP-Posting-Date | 25 Apr 2011 16:30:02 CEST |
| NNTP-Posting-Host | defe7315.newsspool2.arcor-online.net |
| X-Trace | DXC=R5TAF3?>=VT5TOT9_N5i<VA9EHlD;3YcR4Fo<]lROoRQ8kF<OcfhCO[QK8:hOPNgc\K8FCa6^2FWROLF_]FfFg8_2[mmh:RDJ?[ |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:3982 |
Show key headers only | View raw
Am 10.04.2011 18:21, schrieb Mel:
> Chris Angelico wrote:
>
>> Who would use keyword arguments with a function that takes only one arg
>> anyway?
>
> It's hard to imagine. Maybe somebody trying to generalize function calls
> (trying to interpret some other language using a python program?)
>
> # e.g. input winds up having the effect of ..
> function = bool
> name = 'x'
> value = 'the well at the end of the world'
> ## ...
> actions.append ((function, {name:value}))
> ## ...
> for function, args in actions:
> results.append (function (**args))
Wrong structure.
Better do
function = bool
value = 'the well at the end of the world'
## ...
actions.append((function, (value,), {}))
## ...
for function, args, kwargs in actions:
results.append(function(*args, **kwargs))
or maybe even better (taking care for closures):
function = bool
value = 'the well at the end of the world'
## ...
actions.append(lambda val=value: function(val))
## ...
for function in actions:
results.append(function())
>
> Not something I, for one, do every day. But regularity in a language is
> good when you can get it, especially for abstract things like that.
>
> I can sort of guess that `dir` was perhaps coded in C for speed and doesn't
> spend time looking for complicated argument lists.
>
> Python is a pragmatic language, so all the rules come pre-broken.
>
>
> Mel.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar
Re: Argument of the bool function Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-04-25 16:29 +0200
Re: Argument of the bool function Chris Angelico <rosuav@gmail.com> - 2011-04-26 05:33 +1000
Re: Argument of the bool function Paul Rubin <no.email@nospam.invalid> - 2011-04-25 16:26 -0700
Re: Argument of the bool function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-26 02:38 +0000
Re: Argument of the bool function Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-04-25 23:28 +0200
Re: Argument of the bool function Ian Kelly <ian.g.kelly@gmail.com> - 2011-04-25 17:44 -0600
csiph-web