[Python-Dev] why doesn't print pass unicode strings on to the file
object?
Martin von Loewis
loewis@informatik.hu-berlin.de
Tue, 18 Sep 2001 10:02:15 +0200 (MEST)
> > I wish codecs.lookup returned a record with named fields, instead of a
> > list, so I could write
> >
> > sys.stdout = codecs.lookup("iso-8859-1").writer(sys.stdout)
> >
> > (the other field names would be encode,decode, and reader).
>
> Why don't you write a small helper function for the codecs.py
> module ?!
Because I'd like to avoid an inflation of functions. Instead, I'd
prefer codecs.lookup to return an object that has the needed fields,
but behaves like a tuple for backwards compatibility.
> Note that the tuple interface was chosen for sake of speed and
> better handling at C level (tuples can be cached and are easily
> parseable in C).
It may be that an inherited tuple class might achieve the same
effect. Can you identify the places where codecs.lookup is assumed to
return tuples?
Regards,
Martin