Josh English <joshua.r.english <at> gmail.com> writes: > > I have a script that generates a report from a bunch of data I've been > collecting for the past year. I ran the script, successfully, for > several weeks on test runs and creating more detailed reports. > > Today (back from vacation) and the script doesn't work. It's giving me > a name error. > > I'm running python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v. > 1310 32 bit (Intel)]. (Upgrading is not a possibility right now. > Eventually we'll be upgraded top Windows 7.) > > Here is the reduced code: > > fws_first_col = 6 > > for student in range(32): > > if True: > idx = fws_first_col > > for _month in range(12): > idx += 2 > fws_last_col = idx > > print fws_last_col > > I get: > > NameError: name 'fws_last_col' is not defined > > This snippet of code works on it's own, but not in the main script.
That doesn't give me enough information to help you with the issue. In general you need to provide enough code to reproduce the failure, not some modified version that doesn't fail. My guess is that the "if True" is actually something else, and it isn't being interpreted as "True". As such, "fws_last_col" never gets assigned, and thus never gets created. You can fix that by assigning fws_last_col to an appropriate default value before the for loop. But what do I know, that is just a guess. Matt -- http://mail.python.org/mailman/listinfo/python-list