Is there a cleaner way I can have a backslash in a string with out having the compiler think it needs an extra paren? I end up having to send it to the function below to get it to work.(I know the function replaces all the backslashes with double backslashes but that is besides the point)
proc fix(s: string): string =
result=escape(s,prefix="\"",suffix="\\")[1..^2]
If I just try to add a backslash to a string it looks like this.
copyFile(fix(getCurrentDir()&"\"&path),fix(getHomeDir()&"documents"&"\\rawrxd"))
It wants me to add another '"' to the backslash but when I do that it shows up in the string. Any help would be appreciated.try raw string literals, they don't interpret escape sequences.
r"c:\path\to\your\file"
Also, you probably should be using this pattern to join paths, it's more portable.
The '/' operator will join components using dirSep, which can be "/"(Unix) or r"\"(Windows)
import os
"root" / "folder" / "subfolder" / "file"