Does Python 3.x support Unicode-named attributes?

Discussion in 'Python' started by John Nagle, Nov 19, 2009.

  1. John Nagle

    John Nagle Guest

    Does Python 3.x support Unicode-named attributes?

    There are several modules which operate on HTML and try to
    hammer HTML/XML into Python object attributes. I've had
    BeautifulSoup and "urllib" blow up at various times when
    running on non-English HTML/XML.

    Got this error today:

    urllib.py:1197: UnicodeWarning: Unicode equal comparison failed to convert both
    arguments to Unicode - interpreting
    them as being unequal
    res = map(safe_map.__getitem__, s)

    John Nagle
     
    John Nagle, Nov 19, 2009
    #1
    1. Advertising

  2. > Does Python 3.x support Unicode-named attributes?

    Most certainly, yes. All identifiers (and thus all attribute
    names) are Unicode strings in Python 3.x.

    > There are several modules which operate on HTML and try to
    > hammer HTML/XML into Python object attributes. I've had
    > BeautifulSoup and "urllib" blow up at various times when
    > running on non-English HTML/XML.
    >
    > Got this error today:
    >
    > urllib.py:1197: UnicodeWarning: Unicode equal comparison failed to
    > convert both arguments to Unicode - interpreting
    > them as being unequal
    > res = map(safe_map.__getitem__, s)


    Perhaps the library you were using modified __dict__ directly,
    thus getting non-string attribute names into the dict? Or perhaps
    s is not a Unicode string?

    Regards,
    Martin
     
    Martin v. Löwis, Nov 19, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. could ildg
    Replies:
    0
    Views:
    348
    could ildg
    Aug 4, 2005
  2. Robert Kern
    Replies:
    0
    Views:
    490
    Robert Kern
    Aug 4, 2005
  3. Ntys Dd
    Replies:
    2
    Views:
    121
    Run Paint Run Run
    Jun 12, 2010
  4. fhscobey
    Replies:
    0
    Views:
    240
    fhscobey
    Nov 3, 2005
  5. Replies:
    3
    Views:
    157
Loading...

Share This Page