diff --git a/builtin/builtin.go b/builtin/builtin.go index 4e9ca18d..0ccb36aa 100644 --- a/builtin/builtin.go +++ b/builtin/builtin.go @@ -237,7 +237,6 @@ If the iterable is empty, return True. func builtin_all(self, seq py.Object) (py.Object, error) { iter, err := py.Iter(seq) - res := false if err != nil { return nil, err } @@ -249,14 +248,11 @@ func builtin_all(self, seq py.Object) (py.Object, error) { } return nil, err } - if py.ObjectIsTrue(item) { - res = true - } else { - res = false - break + if !py.ObjectIsTrue(item) { + return py.False, nil } } - return py.NewBool(res), nil + return py.True, nil } const any_doc = `any(iterable) -> bool @@ -266,7 +262,6 @@ If the iterable is empty, Py_RETURN_FALSE."` func builtin_any(self, seq py.Object) (py.Object, error) { iter, err := py.Iter(seq) - res := false if err != nil { return nil, err } @@ -279,11 +274,10 @@ func builtin_any(self, seq py.Object) (py.Object, error) { return nil, err } if py.ObjectIsTrue(item) { - res = true - break + return py.True, nil } } - return py.NewBool(res), nil + return py.False, nil } const round_doc = `round(number[, ndigits]) -> number diff --git a/builtin/tests/builtin.py b/builtin/tests/builtin.py index 995a652b..07d1f08d 100644 --- a/builtin/tests/builtin.py +++ b/builtin/tests/builtin.py @@ -11,7 +11,7 @@ assert all((0,0,0)) == False assert all((1,1,0)) == False assert all(["hello", "world"]) == True -assert all([]) == False +assert all([]) == True doc="any" assert any((0,0,0)) == False
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: