Mercurial > hg > config
diff python/example/aspects.py @ 811:0fffb3560641
not sure if we need this but we will keep it for now
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 28 Oct 2016 18:46:46 -0700 |
parents | python/aspects.py@2f0baf81372f |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/example/aspects.py Fri Oct 28 18:46:46 2016 -0700 @@ -0,0 +1,18 @@ +class MakePythonLikeJavascript(object): + def __getattr__(self, name): + return undefined + +class undefined(MakePythonLikeJavascript): + def __nonzero__(self): + return False + def __str__(self): + return 'undefined' + __repr__ = __str__ +undefined = undefined() # singleton + +if __name__ == '__main__': + foo = MakePythonLikeJavascript() + foo.bar = 5 + print foo.bar + print foo.fleem + print foo.fleem.flarg