Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'argument': 0.05; '"if': 0.09; 'ambiguity': 0.09; 'identifier': 0.09; 'strings.': 0.09; 'subject:keys': 0.09; 'def': 0.12; 'argument:': 0.16; 'identifiers': 0.16; 'identifiers.': 0.16; 'kwargs': 0.16; 'mapping,': 0.16; 'preceded': 0.16; 'subject:Non': 0.16; 'subject:expression': 0.16; 'url:html)': 0.16; 'thanks,': 0.17; 'appears': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'question': 0.24; 'function': 0.29; "i'm": 0.30; 'fine,': 0.31; 'keys': 0.31; 'received:132': 0.31; 'url:python': 0.33; '(e.g.': 0.33; 'not.': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'keyword': 0.36; 'leads': 0.36; 'url:org': 0.36; 'message-id:@gmail.com': 0.38; 'mapping': 0.38; 'to:addr:python- list': 0.38; 'previous': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'according': 0.40; 'expression': 0.60; 'url:3': 0.61; 'more': 0.64; 'believe': 0.68; 'evaluate': 0.72; 'url:reference': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; bh=zP6vCYo/gaSAEovGtum6ryw/Jzuw9bqzIoAuujEsZWI=; b=TzbUn3ndpN0O5Qm/q2e7dzCqW5oejyq+D8f1PsSPf8Q815mXTN0W/IXLHocQFHQ4x6 NnI6XMSOdIOcE9X8Z9oH6qPQORHKF9Ov3qckrMdcJQwj31XD48bOaLQSElRsSyu5A5Br jF7Qcpn/YlyKRtfnBF2X08nIarvvSoa3ZxmWvq7m3z8pkqkZ5ykEP9mIM6PoDIzRd4Ki PTZAbmuzO11DtqMZnCX3NjLBS8xpBfDh7s8S/IMhWpx9Fo4cLyB+H7/ujuUv4jAeBoTD tP0nDc3e0VphYNc+1yXcZpoBpaECfVu5X33MVf4uXC1O5w7ObEXbzyQSjp8bnLv7cnlF QNgw== X-Received: by 10.49.117.37 with SMTP id kb5mr14661374qeb.26.1369335128858; Thu, 23 May 2013 11:52:08 -0700 (PDT) Date: Thu, 23 May 2013 14:52:07 -0400 From: Matthew Gilson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 MIME-Version: 1.0 To: python-list@python.org Subject: Non-identifiers in dictionary keys for **expression syntax Content-Type: multipart/alternative; boundary="------------070806000109060302000108" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 104 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369335137 news.xs4all.nl 15925 [2001:888:2000:d::a6]:45988 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45833 This is a multi-part message in MIME format. --------------070806000109060302000108 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit This is a question regarding the documentation around dictionary unpacking. The documentation for the call syntax (http://docs.python.org/3/reference/expressions.html#grammar-token-call) says: "If the syntax **expression appears in the function call, expression must evaluate to a mapping, the contents of which are treated as additional keyword arguments." 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. Using Cpython, we can do the following: def func(**kwargs): print kwargs d = {'foo bar baz':3} So that might lead us to believe that the keys of the mapping do not need to be valid identifiers. However, the previous function does not work with the following dictionary: d = {1:3} because not all the keys are strings. Is there a way to petition to get this more rigorously defined? Thanks, ~Matt --------------070806000109060302000108 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit This is a question regarding the documentation around dictionary unpacking.  The documentation for the call syntax (http://docs.python.org/3/reference/expressions.html#grammar-token-call) says:

"If the syntax **expression appears in the function call, expression must evaluate to a mapping, the contents of which are treated as additional keyword arguments."

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.

Using Cpython, we can do the following:

     def func(**kwargs):
          print kwargs

     d = {'foo bar baz':3}

So that might lead us to believe that the keys of the mapping do not need to be valid identifiers.  However, the previous function does not work with the following dictionary:

    d = {1:3}

because not all the keys are strings.  Is there a way to petition to get this more rigorously defined?

Thanks,
~Matt



--------------070806000109060302000108--