Generic Python shell utilities