[Python-3000] tp_bytes and __bytes__ magic method

Guido van Rossum guido at python.org
Thu Aug 9 00:55:40 CEST 2007


The plan is to kill __unicode__ and only use __str__. But we're not
quite there yet.

On 8/8/07, Victor Stinner <victor.stinner at haypocalc.com> wrote:
> On Thursday 09 August 2007 00:22:51 Christian Heimes wrote:
> > Hey Pythonistas!
> >
> > Victor Stinner just made a good point at #python. The py3k has no magic
> > method and type slot for bytes.
>
> And another problem: mix of __str__ and __unicode__ methods.
>
> class A:
>   def __str__(self): return '__str__'
>
> class B:
>   def __str__(self): return '__str__'
>   def __unicode__(self): return '__unicode__'
>
> print (repr(str( A() )))  # display '__str__'
> print (repr(str( B() )))  # display '__unicode__'
>
>
> Proposition:
>
>   __str__() -> str (2.x) becomes __bytes__() -> bytes (3000)
>   __unicode__() -> unicode (2.x) becomes __str__() -> str (3000)
>
> Victor Stinner aka haypo
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list