Created
April 21, 2018 07:14
-
-
Save appositum/903449160e551846ec285dc21401997a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pointer(object): | |
def __init__(self, target=None): | |
self.target = target | |
_noarg = object() | |
def __call__(self, target=_noarg): | |
if target is not self._noarg: | |
self.target = target | |
return self.target | |
x = Pointer(2) | |
y = x | |
x() # => 2 | |
y() # => 2 | |
y(30) | |
x() # => 30 | |
x(50) | |
y() # => y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment