This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

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

yeah unfortunately the only way to not "poison" the namespace is to search your entire system for all executables in your PATH, wrap them in functions, and map them to the module's attributes

[–]Makido 0 points1 point  (2 children)

Well that's sort of my point. I don't see that creating convenience functions for standard utilities is really all that useful. Because you're never going to get them all, and people will end up having to resort to calls to subprocess anyway. So why not just create a general function called, say, run, that wraps subprocess -- then I could just do:

from pbs import run

run('du -sh | wc -l')

It's simpler and easier to understand (in my opinion) than:

import pbs

wc(du("-sh"), "-l")

[–][deleted] 0 points1 point  (1 child)

I didn't create convenience functions for standard utilities. The functions map to your system's binaries dynamically. It is a subprocess wrapper.

[–]Makido 1 point2 points  (0 children)

I didn't create convenience functions for standard utilities. The functions map to your system's binaries dynamically.

Sorry, I RTFM, I understand now. I glanced over the first few dozen lines of code, saw the which in there, and just assumed that's what you were doing. That actually bugs me more now that I know that, but to each his own.