os.path.dirname()

Returns the directory part of the pathname.

>>> import os
>>> os.path.dirname( '/home/user/temp/file.lis”)
'/home/user/temp'