qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Conway <acon...@redhat.com>
Subject Python gotchas: keywords and unicode strings
Date Wed, 27 Sep 2006 20:45:41 GMT
In case anyone else would be surprised by this:

Python will not allow unicode strings as keys for parameter passing

>>> 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.

View raw message