<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def count_lines_of_code(self, fname=''):
 """ counts non blank lines """

        if fname == '':
            fname = self.fullname
        loc = 0    
        try:
            with open(fname) as f:
                for l in f:
                    if l.strip() != '':
                        loc += 1
            return loc    
        except Exception as ex:
            print('cant count lines of code in "', fname, '":', str(ex))
            return 0