2to3 --fix=idioms
diff --git a/Lib/fontTools/afmLib.py b/Lib/fontTools/afmLib.py
index c1a79cf..9542d1a 100644
--- a/Lib/fontTools/afmLib.py
+++ b/Lib/fontTools/afmLib.py
@@ -177,7 +177,7 @@
 		ncomponents = int(m.group(2))
 		rest = rest[m.regs[0][1]:]
 		components = []
-		while 1:
+		while True:
 			m = componentRE.match(rest)
 			if m is None:
 				raise error("syntax error in AFM file: " + repr(rest))
@@ -215,8 +215,7 @@
 				lines.append(attr + " " + str(value))
 		# then write the attributes we don't know about,
 		# in alphabetical order
-		items = attrs.items()
-		items.sort()
+		items = sorted(attrs.items())
 		for attr, value in items:
 			if attr in preferredAttributeOrder:
 				continue
@@ -254,8 +253,7 @@
 		lines.append("EndKernData")
 		
 		if self._composites:
-			composites = self._composites.items()
-			composites.sort()
+			composites = sorted(self._composites.items())
 			lines.append("StartComposites %s" % len(self._composites))
 			for charname, components in composites:
 				line = "CC %s %s ;" % (charname, len(components))
@@ -316,7 +314,7 @@
 				raise AttributeError(attr)
 	
 	def __getitem__(self, key):
-		if type(key) == types.TupleType:
+		if isinstance(key, types.TupleType):
 			# key is a tuple, return the kernpair
 			return self._kerning[key]
 		else:
@@ -324,7 +322,7 @@
 			return self._chars[key]
 	
 	def __setitem__(self, key, value):
-		if type(key) == types.TupleType:
+		if isinstance(key, types.TupleType):
 			# key is a tuple, set kernpair
 			self._kerning[key] = value
 		else:
@@ -332,7 +330,7 @@
 			self._chars[key] = value
 	
 	def __delitem__(self, key):
-		if type(key) == types.TupleType:
+		if isinstance(key, types.TupleType):
 			# key is a tuple, del kernpair
 			del self._kerning[key]
 		else:
diff --git a/Lib/fontTools/cffLib.py b/Lib/fontTools/cffLib.py
index 3db9065..44236e8 100644
--- a/Lib/fontTools/cffLib.py
+++ b/Lib/fontTools/cffLib.py
@@ -136,7 +136,7 @@
 	def toFile(self, file):
 		lastPosList = None
 		count = 1
-		while 1:
+		while True:
 			if DEBUG:
 				print "CFFWriter.toFile() iteration:", count
 			count = count + 1
@@ -558,8 +558,7 @@
 			return self.charStrings[name], sel
 	
 	def toXML(self, xmlWriter, progress):
-		names = self.keys()
-		names.sort()
+		names = sorted(self.keys())
 		i = 0
 		step = 10
 		numGlyphs = len(names)
diff --git a/Lib/fontTools/fondLib.py b/Lib/fontTools/fondLib.py
index f06c752..b4ae0b8 100644
--- a/Lib/fontTools/fondLib.py
+++ b/Lib/fontTools/fondLib.py
@@ -206,8 +206,7 @@
 	
 	def _buildboundingboxtable(self):
 		if self.boundingBoxes and self._rawoffsettable[:6] == '\0\0\0\0\0\6':
-			boxes = self.boundingBoxes.items()
-			boxes.sort()
+			boxes = sorted(self.boundingBoxes.items())
 			data = '\0\0\0\0\0\6' + struct.pack(">h", len(boxes) - 1)
 			for style, (l, b, r, t) in boxes:
 				data = data + struct.pack(">hhhhh", style, l, b, r, t)
@@ -241,8 +240,7 @@
 			return
 		numberofentries = len(self.widthTables)
 		data = struct.pack('>h', numberofentries - 1)
-		tables = self.widthTables.items()
-		tables.sort()
+		tables = sorted(self.widthTables.items())
 		for stylecode, table in tables:
 			data = data + struct.pack('>h', stylecode)
 			if len(table) != (3 + self.ffLastChar - self.ffFirstChar):
@@ -284,8 +282,7 @@
 			return
 		numberofentries = len(self.kernTables)
 		data = [struct.pack('>h', numberofentries - 1)]
-		tables = self.kernTables.items()
-		tables.sort()
+		tables = sorted(self.kernTables.items())
 		for stylecode, table in tables:
 			data.append(struct.pack('>h', stylecode))
 			data.append(struct.pack('>h', len(table)))  # numberofpairs
@@ -375,8 +372,7 @@
 			for part in split:
 				nameparts[part] = None
 		del nameparts[self.ffFamilyName]
-		nameparts = nameparts.keys()
-		nameparts.sort()
+		nameparts = sorted(nameparts.keys())
 		items = splitnames.items()
 		items.sort()
 		numindices = 0
@@ -433,8 +429,7 @@
 			return
 		numberofentries = len(self.glyphEncoding)
 		data = struct.pack(">h", numberofentries)
-		items = self.glyphEncoding.items()
-		items.sort()
+		items = sorted(self.glyphEncoding.items())
 		for glyphcode, glyphname in items:
 			data = data + chr(glyphcode) + chr(len(glyphname)) + glyphname
 		self._rawglyphencodingsubtable = data
@@ -497,8 +492,7 @@
 		for fond in self.fonds:
 			fond.parse()
 			if hasattr(fond, "psNames") and fond.psNames:
-				psNames = fond.psNames.values()
-				psNames.sort()
+				psNames = sorted(fond.psNames.values())
 				self.fondsbyname[psNames[0]] = fond
 	
 	def minimalparse(self):
diff --git a/Lib/fontTools/misc/bezierTools.py b/Lib/fontTools/misc/bezierTools.py
index 4c897d5..d15e070 100644
--- a/Lib/fontTools/misc/bezierTools.py
+++ b/Lib/fontTools/misc/bezierTools.py
@@ -132,8 +132,7 @@
     a, b, c = calcQuadraticParameters(pt1, pt2, pt3)
     solutions = solveQuadratic(a[isHorizontal], b[isHorizontal],
         c[isHorizontal] - where)
-    solutions = [t for t in solutions if 0 <= t < 1]
-    solutions.sort()
+    solutions = sorted([t for t in solutions if 0 <= t < 1])
     if not solutions:
         return [(pt1, pt2, pt3)]
     return _splitQuadraticAtT(a, b, c, *solutions)
