[Python-3000] PEP 3138- String representation in Python 3000
Joel Bender
jjb5 at cornell.edu
Fri May 16 17:58:31 CEST 2008
I wrote:
> ...and it doesn't have to be reflexive if that...
Umm, that should have said 'have an inverse', which is different than
reflexive or symmetric. I get a little lost on 'surjective' and
'injective', having been taught the terms 'onto' and 'one-to-one'. But
I digress.
For wrapping a file-like object, I would prefer a TransformIO class that
takes read and write transform functions, e.g.,
f = TransformIO(open('data.txt')
, read=ebcdic_to_plaintext
, write=plaintext_to_ebcdic
)
These parameters would be optional, so if 'write' was omitted then write
attempts would fail, likewise for 'read'. Using functools.partial could
be used to provide common transforms:
ISO_8859_1_Transform = functools.partial( TransformIO
, read=ISO_8859_1_Decode
, write=ISO_8859_1_Encode
)
Where the to/from plain text is implicit. And no, I'm not a huge fan of
underbars.
Joel
More information about the Python-3000
mailing list