Get item from set
Aahz
aahz at pythoncraft.com
Wed Apr 29 12:53:18 EDT 2009
In article <gt9t62$g6f$00$1 at news.t-online.com>,
Peter Otten <__peter__ at web.de> wrote:
>Aahz wrote:
>> In article <gt8v37$kib$03$2 at news.t-online.com>,
>> Peter Otten <__peter__ at web.de> wrote:
>>>Aahz wrote:
>>>> In article <gt1kb7$jqg$03$1 at news.t-online.com>,
>>>> Peter Otten <__peter__ at 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.
>>
>> You were wrapping the objects inserted into the set; Raymond's trick
>> involved only wrapping the comparison object. It's therefore much more
>> convenient.
>
>I think you are misreading my code. I took the items (of class X) as they
>were specified by the OP.
>
>The reason I changed their __eq__() method is not that I did not understand
>Raymond's trick, but rather a quirk in the set's item lookup:
Gotcha -- thanks for the explanation!
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur." --Red Adair
More information about the Python-list
mailing list