3 ms·
They could add a __bool__ method to the class the returns false when that level of the namespace is empty. That would allow: if a.b.c: print("c:", a.
by samwillis 3y ago
They could add a __bool__ method to the class the returns false when that level of the namespace is empty. That would allow:
if a.b.c:
print("c:", a.b.c)
- rozab 3y agoThe __contains__ method should be used (and indeed is). What if a.b.c = False?