r/Python • u/RickSore • Nov 14 '17
Senior Python Programmers, what tricks do you want to impart to us young guns?
Like basic looping, performance improvement, etc.
1.3k
Upvotes
r/Python • u/RickSore • Nov 14 '17
Like basic looping, performance improvement, etc.
2
u/flatlander_ Nov 14 '17 edited Nov 16 '17
When you do a
try: except:, make sure that you at least exceptException, or you could run into weird issues like not being able to stop your program. This is becauseKeyboardInterrupt,SystemExitet al are derived fromBaseExceptionand will be swallowed if you don't except them or a superclass.e.g. do this:
and not this: