Fix a few pychecker warnings

Fixes https://github.com/behdad/fonttools/issues/58
diff --git a/Lib/fontTools/afmLib.py b/Lib/fontTools/afmLib.py
index ac31563..fea320d 100644
--- a/Lib/fontTools/afmLib.py
+++ b/Lib/fontTools/afmLib.py
@@ -8,9 +8,6 @@
 from fontTools.misc.py23 import *
 import re
 
-__version__ = "$Id: afmLib.py,v 1.6 2003-05-24 12:50:47 jvr Exp $"
-
-
 # every single line starts with a "word"
 identifierRE = re.compile("^([A-Za-z]+).*")
 
@@ -194,8 +191,7 @@
 	def write(self, path, sep='\r'):
 		import time
 		lines = [	"StartFontMetrics 2.0",
-				"Comment Generated by afmLib, version %s; at %s" % 
-						(__version__.split()[2],
+				"Comment Generated by afmLib; at %s" % 
 						time.strftime("%m/%d/%Y %H:%M:%S", 
 						time.localtime(time.time())))]
 		
diff --git a/Lib/fontTools/cffLib.py b/Lib/fontTools/cffLib.py
index 9265ebc..537fd98 100644
--- a/Lib/fontTools/cffLib.py
+++ b/Lib/fontTools/cffLib.py
@@ -479,7 +479,7 @@
 						gidArray[glyphID] = fd
 				self.gidArray = gidArray
 			else:
-				assert 0, "unsupported FDSelect format: %s" % format
+				assert False, "unsupported FDSelect format: %s" % format
 		else:
 			# reading from XML. Make empty gidArray,, and leave format as passed in.
 			# format == None will result in the smallest representation being used.
@@ -741,7 +741,7 @@
 		priv = PrivateDict(parent.strings, file, offset)
 		file.seek(offset)
 		data = file.read(size)
-		len(data) == size
+		assert len(data) == size
 		priv.decompile(data)
 		return priv
 	def write(self, parent, value):
@@ -857,8 +857,8 @@
 	return strings.getSID(name)
 
 def packCharset0(charset, isCID, strings):
-	format = 0
-	data = [packCard8(format)]
+	fmt = 0
+	data = [packCard8(fmt)]
 	if isCID:
 		getNameID = getCIDfromName
 	else:
@@ -870,7 +870,7 @@
 
 
 def packCharset(charset, isCID, strings):
-	format = 1
+	fmt = 1
 	ranges = []
 	first = None
 	end = 0
@@ -886,17 +886,17 @@
 		elif end + 1 != SID:
 			nLeft = end - first
 			if nLeft > 255:
-				format = 2
+				fmt = 2
 			ranges.append((first, nLeft))
 			first = SID
 		end = SID
 	nLeft = end - first
 	if nLeft > 255:
-		format = 2
+		fmt = 2
 	ranges.append((first, nLeft))
 	
-	data = [packCard8(format)]
-	if format == 1:
+	data = [packCard8(fmt)]
+	if fmt == 1:
 		nLeftFunc = packCard8
 	else:
 		nLeftFunc = packCard16
@@ -916,10 +916,10 @@
 			charset.append(strings[SID])
 	return charset
 
-def parseCharset(numGlyphs, file, strings, isCID, format):
+def parseCharset(numGlyphs, file, strings, isCID, fmt):
 	charset = ['.notdef']
 	count = 1
-	if format == 1:
+	if fmt == 1:
 		nLeftFunc = readCard8
 	else:
 		nLeftFunc = readCard16
@@ -971,15 +971,15 @@
 			file.seek(value)
 			if DEBUG:
 				print("loading Encoding at %s" % value)
-			format = readCard8(file)
-			haveSupplement = format & 0x80
+			fmt = readCard8(file)
+			haveSupplement = fmt & 0x80
 			if haveSupplement:
 				raise NotImplementedError("Encoding supplements are not yet supported")
-			format = format & 0x7f
-			if format == 0:
+			fmt = fmt & 0x7f
+			if fmt == 0:
 				encoding = parseEncoding0(parent.charset, file, haveSupplement,
 						parent.strings)
-			elif format == 1:
+			elif fmt == 1:
 				encoding = parseEncoding1(parent.charset, file, haveSupplement,
 						parent.strings)
 			return encoding
@@ -1043,7 +1043,7 @@
 	return encoding
 
 def packEncoding0(charset, encoding, strings):
-	format = 0
+	fmt = 0
 	m = {}
 	for code in range(len(encoding)):
 		name = encoding[code]
@@ -1057,7 +1057,7 @@
 	while codes and codes[-1] is None:
 		codes.pop()
 
-	data = [packCard8(format), packCard8(len(codes))]
+	data = [packCard8(fmt), packCard8(len(codes))]
 	for code in codes:
 		if code is None:
 			code = 0
@@ -1065,7 +1065,7 @@
 	return bytesjoin(data)
 
 def packEncoding1(charset, encoding, strings):
-	format = 1
+	fmt = 1
 	m = {}
 	for code in range(len(encoding)):
 		name = encoding[code]
@@ -1090,7 +1090,7 @@
 	while ranges and ranges[-1][0] == -1:
 		ranges.pop()
 
-	data = [packCard8(format), packCard8(len(ranges))]
+	data = [packCard8(fmt), packCard8(len(ranges))]
 	for first, nLeft in ranges:
 		if first == -1:  # unencoded
 			first = 0
@@ -1139,23 +1139,23 @@
 		xmlWriter.newline()
 
 	def xmlRead(self, name, attrs, content, parent):
-		format = safeEval(attrs["format"])
+		fmt = safeEval(attrs["format"])
 		file = None
 		numGlyphs = None
-		fdSelect = FDSelect(file, numGlyphs, format)
+		fdSelect = FDSelect(file, numGlyphs, fmt)
 		return fdSelect
 		
 
 def packFDSelect0(fdSelectArray):
-	format = 0
-	data = [packCard8(format)]
+	fmt = 0
+	data = [packCard8(fmt)]
 	for index in fdSelectArray:
 		data.append(packCard8(index))
 	return bytesjoin(data)
 
 
 def packFDSelect3(fdSelectArray):
-	format = 3
+	fmt = 3
 	fdRanges = []
 	first = None
 	end = 0
@@ -1168,7 +1168,7 @@
 			lastFDIndex = fdIndex
 	sentinelGID = i + 1
 		
-	data = [packCard8(format)]
+	data = [packCard8(fmt)]
 	data.append(packCard16( len(fdRanges) ))
 	for fdRange in fdRanges:
 		data.append(packCard16(fdRange[0]))
@@ -1180,11 +1180,11 @@
 class FDSelectCompiler(object):
 	
 	def __init__(self, fdSelect, parent):
-		format = fdSelect.format
+		fmt = fdSelect.format
 		fdSelectArray = fdSelect.gidArray
-		if format == 0:
+		if fmt == 0:
 			self.data = packFDSelect0(fdSelectArray)
-		elif format == 3:
+		elif fmt == 3:
 			self.data = packFDSelect3(fdSelectArray)
 		else:
 			# choose smaller of the two formats
@@ -1300,7 +1300,7 @@
 		elif arg == "SID":
 			conv = ASCIIConverter()
 		else:
-			assert 0
+			assert False
 		table[i] = op, name, arg, default, conv
 
 addConverters(privateDictOperators)
@@ -1417,7 +1417,6 @@
 			if len(fdSelect) == 0: # probably read in from XML; assume fdIndex in CharString data
 				charStrings = self.dictObj.CharStrings
 				for name in self.dictObj.charset:
-					charstring = charStrings[name]
 					fdSelect.append(charStrings[name].fdSelectIndex)
 			fdSelectComp = FDSelectCompiler(fdSelect, self)
 			children.append(fdSelectComp)
@@ -1567,8 +1566,8 @@
 			except:
 				print("Error in charstring ", i)
 				import sys
-				type, value = sys. exc_info()[0:2]
-				raise type(value)
+				typ, value = sys.exc_info()[0:2]
+				raise typ(value)
 			if not i % 30 and progress:
 				progress.increment(0)  # update
 			i = i + 1
diff --git a/Lib/fontTools/inspect.py b/Lib/fontTools/inspect.py
index 93186f0..2f61edd 100644
--- a/Lib/fontTools/inspect.py
+++ b/Lib/fontTools/inspect.py
@@ -12,7 +12,6 @@
 pygtk.require('2.0')
 import gtk
 import sys
-import array
 
 
 
@@ -120,7 +119,7 @@
 			return len(self._children)
 		if hasattr(self, '_items'):
 			return len(self._items)
-		assert 0
+		assert False
 
 	def _ensure_children(self):
 		if hasattr(self, '_children'):
