From a5bbfaf3bd25355c18f337c6c79bf2e28ac10814 Mon Sep 17 00:00:00 2001 From: Prodesire Date: Thu, 12 Apr 2018 22:24:03 +0800 Subject: [PATCH] add path.fileext which return the file extension --- pydu/path.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pydu/path.py b/pydu/path.py index 8c05b0b..ca5a071 100644 --- a/pydu/path.py +++ b/pydu/path.py @@ -44,3 +44,11 @@ def normjoin(path, *paths): def filename(path): """Return the filename without extension.""" return os.path.splitext(os.path.basename(path))[0] + + +def fileext(path): + """ + Return the file extension. + If file has not extension, return empty string. + """ + return os.path.splitext(os.path.basename(path))[1]