Well, exception will raise anyway at lxml side, even if you pass a string with an invalid xpath. I don't see a reason to do the check here.