list comprehension namespace problem
Frank Millman
frank at chagford.com
Fri Sep 25 01:41:42 EDT 2020
Hi all
I have a problem related (I think) to list comprehension namespaces. I
don't understand it enough to figure out a solution.
In the debugger, I want to examine the contents of the current instance,
so I can type
(Pdb) dir(self)
and get the result with no problem.
However, it is a long list containing attribute names and method names,
and I only want to see the attribute names. So I tried this -
(Pdb) [x for x in dir(self) if not callable(getattr(self, x))]
*** NameError: name 'self' is not defined
(Pdb)
Q1. Can someone explain what is going on?
Q2. Is there a way to get what I want?
Thanks
Frank Millman
More information about the Python-list
mailing list