From f8ba2eca804ae167d6597cc89eb270ddd8e1ce23 Mon Sep 17 00:00:00 2001 From: chrysn Date: Wed, 13 Jan 2016 12:29:17 +0100 Subject: 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. --- tests/basics/builtin_property.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/basics/builtin_property.py') 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) -- cgit v1.2.3