Why does the "".join(r) do this?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Hefferon

    #16
    Re: Why does the "".jo in(r) do this?

    Peter Otten <__peter__@web. de> wrote:[color=blue]
    > Of course it would fail with non-ascii characters in the string that shall
    > be converted. Why not allow strings with all 256 chars? Again, as stated in
    > my above post, that would be ambiguous:
    >[/color]
    Thanks, Peter and others, you have been enlightening. I understand
    you to say that Python insists that I explicitly decide the decoding,
    and not just smoosh the strings. Thanks.

    I will write to the documentation person with the suggestion that the
    documentation of .join(seq) at
    http://docs.python.org/lib/string-methods.html#l2h-188 might be
    updated from:
    "Return a string which is the concatenation of the strings in the
    sequence seq."[color=blue][color=green][color=darkred]
    > >> Use either unicode or str, but don't mix them. That should keep you out
    > >> of trouble.[/color][/color]
    >
    > Or make all conversions explicit with the str.decode()/unicode.encode( )
    > methods.[/color]
    Now I only have to figure out whic codec's are available and
    appropriate.
    Thanks again,

    Jim

    Comment

    • Terry Reedy

      #17
      Re: Why does the &quot;&quot;.jo in(r) do this?


      "Jim Hefferon" <jhefferon@smcv t.edu> wrote in message
      news:545cb8c2.0 405220521.ac117 a4@posting.goog le.com...[color=blue]
      > Thanks, Peter and others, you have been enlightening. I understand
      > you to say that Python insists that I explicitly decide the decoding,
      > and not just smoosh the strings. Thanks.[/color]

      Abstractly, byte strings and unicode strings are different types of beasts.
      If you forget what you know about the CPython computer implementation and
      linear computer memories, it make little sense to combine them. The result
      would have to be some currently nonexistent byte-unicode string.

      Terry J. Reedy




      Comment

      Working...