"Exploding" (**myvariable) a dict with unicode keys

Peter Otten __peter__ at web.de
Fri Oct 3 14:57:00 EDT 2008


"Martin v. Löwis" wrote:

> Devin wrote:
>> So Python can have unicode variable names but you can't
>> "explode" (**myvariable) a dict with unicode keys? WTF?
> 
> That works fine for me.

The OP probably means

>>> def f(a=1): return a
...
>>> f(**{"a": 42})
42
>>> f(**{u"a": 42})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: f() keywords must be strings

Peter




More information about the Python-list mailing list