4 ms·
Works great unless None is a valid value for the thing, in which case you'll recalculate it every time. If that was the case you should just use hasattr().
by craigds 11y ago
Works great unless None is a valid value for the thing, in which case you'll recalculate it every time. If that was the case you should just use hasattr().
- rbanffy 11y agoOr try and except AttributeError. Exceptions are a good thing.