Re: Python keyword args can be any string

2016-02-19 Thread Rustom Mody
On Thursday, February 18, 2016 at 11:12:45 AM UTC+5:30, Steven D'Aprano wrote: > Today I learned that **kwargs style keyword arguments can be any string: > > > py> def test(**kw): > ... print(kw) > ... > py> kwargs = {'abc-def': 42, '': 23, '---': 999, '123': 17} > py> test(**kwargs) > {'':

Re: Python keyword args can be any string

2016-02-18 Thread Ben Finney
Steven D'Aprano writes: > A work colleague wanted to pass an argument starting with "-" to a > function. > > Apparently he didn't have a specific argument in mind. He just wanted > to test the function to breaking point by passing invalid argument > names. That seems a reasonable test. >>>

Re: Python keyword args can be any string

2016-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2016 06:55 pm, Mark Lawrence wrote: > On 18/02/2016 05:42, Steven D'Aprano wrote: >> Today I learned that **kwargs style keyword arguments can be any string: >> >> py> def test(**kw): >> ... print(kw) >> ... >> py> kwargs = {'abc-def': 42, '': 23, '---': 999, '123': 17} >> py> t

Re: Python keyword args can be any string

2016-02-17 Thread Mark Lawrence
On 18/02/2016 05:42, Steven D'Aprano wrote: Today I learned that **kwargs style keyword arguments can be any string: py> def test(**kw): ... print(kw) ... py> kwargs = {'abc-def': 42, '': 23, '---': 999, '123': 17} py> test(**kwargs) {'': 23, '123': 17, '---': 999, 'abc-def': 42} Bug or fea

Re: Python keyword args can be any string

2016-02-17 Thread Terry Reedy
On 2/18/2016 12:59 AM, Ben Finney wrote: Steven D'Aprano writes: Today I learned that **kwargs style keyword arguments can be any string: py> def test(**kw): ... print(kw) ... py> kwargs = {'abc-def': 42, '': 23, '---': 999, '123': 17} py> test(**kwargs) {'': 23, '123': 17, '---': 999, '

Re: Python keyword args can be any string

2016-02-17 Thread Ben Finney
Steven D'Aprano writes: > Today I learned that **kwargs style keyword arguments can be any string: > > > py> def test(**kw): > ... print(kw) > ... > py> kwargs = {'abc-def': 42, '': 23, '---': 999, '123': 17} > py> test(**kwargs) > {'': 23, '123': 17, '---': 999, 'abc-def': 42} > > > Bug or

Re: Python keyword args can be any string

2016-02-17 Thread Chris Angelico
On Thu, Feb 18, 2016 at 4:42 PM, Steven D'Aprano wrote: > Today I learned that **kwargs style keyword arguments can be any string: > > > py> def test(**kw): > ... print(kw) > ... > py> kwargs = {'abc-def': 42, '': 23, '---': 999, '123': 17} > py> test(**kwargs) > {'': 23, '123': 17, '---': 999