Commits

Geoffrey Sneddon committed eb6d50a

Add reversed() if it doesn't already exists. Hopefully we now support Py2.3.

  • Participants
  • Parent commits 8d90a26

Comments (0)

Files changed (1)

File anolislib/utils.py

 				node.getparent().text = node.tail
 			else:
 				node.getparent().text += node.tail
+
+global reversed
+try:
+	reversed
+except NameError:
+	def reversed(x):
+		if hasattr(x, 'keys'):
+			raise ValueError("mappings do not support reverse iteration")
+		i = len(x)
+		while i > 0:
+			i -= 1
+			yield x[i]
 						
 class AnolisException(Exception):
 	"""Generic anolis error."""