@@ -157,8 +156,7 @@
     a, b, c, d = calcCubicParameters(pt1, pt2, pt3, pt4)
     solutions = solveCubic(a[isHorizontal], b[isHorizontal], c[isHorizontal],
         d[isHorizontal] - where)
-    solutions = [t for t in solutions if 0 <= t < 1]
-    solutions.sort()
+    solutions = sorted([t for t in solutions if 0 <= t < 1])
     if not solutions:
         return [(pt1, pt2, pt3, pt4)]
     return _splitCubicAtT(a, b, c, d, *solutions)
diff --git a/Lib/fontTools/misc/psCharStrings.py b/Lib/fontTools/misc/psCharStrings.py
index f658327..54fdcd0 100644
--- a/Lib/fontTools/misc/psCharStrings.py
+++ b/Lib/fontTools/misc/psCharStrings.py
@@ -65,7 +65,7 @@
 	
 	def read_realNumber(self, b0, data, index):
 		number = ''
-		while 1:
+		while True:
 			b = ord(data[index])
 			index = index + 1
 			nibble0 = (b & 0xf0) >> 4
@@ -87,7 +87,7 @@
 			oper[item[0]] = item[1]
 		else:
 			oper[item[0]] = item[1:]
-		if type(item[0]) == types.TupleType:
+		if isinstance(item[0], types.TupleType):
 			opc[item[1]] = item[0]
 		else:
 			opc[item[1]] = (item[0],)
@@ -334,7 +334,7 @@
 				return None, 0, 0
 			token = self.program[index]
 			index = index + 1
-		isOperator = type(token) == StringType
+		isOperator = isinstance(token, StringType)
 		return token, isOperator, index
 	
 	def getBytes(self, index, nBytes):
@@ -364,7 +364,7 @@
 		else:
 			index = 0
 			args = []
-			while 1:
+			while True:
 				token, isOperator, index = self.getToken(index)
 				if token is None:
 					break
@@ -472,7 +472,7 @@
 			return
 		program = []
 		index = 0
-		while 1:
+		while True:
 			token, isOperator, index = self.getToken(index)
 			if token is None:
 				break
@@ -510,7 +510,7 @@
 			pushToProgram = lambda x: None
 		pushToStack = self.operandStack.append
 		index = 0
-		while 1:
+		while True:
 			token, isOperator, index = charString.getToken(index)
 			if token is None:
 				break  # we're done!
@@ -1143,7 +1143,7 @@
 		return None, index
 	
 	def handle_operator(self, operator, argType):
-		if type(argType) == type(()):
+		if isinstance(argType, type(())):
 			value = ()
 			for i in range(len(argType)-1, -1, -1):
 				arg = argType[i]
diff --git a/Lib/fontTools/misc/sstruct.py b/Lib/fontTools/misc/sstruct.py
index e2759ef..9363037 100644
--- a/Lib/fontTools/misc/sstruct.py
+++ b/Lib/fontTools/misc/sstruct.py
@@ -63,7 +63,7 @@
 def pack(format, object):
 	formatstring, names, fixes = getformat(format)
 	elements = []
-	if type(object) is not types.DictType:
+	if not isinstance(object, types.DictType):
 		object = object.__dict__
 	for name in names:
 		value = object[name]
@@ -78,7 +78,7 @@
 	if object is None:
 		object = {}
 	formatstring, names, fixes = getformat(format)
-	if type(object) is types.DictType:
+	if isinstance(object, types.DictType):
 		dict = object
 	else:
 		dict = object.__dict__
diff --git a/Lib/fontTools/misc/textTools.py b/Lib/fontTools/misc/textTools.py
index fd64ed5..e72282a 100644
--- a/Lib/fontTools/misc/textTools.py
+++ b/Lib/fontTools/misc/textTools.py
@@ -77,8 +77,7 @@
 			(lower(item), item), alist)
 	except TypeError:
 		# at least one element in alist is not a string, proceed the normal way...
-		alist = alist[:]
-		alist.sort()
+		alist = sorted(alist[:])
 		return alist
 	else:
 		tupledlist.sort()
diff --git a/Lib/fontTools/misc/xmlReader.py b/Lib/fontTools/misc/xmlReader.py
index b2132ef..6dd1e27 100644
--- a/Lib/fontTools/misc/xmlReader.py
+++ b/Lib/fontTools/misc/xmlReader.py
@@ -37,7 +37,7 @@
 		parser.CharacterDataHandler = self._characterDataHandler
 		
 		pos = 0
-		while 1:
+		while True:
 			chunk = file.read(BUFSIZE)
 			if not chunk:
 				parser.Parse(chunk, 1)
diff --git a/Lib/fontTools/misc/xmlWriter.py b/Lib/fontTools/misc/xmlWriter.py
index 52d9a5c..9246255 100644
--- a/Lib/fontTools/misc/xmlWriter.py
+++ b/Lib/fontTools/misc/xmlWriter.py
@@ -108,8 +108,7 @@
 	def stringifyattrs(self, *args, **kwargs):
 		if kwargs:
 			assert not args
-			attributes = kwargs.items()
-			attributes.sort()
+			attributes = sorted(kwargs.items())
 		elif args:
 			assert len(args) == 1
 			attributes = args[0]
diff --git a/Lib/fontTools/nfntLib.py b/Lib/fontTools/nfntLib.py
index 8e080d1..980af02 100644
--- a/Lib/fontTools/nfntLib.py
+++ b/Lib/fontTools/nfntLib.py
@@ -276,7 +276,7 @@
 		if not nameOrID:
 			# just take the first in the file
 			res = Res.Get1IndResource(resType, 1)
-		elif type(nameOrID) == types.IntType:
+		elif isinstance(nameOrID, types.IntType):
 			res = Res.Get1Resource(resType, nameOrID)
 		else:
 			res = Res.Get1NamedResource(resType, nameOrID)
diff --git a/Lib/fontTools/pens/pointInsidePen.py b/Lib/fontTools/pens/pointInsidePen.py
index 131c75f..c658f96 100644
--- a/Lib/fontTools/pens/pointInsidePen.py
+++ b/Lib/fontTools/pens/pointInsidePen.py
@@ -120,8 +120,7 @@
 		cy = (y2 - dy) * 3.0
 		by = (y3 - y2) * 3.0 - cy
 		ay = y4 - dy - cy - by
