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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions py/dict.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ var (

func init() {
StringDictType.Dict["items"] = MustNewMethod("items", func(self Object, args Tuple) (Object, error) {
err := UnpackTuple(args, nil, "items", 0, 0)
if err != nil {
return nil, err
}
sMap := self.(StringDict)
o := make([]Object, 0, len(sMap))
for k, v := range sMap {
Expand Down
2 changes: 2 additions & 0 deletions py/tests/dict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2018 The go-python Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
from libtest import assertRaises

doc="str"
assert str({}) == "{}"
Expand Down Expand Up @@ -35,6 +36,7 @@
assert v == "b"
if k == "c":
assert v == 5.5
assertRaises(TypeError, a.items, 'a')

doc="__contain__"
a = {'hello': 'world'}
Expand Down