diff options
author | chrysn <chrysn@fsfe.org> | 2016-01-13 12:29:17 +0100 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-01-14 21:15:18 +0200 |
commit | f8ba2eca804ae167d6597cc89eb270ddd8e1ce23 (patch) | |
tree | 49f6143c77a0dd90c493b922bcaee689958526fb /tests/basics/builtin_property.py | |
parent | dea585f8ae71be75021e8a9513278c04e4d6a423 (diff) | |
download | micropython-f8ba2eca804ae167d6597cc89eb270ddd8e1ce23.tar.gz micropython-f8ba2eca804ae167d6597cc89eb270ddd8e1ce23.zip |
builtin property: accept keyword arguments
this allows python code to use property(lambda:..., doc=...) idiom.
named versions for the fget, fset and fdel arguments are left out in the
interest of saving space; they are rarely used and easy to enable when
actually needed.
a test case is included.
Diffstat (limited to 'tests/basics/builtin_property.py')
-rw-r--r-- | tests/basics/builtin_property.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/basics/builtin_property.py b/tests/basics/builtin_property.py index 3b3b32d166..403abd62f4 100644 --- a/tests/basics/builtin_property.py +++ b/tests/basics/builtin_property.py @@ -93,3 +93,10 @@ try: del d.prop except AttributeError: print('AttributeError') + +# properties take keyword arguments +class E: + p = property(lambda self: 42, doc="This is truth.") + # not tested for because the other keyword arguments are not accepted + # q = property(fget=lambda self: 21, doc="Half the truth.") +print(E().p) |