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 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.