Mercurial > slides-fragments
changeset 145:6f5b64d36e0a
created
| author | 127.0.0.1 |
|---|---|
| date | Thu, 30 Jan 2014 09:24:11 +0100 |
| parents | f0c2223e8188 |
| children | 8bd4626195ab |
| files | equals |
| diffstat | 1 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/equals Thu Jan 30 09:24:11 2014 +0100 @@ -0,0 +1,26 @@ +**Wrong:** +{{{#!python +class C(object): + def __eq__(self, other): + ... + +C() != C() +}}} + +**Better:** +{{{#!python +class C(object): + def __eq__(self, other): + ... + def __ne__(self, other): + return not self.__eq__(other) +}}} + +**Better:** +{{{#!python +import functools + +@functools.total_ordering +class C(object): + ... +}}} \ No newline at end of file
