Crappy Python code of the day
Steven D'Aprano
steve at pearwood.info
Wed Feb 15 21:25:26 EST 2017
This has been in production for months, the writer of the code has left
and the new maintainer has been asked to find out why it has been
crashing with UnboundLocalError:
try:
result = future.result()
except requests.exceptions.ConnectionError as e:
pass
resp = self.client.service.GetModifiedTerminals(
__inject={'reply': result.content})
Traceback (most recent call last):
[incriminating details removed for the protection of the guilty]
UnboundLocalError: local variable 'result' referenced before assignment
https://realpython.com/blog/python/the-most-diabolical-python-antipattern/
--
Steve
More information about the Python-list
mailing list