Added support for named arguments

#1 Open

Bitbucket cannot automatically merge this request.

The commits that make up this pull request have been removed.

Bitbucket cannot automatically merge this request due to conflicts.

Review the conflicts on the Overview tab. You can then either decline the request or merge it manually on your local system using the following commands:

hg update default
hg pull -r mbatchkarov/named-args
hg merge mbatchkarov/named-args
hg commit -m 'Merged in mbatchkarov/iterpipes/mbatchkarov/named-args (pull request #1)'
  1. Miroslav Batchkarov
>>>formatted, _ = format('echo {dir} | wc {opt}', dir="hi", opt="-l")
>>>print formatted
'echo hi | wc -l'

The old syntax is supported, too:

>>>result, _ = format('func {}', ['x'])
>>>print result
'func x'

One can use either the new syntax or the old one, not both. The following will raise a TypeError

format('echo {} | wc {opt}', "hi", opt="-l")

The external interface of iterpipes is not affected. Cmd objects are created as before. Internally, the format function consumes some of the parameters it is passed in and return the ones that are unused. These are passed on to popen as before.

Comments (2)

  1. Andrey Vlasovskikh repo owner

    Miroslav, thanks for your pull request! I will modify it a little and merge into the master branch as soon as I have some free time to work on the library.

    By the way, what's your opinion on the new iterpipes API (the Cmd class as opposed to the 0.4 API described here)?