Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-10 Thread Christian Heimes
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 > s

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Guido van Rossum
> On Thursday 09 August 2007 00:54:47 Guido van Rossum wrote: > > On 8/8/07, Christian Heimes <[EMAIL PROTECTED]> wrote: > > > Victor Stinner just made a good point at #python. The py3k has no magic > > > method and type slot for bytes (...) > > > I can think of a bunch of use cases for a magic met

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Christian Heimes
Guido van Rossum wrote: >> I can think of a bunch of use cases for a magic method. > > Such as? The __bytes__ method could be used to implement a byte representation of an arbitrary object. The byte representation can then be used to submit the object over wire or dump it into a file. In Python 2

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Victor Stinner
On Thursday 09 August 2007 00:54:47 Guido van Rossum wrote: > On 8/8/07, Christian Heimes <[EMAIL PROTECTED]> wrote: > > Victor Stinner just made a good point at #python. The py3k has no magic > > method and type slot for bytes (...) > > I can think of a bunch of use cases for a magic method. > > S

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Guido van Rossum
The plan is to kill __unicode__ and only use __str__. But we're not quite there yet. On 8/8/07, Victor Stinner <[EMAIL PROTECTED]> 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 mag

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Guido van Rossum
On 8/8/07, Christian Heimes <[EMAIL PROTECTED]> wrote: > Victor Stinner just made a good point at #python. The py3k has no magic > method and type slot for bytes. Python has magic methods like __int__ > for int(ob) and __str__ for str(ob). Are you considering to add a > __bytes__ method and tp_byte

Re: [Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Victor Stinner
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__'

[Python-3000] tp_bytes and __bytes__ magic method

2007-08-08 Thread Christian Heimes
Hey Pythonistas! Victor Stinner just made a good point at #python. The py3k has no magic method and type slot for bytes. Python has magic methods like __int__ for int(ob) and __str__ for str(ob). Are you considering to add a __bytes__ method and tp_bytes? I can think of a bunch of use cases for a