Answer by 5gon12eder for Use exception as check - is it good idea?
The Python – unlike most of the rest of the world – people actually encourage this use of exceptions.They call it the EAFP principle, quoting American computer scientist and United States Navy rear...
View ArticleAnswer by kuma DK for Use exception as check - is it good idea?
Exceptions are not for checking.it should be used as last option if you are unable to deal with some run time issue. Most probably to catch any unexpected but foreseen issues while running. ex- db...
View ArticleAnswer by Karl M.W. for Use exception as check - is it good idea?
The general rule I operate by is:Do you expect it to pass?If I expect an action will be successful most of the time, I use exceptions.If I expect an action to fail most of the time, I'll intercept it...
View ArticleUse exception as check - is it good idea?
I have code: print('Adding user %s...' % user) # my own class with method sysacts.useradd() # check if user exist after been added try: pwd.getpwnam(user) print('Done.') except KeyError as e:...
View Article
More Pages to Explore .....