def __init__(self, filename, basetemplate = None, tags = None):
		"""
			filename     --	filename of the template
			basetemplate --	used to copy one instance to another
			tags         --	any predefined tags already known
		"""
		self.strings = basetemplate or []
		self.tags = tags or {}

		if filename:
			filetemplate = open(filename, 'r').read()

			# Iterate over all template tag matches
			startoffset = 0
			for match in self.markup.finditer(filetemplate):
				# Everything from the last match up to this match is
				# regular text
				self.strings.append(\
					filetemplate[startoffset:match.start('starttag')])

				# Retrieve the tagname from the match
				tagname = match.group('tagname')

				# if there a value already defined for this tag, use it.
				# (either the tag is used more than once or this instance
				# was copied from another instance.) Otherwise use the
				# string between starttag and endtag as default value
				if not tagname in self.tags:
					self.tags[tagname] = match.group('enclosed')

				# Add the tagname to the strings list. Every second string
				# is a tagname
				self.strings.append(tagname)
				startoffset = match.end('endtag')

			# Add the remainder as a whole
			self.strings.append(filetemplate[startoffset:])

			filename     --	filename of the template
			basetemplate --	used to copy one instance to another
			tags         --	any predefined tags already known
		
recipes/Python/577203_Userfriendly_Webpage_Template/recipe-577203.py