[bearophileh...@lycos.com]
> But some other times you may accept to change the class and the set/
> dict, making it tell apart the keys only when they are different
> object:
>
> class Some(object):
> def __init__(self, y):
> self._y = y
> def __eq__(self, other):
> return s
In article ,
Peter Otten <__pete...@web.de> wrote:
>Aahz wrote:
>> In article ,
>> Peter Otten <__pete...@web.de> wrote:
>>>Aahz wrote:
In article ,
Peter Otten <__pete...@web.de> wrote:
>
>Here's a trick to find the actual element. I think Raymond Hettinger
>posted an impl
Aahz wrote:
> In article ,
> Peter Otten <__pete...@web.de> wrote:
>>Aahz wrote:
>>> In article ,
>>> Peter Otten <__pete...@web.de> wrote:
Here's a trick to find the actual element. I think Raymond Hettinger
posted an implementation of this idea recently, but I can't find it at
>>>
In article ,
Peter Otten <__pete...@web.de> wrote:
>Aahz wrote:
>> In article ,
>> Peter Otten <__pete...@web.de> wrote:
>>>
>>>Here's a trick to find the actual element. I think Raymond Hettinger
>>>posted an implementation of this idea recently, but I can't find it at the
>>>moment.
>>
>> Your
Aahz wrote:
> In article ,
> Peter Otten <__pete...@web.de> wrote:
>>
>>Here's a trick to find the actual element. I think Raymond Hettinger
>>posted an implementation of this idea recently, but I can't find it at the
>>moment.
>
> Your code is inverted from Raymond's:
I can't see the inversion
Johannes Bauer wrote:
Hi group,
I have a very simple about sets. This is a minimal example:
#!/usr/bin/python
class x():
def __init__(self, y):
self.__y = y
def __eq__(self, other):
return self.__y == other.__y
def __hash__(self):
In article ,
Peter Otten <__pete...@web.de> wrote:
>
>Here's a trick to find the actual element. I think Raymond Hettinger posted
>an implementation of this idea recently, but I can't find it at the moment.
Your code is inverted from Raymond's:
http://code.activestate.com/recipes/499299/
class
Peter Otten schrieb:
> class Grab:
> def __init__(self, value):
> self.search_value = value
> def __hash__(self):
> return hash(self.search_value)
> def __eq__(self, other):
> if self.search_value == other:
> self.actual_value = other
> r
Johannes Bauer schrieb:
> Is there something like the "getelement" function? How can I do what I want?
One side note: The obvious trivial solution:
def findset(s, e):
for i in s:
if e == i:
return i
return None
is because of its complexity
Peter Otten:
> [...] I think Raymond Hettinger posted
> an implementation of this idea recently, but I can't find it at the moment.
> [...]
> class Grab:
> def __init__(self, value):
> self.search_value = value
> def __hash__(self):
> return hash(self.search_value)
> def
Johannes Bauer wrote:
> I have a very simple about sets. This is a minimal example:
> The problem is: two instances of x() are equal (__eq__ returns true),
> but they are not identical. I have an equal element ("z"), but want to
> get the *actual* element ("a") in the set. I.d. in the above examp
Hi group,
I have a very simple about sets. This is a minimal example:
#!/usr/bin/python
class x():
def __init__(self, y):
self.__y = y
def __eq__(self, other):
return self.__y == other.__y
def __hash__(self):
return hash(self
12 matches
Mail list logo