-		solutions = solveCubic(ay, by, cy, dy - y)
-		solutions.sort()
+		solutions = sorted(solveCubic(ay, by, cy, dy - y))
 		solutions = [t for t in solutions if ZERO_MINUS_EPSILON <= t <= ONE_PLUS_EPSILON]
 		if not solutions:
 			return
@@ -176,8 +175,7 @@
 		c = y1
 		b = (y2 - c) * 2.0
 		a = y3 - c - b
-		solutions = solveQuadratic(a, b, c - y)
-		solutions.sort()
+		solutions = sorted(solveQuadratic(a, b, c - y))
 		solutions = [t for t in solutions if ZERO_MINUS_EPSILON <= t <= ONE_PLUS_EPSILON]
 		if not solutions:
 			return
diff --git a/Lib/fontTools/t1Lib.py b/Lib/fontTools/t1Lib.py
index d119f32..cea58c2 100644
--- a/Lib/fontTools/t1Lib.py
+++ b/Lib/fontTools/t1Lib.py
@@ -177,7 +177,7 @@
 	"""reads a PFB font file, returns raw data"""
 	f = open(path, "rb")
 	data = []
-	while 1:
+	while True:
 		if f.read(1) != chr(128):
 			raise T1Error('corrupt PFB file')
 		code = ord(f.read(1))
@@ -311,7 +311,7 @@
 
 def findEncryptedChunks(data):
 	chunks = []
-	while 1:
+	while True:
 		eBegin = string.find(data, EEXECBEGIN)
 		if eBegin < 0:
 			break
diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py
index 251fb30..198d750 100644
--- a/Lib/fontTools/ttLib/__init__.py
+++ b/Lib/fontTools/ttLib/__init__.py
@@ -519,8 +519,7 @@
 	
 	def getGlyphNames(self):
 		"""Get a list of glyph names, sorted alphabetically."""
-		glyphNames = self.getGlyphOrder()[:]
-		glyphNames.sort()
+		glyphNames = sorted(self.getGlyphOrder()[:])
 		return glyphNames
 	
 	def getGlyphNames2(self):
