>>> os.path.basename('http://example.com/file.txt') 'file.txt'
.. and I thought
os.path.* work only on local paths and not URLs? Note that the above example was run on Windows too .. with similar result.
In practice many functions of
On windows, look at the source code: C:\Python25\Lib\ntpath.py
os.path.split (in the same file) just split "\" (and sth. else)
Use the source Luke:
Edit (response to clarification):
It works for URLs by accident, that's it. Because of that, exploiting its behaviour could be considered code smell by some.
Trying to "fix" it (check if passed path is not url) is also surprisingly difficult
are at the same time correct pathnames and URLs (relative), so is the
To sum it up: import this