diff --git a/Lib/fontTools/misc/arrayTools.py b/Lib/fontTools/misc/arrayTools.py
index 8ed5d6d..f680578 100644
--- a/Lib/fontTools/misc/arrayTools.py
+++ b/Lib/fontTools/misc/arrayTools.py
@@ -117,7 +117,6 @@
     the resulting rectangle is NOT smaller than the original.
     """
     (xMin, yMin, xMax, yMax) = rect1
-    import math
     xMin = int(math.floor(xMin))
     yMin = int(math.floor(yMin))
     xMax = int(math.ceil(xMax))
diff --git a/Lib/fontTools/misc/bezierTools.py b/Lib/fontTools/misc/bezierTools.py
index 179ab3c..9e38422 100644
--- a/Lib/fontTools/misc/bezierTools.py
+++ b/Lib/fontTools/misc/bezierTools.py
@@ -88,18 +88,16 @@
     """
     pt1x, pt1y = pt1
     pt2x, pt2y = pt2
-    
+
     ax = (pt2x - pt1x)
     ay = (pt2y - pt1y)
-    
+
     bx = pt1x
     by = pt1y
-    
-    ax1 = (ax, ay)[isHorizontal]
-    
+
     if ax == 0:
         return [(pt1, pt2)]
-        
+
     t = (where - (bx, by)[isHorizontal]) / ax
     if 0 <= t < 1:
         midPt = ax * t + bx, ay * t + by
@@ -281,8 +279,7 @@
     return roots
 
 
