def find_comment(line):
    """ Finds the index of a comment # and returns None if not found """
    instring, instring_char = False, ''
    for i, char in enumerate(line):
        if char in ('"', "'"):
            if instring:
                if char == instring_char:
                    instring = False
                    instring_char = ''
            else:
                instring = True
                instring_char = char
        elif char == '#':
            if not instring:
                return i
    return None
