tkbx
tkbx

Reputation: 16285

ntpath.basename() alternative?

I'm trying to use ntpath.basename() to take a string like /Users/user/file_one and get file_one. However, I'm having problems with ntpath. It works when I run the script, but after I py2app it, ntpath no longer works. Is there an alternative to ntpath? I'm not sure what special features it has for Windows, but my script is build for OS X, and therefore only uses forward slashes, so I should be fine without the "NT magic" that ntpath offers.

Upvotes: 1

Views: 5644

Answers (1)

tiago
tiago

Reputation: 23492

>>> import os
>>> print(os.path.split('/Users/user/file_one')[1])
file_one
>>> print(os.path.basename('/Users/user/file_one'))
file_one

Upvotes: 3

Related Questions