[issue35871] Pdb NameError in generator param and list comprehension
Jayanth Raman added the comment: 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() -- ___ Python tracker <https://bugs.python.org/issue35871> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35871] Pdb NameError in generator param and list comprehension
New submission from Jayanth Raman : I get a NameError for a variable in the generator param of a function or in a list comprehension. See example below. The variable is available to the program, but not to the interactive Pdb shell. # Test file: def main(nn=10): xx = list(range(nn)) breakpoint() for ii in range(nn): num = sum(xx[jj] for jj in range(nn)) print(f'xx={xx}') if __name__ == '__main__': main() $ python3 Python 3.7.2 (default, Jan 13 2019, 12:50:15) [Clang 10.0.0 (clang-1000.11.45.5)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> $ python3 /tmp/test.py > /tmp/test.py(5)main() -> for ii in range(nn): (Pdb) n > /tmp/test.py(6)main() -> num = sum(xx[jj] for jj in range(nn)) (Pdb) sum(xx[jj] for jj in range(nn)) *** NameError: name 'xx' is not defined (Pdb) [xx[jj] for jj in range(nn)] *** NameError: name 'xx' is not defined (Pdb) c xx=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] FWIW python3 is a homebrew installation. I had the same issue with 3.7.0 as well (also homebrew): Python 3.7.0 (default, Sep 18 2018, 18:47:22) [Clang 9.1.0 (clang-902.0.39.2)] on darwin -- components: Interpreter Core messages: 334639 nosy: jayanth priority: normal severity: normal status: open title: Pdb NameError in generator param and list comprehension versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue35871> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35738] Update timeit documentation to reflect default repeat of three
New submission from Jayanth Raman : In the Examples section of the timeit documentation, repeat() returns a list of size three. But the default is now five and the documentation should reflect that. Thanks. -- assignee: docs@python components: Documentation messages: 333635 nosy: docs@python, jayanth priority: normal severity: normal status: open title: Update timeit documentation to reflect default repeat of three type: enhancement versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue35738> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21330] Typo in Unicode HOWTO documentation
New submission from Jayanth Raman: It should be 128 such characters in the following sentence: For example, you can’t fit both the accented characters used in Western Europe and the Cyrillic alphabet used for Russian into the 128-255 range because there are more than 127 such characters. -- assignee: docs@python components: Documentation messages: 217016 nosy: docs@python, jayanth priority: normal severity: normal status: open title: Typo in Unicode HOWTO documentation type: behavior versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21330 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13410] String formatting bug in interactive mode
New submission from Jayanth Raman raman.jaya...@gmail.com: With file xx.py: class Foo(object): def __init__(self, x): self.x = x def __long__(self): return long(self.x) def __float__(self): return float(self.x) y = Foo(22) print '%d' % y print '%d' % y Interactive mode: $ python -V Python 2.6.7 $ python -i xx.py 22 22 TypeError: int() argument must be a string or a number, not 'Foo' '%d' % y '22' '%d' % y TypeError: int() argument must be a string or a number, not 'Foo' '%d' % y '22' '%d' % y TypeError: int() argument must be a string or a number, not 'Foo' It alternates between printing '22' and print a TypeError message. Expected it to be consistent. Also, the first carraige-return (with no input) results in an error message. Did not expect an error message. In fact, typing pretty much anything (e.g. an undefined variable or raise(Exception())) results in the same error message. On Mac OS X Darwin Kernel Version 10.8.0 Python 2.6.7 (r267:88850, Jul 6 2011, 13:57:37) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Thanks. -- assignee: ronaldoussoren components: Macintosh messages: 147711 nosy: jayanth, ronaldoussoren priority: normal severity: normal status: open title: String formatting bug in interactive mode type: behavior versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13410 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com