Python: please help me to escape the escapes!!



  • Sweet, simple and fustrating ...

    I need Poser to write a Python script file with code in it that will be read by another appication (Marvelous Designer).
    In the code I give a few pathnames of files I want MD to read.
    I happily construct the path names of the file with 'os.path.join()' and get a string with single backslashes.
    To use the neames in a code they need of course to be with double backslashes.
    I use str.replace('//', '////') which should do the trick so I can write the string to file, but no avail.
    I tried not to convert the text and write binary, but no avail.

    Fustrated to bitter end I changed filenames so the names do not begin with a character that together with the backslash could from an escape sequence, but AAAARGH!!!

    Any solutions anyone?
    please??



  • Ok, solved.
    the replace method does not change the .str but returns a copy with the replacements made.
    Dumbass me had not read the docs with enough attention.
    <feels stupid>