-def solveCubic(a, b, c, d,
-        abs=abs, pow=pow, sqrt=sqrt, cos=cos, acos=acos, pi=pi):
+def solveCubic(a, b, c, d):
     """Solve a cubic equation where a, b, c and d are real.
         a*x*x*x + b*x*x + c*x + d = 0
     This function returns a list of roots. Note that the returned list
diff --git a/Lib/fontTools/misc/eexec.py b/Lib/fontTools/misc/eexec.py
index 1264355..26d596c 100644
--- a/Lib/fontTools/misc/eexec.py
+++ b/Lib/fontTools/misc/eexec.py
@@ -55,7 +55,7 @@
 
 
 def _test():
-	import fontTools.misc.eexecOp as eexecOp
+	import fontTools.misc.eexecOp
 	testStr = "\0\0asdadads asds\265"
 	print(decrypt, decrypt(testStr, 12321))
 	print(eexecOp.decrypt, eexecOp.decrypt(testStr, 12321))
diff --git a/Lib/fontTools/misc/psCharStrings.py b/Lib/fontTools/misc/psCharStrings.py
index 6b5bc6f..b89a8a2 100644
--- a/Lib/fontTools/misc/psCharStrings.py
+++ b/Lib/fontTools/misc/psCharStrings.py
@@ -859,7 +859,7 @@
 	# MultipleMaster. Well...
 	#
 	def op_blend(self, index):
-		args = self.popall()
+		self.popall()
 	
 	# misc
 	def op_and(self, index):
@@ -1125,9 +1125,9 @@
 		return value
 	
 	def popall(self):
-		all = self.stack[:]
+		args = self.stack[:]
 		del self.stack[:]
-		return all
+		return args
 	
 	def do_operator(self, b0, data, index):
 		if b0 == 12:
diff --git a/Lib/fontTools/misc/psOperators.py b/Lib/fontTools/misc/psOperators.py
index a67b239..eb1b43d 100644
--- a/Lib/fontTools/misc/psOperators.py
+++ b/Lib/fontTools/misc/psOperators.py
@@ -161,7 +161,6 @@
 	def __str__(self):
 		psstring = "%d dict dup begin\n" % len(self.value)
 		items = sorted(self.value.items())
-		dictrepr = "%d dict dup begin\n" % len(items)
 		for key, value in items:
 			access = _accessstrings[value.access]
 			if access:
@@ -208,9 +207,9 @@
 class PSOperators:
 	
 	def ps_def(self):
-		object = self.pop()
+		obj = self.pop()
 		name = self.pop()
-		self.dictstack[-1][name.value] = object
+		self.dictstack[-1][name.value] = obj
 	
 	def ps_bind(self):
 		proc = self.pop('proceduretype')
@@ -225,12 +224,12 @@
 			else:
 				if not item.literal:
 					try:
-						object = self.resolve_name(item.value)
+						obj = self.resolve_name(item.value)
 					except:
 						pass
 					else:
-						if object.type == 'operatortype':
-							proc.value[i] = object
+						if obj.type == 'operatortype':
+							proc.value[i] = obj
 	
 	def ps_exch(self):
 		if len(self.stack) < 2:
@@ -246,11 +245,11 @@
 		self.push(self.stack[-1])
 	
 	def ps_exec(self):
-		object = self.pop()
-		if object.type == 'proceduretype':
-			self.call_procedure(object)
+		obj = self.pop()
+		if obj.type == 'proceduretype':
+			self.call_procedure(obj)
 		else:
-			self.handle_object(object)
+			self.handle_object(obj)
 	
 	def ps_count(self):
 		self.push(ps_integer(len(self.stack)))
@@ -310,13 +309,13 @@
 		self.push(ps_file(self.tokenizer))
 	
 	def ps_eexec(self):
-		file = self.pop('filetype').value
-		file.starteexec()
+		f = self.pop('filetype').value
+		f.starteexec()
 	
 	def ps_closefile(self):
-		file = self.pop('filetype').value
-		file.skipwhite()
-		file.stopeexec()
+		f = self.pop('filetype').value
+		f.skipwhite()
+		f.stopeexec()
 	
 	def ps_cleartomark(self):
 		obj = self.pop()
@@ -328,31 +327,29 @@
 				len = len):
 		s = self.pop('stringtype')
 		oldstr = s.value
-		file = self.pop('filetype')
+		f = self.pop('filetype')
 		#pad = file.value.read(1)
 		# for StringIO, this is faster
-		file.value.pos = file.value.pos + 1
-		newstr = file.value.read(len(oldstr))
+		f.value.pos = f.value.pos + 1
+		newstr = f.value.read(len(oldstr))
 		s.value = newstr
 		self.push(s)
 		self.push(ps_boolean(len(oldstr) == len(newstr)))
 	
 	def ps_known(self):
 		key = self.pop()
-		dict = self.pop('dicttype', 'fonttype')
-		self.push(ps_boolean(key.value in dict.value))
+		d = self.pop('dicttype', 'fonttype')
+		self.push(ps_boolean(key.value in d.value))
 	
 	def ps_if(self):
 		proc = self.pop('proceduretype')
-		bool = self.pop('booleantype')
-		if bool.value:
+		if self.pop('booleantype').value:
 			self.call_procedure(proc)
 	
 	def ps_ifelse(self):
 		proc2 = self.pop('proceduretype')
 		proc1 = self.pop('proceduretype')
-		bool = self.pop('booleantype')
-		if bool.value:
+		if self.pop('booleantype').value:
 			self.call_procedure(proc1)
 		else:
 			self.call_procedure(proc2)
@@ -411,8 +408,7 @@
 	
 	def ps_load(self):
 		name = self.pop()
-		object = self.resolve_name(name.value)
-		self.push(object)
+		self.push(self.resolve_name(name.value))
 	
 	def ps_put(self):
 		obj1 = self.pop()
@@ -440,7 +436,7 @@
 		elif tp == 'stringtype':
 			self.push(ps_integer(ord(obj2.value[obj1.value])))
 		else:
-			assert 0, "shouldn't get here"
+			assert False, "shouldn't get here"
 	
 	def ps_getinterval(self):
 		obj1 = self.pop('integertype')
@@ -466,8 +462,7 @@
 			obj3.value = newstr
 	
 	def ps_cvn(self):
-		str = self.pop('stringtype')
-		self.push(ps_name(str.value))
+		self.push(ps_name(self.pop('stringtype').value))
 	
 	def ps_index(self):
 		n = self.pop('integertype').value
@@ -528,13 +523,11 @@
 		self.pop()
 	
 	def ps_dict(self):
-		num = self.pop('integertype')
-		dict = ps_dict({})
-		self.push(dict)
+		self.pop('integertype')
+		self.push(ps_dict({}))
 	
 	def ps_begin(self):
-		dict = self.pop('dicttype')
-		self.dictstack.append(dict.value)
+		self.dictstack.append(self.pop('dicttype')value)
 	
 	def ps_end(self):
 		if len(self.dictstack) > 2:
diff --git a/Lib/fontTools/misc/sstruct.py b/Lib/fontTools/misc/sstruct.py
index ecf495b..d4958f7 100644
--- a/Lib/fontTools/misc/sstruct.py
+++ b/Lib/fontTools/misc/sstruct.py
@@ -5,14 +5,14 @@
 struct, except the objects passed and returned are not tuples 
 (or argument lists), but dictionaries or instances. 
 
-Just like struct, we use format strings to describe a data 
+Just like struct, we use fmt strings to describe a data 
 structure, except we use one line per element. Lines are 
 separated by newlines or semi-colons. Each line contains 
 either one of the special struct characters ('@', '=', '<', 
 '>' or '!') or a 'name:formatchar' combo (eg. 'myFloat:f'). 
 Repetitions, like the struct module offers them are not useful 
 in this context, except for fixed length strings  (eg. 'myInt:5h' 
-is not allowed but 'myString:5s' is). The 'x' format character 
+is not allowed but 'myString:5s' is). The 'x' fmt character 
 (pad byte) is treated as 'special', since it is by definition 
 anonymous. Extra whitespace is allowed everywhere.
 
@@ -22,14 +22,14 @@
 the number of bits after the point. Fixed point numbers get 
 converted to floats.
 
-pack(format, object):
+pack(fmt, object):
 	'object' is either a dictionary or an instance (or actually
 	anything that has a __dict__ attribute). If it is a dictionary, 
 	its keys are used for names. If it is an instance, it's 
 	attributes are used to grab struct elements from. Returns
 	a string containing the data.
 
-unpack(format, data, object=None)
+unpack(fmt, data, object=None)
 	If 'object' is omitted (or None), a new dictionary will be 
 	returned. If 'object' is a dictionary, it will be used to add 
 	struct elements to. If it is an instance (or in fact anything
@@ -37,12 +37,12 @@
 	each struct element. In the latter two cases, 'object' itself 
 	is returned.
 
-unpack2(format, data, object=None)
+unpack2(fmt, data, object=None)
 	Convenience function. Same as unpack, except data may be longer 
 	than needed. The returned value is a tuple: (object, leftoverdata).
 
-calcsize(format)
-	like struct.calcsize(), but uses our own format strings:
+calcsize(fmt)
+	like struct.calcsize(), but uses our own fmt strings:
 	it returns the size of the data in bytes.
 """
 
