1

I reading list of paths from XML, path contain irregular elemnts uses by a certian application that translate them internaly. the current path string is usless for me and I wish to normaliz them.

example: 
path = "%personal%\new_lcation\%vendorlibs%\generated"
# split this to a list
omponents = path.split(os.sep)
# replace elemnts 0,2
components[0]="c:\ProgramFiles"  
components[2]="somthing"

How do I join everythings now to standard path string?

thanks

1
  • You won't get what you expect because you're using plain string literals instead of "raw" string literals. For example, "\n" is the newline character. When working with paths on Windows, use raw strings, such as r"%personal%\new_lcation\%vendorlibs%\generated". Commented Jun 24, 2012 at 19:18

1 Answer 1

3

os.path.join(*components). os.path.join documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.