En Mon, 02 Nov 2009 22:05:42 -0300, Jess Austin
escribió:
On Nov 1, 1:13 am, "Gabriel Genellina" wrote:
Looks like in 3.1 this can be done with bytes+str and viceversa, even
if bytes and str don't have a common ancestor (other than object;
basestring doesn't exist in 3.x):
The same examp
On Nov 1, 1:13 am, "Gabriel Genellina" wrote:
> Looks like in 3.1 this can be done with bytes+str and viceversa, even if
> bytes and str don't have a common ancestor (other than object; basestring
> doesn't exist in 3.x):
>
> p3> Base = bytes
> p3> Other = str
> p3>
> p3> class Derived(Base):
En Fri, 30 Oct 2009 17:55:27 -0300, Jess Austin
escribió:
On Oct 29, 10:41 pm, "Gabriel Genellina"
wrote:
We know the last test fails because the == logic fails to recognize
mySet (on the right side) as a "more specialized" object than frozenset
(on the left side), because set and frozen
On Oct 29, 10:41 pm, "Gabriel Genellina"
wrote:
> We know the last test fails because the == logic fails to recognize mySet
> (on the right side) as a "more specialized" object than frozenset (on the
> left side), because set and frozenset don't have a common base type
> (although they share
En Wed, 28 Oct 2009 23:12:53 -0300, Jess Austin
escribió:
class mySet(set):
... def __eq__(self, other):
... print "called mySet.__eq__()!"
... if isinstance(other, (set, frozenset)):
... return True
... return set.__eq__(self, other)
...
Now I want t
On Oct 29, 3:54 pm, Mick Krippendorf wrote:
> Jess Austin wrote:
> > That's nice, but it means that everyone who imports my class will have
> > to import the monkeypatch of frozenset, as well. I'm not sure I want
> > that. More ruby than python, ne?
>
> I thought it was only a toy class?
Well,
Jess Austin wrote:
> That's nice, but it means that everyone who imports my class will have
> to import the monkeypatch of frozenset, as well. I'm not sure I want
> that. More ruby than python, ne?
I thought it was only a toy class?
Mick.
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 28, 10:07 pm, Mick Krippendorf wrote:
> You could just overwrite set and frozenset:
>
> class eqmixin(object):
> def __eq__(self, other):
> print "called %s.__eq__()" % self.__class__
> if isinstance(other, (set, frozenset)):
> return True
> return su
Jess Austin schrieb:
> >>> frozenset([1]) == mySet()
> False
>
> frozenset doesn't use mySet.__eq__() because mySet is not a subclass
> of frozenset as it is for set.
You could just overwrite set and frozenset:
class eqmixin(object):
def __eq__(self, other):
print "called %s.__eq__()
I'm subclassing set, and redefining __eq__(). I'd appreciate any
relevant advice.
>>> class mySet(set):
... def __eq__(self, other):
... print "called mySet.__eq__()!"
... if isinstance(other, (set, frozenset)):
... return True
... return set.__eq__(self, o
10 matches
Mail list logo