(original) (raw)
On Wed, Jan 15, 2014 at 5:00 PM, Steven D'Aprano <steve@pearwood.info> wrote:
On Thu, Jan 16, 2014 at 10:55:31AM +1300, Greg Ewing wrote:+1
\> Neil Schemenauer wrote:
\> >Objects that implement \_\_str\_\_ can also implement \_\_bytes\_\_ if they
\> >can guarantee that ASCII characters are always returned,
\>
\> I think \_\_ascii\_ would be a better name. I'd expect
\> a method called \_\_bytes\_\_ on an int to return some
\> version of its binary value.
If we are going the route of a new magic method then \_\_ascii\_\_ or \_\_bytes\_format\_\_ get my vote as long as they only return bytes (I see no need to abbreviate to \_\_bformat\_\_ or \_\_formatb\_\_ when we have method names as long as \_\_text\_signature\_\_ now).