From 9e142a8cd95bf64f0f4525a9cb5cd6a581f2fd84 Mon Sep 17 00:00:00 2001 From: neingeist Date: Tue, 26 Aug 2014 17:57:06 +0200 Subject: [PATCH] __del__ --- abcmeta.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 abcmeta.py diff --git a/abcmeta.py b/abcmeta.py new file mode 100644 index 0000000..712d526 --- /dev/null +++ b/abcmeta.py @@ -0,0 +1,49 @@ +from __future__ import division, print_function +import abc + + +class Base(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractproperty + def x(self): + return 'Should never get here' + + @abc.abstractmethod + def process(self, data): + """ Process data. + Return bool + + """ + return + + def __del__(self): + print("__del__") + + +class Implementation(Base): + def __init__(self): + self._x = True + + @property + def x(self): + return self._x + + @x.setter + def x(self, value): + self._x = value + + def process(self, data): + data += 1 + return True + +# b = Base() +# print(b.x) + +i = Implementation() +print(i.x) +a = 1 +i.process(a) +print(a) + +i2 = Implementation()