Ciasto piekarz
Ciasto piekarz

Reputation: 8277

how to expand items of tuple as argument os system call?

I want to expand tuple items i have collected from sys.argv to be passed as argument

like below

os.system('git send-email ' + *args)

but its giving error at *args

Upvotes: 1

Views: 591

Answers (3)

falsetru
falsetru

Reputation: 369054

How about using subprocess.call:

subprocess.call(['git', 'send-email'] + list(args))

See Replacing Older Functions with the subprocess Module.

Upvotes: 5

Bi Rico
Bi Rico

Reputation: 25813

How about this:

import subprocess

cmd = ['git', 'send-email']
cmd.extend(args)
subprocess.call(cmd)

Upvotes: 1

Ajurna
Ajurna

Reputation: 561

would it be a simple as?

os.system('git send-email ' + ' '.join(args))

Upvotes: 2

Related Questions