[Python-bugs-list] [ python-Bugs-605047 ] Tutorial and list comprehension scope
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 05 Sep 2002 06:10:34 -0700
Bugs item #605047, was opened at 2002-09-05 14:10
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=605047&group_id=5470
Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: John J Lee (jjlee)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Tutorial and list comprehension scope
Initial Comment:
I just made an expensive mistake with a list comprehension:
val = mean(vals)
bad_vals = sum([val < 0.0 or val > 1.0 for val in vals])
val gets clobbered by the list comprehension, silently messing
up my statistics.
Shouldn't there be a mention of this behaviour in the tutorial
(section 5.1.4, or in the part of section 9 on scope)?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=605047&group_id=5470