Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Python3.3 str() bug?

Reply
Thread Tools

Re: Python3.3 str() bug?

 
 
Ian Kelly
Guest
Posts: n/a
 
      11-09-2012
On Fri, Nov 9, 2012 at 2:18 AM, Helmut Jarausch
<(E-Mail Removed)-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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments