os.path.normpath question

B

Bart

I'm using this and ran across backslash issues in one of my paths.

archpath = os.path.normpath('E:\foo\FTP\HLS\archive')

was translating to:

E:\lsfprod\law\uch_interfaces\FTP\HLSrchive

which caused me to start using the 'raw' declaration before the path
string like this:

archpath = os.path.normpath(r'E:\foo\FTP\HLS\archive')

Is this the right way to use this?
 
P

Peter Otten

Bart said:
I'm using this and ran across backslash issues in one of my paths.

archpath = os.path.normpath('E:\foo\FTP\HLS\archive')

was translating to:

E:\lsfprod\law\uch_interfaces\FTP\HLSrchive

which caused me to start using the 'raw' declaration before the path
string like this:

archpath = os.path.normpath(r'E:\foo\FTP\HLS\archive')

Is this the right way to use this?

Yes, but os.path.normpath() has nothing to with it. It's just how Python
translates any string literal to a string object, see

http://docs.python.org/reference/lexical_analysis.html#string-literals

Peter
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top