I have a list of file paths eg:
file_paths = [
'repo/batcha/somefile.txt',
'repo/batcha/someotherfile.txt',
]
I want to loop over then and add an id to each filename.
for _id, path in enumerate(file_paths):
<add _id to filename>
With an expected output something like:
[
'repo/batcha/node1_somefile.txt',
'repo/batcha/node2_someotherfile.txt',
]
I can of course use filename.split('/')
on these examples to get at the filename part. I would like to know whether there is, however, a solution using something like os.path that could consistently extract the filename portion of a path in an os independent manner.