@@ -59,13 +59,13 @@
 class Error(Exception):
 	pass
 
-def pack(format, object):
-	formatstring, names, fixes = getformat(format)
+def pack(fmt, obj):
+	formatstring, names, fixes = getformat(fmt)
 	elements = []
-	if not isinstance(object, dict):
-		object = object.__dict__
+	if not isinstance(obj, dict):
+		obj = obj.__dict__
 	for name in names:
-		value = object[name]
+		value = obj[name]
 		if name in fixes:
 			# fixed point conversion
 			value = fl2fi(value, fixes[name])
@@ -75,15 +75,15 @@
 	data = struct.pack(*(formatstring,) + tuple(elements))
 	return data
 
-def unpack(format, data, object=None):
-	if object is None:
-		object = {}
+def unpack(fmt, data, obj=None):
+	if obj is None:
+		obj = {}
 	data = tobytes(data)
-	formatstring, names, fixes = getformat(format)
-	if isinstance(object, dict):
-		d = object
+	formatstring, names, fixes = getformat(fmt)
+	if isinstance(obj, dict):
+		d = obj
 	else:
-		d = object.__dict__
+		d = obj.__dict__
 	elements = struct.unpack(formatstring, data)
 	for i in range(len(names)):
 		name = names[i]
@@ -97,14 +97,14 @@
 			except UnicodeDecodeError:
 				pass
 		d[name] = value
-	return object
+	return obj
 
-def unpack2(format, data, object=None):
-	length = calcsize(format)
-	return unpack(format, data[:length], object), data[length:]
+def unpack2(fmt, data, obj=None):
+	length = calcsize(fmt)
+	return unpack(fmt, data[:length], obj), data[length:]
 
-def calcsize(format):
-	formatstring, names, fixes = getformat(format)
+def calcsize(fmt):
+	formatstring, names, fixes = getformat(fmt)
 	return struct.calcsize(formatstring)
 
 
@@ -119,7 +119,7 @@
 		"(#.*)?$"						# [comment] + end of string
 	)
 
-# matches the special struct format chars and 'x' (pad byte)
+# matches the special struct fmt chars and 'x' (pad byte)
 _extraRE = re.compile("\s*([x@=<>!])\s*(#.*)?$")
 
 # matches an "empty" string, possibly containing whitespace and/or a comment
@@ -132,11 +132,11 @@
 
 _formatcache = {}
 
-def getformat(format):
+def getformat(fmt):
 	try:
-		formatstring, names, fixes = _formatcache[format]
+		formatstring, names, fixes = _formatcache[fmt]
 	except KeyError:
-		lines = re.split("[\n;]", format)
+		lines = re.split("[\n;]", fmt)
 		formatstring = ""
 		names = []
 		fixes = {}
@@ -147,11 +147,11 @@
 			if m:
 				formatchar = m.group(1)
 				if formatchar != 'x' and formatstring:
-					raise Error("a special format char must be first")
+					raise Error("a special fmt char must be first")
 			else:
 				m = _elementRE.match(line)
 				if not m:
-					raise Error("syntax error in format: '%s'" % line)
+					raise Error("syntax error in fmt: '%s'" % line)
 				name = m.group(1)
 				names.append(name)
 				formatchar = m.group(2)
@@ -166,11 +166,11 @@
 					assert m.group(5) == "F"
 					fixes[name] = after
 			formatstring = formatstring + formatchar
