Hacker News new | ask | show | jobs
by onyb 3290 days ago
This seems to be a simple wrapper around subprocess, but I'm afraid it is not changing things dramatically. Overall, I don't agree that Sultan's syntax is any more Pythonic than subprocess itself.

+1 for https://sultan.readthedocs.io/en/latest/sultan-examples.html...

I think it would be interesting if you could iterate on the results of "ls -l", where each row is represented by an object.

2 comments

Representing each row as an object works, but it ends up having us write custom objects for different result types. When you run Sultan().ls('-l'), you will get back a list of Strings, which you can freely use in Python for your specific needs (like use a Regex to fetch date/times or file size). I felt like this offers developers the best flexibility, rather than trying to customize each output (which will definitely make the codebase very confusing)
And then I remember that Windows PowerShell does (attempts to, to be fair) exactly that
attempts to, to be fair

Output of ls in PS is an Array of objects (DirectoryInfo or FileInfo instances). How is that merely an attempt?

While PS-native stuff yield objects, not all pre-PS utilities/builtins are overriden or have interface for PS and output old fashioned text blob, which is not automagically parsed in any way by PS. My comment was system-level, not utility-level.