A bug in Python v2.6.6 documentation

April 1, 2011
3:56 a.m.
Hello, I have found a bug in the chapter 9.7.1. Itertool functions: product(A, B) is not equivalent to ((x,y) for x in A for y in B) It is untrue for dependent iterators - and here is the proof:
class c: ... def g(self): ... for i in xrange(self.x): ... yield i ... def h(self, x): ... for i in xrange(x): ... self.x = i ... yield i for i in ((x, y) for x in d.h(4) for y in d.g()): ... print i (1, 0) (2, 0) (2, 1) (3, 0) (3, 1) (3, 2) for i in product(d.h(4), d.g()): ... print i (0, 0) (0, 1) (0, 2) (1, 0) (1, 1) (1, 2) (2, 0) (2, 1) (2, 2) (3, 0) (3, 1) (3, 2)
Greetings, J.Kowalski
5078
Age (days ago)
5078
Last active (days ago)
0 comments
1 participants
participants (1)
-
Jakub Kowalski