-		_formatcache[format] = formatstring, names, fixes
+		_formatcache[fmt] = formatstring, names, fixes
 	return formatstring, names, fixes
 
 def _test():
-	format = """
+	fmt = """
 		# comments are allowed
 		>  # big endian (see documentation for struct)
 		# empty lines are allowed:
@@ -184,7 +184,7 @@
 		afixed: 16.16F
 	"""
 	
-	print('size:', calcsize(format))
+	print('size:', calcsize(fmt))
 	
 	class foo(object):
 		pass
@@ -200,11 +200,11 @@
 	i.adouble = 0.5
 	i.afixed = 1.5
 	
-	data = pack(format, i)
+	data = pack(fmt, i)
 	print('data:', repr(data))
-	print(unpack(format, data))
+	print(unpack(fmt, data))
 	i2 = foo()
-	unpack(format, data, i2)
+	unpack(fmt, data, i2)
 	print(vars(i2))
 
 if __name__ == "__main__":
diff --git a/Lib/fontTools/misc/textTools.py b/Lib/fontTools/misc/textTools.py
index be0c9fc..4d0f05a 100644
--- a/Lib/fontTools/misc/textTools.py
+++ b/Lib/fontTools/misc/textTools.py
@@ -37,22 +37,22 @@
 
 
 def num2binary(l, bits=32):
-	all = []
-	bin = ""
+	items = []
+	binary = ""
 	for i in range(bits):
 		if l & 0x1:
-			bin = "1" + bin
+			binary = "1" + binary
 		else:
-			bin = "0" + bin
+			binary = "0" + binary
 		l = l >> 1
 		if not ((i+1) % 8):
-			all.append(bin)
-			bin = ""
-	if bin:
-		all.append(bin)
-	all.reverse()
+			items.append(binary)
+			binary = ""
+	if binary:
+		items.append(binary)
+	items.reverse()
 	assert l in (0, -1), "number doesn't fit in number of bits"
-	return ' '.join(all)
+	return ' '.join(items)
 
 
 def binary2num(bin):
diff --git a/Lib/fontTools/misc/transform.py b/Lib/fontTools/misc/transform.py
index 531b288..51c8da7 100644
--- a/Lib/fontTools/misc/transform.py
+++ b/Lib/fontTools/misc/transform.py
@@ -373,9 +373,6 @@
 	return Transform(x, 0, 0, y, 0, 0)
 
 
-def _test():
-	import doctest, transform
-	return doctest.testmod(transform)
-
 if __name__ == "__main__":
-	_test()
+	import doctest
+	doctest.testmod()
diff --git a/Lib/fontTools/misc/xmlReader.py b/Lib/fontTools/misc/xmlReader.py
index 085e057..1e36c4f 100644
--- a/Lib/fontTools/misc/xmlReader.py
+++ b/Lib/fontTools/misc/xmlReader.py
@@ -25,9 +25,8 @@
 	def read(self):
 		if self.progress:
 			import stat
-			self.progress.set(0, os.stat(fileName)[stat.ST_SIZE] // 100 or 1)
-		file = open(self.fileName)
-		self._parseFile(file)
+			self.progress.set(0, os.stat(self.fileName)[stat.ST_SIZE] // 100 or 1)
+		self._parseFile(open(self.fileName))
 		file.close()
 	
 	def _parseFile(self, file):
@@ -97,9 +96,9 @@
 			self.contentStack.append([])
 			self.root = (name, attrs, self.contentStack[-1])
 		else:
-			list = []
-			self.contentStack[-1].append((name, attrs, list))
-			self.contentStack.append(list)
+			l = []
+			self.contentStack[-1].append((name, attrs, l))
+			self.contentStack.append(l)
 	
 	def _characterDataHandler(self, data):
 		if self.stackSize > 1:
diff --git a/Lib/fontTools/misc/xmlWriter.py b/Lib/fontTools/misc/xmlWriter.py
index b3ce7f2..93f57e3 100644
--- a/Lib/fontTools/misc/xmlWriter.py
+++ b/Lib/fontTools/misc/xmlWriter.py
@@ -4,7 +4,6 @@
 from fontTools.misc.py23 import *
 import sys
 import string
-import struct
 
 INDENT = "  "
 
diff --git a/Lib/fontTools/pens/reportLabPen.py b/Lib/fontTools/pens/reportLabPen.py
index c1c394e..d383100 100644
--- a/Lib/fontTools/pens/reportLabPen.py
+++ b/Lib/fontTools/pens/reportLabPen.py
@@ -1,6 +1,7 @@
 from __future__ import print_function, division
 from fontTools.misc.py23 import *
 from fontTools.pens.basePen import BasePen
+from reportlab.graphics.shapes import Path
 
 
 class ReportLabPen(BasePen):
@@ -10,7 +11,6 @@
 	def __init__(self, glyphSet, path=None):
 		BasePen.__init__(self, glyphSet)
 		if path is None:
-			from reportlab.graphics.shapes import Path
 			path = Path()
 		self.path = path
 
@@ -43,7 +43,6 @@
 
 	from fontTools.ttLib import TTFont
 	from reportlab.lib import colors
-	from reportlab.graphics.shapes import Path
 
 	path = sys.argv[1]
 	glyphName = sys.argv[2]
diff --git a/Lib/fontTools/subset.py b/Lib/fontTools/subset.py
index 1a1601d..ce6cf40 100644
--- a/Lib/fontTools/subset.py
+++ b/Lib/fontTools/subset.py
@@ -1824,7 +1824,7 @@
             if x in v:
               v.remove(x)
         else:
-          assert 0
+          assert False
 
       opts[k] = v
     self.set(**opts)
diff --git a/Lib/fontTools/t1Lib.py b/Lib/fontTools/t1Lib.py
index 1a81a99..15825d2 100644
--- a/Lib/fontTools/t1Lib.py
+++ b/Lib/fontTools/t1Lib.py
@@ -103,8 +103,8 @@
 def read(path, onlyHeader=0):
 	"""reads any Type 1 font file, returns raw data"""
 	normpath = path.lower()
-	creator, type = getMacCreatorAndType(path)
-	if type == 'LWFN':
+	creator, typ = getMacCreatorAndType(path)
+	if typ == 'LWFN':
 		return readLWFN(path, onlyHeader), 'LWFN'
 	if normpath[-4:] == '.pfb':
 		return readPFB(path, onlyHeader), 'PFB'
@@ -357,16 +357,16 @@
 # pfb helpers
 
 def longToString(long):
-	str = ""
+	s = ""
 	for i in range(4):
-		str = str + bytechr((long & (0xff << (i * 8))) >> i * 8)
-	return str
+		s += bytechr((long & (0xff << (i * 8))) >> i * 8)
+	return s
 
-def stringToLong(str):
-	if len(str) != 4:
+def stringToLong(s):
+	if len(s) != 4:
 		raise ValueError('string must be 4 bytes long')
-	long = 0
+	l = 0
 	for i in range(4):
-		long = long + (byteord(str[i]) << (i * 8))
-	return long
+		l += byteord(s[i]) << (i * 8)
+	return l
 
diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py
index bb9f262..9ecb04d 100644
--- a/Lib/fontTools/ttLib/__init__.py
+++ b/Lib/fontTools/ttLib/__init__.py
@@ -889,12 +889,11 @@
 def xmlToTag(tag):
 	"""The opposite of tagToXML()"""
 	if tag == "OS_2":
-		return "OS/2"
+		return Tag("OS/2")
 	if len(tag) == 8:
 		return identifierToTag(tag)
 	else:
-		return tag + " " * (4 - len(tag))
-	return Tag(tag)
+		return Tag(tag + " " * (4 - len(tag)))
 
 
 def debugmsg(msg):
diff --git a/Lib/fontTools/ttLib/sfnt.py b/Lib/fontTools/ttLib/sfnt.py
index da5c79d..4740376 100644
--- a/Lib/fontTools/ttLib/sfnt.py
+++ b/Lib/fontTools/ttLib/sfnt.py
@@ -201,6 +201,7 @@
 				self.metaOrigLength = len(data.metaData)
 				self.file.seek(0,2)
 				self.metaOffset = self.file.tell()
+				import zlib
 				compressedMetaData = zlib.compress(data.metaData)
 				self.metaLength = len(compressedMetaData)
 				self.file.write(compressedMetaData)
@@ -430,14 +431,15 @@
 			self.minorVersion = reader.minorVersion
 			if reader.metaLength:
 				reader.file.seek(reader.metaOffset)
-				rawData = read.file.read(reader.metaLength)
+				rawData = reader.file.read(reader.metaLength)
 				assert len(rawData) == reader.metaLength
+				import zlib
 				data = zlib.decompress(rawData)
 				assert len(data) == reader.metaOrigLength
 				self.metaData = data
 			if reader.privLength:
 				reader.file.seek(reader.privOffset)
-				data = read.file.read(reader.privLength)
+				data = reader.file.read(reader.privLength)
 				assert len(data) == reader.privLength
 				self.privData = data
 
@@ -485,7 +487,6 @@
 	sfnt directory. 'n' is the number of tables.
 	"""
 	# This stuff needs to be stored in the file, because?
