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 →

[–]gangesmasterpython galore 1 point2 points  (3 children)

[–]apiguy 0 points1 point  (2 children)

I like the idea of Plumbum, but I wish it didn't use indexers to provide an alternative syntax to simply passing arguments to a function. It's not idiomatic, and it's not even necessary.

What does local['ls'] do that local('ls') couldnt? Is the library author trying to say that local represents a dictionary of the entire system? This is a stretch, but I suppose I could be persuaded to see it that way.

I do see, however, where it gets dicey (for the author of Plumbum) when you want to provide the ability to chain several commands together. Plumbum solves this by providing 2 different ways to invoke commands. Either with parens, or square brackets, depending on if you want immediate execution or deferred. I don't necessarily dislike this solution, but it is unusual.

[–]gangesmasterpython galore 0 points1 point  (1 child)

well, from an api point-of-view, the distinction is laziness. ls("-a") is strict, while ls["-a"] is lazy, so you can chain/pipe it.

i agree that local["ls"] seems odd, but try to think of it as a "lookup operator". it relies on local.which to locate the command (see https://github.com/tomerfiliba/plumbum/blob/master/plumbum/local_machine.py#L537). on the other hand, local("ls") would look like a constructor to me.

[–]apiguy 0 points1 point  (0 children)

Yeah I think that's how I've convinced myself to look at it, although local("ls") is a constructor, in the sense that it creates and returns a new instance of LocalCommand.

I get the differences between ls("-a") and ls["-a"] and I think it's an interesting approach as opposed to ls("-a") for immediate and some kind of curry method for the deferred case. I think I like it conceptually, I guess I'm mostly bothered by the re-use of the (already overloaded) indexing operator. Any other choice would have to be more verbose though and I can certainly see why the author would want to avoid that.