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


Groups > comp.lang.python > #45837

Re: Non-identifiers in dictionary keys for **expression syntax

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.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 <ethan@stoneleaf.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'argument': 0.05; 'ambiguity': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'identifier': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'subject:keys': 0.09; '~ethan~': 0.09; 'def': 0.12; 'definition.': 0.16; 'identifier,': 0.16; 'identifiers': 0.16; 'preceded': 0.16; 'received:69.93': 0.16; 'subject:Non': 0.16; 'subject:expression': 0.16; 'url:html)': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "i'm": 0.30; 'fine,': 0.31; 'keys': 0.31; 'worked': 0.33; 'url:python': 0.33; '(e.g.': 0.33; 'not.': 0.33; 'could': 0.34; 'but': 0.35; 'keyword': 0.36; 'leads': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'mapping': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'according': 0.40; 'even': 0.60; 'url:3': 0.61; 'received:173': 0.61; 'dict.': 0.84
Date Thu, 23 May 2013 12:37:18 -0700
From Ethan Furman <ethan@stoneleaf.us>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: Non-identifiers in dictionary keys for **expression syntax
References <mailman.2029.1369335137.3114.python-list@python.org> <b078gcF5qh7U1@mid.individual.net>
In-Reply-To <b078gcF5qh7U1@mid.individual.net>
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - gator410.hostgator.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - stoneleaf.us
X-BWhitelist no
X-Source
X-Source-Args
X-Source-Dir
X-Source-Sender ([173.12.184.235]) [173.12.184.235]:35461
X-Source-Auth ethan+stoneleaf.us
X-Email-Count 1
X-Source-Cap dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ==
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2032.1369339060.3114.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369339060 news.xs4all.nl 15910 [2001:888:2000:d::a6]:39922
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45837

Show key headers only | View raw


On 05/23/2013 12:20 PM, Neil Cerutti wrote:
> On 2013-05-23, Matthew Gilson <m.gilson1@gmail.com> wrote:
>>
>> That's fine, but what is a keyword argument?  According to the glossary
>> (http://docs.python.org/3.3/glossary.html):
>>
>> /"keyword argument/: an argument preceded by an identifier (e.g. name=)
>> in a function call or passed as a value in a dictionary preceded by **."
>>
>> As far as I'm concerned, this leads to some ambiguity in
>> whether the keys of the mapping need to be valid identifiers or
>> not.
>
> I don't see any ambiguity. A keyword argument is an argument
> preceded by an identifier according to the definition. Where are
> you perceiving wiggle room?

--> def func(**kwargs):
...     print(kwargs)
...

--> d = {'foo bar baz':3}

--> func(**d)
{'foo bar baz': 3}

Even though 'foo bar baz' is not a valid identifier, and could not be passed as `func(foo bar baz = 3)`, it still worked 
when going through a dict.

--
~Ethan~

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


Thread

Non-identifiers in dictionary keys for **expression syntax Matthew Gilson <m.gilson1@gmail.com> - 2013-05-23 14:52 -0400
  Re: Non-identifiers in dictionary keys for **expression syntax Neil Cerutti <neilc@norwich.edu> - 2013-05-23 19:20 +0000
    Re: Non-identifiers in dictionary keys for **expression syntax Ethan Furman <ethan@stoneleaf.us> - 2013-05-23 12:37 -0700
    Re: Non-identifiers in dictionary keys for **expression syntax Matthew Gilson <m.gilson1@gmail.com> - 2013-05-23 16:49 -0400

csiph-web