Skip to content

Instantly share code, notes, and snippets.

@SRomansky
Created November 1, 2014 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SRomansky/1d9764a4fea6a79fcbd3 to your computer and use it in GitHub Desktop.
Save SRomansky/1d9764a4fea6a79fcbd3 to your computer and use it in GitHub Desktop.
UnboundLocalError exception
freeseer/tests/framework/database/test_database.py:104:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <freeseer.framework.database.QtDBConnector object at 0x7f7d4c743110>, fname = ''
def export_talks_to_csv(self, fname):
fieldNames = ('Title',
'Speaker',
'Abstract',
'Category',
'Event',
'Room',
'Date',
'StartTime',
'EndTime')
try:
file = open(fname, 'w')
writer = csv.DictWriter(file, fieldnames=fieldNames)
headers = dict((n, n) for n in fieldNames)
writer.writerow(headers)
result = self.get_talks()
while result.next():
log.debug(unicode(result.value(1).toString()))
writer.writerow({'Title': unicode(result.value(1).toString()),
'Speaker': unicode(result.value(2).toString()),
'Abstract': unicode(result.value(3).toString()),
'Category': unicode(result.value(4).toString()),
'Event': unicode(result.value(5).toString()),
'Room': unicode(result.value(6).toString()),
'Date': unicode(result.value(7).toString()),
'StartTime': unicode(result.value(8).toString()),
'EndTime': unicode(result.value(9).toString())})
finally:
> file.close()
E UnboundLocalError: local variable 'file' referenced before assignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment