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

Devin devin.torres at gmail.com
Fri Oct 3 16:27:53 EDT 2008


On Oct 3, 2:29 pm, "Martin v. Löwis" <mar... at v.loewis.de> wrote:
> Devin wrote:
> > On Oct 3, 1:57 pm, Peter Otten <__pete... at web.de> wrote:
> >> "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
>
> > Yes, that's exactly what I mean.
>
> Hmm. Why did you say that Python can have unicode variable
> names? In the version you are using, it can't. In Python
> 3.0, it can, but then, you can also use Unicode strings
> as keys in **arguments, in Python 3.0.
>
> Regards,
> Martin

Oh. I read somewhere that UTF-8 variable names we're supported. I
thought I even saw a colleague using Kanji.



More information about the Python-list mailing list