@@ -913,8 +912,7 @@
 	specification, or according to a custom tableOrder. If given and not
 	None, tableOrder needs to be a list of tag names.
 	"""
-	tagList = list(tagList)
-	tagList.sort()
+	tagList = sorted(tagList)
 	if tableOrder is None:
 		if "DSIG" in tagList:
 			# DSIG should be last (XXX spec reference?)
diff --git a/Lib/fontTools/ttLib/macUtils.py b/Lib/fontTools/ttLib/macUtils.py
index 8e65128..3e05177 100644
--- a/Lib/fontTools/ttLib/macUtils.py
+++ b/Lib/fontTools/ttLib/macUtils.py
@@ -60,7 +60,7 @@
 	def __init__(self, path, res_name_or_index):
 		resref = MyOpenResFile(path)
 		Res.UseResFile(resref)
-		if type(res_name_or_index) == type(""):
+		if isinstance(res_name_or_index, type("")):
 			res = Res.Get1NamedResource('sfnt', res_name_or_index)
 		else:
 			res = Res.Get1IndResource('sfnt', res_name_or_index)
diff --git a/Lib/fontTools/ttLib/sfnt.py b/Lib/fontTools/ttLib/sfnt.py
index 112b827..2248236 100644
--- a/Lib/fontTools/ttLib/sfnt.py
+++ b/Lib/fontTools/ttLib/sfnt.py
@@ -173,8 +173,7 @@
 		"""All tables must have been written to disk. Now write the
 		directory.
 		"""
-		tables = self.tables.items()
-		tables.sort()
+		tables = sorted(self.tables.items())
 		if len(tables) != self.numTables:
 			from fontTools import ttLib
 			raise ttLib.TTLibError("wrong number of tables; expected %d, found %d" % (self.numTables, len(tables)))
@@ -250,8 +249,7 @@
 			# Create a SFNT directory for checksum calculation purposes
 			self.searchRange, self.entrySelector, self.rangeShift = getSearchRange(self.numTables)
 			directory = sstruct.pack(sfntDirectoryFormat, self)
-			tables = self.tables.items()
-			tables.sort()
+			tables = sorted(self.tables.items())
 			for tag, entry in tables:
 				sfntEntry = SFNTDirectoryEntry()
 				for item in ['tag', 'checkSum', 'offset', 'length']:
diff --git a/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py b/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py
index 74013fa..4aeaf4b 100644
--- a/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py
+++ b/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py
@@ -40,7 +40,7 @@
 	def fromXML(self, name, attrs, content, ttFont):
 		metricNames = set(sstruct.getformat(self.__class__.binaryFormat)[1])
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			# Make sure this is a metric that is needed by GlyphMetrics.
diff --git a/Lib/fontTools/ttLib/tables/C_O_L_R_.py b/Lib/fontTools/ttLib/tables/C_O_L_R_.py
index 4fcf204..948ce8e 100644
--- a/Lib/fontTools/ttLib/tables/C_O_L_R_.py
+++ b/Lib/fontTools/ttLib/tables/C_O_L_R_.py
@@ -119,7 +119,7 @@
 
 
 	def __getitem__(self, glyphSelector):
-		if type(glyphSelector) == IntType:
+		if isinstance(glyphSelector, IntType):
 			# its a gid, convert to glyph name
 			glyphSelector = self.getGlyphName(glyphSelector)
 
@@ -129,7 +129,7 @@
 		return self.ColorLayers[glyphSelector]
 
 	def __setitem__(self, glyphSelector, value):
-		if type(glyphSelector) == IntType:
+		if isinstance(glyphSelector, IntType):
 			# its a gid, convert to glyph name
 			glyphSelector = self.getGlyphName(glyphSelector)
 
@@ -151,7 +151,7 @@
 	def fromXML(self, eltname, attrs, content, ttFont):
 		for (name, value) in attrs.items():
 			if name == "name":
-				if type(value) == IntType:
+				if isinstance(value, IntType):
 					value = ttFont.getGlyphName(value)
 				setattr(self, name, value)
 			else:
diff --git a/Lib/fontTools/ttLib/tables/DefaultTable.py b/Lib/fontTools/ttLib/tables/DefaultTable.py
index abdb1ca..704546e 100644
--- a/Lib/fontTools/ttLib/tables/DefaultTable.py
+++ b/Lib/fontTools/ttLib/tables/DefaultTable.py
@@ -37,7 +37,7 @@
 		return "<'%s' table at %x>" % (self.tableTag, id(self))
 	
 	def __cmp__(self, other):
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		return cmp(self.__dict__, other.__dict__)
diff --git a/Lib/fontTools/ttLib/tables/E_B_D_T_.py b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
index cfd38f5..e35819d 100644
--- a/Lib/fontTools/ttLib/tables/E_B_D_T_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
@@ -155,7 +155,7 @@
 
 			bitmapGlyphDict = {}
 			for element in content:
-				if type(element) != TupleType:
+				if not isinstance(element, TupleType):
 					continue
 				name, attrs, content = element
 				if name[4:].startswith(_bitmapGlyphSubclassPrefix[4:]):
@@ -191,7 +191,7 @@
 		self.name = attrs['name']
 		componentNames = set(sstruct.getformat(ebdtComponentFormat)[1][1:])
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			if name in componentNames:
@@ -287,7 +287,7 @@
 
 	dataRows = []
 	for element in content:
-		if type(element) != TupleType:
+		if not isinstance(element, TupleType):
 			continue
 		name, attr, content = element
 		# Chop off 'imagedata' from the tag to get just the option.
@@ -328,7 +328,7 @@
 
 	dataRows = []
 	for element in content:
-		if type(element) != TupleType:
+		if not isinstance(element, TupleType):
 			continue
 		name, attr, content = element
 		if name == 'row':
@@ -415,7 +415,7 @@
 	def fromXML(self, name, attrs, content, ttFont):
 		self.readMetrics(name, attrs, content, ttFont)
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attr, content = element
 			# Chop off 'imagedata' from the tag to get just the option.
@@ -464,7 +464,7 @@
 
 		def readMetrics(self, name, attrs, content, ttFont):
 			for element in content:
-				if type(element) != TupleType:
+				if not isinstance(element, TupleType):
 					continue
 				name, attrs, content = element
 				if name == curMetricsName:
@@ -671,13 +671,13 @@
 	def fromXML(self, name, attrs, content, ttFont):
 		self.readMetrics(name, attrs, content, ttFont)
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attr, content = element
 			if name == 'components':
 				self.componentArray = []
 				for compElement in content:
-					if type(compElement) != TupleType:
+					if not isinstance(compElement, TupleType):
 						continue
 					name, attrs, content = compElement
 					if name == 'ebdtComponent':
diff --git a/Lib/fontTools/ttLib/tables/E_B_L_C_.py b/Lib/fontTools/ttLib/tables/E_B_L_C_.py
index 4357f5a..9e91433 100644
--- a/Lib/fontTools/ttLib/tables/E_B_L_C_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_L_C_.py
@@ -242,7 +242,7 @@
 
 	def fromXML(self, name, attrs, content, ttFont, locator):
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			if name == 'bitmapSizeTable':
@@ -282,7 +282,7 @@
 		# bitmap size table. Only read the information from these names.
 		dataNames = set(self._getXMLMetricNames())
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			if name == 'sbitLineMetrics':
@@ -311,7 +311,7 @@
 	def fromXML(self, name, attrs, content, ttFont):
 		metricNames = set(sstruct.getformat(sbitLineMetricsFormat)[1])
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			if name in metricNames:
@@ -378,7 +378,7 @@
 
 		self.names = []
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			if name == 'glyphLoc':
@@ -494,7 +494,7 @@
 
 	def readMetrics(self, name, attrs, content, ttFont):
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			if name == 'imageSize':
diff --git a/Lib/fontTools/ttLib/tables/L_T_S_H_.py b/Lib/fontTools/ttLib/tables/L_T_S_H_.py
index 23c3d7c..bae8778 100644
--- a/Lib/fontTools/ttLib/tables/L_T_S_H_.py
+++ b/Lib/fontTools/ttLib/tables/L_T_S_H_.py
@@ -35,8 +35,7 @@
 		return struct.pack(">HH", version, numGlyphs) + yPels.tostring()
 	
 	def toXML(self, writer, ttFont):
-		names = self.yPels.keys()
-		names.sort()
+		names = sorted(self.yPels.keys())
 		for name in names:
 			writer.simpletag("yPel", name=name, value=self.yPels[name])
 			writer.newline()
diff --git a/Lib/fontTools/ttLib/tables/M_E_T_A_.py b/Lib/fontTools/ttLib/tables/M_E_T_A_.py
index 15e29c7..4c51e74 100644
--- a/Lib/fontTools/ttLib/tables/M_E_T_A_.py
+++ b/Lib/fontTools/ttLib/tables/M_E_T_A_.py
@@ -229,7 +229,7 @@
 		"""Compare method, so a list of NameRecords can be sorted
 		according to the spec by just sorting it..."""
 
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		return cmp(self.glyphID, other.glyphID)
@@ -314,7 +314,7 @@
 		"""Compare method, so a list of NameRecords can be sorted
 		according to the spec by just sorting it..."""
 
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		return cmp(self.labelID, other.labelID)
diff --git a/Lib/fontTools/ttLib/tables/O_S_2f_2.py b/Lib/fontTools/ttLib/tables/O_S_2f_2.py
index 7df581a..7428719 100644
--- a/Lib/fontTools/ttLib/tables/O_S_2f_2.py
+++ b/Lib/fontTools/ttLib/tables/O_S_2f_2.py
@@ -172,7 +172,7 @@
 		if name == "panose":
 			self.panose = panose = Panose()
 			for element in content:
-				if type(element) == TupleType:
+				if isinstance(element, TupleType):
 					name, attrs, content = element
 					panose.fromXML(name, attrs, content, ttFont)
 		elif name in ("ulUnicodeRange1", "ulUnicodeRange2", 
diff --git a/Lib/fontTools/ttLib/tables/S_V_G_.py b/Lib/fontTools/ttLib/tables/S_V_G_.py
index f41e7d3..97d0b82 100644
--- a/Lib/fontTools/ttLib/tables/S_V_G_.py
+++ b/Lib/fontTools/ttLib/tables/S_V_G_.py
@@ -327,7 +327,7 @@
 
 	def fromXML(self, name, attrs, content, ttFont):
 		for element in content:
-			if type(element) == type(""):
+			if isinstance(element, type("")):
 				continue
 			name, attrib, content = element
 			if name == "colorParamUINameID":
@@ -352,7 +352,7 @@
 	def fromXML(self, name, attrs, content, ttFont):
 		self.uiNameID = int(attrs["uiNameID"])
 		for element in content:
-			if type(element) == type(""):
+			if isinstance(element, type("")):
 				continue
 			name, attrib, content = element
 			if name == "colorRecord":
diff --git a/Lib/fontTools/ttLib/tables/T_S_I__1.py b/Lib/fontTools/ttLib/tables/T_S_I__1.py
index 53f02ba..d2a9465 100644
--- a/Lib/fontTools/ttLib/tables/T_S_I__1.py
+++ b/Lib/fontTools/ttLib/tables/T_S_I__1.py
@@ -59,8 +59,7 @@
 			data = data + text
 		
 		extra_indices = []
-		codes = self.extras.items()
-		codes.sort()
+		codes = sorted(self.extras.items())
 		for i in range(len(codes)):
 			if len(data) % 2:
 				data = data + "\015"  # align on 2-byte boundaries, fill with return chars.
@@ -78,8 +77,7 @@
 		return data
 	
 	def toXML(self, writer, ttFont):
-		names = self.glyphPrograms.keys()
-		names.sort()
+		names = sorted(self.glyphPrograms.keys())
 		writer.newline()
 		for name in names:
 			text = self.glyphPrograms[name]
diff --git a/Lib/fontTools/ttLib/tables/T_S_I__5.py b/Lib/fontTools/ttLib/tables/T_S_I__5.py
index f81d33e..5a6f26c 100644
--- a/Lib/fontTools/ttLib/tables/T_S_I__5.py
+++ b/Lib/fontTools/ttLib/tables/T_S_I__5.py
@@ -28,8 +28,7 @@
 		return a.tostring()
 	
 	def toXML(self, writer, ttFont):
-		names = self.glyphGrouping.keys()
-		names.sort()
+		names = sorted(self.glyphGrouping.keys())
 		for glyphName in names:
 			writer.simpletag("glyphgroup", name=glyphName, value=self.glyphGrouping[glyphName])
 			writer.newline()
diff --git a/Lib/fontTools/ttLib/tables/V_O_R_G_.py b/Lib/fontTools/ttLib/tables/V_O_R_G_.py
index 832402f..30c6096 100644
--- a/Lib/fontTools/ttLib/tables/V_O_R_G_.py
+++ b/Lib/fontTools/ttLib/tables/V_O_R_G_.py
@@ -96,7 +96,7 @@
 
 
 	def __getitem__(self, glyphSelector):
-		if type(glyphSelector) == IntType:
+		if isinstance(glyphSelector, IntType):
 			# its a gid, convert to glyph name
 			glyphSelector = self.getGlyphName(glyphSelector)
 
@@ -106,7 +106,7 @@
 		return self.VOriginRecords[glyphSelector]
 
 	def __setitem__(self, glyphSelector, value):
-		if type(glyphSelector) == IntType:
+		if isinstance(glyphSelector, IntType):
 			# its a gid, convert to glyph name
 			glyphSelector = self.getGlyphName(glyphSelector)
 
diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
index aea7969..90225b6 100644
--- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py
+++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
@@ -132,8 +132,7 @@
 				("language", self.language),
 				])
 		writer.newline()
-		codes = self.cmap.items()
-		codes.sort()
+		codes = sorted(self.cmap.items())
 		self._writeCodes(codes, writer)
 		writer.endtag(self.__class__.__name__)
 		writer.newline()
@@ -151,7 +150,7 @@
 			writer.newline()
 	
 	def __cmp__(self, other):
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 
 		# implemented so that list.sort() sorts according to the cmap spec.
 		selfTuple = (
@@ -191,8 +190,7 @@
 		if self.data:
 			return struct.pack(">HHH", 0, 262, self.language) + self.data
 
-		charCodeList = self.cmap.items()
-		charCodeList.sort()
+		charCodeList = sorted(self.cmap.items())
 		charCodes = [entry[0] for entry in charCodeList]
 		valueList = [entry[1] for entry in charCodeList]
 		assert charCodes == list(range(256))
@@ -209,7 +207,7 @@
 			self.cmap = {}
 		cmap = self.cmap
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			if name != "map":
@@ -380,8 +378,7 @@
 		kEmptyTwoCharCodeRange = -1
 		notdefGI = 0
 
-		items = self.cmap.items()
-		items.sort()
+		items = sorted(self.cmap.items())
 		charCodes = [item[0] for item in items]
 		names = [item[1] for item in items]
 		nameMap = ttFont.getReverseGlyphMap()
@@ -529,7 +526,7 @@
 		cmap = self.cmap
 
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			if name != "map":
@@ -821,7 +818,7 @@
 		cmap = self.cmap
 
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			nameMap, attrsMap, dummyContent = element
 			if nameMap != "map":
@@ -890,7 +887,7 @@
 		cmap = self.cmap
 
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			if name != "map":
@@ -1016,8 +1013,7 @@
 				("nGroups", self.nGroups),
 				])
 		writer.newline()
-		codes = self.cmap.items()
-		codes.sort()
+		codes = sorted(self.cmap.items())
 		self._writeCodes(codes, writer)
 		writer.endtag(self.__class__.__name__)
 		writer.newline()
@@ -1033,7 +1029,7 @@
 		cmap = self.cmap
 
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			if name != "map":
@@ -1164,8 +1160,7 @@
 				])
 		writer.newline()
 		uvsDict = self.uvsDict
-		uvsList = uvsDict.keys()
-		uvsList.sort()
+		uvsList = sorted(uvsDict.keys())
 		for uvs in uvsList:
 			uvList = uvsDict[uvs]
 			uvList.sort(cmpUVSListEntry)
@@ -1190,7 +1185,7 @@
 			uvsDict = self.uvsDict 
 
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			if name != "map":
@@ -1211,8 +1206,7 @@
 			return struct.pack(">HLL", self.format, self.length , self.numVarSelectorRecords) + self.data
 
 		uvsDict = self.uvsDict
-		uvsList = uvsDict.keys()
-		uvsList.sort()
+		uvsList = sorted(uvsDict.keys())
 		self.numVarSelectorRecords = len(uvsList)
 		offset = 10 + self.numVarSelectorRecords*11 # current value is end of VarSelectorRecords block.
 		data = []
diff --git a/Lib/fontTools/ttLib/tables/_g_a_s_p.py b/Lib/fontTools/ttLib/tables/_g_a_s_p.py
index 0efbbd0..3e69ca2 100644
--- a/Lib/fontTools/ttLib/tables/_g_a_s_p.py
+++ b/Lib/fontTools/ttLib/tables/_g_a_s_p.py
@@ -25,8 +25,7 @@
 		version = 0 # ignore self.version
 		numRanges = len(self.gaspRange)
 		data = ""
-		items = self.gaspRange.items()
-		items.sort()
+		items = sorted(self.gaspRange.items())
 		for rangeMaxPPEM, rangeGaspBehavior in items:
 			data = data + struct.pack(">HH", rangeMaxPPEM, rangeGaspBehavior)
 			if rangeGaspBehavior & ~(GASP_GRIDFIT | GASP_DOGRAY):
@@ -35,8 +34,7 @@
 		return data
 	
 	def toXML(self, writer, ttFont):
-		items = self.gaspRange.items()
-		items.sort()
+		items = sorted(self.gaspRange.items())
 		for rangeMaxPPEM, rangeGaspBehavior in items:
 			writer.simpletag("gaspRange", [
 					("rangeMaxPPEM", rangeMaxPPEM),
diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
index cdc8213..601794b 100644
--- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py
+++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
@@ -124,7 +124,7 @@
 			setattr(glyph, attr, safeEval(attrs.get(attr, '0')))
 		self.glyphs[glyphName] = glyph
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			glyph.fromXML(name, attrs, content, ttFont)
@@ -290,7 +290,7 @@
 			coordinates = GlyphCoordinates()
 			flags = []
 			for element in content:
-				if type(element) != TupleType:
+				if not isinstance(element, TupleType):
 					continue
 				name, attrs, content = element
 				if name != "pt":
@@ -318,7 +318,7 @@
 		elif name == "instructions":
 			self.program = ttProgram.Program()
 			for element in content:
-				if type(element) != TupleType:
+				if not isinstance(element, TupleType):
 					continue
 				name, attrs, content = element
 				self.program.fromXML(name, attrs, content, ttFont)
@@ -425,7 +425,7 @@
 		xFormat = ">" # big endian
 		yFormat = ">" # big endian
 		i = j = 0
-		while 1:
+		while True:
 			flag = ord(data[i])
 			i = i + 1
 			repeat = 1
@@ -672,7 +672,7 @@
 					# padding.
 					coordBytes = 0
 					j = 0
-					while 1:
+					while True:
 						flag = data[i]
 						i = i + 1
 						repeat = 1
@@ -725,7 +725,7 @@
 		self.data = data
 	
 	def __cmp__(self, other):
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		return cmp(self.__dict__, other.__dict__)
@@ -888,7 +888,7 @@
 		self.flags = safeEval(attrs["flags"])
 	
 	def __cmp__(self, other):
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		return cmp(self.__dict__, other.__dict__)
@@ -971,7 +971,7 @@
 
 def reprflag(flag):
 	bin = ""
-	if type(flag) == StringType:
+	if isinstance(flag, StringType):
 		flag = ord(flag)
 	while flag:
 		if flag & 0x01:
diff --git a/Lib/fontTools/ttLib/tables/_h_d_m_x.py b/Lib/fontTools/ttLib/tables/_h_d_m_x.py
index 617daf9..5a46a91 100644
--- a/Lib/fontTools/ttLib/tables/_h_d_m_x.py
+++ b/Lib/fontTools/ttLib/tables/_h_d_m_x.py
@@ -34,8 +34,7 @@
 		pad = (self.recordSize - 2 - numGlyphs) * "\0"
 		self.numRecords = len(self.hdmx)
 		data = sstruct.pack(hdmxHeaderFormat, self)
-		items = self.hdmx.items()
-		items.sort()
+		items = sorted(self.hdmx.items())
 		for ppem, widths in items:
 			data = data + chr(ppem) + chr(max(widths.values()))
 			for glyphID in range(len(glyphOrder)):
@@ -47,8 +46,7 @@
 	def toXML(self, writer, ttFont):
 		writer.begintag("hdmxData")
 		writer.newline()
-		ppems = self.hdmx.keys()
-		ppems.sort()
+		ppems = sorted(self.hdmx.keys())
 		records = []
 		format = ""
 		for ppem in ppems:
diff --git a/Lib/fontTools/ttLib/tables/_h_e_a_d.py b/Lib/fontTools/ttLib/tables/_h_e_a_d.py
index 38f60bf..d1879df 100644
--- a/Lib/fontTools/ttLib/tables/_h_e_a_d.py
+++ b/Lib/fontTools/ttLib/tables/_h_e_a_d.py
@@ -87,7 +87,7 @@
 		setattr(self, name, value)
 	
 	def __cmp__(self, other):
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		selfdict = self.__dict__.copy()
diff --git a/Lib/fontTools/ttLib/tables/_h_m_t_x.py b/Lib/fontTools/ttLib/tables/_h_m_t_x.py
index a750789..bde72e4 100644
--- a/Lib/fontTools/ttLib/tables/_h_m_t_x.py
+++ b/Lib/fontTools/ttLib/tables/_h_m_t_x.py
@@ -72,8 +72,7 @@
 		return data
 	
 	def toXML(self, writer, ttFont):
-		names = self.metrics.keys()
-		names.sort()
+		names = sorted(self.metrics.keys())
 		for glyphName in names:
 			advance, sb = self.metrics[glyphName]
 			writer.simpletag("mtx", [
diff --git a/Lib/fontTools/ttLib/tables/_k_e_r_n.py b/Lib/fontTools/ttLib/tables/_k_e_r_n.py
index f38e9bf..b987a05 100644
--- a/Lib/fontTools/ttLib/tables/_k_e_r_n.py
+++ b/Lib/fontTools/ttLib/tables/_k_e_r_n.py
@@ -120,10 +120,9 @@
 		data = struct.pack(">HHHH", nPairs, searchRange, entrySelector, rangeShift)
 		
 		# yeehee! (I mean, turn names into indices)
-		kernTable = map(lambda ((left, right), value), getGlyphID=ttFont.getGlyphID:
+		kernTable = sorted(map(lambda ((left, right), value), getGlyphID=ttFont.getGlyphID:
 					(getGlyphID(left), getGlyphID(right), value), 
-				self.kernTable.items())
-		kernTable.sort()
+				self.kernTable.items()))
 		for left, right, value in kernTable:
 			data = data + struct.pack(">HHh", left, right, value)
 		return struct.pack(">HHH", self.version, len(data) + 6, self.coverage) + data
@@ -131,8 +130,7 @@
 	def toXML(self, writer, ttFont):
 		writer.begintag("kernsubtable", coverage=self.coverage, format=0)
 		writer.newline()
-		items = self.kernTable.items()
-		items.sort()
+		items = sorted(self.kernTable.items())
 		for (left, right), value in items:
 			writer.simpletag("pair", [
 					("l", left),
@@ -149,7 +147,7 @@
 		if not hasattr(self, "kernTable"):
 			self.kernTable = {}
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			self.kernTable[(attrs["l"], attrs["r"])] = safeEval(attrs["v"])
@@ -164,7 +162,7 @@
 		del self.kernTable[pair]
 	
 	def __cmp__(self, other):
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		return cmp(self.__dict__, other.__dict__)
diff --git a/Lib/fontTools/ttLib/tables/_l_o_c_a.py b/Lib/fontTools/ttLib/tables/_l_o_c_a.py
index 32e6dc3..1ef4d54 100644
--- a/Lib/fontTools/ttLib/tables/_l_o_c_a.py
+++ b/Lib/fontTools/ttLib/tables/_l_o_c_a.py
@@ -60,7 +60,7 @@
 		return len(self.locations)
 	
 	def __cmp__(self, other):
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		return cmp(self.locations, other.locations)
diff --git a/Lib/fontTools/ttLib/tables/_m_a_x_p.py b/Lib/fontTools/ttLib/tables/_m_a_x_p.py
index 79b8473..737af07 100644
--- a/Lib/fontTools/ttLib/tables/_m_a_x_p.py
+++ b/Lib/fontTools/ttLib/tables/_m_a_x_p.py
@@ -112,8 +112,7 @@
 			headTable.flags = headTable.flags & ~0x2
 	
 	def testrepr(self):
-		items = self.__dict__.items()
-		items.sort()
+		items = sorted(self.__dict__.items())
 		print ". . . . . . . . ."
 		for combo in items:
 			print "  %s: %s" % combo
diff --git a/Lib/fontTools/ttLib/tables/_n_a_m_e.py b/Lib/fontTools/ttLib/tables/_n_a_m_e.py
index e289533..b1ef1f4 100644
--- a/Lib/fontTools/ttLib/tables/_n_a_m_e.py
+++ b/Lib/fontTools/ttLib/tables/_n_a_m_e.py
@@ -89,7 +89,7 @@
 		return None # not found
 	
 	def __cmp__(self, other):
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		return cmp(self.names, other.names)
@@ -138,7 +138,7 @@
 		"""Compare method, so a list of NameRecords can be sorted
 		according to the spec by just sorting it..."""
 
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 
 		selftuple = (
 			getattr(self, "platformID", None),
diff --git a/Lib/fontTools/ttLib/tables/_p_o_s_t.py b/Lib/fontTools/ttLib/tables/_p_o_s_t.py
index 9cfd7c7..e26c3a0 100644
--- a/Lib/fontTools/ttLib/tables/_p_o_s_t.py
+++ b/Lib/fontTools/ttLib/tables/_p_o_s_t.py
@@ -165,8 +165,7 @@
 						"ps name mapping for those cases where they differ. That's what\n"
 						"you see below.\n")
 			writer.newline()
-			items = self.mapping.items()
-			items.sort()
+			items = sorted(self.mapping.items())
 			for name, psName in items:
 				writer.simpletag("psName", name=name, psName=psName)
 				writer.newline()
@@ -195,7 +194,7 @@
 		elif name == "psNames":
 			self.mapping = {}
 			for element in content:
-				if type(element) != TupleType:
+				if not isinstance(element, TupleType):
 					continue
 				name, attrs, content = element
 				if name == "psName":
@@ -203,7 +202,7 @@
 		elif name == "extraNames":
 			self.extraNames = []
 			for element in content:
-				if type(element) != TupleType:
+				if not isinstance(element, TupleType):
 					continue
 				name, attrs, content = element
 				if name == "psName":
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index fcbc5e1..cac8a40 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -43,8 +43,7 @@
 		self.table = tableClass()
 		self.table.decompile(reader, font)
 		if cachingStats:
-			stats = [(v, k) for k, v in cachingStats.items()]
-			stats.sort()
+			stats = sorted([(v, k) for k, v in cachingStats.items()])
 			stats.reverse()
 			print "cachingsstats for ", self.tableTag
 			for v, k in stats:
@@ -289,7 +288,7 @@
 		return hash(self.items)
 	
 	def __cmp__(self, other):
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		return cmp(self.items, other.items)
@@ -675,7 +674,7 @@
 			setattr(self, conv.name, value)
 	
 	def __cmp__(self, other):
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		self.ensureDecompiled()
@@ -829,19 +828,19 @@
 		for k, v in attrs.items():
 			setattr(self, k, int(v))
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			value = getattr(otTables, name)()
 			for elem2 in content:
-				if type(elem2) != TupleType:
+				if not isinstance(elem2, TupleType):
 					continue
 				name2, attrs2, content2 = elem2
 				value.fromXML(name2, attrs2, content2, font)
 			setattr(self, name, value)
 	
 	def __cmp__(self, other):
-		if type(self) != type(other): return cmp(type(self), type(other))
+		if not isinstance(self, type(other)): return cmp(type(self), type(other))
 		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
 
 		return cmp(self.__dict__, other.__dict__)
diff --git a/Lib/fontTools/ttLib/tables/otConverters.py b/Lib/fontTools/ttLib/tables/otConverters.py
index 73cd16e..03a1a1f 100644
--- a/Lib/fontTools/ttLib/tables/otConverters.py
+++ b/Lib/fontTools/ttLib/tables/otConverters.py
@@ -198,7 +198,7 @@
 		if Format is not None:
 			table.Format = int(Format)
 		for element in content:
-			if type(element) == TupleType:
+			if isinstance(element, TupleType):
 				name, attrs, content = element
 				table.fromXML(name, attrs, content, font)
 			else:
diff --git a/Lib/fontTools/ttLib/tables/otTables.py b/Lib/fontTools/ttLib/tables/otTables.py
index a877b77..71c6f24 100644
--- a/Lib/fontTools/ttLib/tables/otTables.py
+++ b/Lib/fontTools/ttLib/tables/otTables.py
@@ -163,8 +163,7 @@
 		items = mapping.items()
 		getGlyphID = font.getGlyphID
 		gidItems = [(getGlyphID(item[0]), getGlyphID(item[1])) for item in items]
-		sortableItems = list(zip(gidItems, items))
-		sortableItems.sort()
+		sortableItems = sorted(zip(gidItems, items))
 
 		# figure out format
 		format = 2
@@ -193,8 +192,7 @@
 		return rawTable
 	
 	def toXML2(self, xmlWriter, font):
-		items = self.mapping.items()
-		items.sort()
+		items = sorted(self.mapping.items())
 		for inGlyph, outGlyph in items:
 			xmlWriter.simpletag("Substitution",
 					[("in", inGlyph), ("out", outGlyph)])
@@ -273,8 +271,7 @@
 		return {"ClassRangeRecord": ranges}
 	
 	def toXML2(self, xmlWriter, font):
-		items = self.classDefs.items()
-		items.sort()
+		items = sorted(self.classDefs.items())
 		for glyphName, cls in items:
 			xmlWriter.simpletag("ClassDef", [("glyph", glyphName), ("class", cls)])
 			xmlWriter.newline()
@@ -329,8 +326,7 @@
 		return {"Coverage": cov, "AlternateSet": alternates}
 	
 	def toXML2(self, xmlWriter, font):
-		items = self.alternates.items()
-		items.sort()
+		items = sorted(self.alternates.items())
 		for glyphName, alternates in items:
 			xmlWriter.begintag("AlternateSet", glyph=glyphName)
 			xmlWriter.newline()
@@ -349,7 +345,7 @@
 		set = []
 		alternates[glyphName] = set
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			set.append(attrs["glyph"])
@@ -396,8 +392,7 @@
 		return {"Coverage": cov, "LigatureSet": ligSets}
 	
 	def toXML2(self, xmlWriter, font):
-		items = self.ligatures.items()
-		items.sort()
+		items = sorted(self.ligatures.items())
 		for glyphName, ligSets in items:
 			xmlWriter.begintag("LigatureSet", glyph=glyphName)
 			xmlWriter.newline()
@@ -417,7 +412,7 @@
 		ligs = []
 		ligatures[glyphName] = ligs
 		for element in content:
-			if type(element) != TupleType:
+			if not isinstance(element, TupleType):
 				continue
 			name, attrs, content = element
 			lig = Ligature()
@@ -523,8 +518,7 @@
 	if hasattr(oldSubTable, 'sortCoverageLast'):
 		newSubTable.sortCoverageLast = oldSubTable.sortCoverageLast
 	
-	oldAlts = oldSubTable.alternates.items()
-	oldAlts.sort()
+	oldAlts = sorted(oldSubTable.alternates.items())
 	oldLen = len(oldAlts)
 
 	if overflowRecord.itemName in [ 'Coverage', 'RangeRecord']:
@@ -552,8 +546,7 @@
 def splitLigatureSubst(oldSubTable, newSubTable, overflowRecord):
 	ok = 1
 	newSubTable.Format = oldSubTable.Format
-	oldLigs = oldSubTable.ligatures.items()
-	oldLigs.sort()
+	oldLigs = sorted(oldSubTable.ligatures.items())
 	oldLen = len(oldLigs)
 
 	if overflowRecord.itemName in [ 'Coverage', 'RangeRecord']:
diff --git a/Lib/fontTools/ttLib/tables/ttProgram.py b/Lib/fontTools/ttLib/tables/ttProgram.py
index e6f79ab..92dd0e2 100644
--- a/Lib/fontTools/ttLib/tables/ttProgram.py
+++ b/Lib/fontTools/ttLib/tables/ttProgram.py
@@ -269,7 +269,7 @@
 			skipWhite=_skipWhite, mnemonicDict=mnemonicDict, strip=string.strip,
 			binary2num=binary2num):
 		assembly = self.assembly
-		if type(assembly) == type([]):
+		if isinstance(assembly, type([])):
 			assembly = string.join(assembly, " ")
 		bytecode = []
 		push = bytecode.append
diff --git a/Lib/fontTools/ttx.py b/Lib/fontTools/ttx.py
index 2e477ef..cd42084 100644
--- a/Lib/fontTools/ttx.py
+++ b/Lib/fontTools/ttx.py
@@ -173,8 +173,7 @@
 	import string
 	ttf = TTFont(input, fontNumber=options.fontNumber, lazy=True)
 	reader = ttf.reader
-	tags = reader.keys()
-	tags.sort()
+	tags = sorted(reader.keys())
 	print 'Listing table info for "%s":' % input
 	format = "    %4s  %10s  %7s  %7s"
 	print format % ("tag ", "  checksum", " length", " offset")
@@ -224,7 +223,7 @@
 		overflowRecord = e.value
 		print "Attempting to fix OTLOffsetOverflowError", e
 		lastItem = overflowRecord 
-		while 1:
+		while True:
 			ok = 0
 			if overflowRecord.itemName == None:
 				ok = fixLookupOverFlows(ttf, overflowRecord)
diff --git a/MetaTools/roundTrip.py b/MetaTools/roundTrip.py
index 9438f0b..4b13006 100755
--- a/MetaTools/roundTrip.py
+++ b/MetaTools/roundTrip.py
@@ -46,7 +46,7 @@
 		diffcmd = 'diff -U2 -I ".*modified value\|checkSumAdjustment.*" "%s" "%s"' % (xmlFile1, xmlFile2)
 		output = os.popen(diffcmd, "r", 1)
 		lines = []
-		while 1:
+		while True:
 			line = output.readline()
 			if not line:
 				break