diff options
author | Joe Anderson <jandew+dev@gmail.com> | 2011-11-13 14:40:52 -0600 |
---|---|---|
committer | Joe Anderson <jandew+dev@gmail.com> | 2011-11-13 14:40:52 -0600 |
commit | 0b83a5931534efeee7bf0f763a240e566d9cdfe2 (patch) | |
tree | 4a6640d4bfa6650cf7203afc159a224c40443ca1 /diffeq.py | |
parent | 5a2a5441bae50c7859b26dfc4c1550f8fb05cbf1 (diff) | |
parent | 92b01ef48a648324ef07aebacf062e55f392340e (diff) | |
download | toss-0b83a5931534efeee7bf0f763a240e566d9cdfe2.tar.gz toss-0b83a5931534efeee7bf0f763a240e566d9cdfe2.zip |
WIP on master: 5a2a544 forgot about this stash
Diffstat (limited to 'diffeq.py')
-rw-r--r-- | diffeq.py | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -10,18 +10,30 @@ class DiffEq(object): >>> self._foo=2 #setting an _under var makes it still callable by... >>> self.foo 2 + >>> self.foo is self._foo + True #so they share the same namespace >>> # Now suppose foo is a class method and bar is in _flags. - >>> self.foo #finding the object having not found it before + >>> self.foo #finding the object having not found it before: #self.foo() is called and stored to self.__foo #self.__foo is returned - >>> self.foo #finding the object having asked for it before + >>> self.foo #finding the object having asked for it before: #self.__foo is returned >>> self.bar=2 #setting bar resets all self.__foos >>> self.foo #self.foo() is called again, self.__foo returned + + >>> # You can also subvert the second mechanism using the first, + >>> # as the mechansims do not recurse on themselves. + >>> # Suppose _foo is a class method, bar is in _flags + >>> self.foo + <bound method self._foo of ... > + >>> self._foo + <bound method self._foo of ... > + >>> self + >>> # The class is prevented from creating ___trunder variables. Note that with this behavior you should treat all variable names, be they normal, _under, or __dunder, as in the same namespace. Don't even try to @@ -59,7 +71,7 @@ class DiffEq(object): sgetattr = super(DiffEq, self).__getattribute__ try: value = sgetattr(attr) - if type(value) == types.MethodType: + if type(value) == types.MethodType and attr[0] != '_': try: value = sgetattr("__" + attr) except AttributeError: value = value() |