Python treats non-breaking space wrong?

Discussion in 'Python' started by magnus.lycka, Jun 5, 2010.

  1. magnus.lycka

    magnus.lycka Guest

    It seems that Python treats non-breaking space (\xa0) as a normal
    whitespace character, e.g. when splitting a string. See below:
    ['hello', 'there']

    Surely this is not intended behaviour?
    magnus.lycka, Jun 5, 2010
    1. Advertisements

  2. Yes it is.

    str.split() breaks on whitespace, and \xa0 is whitespace according to the
    Unicode standard. To put it another way, str.split() is not a word-
    wrapping split. This has been reported before, and rejected as a won't-
    Steven D'Aprano, Jun 5, 2010
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.