Sorry for the terrible title. I had to figure out the terminology and an trying to put all relevant points there.
Consider the following simple interaction in Python:
Python 3.6.9 (default, Jul 21 2019, 14:33:59)
[GCC 7.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> python.el: native completion setup loaded
>>> s1 = [ i for i in range(10)]
>>> [i for i in range(len(s1)) if s1[i]%2 == 0]
[0, 2, 4, 6, 8]
The last statement creates (and prints) indexes of the even elements in the original array s1.
But the equivalent does not work in pdb:
(Pdb) !s1 = [ i for i in range(10)]
(Pdb) s1
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
(Pdb) ![i for i in range(len(s1)) if s1[i]%2 == 0]
*** NameError: name 's1' is not defined
Why is s1 in scope in python interpreter but not in debugger? I am trying to identify elements in the array that meet certain criteria. What is the python way to do this in debugger?