Joel Bender wrote: > Jason Orendorff wrote: > >> Hooks would help with that, or even eliminate the need altogether. > > IMHO, having a __bytes__ method would go a long way.
This would be better done with generic functions once we have them. I general, I feel it's better not to embed knowledge of a particular serialization scheme in an object. Otherwise, you'd end up with every class having to know about 'pickle' and 'shelve' and 'marshall' and 'JSON' and 'serialize-to-XML' and every other weird serialization format that people come up with. Instead, this is exactly what GFs are good for, so that neither the object nor the serializer have to handle the N*M combinations of the two. Of course, this criticism also works against having a __str__ method, instead of simply defining 'str()' as a GF. And there is some validity to that point. But for historical reasons, we're not likely to change it. And there's also some validity to the argument that a 'printable' representation is the one universal converter that deserves special status. -- Talin _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
