On Apr 18, 9:43 pm, Aaron Brady wrote:
> On Apr 17, 9:41 pm, Steven D'Aprano
> cybersource.com.au> wrote:
> > On Fri, 17 Apr 2009 18:22:49 -0700, Pavel Panchekha wrote:
> > > I've got an object which has a method, __nonzero__ The problem is, that
> > > method is attached to that object not that c
On Apr 17, 9:41 pm, Steven D'Aprano wrote:
> On Fri, 17 Apr 2009 18:22:49 -0700, Pavel Panchekha wrote:
> > I've got an object which has a method, __nonzero__ The problem is, that
> > method is attached to that object not that class
>
> >> a = GeneralTypeOfObject()
> >> a.__nonzero__ = lambda: Fal
En Sat, 18 Apr 2009 19:39:24 -0300, Pavel Panchekha
escribió:
On Apr 18, 4:01 pm, Piet van Oostrum wrote:
But you can give each object its own class and then put the special
methods in that class:
>>> def create_special_object(bases, *args):
... if not isinstance(bases, tuple):
...
On Apr 18, 4:01 pm, Piet van Oostrum wrote:
> But you can give each object its own class and then put the special
> methods in that class:
>
> >>> def create_special_object(bases, *args):
>
> ... if not isinstance(bases, tuple):
> ... bases = bases,
> ... cls = type("SpecialClass", bases,
> Pavel Panchekha (PP) wrote:
>>> The docs don't say you can do that:
>PP> Thanks, hadn't noticed that.
>>> Should you be able to?
>PP> I'd say so. In my case, I need a class that can encapsulate any
>PP> object, add a few methods to it, and spit something back that works
>PP> just like the
On Apr 17, 9:22 pm, Pavel Panchekha wrote:
> I've got an object which has a method, __nonzero__
> The problem is, that method is attached to that object not that class
>
> > a = GeneralTypeOfObject()
> > a.__nonzero__ = lambda: False
> > a.__nonzero__()
>
> False
>
> But:
>
> > bool(a)
>
> True
>
On Fri, 17 Apr 2009 18:22:49 -0700, Pavel Panchekha wrote:
> I've got an object which has a method, __nonzero__ The problem is, that
> method is attached to that object not that class
>
>> a = GeneralTypeOfObject()
>> a.__nonzero__ = lambda: False
>> a.__nonzero__()
> False
>
> But:
>
>> bool(a
On Apr 17, 9:28 pm, Pavel Panchekha wrote:
> > The docs don't say you can do that:
>
> Thanks, hadn't noticed that.
>
> > Should you be able to?
>
> I'd say so. In my case, I need a class that can encapsulate any
> object, add a few methods to it, and spit something back that works
> just like the
> The docs don't say you can do that:
Thanks, hadn't noticed that.
> Should you be able to?
I'd say so. In my case, I need a class that can encapsulate any
object, add a few methods to it, and spit something back that works
just like the object, but also has those extra methods. I can't just
add
On Apr 17, 8:22 pm, Pavel Panchekha wrote:
> I've got an object which has a method, __nonzero__
> The problem is, that method is attached to that object not that class
>
> > a = GeneralTypeOfObject()
> > a.__nonzero__ = lambda: False
> > a.__nonzero__()
>
> False
>
> But:
>
> > bool(a)
>
> True
>
On Fri, Apr 17, 2009 at 6:22 PM, Pavel Panchekha wrote:
> I've got an object which has a method, __nonzero__
> The problem is, that method is attached to that object not that class
>
>> a = GeneralTypeOfObject()
>> a.__nonzero__ = lambda: False
>> a.__nonzero__()
> False
>
> But:
>
>> bool(a)
> Tr
I've got an object which has a method, __nonzero__
The problem is, that method is attached to that object not that class
> a = GeneralTypeOfObject()
> a.__nonzero__ = lambda: False
> a.__nonzero__()
False
But:
> bool(a)
True
What to do?
--
http://mail.python.org/mailman/listinfo/python-list
12 matches
Mail list logo