diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-04-25 21:15:16 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-04-25 21:17:42 +0300 |
commit | 755565d2cbc7c7f7abe6f457012b49ddf6b23ca1 (patch) | |
tree | a61d0de0090976a0b5405d2678ed5287f692efa1 /tests/basics | |
parent | 410f30772fa3e121d1c6f8c9e2418fad7579e6f4 (diff) | |
download | micropython-755565d2cbc7c7f7abe6f457012b49ddf6b23ca1.tar.gz micropython-755565d2cbc7c7f7abe6f457012b49ddf6b23ca1.zip |
py: Support instance __call__ method.
Diffstat (limited to 'tests/basics')
-rw-r--r-- | tests/basics/class_call.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/basics/class_call.py b/tests/basics/class_call.py new file mode 100644 index 0000000000..b7a3d70f9e --- /dev/null +++ b/tests/basics/class_call.py @@ -0,0 +1,18 @@ +class C1: + def __call__(self, val): + print('call', val) + return 'item' + +class C2: + + def __getattr__(self, k): + pass + +c1 = C1() +print(c1(1)) + +c2 = C2() +try: + print(c2(1)) +except TypeError: + print("TypeError") |