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
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to