Cheers,
Khoa
On 1/5/06, Mike C. Fletcher <
[EMAIL PROTECTED]> wrote:
Christian Tismer wrote:
>Khoa Nguyen wrote:
>
>
>>I would like to pass some keyword with special character to a
>>foo(**kwargs) function, but it doesn't work
>>
>>def foo(**kwargs):
>> print kwargs
>>
>>
>>This doesn't work:
>>
>>foo(a-special-keyword=5)
>>
>>How do I tell Python to treat '-' as a normal character but not part of
>>an _expression_?
>>
>>
>
>By changing the parser :-)
>
>
Oh, you py-py guys, always thinking you have to re-implement Python ;)
>Keywords are limited to obey Python syntax.
>
>
Sure, but you can do something like this:
>>> def x( **named ):
... print named
...
>>> x( **{'some-var-with- weird chars': True } )
{'some-var-with- weird chars': True}
That is, for the OP (who is unlikely to rewrite the parser), the
solution could be as simple as treating the keyword as a piece of data
and applying it to the function.
Have fun,
Mike
--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
-- http://mail.python.org/mailman/listinfo/python-list