Make starmap() match its pure python definition and accept any itertable input (not just tuples).

This commit is contained in:
Raymond Hettinger 2008-01-17 03:02:14 +00:00
parent 3ad2acc857
commit 473170908e
4 changed files with 15 additions and 8 deletions

View file

@ -292,7 +292,8 @@ def test_starmap(self):
self.assertEqual(take(3, starmap(operator.pow, izip(count(), count(1)))),
[0**1, 1**2, 2**3])
self.assertEqual(list(starmap(operator.pow, [])), [])
self.assertRaises(TypeError, list, starmap(operator.pow, [[4,5]]))
self.assertEqual(list(starmap(operator.pow, [iter([4,5])])), [4**5])
self.assertRaises(TypeError, list, starmap(operator.pow, [None]))
self.assertRaises(TypeError, starmap)
self.assertRaises(TypeError, starmap, operator.pow, [(4,5)], 'extra')
self.assertRaises(TypeError, starmap(10, [(4,5)]).next)