[Python-ideas] os.path.join

Chris Angelico rosuav at gmail.com
Mon Nov 4 17:07:27 CET 2013


On Tue, Nov 5, 2013 at 2:29 AM, anatoly techtonik <techtonik at gmail.com> wrote:
> Right. But I am working more with URL paths nowadays. In there if I
> want to join two paths, no matter if 2nd starts with slash or not, I
> don't really expect the 2nd to rewrite the first.

Then os.path.join is probably the wrong tool for the job. Do you want
to collapse "/foo/bar" + "../quux" into "/foo/quux"? That rewrites the
first. If not, don't use a function that does that. Try simple string
concatenation instead.

ChrisA



More information about the Python-list mailing list