From c1d9bbc3453454aceb28f51e72e4aeb8ef1c12eb Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 30 Jan 2014 04:37:19 +0200 Subject: Implement __bool__ and __len__ via unary_op virtual method for all types. __bool__() and __len__() are just the same as __neg__() or __invert__(), and require efficient dispatching implementation (not requiring search/lookup). type->unary_op() is just the right choice for this short of adding standalone virtual method(s) to already big mp_obj_type_t structure. --- tests/basics/true-value.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/basics/true-value.py') diff --git a/tests/basics/true-value.py b/tests/basics/true-value.py index 6ba410ddc..1dd547f32 100644 --- a/tests/basics/true-value.py +++ b/tests/basics/true-value.py @@ -3,9 +3,18 @@ if not False: print("False") +if not None: + print("None") + if not 0: print("0") +if not 0.0: + print("float 0") + +if not 0+0j: + print("complex 0") + if not "": print("Empty string") if "foo": -- cgit v1.2.3