-	import math
 	exponent = maxPowerOfTwo(n)
 	searchRange = (2 ** exponent) * 16
 	entrySelector = exponent
diff --git a/Lib/fontTools/ttLib/tables/ttProgram.py b/Lib/fontTools/ttLib/tables/ttProgram.py
index 156e4a2..bdc14e8 100644
--- a/Lib/fontTools/ttLib/tables/ttProgram.py
+++ b/Lib/fontTools/ttLib/tables/ttProgram.py
@@ -193,7 +193,7 @@
 _pushCountPat = re.compile(r"[A-Z][A-Z0-9]*\s*\[.*?\]\s*/\* ([0-9]*).*?\*/")
 
 
-def _skipWhite(data, pos, _whiteRE=_whiteRE):
+def _skipWhite(data, pos):
 	m = _whiteRE.match(data, pos)
 	newPos = m.regs[0][1]
 	assert newPos >= pos
@@ -267,16 +267,14 @@
 			assert name == "bytecode"
 			self.fromBytecode(readHex(content))
 	
-	def _assemble(self, 
-			skipWhite=_skipWhite, mnemonicDict=mnemonicDict,
-			binary2num=binary2num):
+	def _assemble(self):
 		assembly = self.assembly
 		if isinstance(assembly, type([])):
 			assembly = ' '.join(assembly)
 		bytecode = []
 		push = bytecode.append
 		lenAssembly = len(assembly)
