This is super pedantic and minor, but AttributeError is for failures dealing with attributes, not arguments passed in. This should probably be a ValueError (or maybe a TypeError): http://docs.python.org/2/library/exceptions.html#exceptions.ValueError

Discussion: http://stackoverflow.com/questions/256222/which-exception-should-i-raise-on-bad-illegal-argument-combinations-in-python