Can't reference fn before assignment in python