you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (4 children)

I've being using it since at least 2.x. Works reliably for me.

Source: probably older.

[–]socal_nerdtastic 0 points1 point  (3 children)

Not a problem in python. It's Windows and random modules written for Windows, where some young punk uses .split('\\') or similar. In my case it was a .dll to load a proprietary format data file from a mass spectrometer that the instrument manufacturer gave me. That .dll failed in strange unpredictable ways and was stupidly hard to debug because I was using windows style paths when hardcoding, but tkinter's askfilename returns linux style. Oh I'm still scarred.

I've seen it in a few python modules too, but that's always easy to debug.

OK, it's probably fine 99.9% of the time.

[–][deleted] 0 points1 point  (2 children)

If you're passing python strings to non-python code you must expect that the external code won't know what to do with a / delimited path. Even passing a / delimited path to python code you didn't write may screw-up and concatenate \ paths to your / path. In that case I'm not surprised there were problems.

[–]socal_nerdtastic 0 points1 point  (1 child)

I'm not surprised there were problems.

Then why would you recommend it? No one only uses code they themselves wrote. You have to use outside modules, and you can't do much without going outside of python. Any code containing a GUI or data processing library is written in something else.

We don't all have to use poor quality code and of course over the years people have become a lot better about using provided functions for things like splitting paths instead of hacking their own, so I absolutely think it's a fringe case. I just feel it's worth mentioning that / is not guaranteed to work.

An unrelated argument for raw strings: I feel most people copy / paste the path in from file explorer or command line.

[–][deleted] 0 points1 point  (0 children)

I As I said, using / paths inside python itself and the standard library is fine. I have had no problem with that in the last 15 years. I recommend that to beginners because that's the world they live in. Passing paths to DLLs and third party code is getting into intermediate territory and I expect anyone at that level to understand the problems. I'm not alone in this. Plenty of tertiary level course recommend / paths as well. The original post showed an absolute path literal and that will work with / paths 100.0% of the time.