[Tutor] How can a CGI program get the URL that called it?
Steven D'Aprano
steve at pearwood.info
Sat Jan 11 00:43:11 CET 2014
On Fri, Jan 10, 2014 at 02:44:35PM -0800, Terry Carroll wrote:
> As it turns out, since I was testing on a Windows box, os.path.relpath was
> (reasonably) using a '\' as the separator character (surprisingly, so does
> posixpath.relpath).
Are you sure about that? If it did, that would be an astonishing bug. I
cannot replicate the behaviour you describe:
py> posixpath.relpath("/a/b/c")
'../../a/b/c'
However, if you pass a path using \ to posixpath, it treats them as
non-separators:
py> posixpath.relpath("\\a\\b\\c")
'\\a\\b\\c'
That's because the given path \a\b\c under POSIX represents a file named
"backslash a backslash b backslash c" in the current directory, not a
file named c in a directory b in a directory a.
If you still think this is an issue, can you Can you post a minimal set
of code that demonstrates that problem? Also, please specify the Python
version.
Thanks,
--
Steven
More information about the Tutor
mailing list