os.path.normpath

N

nathanbullock

I am using a windows box and passing a string like "../foo/../foo2" to
normpath which then returns "..\\foo2". But if this string is going
into a webpage link it should really be "../foo".

Is there any way to tell os.path.normpath to act like we are an a unix
style box?

What about in the new python 2.5 Path class?

Nathan
 
G

Gabriel Genellina

At said:
I am using a windows box and passing a string like "../foo/../foo2" to
normpath which then returns "..\\foo2". But if this string is going
into a webpage link it should really be "../foo".

You could just .replace('\\','/') on the resulting string. Or use the
urlparse module.
Is there any way to tell os.path.normpath to act like we are an a unix
style box?

The fact than '/' is used as a path separator both on unix and on
HTTP URLs should be considered as a mere coincidence (in fact it isn't...)
URLs dont necesarily point to a real file on a real file system (Zope
is an example).



Gabriel Genellina
Softlab SRL





__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
 
G

grahamd

I am using a windows box and passing a string like "../foo/../foo2" to
normpath which then returns "..\\foo2". But if this string is going
into a webpage link it should really be "../foo".

Is there any way to tell os.path.normpath to act like we are an a unix
style box?

Use posixpath.normpath() instead.
 
D

Dennis Lee Bieber

I am using a windows box and passing a string like "../foo/../foo2" to
normpath which then returns "..\\foo2". But if this string is going
into a webpage link it should really be "../foo".
Somehow I missed this the first time...

If this is for a URL, shouldn't the a URL specific library be
considered?
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top