Matthew Barnett <pyt...@mrabarnett.plus.com> added the comment:

The problem with the shorthand form is that the generators use the
values that are bound to 'a' and 'p' when they are iterated, not when
they are created. You can test this by inserting:

    a = "X"

just before the assert: you'll get a TypeError later on.

You need something like this:

        m = []
        for (a,p,) in ((2,p2),(3,p3),(5,p5)):
            def gen(a=a, p=p):
                return (a*x for x in p)
            m.append(gen(a, p))

----------
nosy: +mrabarnett

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7439>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to