Not piping strings avoids this issue completely. Marcel’s ls produces a stream of File objects, which can be processed without worrying about whitespace, EOL, etc.
In general, this approach avoids parsing the output of any command. You always get a stream of Python values.
As long as Python does the right thing with globs, there is really no room for marcel to get it wrong. Not sure what additional validation you are thinking of.
The File object encapsulates a path. If you use it, e.g. to read contents, and the file doesn't exist, then it will fail with an appropriate error message.
Files come and go. References to them go stale. Every user and tool deals with this. This isn't a "validation" issue.
Not piping strings avoids this issue completely. Marcel’s ls produces a stream of File objects, which can be processed without worrying about whitespace, EOL, etc.
In general, this approach avoids parsing the output of any command. You always get a stream of Python values.