File: __init__.py

package info (click to toggle)
preggy 1.4.4-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 408 kB
  • sloc: python: 1,929; makefile: 22; sh: 8
file content (61 lines) | stat: -rw-r--r-- 1,257 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: utf-8 -*-


class Comparable(object):

    def __init__(self, foo='bar'):
        self.foo = foo

    def __hash__(self):
        return hash(self.foo)

    def __lt__(self, other):
        return self.foo < other.foo

    def __le__(self, other):
        return self.foo <= other.foo

    def __eq__(self, other):
        return self.foo == other.foo

    def __ne__(self, other):
        return self.foo != other.foo

    def __gt__(self, other):
        return self.foo > other.foo

    def __ge__(self, other):
        return self.foo >= other.foo

    def __cmp__(self, other):
        return cmp(self.foo, other.foo)


class AnotherComparable(object):

    def __init__(self, baz='qux'):
        self.baz = baz

    def __hash__(self):
        return hash(self.baz)

    def __lt__(self, other):
        return self.baz < other.baz

    def __le__(self, other):
        return self.baz <= other.baz

    def __eq__(self, other):
        return self.baz == other.baz

    def __ne__(self, other):
        return self.baz != other.baz

    def __gt__(self, other):
        return self.baz > other.baz

    def __ge__(self, other):
        return self.baz >= other.baz

    def __cmp__(self, other):
        return cmp(self.baz, other.baz)