python detect complete