Shorten python code for getting detail info