PDB scope problem

Dale Strickland-Clark dale at out-think.no-spam.co.uk
Mon Oct 22 12:43:29 EDT 2007


While debugging with PDB earlier, I discovered this idiosyncracy:

(Pdb) lstValues
[[Decimal("1"), Decimal("47.0")]]
(Pdb) agg
[0, 1]
(Pdb) print list([sum(v[i] for i in range(len(agg))) for v in lstValues])
*** NameError: global name 'v' is not defined
(Pdb) 

However, the Python interpreter is happy with it if entered directly:

>>> lstValues
[[Decimal("1"), Decimal("47.0")]]
>>> agg = [0,1]
>>> print list([sum(v[i] for i in range(len(agg))) for v in lstValues])
[Decimal("48.0")]
>>> 

There seems to be some sort of scope problem in PDB.

-- 
Dale Strickland-Clark





More information about the Python-list mailing list