I think pythonic is more important than performance and I would still choose that version over a try-catch block, were it slower. Being pythonic means it represents a commonly understood pattern in Python code, therefore it is more efficient in communicating intent.
Exactly. The point of following a code style is to make obvious patterns easy to spot and deviations stand out. That’s why code style guidelines say your priorities should be:
follow whatever style the code around it uses
follow project style guidelines
do the technically optimal option
3 should only be prioritized if the win is big enough, and there should probably be a comment right there explaining why the deviation was made.
I think pythonic is more important than performance and I would still choose that version over a try-catch block, were it slower. Being pythonic means it represents a commonly understood pattern in Python code, therefore it is more efficient in communicating intent.
Exactly. The point of following a code style is to make obvious patterns easy to spot and deviations stand out. That’s why code style guidelines say your priorities should be:
3 should only be prioritized if the win is big enough, and there should probably be a comment right there explaining why the deviation was made.