[issue5382] Allow Python keywords as keyword arguments for functions.

2009-02-27 Thread Matthew Barnett
Matthew Barnett added the comment: The normal use of a keyword argument is to refer to a formal argument, which is an identifier. Being able to wrap it up into a dict is a later addition, and it's necessary to turn the identifier into a string because it's not possible to use a bare word (as Per

[issue5382] Allow Python keywords as keyword arguments for functions.

2009-02-27 Thread David Kerkeslager
David Kerkeslager added the comment: Thank you all for reading and responding to my submission. I post the following without expectation of results, only to expand my reasoning: The following aren't applicable to the situation I described: def f(): class return def f(class): cla

[issue5382] Allow Python keywords as keyword arguments for functions.

2009-02-27 Thread Georg Brandl
Georg Brandl added the comment: This is not going to happen: First, function call syntax is nicely parallel to parameter definition syntax, and it is obviously not possible to define parameters named like keywords. Second, making exceptions like this leads to more exceptions and finally incons

[issue5382] Allow Python keywords as keyword arguments for functions.

2009-02-27 Thread David W. Lambert
David W. Lambert added the comment: You can sneak them in thusly: def f(**kwargs): print(kwargs) f(**{'class':'sidebar'}) ___ Python tracker ___ ___

[issue5382] Allow Python keywords as keyword arguments for functions.

2009-02-27 Thread Matthew Barnett
Matthew Barnett added the comment: The usual trick is to append "_": xhtmlNode('div',class_='sidebar') Could you modify the function to remove the trailing "_"? -- nosy: +mrabarnett ___ Python tracker ___

[issue5382] Allow Python keywords as keyword arguments for functions.

2009-02-27 Thread David W. Lambert
David W. Lambert added the comment: Use cases are easy to find. So easily found that there's probably a sound reason for reserved words. The proposal couples lexical analysis to the parser. # syntax error or name error? def f(): class return def f(class): class return ---

[issue5382] Allow Python keywords as keyword arguments for functions.

2009-02-27 Thread David Kerkeslager
New submission from David Kerkeslager : This problem arose in this thread: http://www.python-forum.org/pythonforum/viewtopic.php?f=2&t=11606 Basically, we have the following function which will generate an XHTML node: def xhtmlNode(tag, **attr):... If we call: xhtmlNode('div',class='sidebar'