<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def analyse(self, path_and_filename, pattern):
 """ Find out lines of code and lines of comments. Args: path_and_filename (str):
 path and filename to parse for loc and com. pattern (str):
 regex to search for line commens and block comments Returns: int, int: loc and com for given file. """

        with open(path_and_filename) as handle:
            content = handle.read()
            loc = content.count('\n') + 1
            com = 0
            for match in re.findall(pattern, content, re.DOTALL):
                com += match.count('\n') + 1

            return max(0, loc - com), com