Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> However, you can dispatch back to the instance if you really must:
>
>
> class MyObj(object):
> def __init__(self):
> self.__str__ = lambda self: "I'm an object!"
> def __str__(self):
> return self.__str__(self)
>
>
> But hon
On Thu, 23 Oct 2008 10:55:56 +0200, Christian Heimes wrote:
> netimen wrote:
>> How can I substitute __str__ method of an instance?
>
> It's not possible. For performance and other reasons most __*__ methods
> are looked up on the type only.
>
> Christian
However, you can dispatch back to the i
Diez B. Roggisch a écrit :
Christian Heimes wrote:
netimen wrote:
How can I substitute __str__ method of an instance?
It's not possible. For performance and other reasons most __*__ methods
are looked up on the type only.
Is that documented somewhere? I *know* it is that way, yet I'd like t
netimen a écrit :
I couldn't substitute __str__ method of an instance. Though I managed
to substitute ordinary method of an instance:
from types import MethodType
class Foo(object):
pass
class Printer(object):
def __call__(self, obj_self):
return 'printed'
f = Foo()
f.printe
Christian Heimes wrote:
> netimen wrote:
>> How can I substitute __str__ method of an instance?
>
> It's not possible. For performance and other reasons most __*__ methods
> are looked up on the type only.
Is that documented somewhere? I *know* it is that way, yet I'd like to have
place to read
netimen wrote:
> I couldn't substitute __str__ method of an instance. Though I managed
> to substitute ordinary method of an instance:
>
> from types import MethodType
>
> class Foo(object):
> pass
>
> class Printer(object):
>
> def __call__(self, obj_self):
> return 'printed'
netimen wrote:
How can I substitute __str__ method of an instance?
It's not possible. For performance and other reasons most __*__ methods
are looked up on the type only.
Christian
--
http://mail.python.org/mailman/listinfo/python-list