node get path except last part code example
Example 1: how to get just the filename in python
import os
>>> base=os.path.basename('/root/dir/sub/file.ext')
>>> base
'file.ext'
>>> os.path.splitext(base)
('file', '.ext')
>>> os.path.splitext(base)[0]
'file'
Example 2: python how to get the last element in a list
some_list = [1, 2, 3]
some_list[-1]
print(some_list)
#Output = 3