An assertion would be better than raising IndexError; also, shouldn't we be checking "1.0" == key?