Reputation: 6116
I am trying to use os.path.basename(path)
on a string. I thought that was how it was used. In the doc for version 3 it clearly says that is the case but I am using 2.7. How do I use the method if all I have is a string (which clearly don't have a path attribute?)
Upvotes: 0
Views: 1313
Reputation: 31339
You probably have overridden os
with your own variable.
Something like this:
import os
# ...
os = "abc"
# ...
os.path # <-- error
Make sure you don't shadow imported libraries.
Upvotes: 2