Author: David Schneider <david.schnei...@picle.org> Branch: Changeset: r40:912d94ab5156 Date: 2011-09-22 11:18 +0200 http://bitbucket.org/pypy/lang-io/changeset/912d94ab5156/
Log: implement List remove(item) diff --git a/io/list.py b/io/list.py --- a/io/list.py +++ b/io/list.py @@ -128,6 +128,12 @@ raise Exception, 'index out of bounds' return w_target + +@register_method('List', 'remove') +def list_remove_all(space, w_target, w_message, w_context): + w_item = w_message.arguments[0].eval(space, w_target, w_context) + w_target.list_items.remove(w_item) + return w_target @register_method('List', 'atPut') def list_reverse_in_place(space, w_target, w_message, w_context): diff --git a/io/test/test_list.py b/io/test/test_list.py --- a/io/test/test_list.py +++ b/io/test/test_list.py @@ -197,6 +197,11 @@ res, space = interpret(inp) assert isinstance(res, W_List) assert [x.value for x in res.list_items] == [] +def test_remove(): + inp = 'a := list(9,8,7,6,5,4,3,2,1,100); a remove(7)' + res, space = interpret(inp) + assert isinstance(res, W_List) + assert [int(x.number_value) for x in res.list_items] == [9,8,6,5,4,3,2,1,100] def test_at_put(): inp = 'a := list(9,8,7,6,5,4,3,2,1,100); a atPut(3, 1045)' _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit