2 ms·
I'm pretty sure the "-" vs "None" meant that there wasn't a truthy alternative to None. More accurate would have been "N/A" vs "None". Not clear on the __nonzer
by Arnor 13y ago
I'm pretty sure the "-" vs "None" meant that there wasn't a truthy alternative to None. More accurate would have been "N/A" vs "None". Not clear on the __nonzero__/__bool__ stuff...
- falcolas 13y ago__nonzero__/__bool__ are the methods called on objects when evaluating truthiness. So, if you're implementing custom objects, those are what you would use, and return either True or False, based on their truthiness value. As an example, you might represent __bool__ on a database connection object to reflect whether there is a live connection, allowing you to: if not conn: conn = MySQLdb.Connect()