On Fri, Nov 9, 2012 at 2:18 AM, Helmut Jarausch <jarau...@igpm.rwth-aachen.de> wrote: > Hi, > > probably I'm missing something. > > Using str(Arg) works just fine if Arg is a list. > But > str([],encoding='latin-1') > > gives the error > TypeError: coercing to str: need bytes, bytearray or buffer-like object, > list found > > If this isn't a bug how can I use str(Arg,encoding='latin-1') in general. > Do I need to flatten any data structure which is normally excepted by str() ?
In general, the __str__ implementations of complex data structures will call repr() on their components, not str(). repr() normally does not do any decoding in the first place and does not take an encoding argument, so even if str([]) accepted an encoding, it wouldn't be useful for anything. -- http://mail.python.org/mailman/listinfo/python-list