Get item from set
Johannes Bauer
dfnsonfsduifb at gmx.de
Sun Apr 26 08:52:18 EDT 2009
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
> return True
> return False
>
> assert a == z
> assert a is not z
> grab = Grab(z)
> grab in s
> assert grab.actual_value is a
Wow, this is truly amazing! I'd never have come up with that solution.
Just wonderful, thank you very much! :-))
Kind regards,
Johannes
--
"Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
verlästerung von Gott, Bibel und mir und bewusster Blasphemie."
-- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
<48d8bf1d$0$7510$5402220f at news.sunrise.ch>
More information about the Python-list
mailing list