summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/getattr.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics/getattr.py')
-rw-r--r--tests/basics/getattr.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/basics/getattr.py b/tests/basics/getattr.py
new file mode 100644
index 0000000000..a021e38fb0
--- /dev/null
+++ b/tests/basics/getattr.py
@@ -0,0 +1,11 @@
+# test __getattr__
+
+class A:
+ def __init__(self, d):
+ self.d = d
+
+ def __getattr__(self, attr):
+ return self.d[attr]
+
+a = A({'a':1, 'b':2})
+print(a.a, a.b)