[Python-3000] tp_bytes and __bytes__ magic method

Christian Heimes lists at cheimes.de
Fri Aug 10 10:57:26 CEST 2007


Guido van Rossum wrote:
> This could just as well be done using a method on that specific
> object. I don't think having to write x.as_bytes() is worse than
> bytes(x), *unless* there are contexts where it's important to convert
> something to bytes without knowing what kind of thing it is. For
> str(), such a context exists: print(). For bytes(), I'm not so sure.
> The use cases given here seem to be either very specific to a certain
> class, or could be solved using other generic APIs like pickling.


I see your point. Since nobody else beside Victor and me are interested
in __bytes__ I retract my proposal. Thanks for your time.

Christian



More information about the Python-3000 mailing list