12.3. Raising exceptions

You can also raise an exception in your code, if you consider that the program should be interrupted:

	  if something_wrong:
             raise Exception
	
You can associate a message to the raise statement:
	  if something_wrong:
             raise Exception, " something went wrong"
	

Example 12.3. Raising an exception in case of a wrong DNA character

def check_dna(dna, alphabet='atgc'):
    """ using exceptions """
    
    for base in dna:
        if base not in alphabet:
            raise ValueError, "%s not in %s" % (base, alphabet)

    return True