i see many examples where / filename separators are used for Windows. but a user of my script on Windows might type in \ as the file separator. should i replace all \ characters with /? what if a file name on Windows has a / in its name much like Linux can have \ in a file name?
(Oct-01-2019, 12:25 AM)Skaperen Wrote: [ -> ]what if a file name on Windows has a / in its name much like Linux can have \ in a file name?
That is not possible. Look at the reserved (forbidden in file name) chars:
https://docs.microsoft.com/en-us/windows...ing-a-file
And if you accept filename as user input you need to validate the input not to include any of these
open(fn,'w')
should fail with an invalid filename, correct? i would expect open(fn,'r')
to fail, somehow, too.
one of the disadvantages of not being a windows user ... i don't end up knowing these things.
Yes, it will fail. I just don't see the logic to handle some problem chars and not handle others
i didn't know / was invalid in Windows. that actually eliminates the issues around portability. all that is needed is replacing every / with \ before it goes to the system. and python apparently takes care of this for me. so i just have paths with / characters. since users could type in \ i just need to replace those with / before letting open() or other python code have it have it.
i should go figure out how to start up a cloud instance with Windows in it then learn how to install Python3 in it.