News for hackers. Stuff that matters.
Re:No script is too simple by sixstringtheory on Tuesday September 22, 2020 @04:36PM (#24559586)
Quickest and dirtiest way I've found, but yes, not idiomatic Python:

    subprocess.check_output("grep ^$(whoami) /etc/passwd | awk -F : '{print $NF}'", shell=True, encoding="utf-8").strip()
I didn't test that particular line, but in general this is how I execute shell pipelines in Python.
Re:No script is too simple by yjftsjthsd-h on Tuesday September 22, 2020 @07:30PM (#24561246)
:) I agree that that works, of course, but if we have to use shell=True and just shove the whole thing like that then it loses a rather lot of the "Python" appeal. Still valuable if you need to feed the output into Python, of course.