FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

builtin: Update builtin_all and builtin_any for Python3 by corona10 · Pull Request #15 · go-python/gpython · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .go  (1) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 5 additions & 11 deletions builtin/builtin.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion builtin/tests/builtin.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

Back | FazBrowse Home | New Git URL