I think i am over using try and except in my code. It's pretty much everywhere, where i have regexp matching. If it does not find the regex, it throws an exception, so i use the try and except to capture this to prevent my code from crashing. Example of what i'm talking about.
try:
Output = "John Bob Charlie"
match = re.search(r'John', Output, re.M|re.I) #use try/except, to stop unmatch causing crash
except:
print("Darn, no John")
Is there a better way of doing this or is this normal?? I'm new to Python and coming from Perl, a simple
if match{
print('we have found John')
}
Was all i needed.
Thanks in advance
if match:repl.it/@JoranBeasley/EmbarrassedHeavyScientisttry/cachethat doesnt do what OP thinks it does (I think thats what he meant at least)