From 2c0fbebde3d1d668855d2c9b52b20483f4f5ebd0 Mon Sep 17 00:00:00 2001 From: Casey Dahlin Date: Tue, 23 Dec 2008 00:21:14 -0500 Subject: Add __eq__ and __hash__ --- pattern.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pattern.py b/pattern.py index a1919b5..7ff95d8 100644 --- a/pattern.py +++ b/pattern.py @@ -81,3 +81,11 @@ class Pattern: def __repr__(self): return str(self) + + def __hash__(self): + return hash(str(self)) + + def __eq__(self, other): + if not other.__class__ == Pattern: + return False + return self.items == other.items and self.invert == other.invert -- cgit