I've always tended to use raw strings, simply for the ease of copy/pasting existing paths into scripts. But now I've started using forward slashes more when typing paths as I switch between Windows and Linux regularly. Forward slashes can be used in python regardless of operating system and can also be used in the Windows and Linux command prompts.
C:\Windows\System32>dir "C:/Temp/Test" Volume in drive C is Default Volume Serial Number is F29F-D7D5 Directory of C:\Temp\Test 14/12/2015 01:48 PM <DIR> . 14/12/2015 01:48 PM <DIR> ..
Depends. There is always a gotcha if you aren't careful... as I have posted on my blog as you well know.
The path to enlightenment.... Buddism
The enlightenment of paths ... GISism
spoiler alert Filenames and file paths in Python and do be aware of unicode in python 3
I do Raw strings (e.g. r'C:\somefolder\somefile') for the basic directory, then I use os.path.join() for anything more.
Same. Raw strings in variables for basepaths, os.path.join() for branching paths.
I use Raw string, just because i can copy and paste the path quickly and without errors ( anywhere you can remove the chance of errors is a big time saver)
Just to add to the confusion...
From xkcd. Love it.
I use os.path.join() for everything. I never put a slash "\" or "/"
I do this too. I don't typically hard-code paths. Usually I will have the user pass whatever base workspace is needed through parameters and build from there, even if the user is just me. So I'm not usually joining long strings of folders, but only the base workspace and filename. I don't end up need one-offs and testing scripts, since I can reuse the same base script over and over again.
you don't have to create a list/iterator and then pass it in, you can just do
Seriously though, I'll have a path in a json configuration file "\\\\some\\path\\here" outside of the code, but the moment it hits the code, everything is relative to that path (or another preconfigured path) and all other paths are built on top of that path using os.path.join()
If you don't like typing all the 'quotes', I guess you could do something like....
Retrieving data ...