import re


def findLastAssignment(lines, row, attrName):
	"""Finds the most recent assignment of `attrName' before `row'. Returns
	everything after the '=' sign or None, if there was no match."""
	contRegex = re.compile(r'[^#]*?' +      # Don't search in comments.
	                       attrName  +
	                       r'\s*=\s*(.*)')  # Assignment
	
	cRow = row - 1
	while cRow >= 0:
		match = contRegex.search(lines[cRow])
		if match:
			return match.group(1)
		cRow = cRow - 1
	return None