[Python-Dev] Re: [Python-checkins] python/dist/src/Include unicodeobject.h, 2.42, 2.43

Skip Montanaro skip at pobox.com
Wed Jun 2 13:41:44 EDT 2004

    perky> - SF #962502: Add two more methods for unicode type; width() and
    perky> iswide() for east asian width manipulation.

    Skip> Should strings grow these methods as well for symmetry?

    Hye-Shik> I think there'll be two possible behaviors for strings:

    Hye-Shik> 1) regard all characters as non-wide.
    Hye-Shik> 2) decode the string to unicode with the system default encoding
    Hye-Shik>    and call its methods.


    Hye-Shik> I didn't make my mind between these two yet.  What do you think?

#1 sounds like the most reasonable to me.  You can't rely on strings coming
into your program with proper encoding information, and they might come from
an environment different than sys.defaultencoding (think WWW), so #2 seems
like it would create as many problems as it solves.  All I'm interested in
is avoiding needless occurrences of these constructs in code:

    if isinstance(s, unicode):
        width = s.width()


        width = s.width()
    except AttributeError:


More information about the Python-Dev mailing list