Eval() Incorrectly Returning File Path String

   1038   5   3
User Avatar
Member
5 posts
Joined: July 2022
Offline
Heya,

I have a string parameter that hold a file path of the format: \\ServerURL\Project\Path

Is then input with set(), displays correctly in the parameter, but when read out using eval() it returns as: \ServerURL\Project\Path

I know I can just add an extra backslash at the beginning to fix it but just curious if this is known/fixable. Perhaps something to do with raw strings?

Cheers!
User Avatar
Member
160 posts
Joined: Feb. 2016
Offline
You can probably use rawValue() instead of eval()
Edited by AslakKS - Feb. 22, 2023 04:43:34
User Avatar
Member
5 posts
Joined: July 2022
Offline
Thanks a lot! No ideas how in hour of searching I never found that. That fixes it but it does feel a bit buggy that it returns in that manner as by rights the non raw string should still be \\ and not \. It just means that at some point, the eval() function returns the non raw string as a raw string which it then outputs. Its interesting because normally single slashes wouldnt be possible in a python non raw string so it has a check to convert those back to double slashes but at the same time converting the quad slash to a double. Worth a bug report?
User Avatar
Member
256 posts
Joined: July 2013
Offline
I guess it's an escaping issue with backslashes, you could try using forward slashes, file loading wise that works fine on both windows and Linux.
More code, less clicks.
User Avatar
Member
5 posts
Joined: July 2022
Offline
Yeah, I am currently doing that conversion, bit of a pain due to the path logic that I use but Id rather it work on both systems. Also it appears that when windows format file locations are in the file string, the file chooser doesn't open at the directory in the string.
Edited by stephenscollay - Feb. 22, 2023 17:41:31
User Avatar
Member
30 posts
Joined:
Offline
houdini has always been troublesome with backslashes (notice when you pick a file path in windows, it converts to forward slashes).

long story short, always use forward slashes, even on windows.

cheers,
chrisg
  • Quick Links