You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Alan Conway <ac...@redhat.com> on 2006/09/27 22:45:41 UTC
Python gotchas: keywords and unicode strings
In case anyone else would be surprised by this:
Python will not allow unicode strings as keys for parameter passing
purposes:
>>> def f(a=1, b=2): print a, b
...
>>> f(**{"a":1, "b":2})
1 2
>>> f(**{u"a":1, "b":2}) # u"a" is unicode
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: f() keywords must be strings
The qpid decoder returns unicode strings, you need to str() them if you
want to use them for keyword args.