-		pos = skipWhite(assembly, 0)
+		pos = _skipWhite(assembly, 0)
 		while pos < lenAssembly:
 			m = _tokenRE.match(assembly, pos)
 			if m is None:
@@ -302,7 +300,7 @@
 					push(op)
 			else:
 				args = []
-				pos = skipWhite(assembly, pos)
+				pos = _skipWhite(assembly, pos)
 				while pos < lenAssembly:
 					m = _tokenRE.match(assembly, pos)
 					if m is None:
@@ -311,7 +309,7 @@
 					if number is None and comment is None:
 						break
 					pos = m.regs[0][1]
-					pos = skipWhite(assembly, pos)
+					pos = _skipWhite(assembly, pos)
 					if comment is not None:
 						continue
 					args.append(int(number))
@@ -340,7 +338,7 @@
 				else:
 					for value in args:
 						push(value)
-			pos = skipWhite(assembly, pos)
+			pos = _skipWhite(assembly, pos)
 		
 		if bytecode:
 			assert max(bytecode) < 256 and min(bytecode) >= 0
@@ -353,7 +351,6 @@
 		numBytecode = len(bytecode)
 		while i < numBytecode:
 			op = bytecode[i]
-			arg = 0
 			try:
 				mnemonic, argBits, argoffset = opcodeDict[op]
 			except KeyError:
diff --git a/Lib/fontTools/ttx.py b/Lib/fontTools/ttx.py
index ae3c115..8c4b542 100644
--- a/Lib/fontTools/ttx.py
+++ b/Lib/fontTools/ttx.py
@@ -72,13 +72,13 @@
 from fontTools.ttLib.tables.otBase import OTLOffsetOverflowError
 from fontTools.ttLib.tables.otTables import fixLookupOverFlows, fixSubTableOverFlows
 from fontTools.misc.macCreatorType import getMacCreatorAndType
-from fontTools import version
 import os
 import sys
 import getopt
 import re
 
 def usage():
+	from fontTools import version
 	print(__doc__ % version)
 	sys.exit(2)
 
@@ -87,15 +87,15 @@
 opentypeheaderRE = re.compile('''sfntVersion=['"]OTTO["']''')
 
 def makeOutputFileName(input, outputDir, extension):
-	dir, file = os.path.split(input)
-	file, ext = os.path.splitext(file)
+	dirName, fileName = os.path.split(input)
+	fileName, ext = os.path.splitext(fileName)
 	if outputDir:
-		dir = outputDir
-	file = numberAddedRE.split(file)[0]
-	output = os.path.join(dir, file + extension)
+		dirName = outputDir
+	fileName = numberAddedRE.split(fileName)[0]
+	output = os.path.join(dirName, fileName + extension)
 	n = 1
 	while os.path.exists(output):
-		output = os.path.join(dir, file + "#" + repr(n) + extension)
+		output = os.path.join(dirName, fileName + "#" + repr(n) + extension)
 		n = n + 1
 	return output
 
@@ -122,6 +122,7 @@
 		for option, value in rawOptions:
 			# general options
 			if option == "-h":
+				from fontTools import version
 				print(__doc__ % version)
 				sys.exit(0)
 			elif option == "-d":