Which is best practices to return Boolean value from a function:
- Hardcoded
- as a variable
Code 1 :
(status, response) = self.generate_pdf(html_data)
if not status:
return (False, response)
Code 2:
(status, response) = self.generate_pdf(html_data)
if not status:
return (status, response)
According to me returning hardcode value (False or True) is good.
[More details]
I always return two parameter from every function, status and response. A status is Boolean object i.e. value is True or False. A response is dictionary object.
As status have a value False i.e. status is referring address of False.
>>> id(False)
493227104
>>> status = False
>>> id(status')
493227104
So returning reference variable name is good practices or actual bool value ?