This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jayanth
Recipients jayanth, xdegaye, xtreak
Date 2019-02-01.05:21:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1548998492.91.0.442311015756.issue35871@roundup.psfhosted.org>
In-reply-to
Content
Thanks for the "interact" tip.

FWIW, I see this issue in 2.7.10 as well.  Although the list comprehension works.

$ python
Python 2.7.10 (default, Oct  6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D

$ python /tmp/test2.py
> /tmp/test2.py(5)main()
-> for ii in range(nn):
(Pdb) n
> /tmp/test2.py(6)main()
-> num = sum(xx[jj] for jj in range(nn))
(Pdb) sum(xx[jj] for jj in range(nn))
*** NameError: global name 'xx' is not defined
(Pdb) [xx[jj] for jj in range(nn)]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
(Pdb) c
('xx', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

# test2.py

def main(nn=10):
    xx = list(range(nn))
    import pdb; pdb.set_trace()
    for ii in range(nn):
        num = sum(xx[jj] for jj in range(nn))
    print('xx', xx)

if __name__ == '__main__':
    main()
History
Date User Action Args
2019-02-01 05:21:34jayanthsetrecipients: + jayanth, xdegaye, xtreak
2019-02-01 05:21:32jayanthsetmessageid: <1548998492.91.0.442311015756.issue35871@roundup.psfhosted.org>
2019-02-01 05:21:32jayanthlinkissue35871 messages
2019-02-01 05:21:32jayanthcreate