[Twisted-Python] twisted.internet.abstract.FileDescription.write vs unicode

Mary Gardiner mary-twisted at puzzling.org
Mon Jul 12 18:53:12 EDT 2004

On Mon, Jul 12, 2004, Jeff Bowden wrote:
> Is there a good reason for 
> twisted.internet.abstract.FileDescription.write to require 
> isinstance(data, str) rather than also allowing isinstance(type, unicode)??

This is one of those rare things, an FAQ that really is a "Frequently
Asked Question" not a "Question We Wish You'd Ask".

Unfortunately, I haven't actually added it to the FAQs yet :( See the
discussion at
http://www.twistedmatrix.com/users/roundup.twistd/twisted/issue617, in
particular Glyph Lefkowitz's comment:

    "Q. Why doesn't {API X} accept both string objects and unicode
    objects?  Isn't it better to use unicode so you can support

    A. Unicode is for talking about strings of human-readable text.
    String objects can also be used for this purpose, and when they are,
    it is better to use unicode, you are correct.  However, {API X} is
    dealing with raw data, probably coming from a network connection,
    and is using String objects as containers of sequences of bytes.
    Unicode has no way of representing sequences of bytes and streams of
    'raw', unparsed data.  The data has to be translated at some level
    *above* that, in order to get things like unicode character
    alignment correct.

    For more information and some idea of the complexity involved, read
    http://www.sidhe.org/~dan/blog/archives/000255.html and


More information about the Twisted-Python mailing list