user3456863
user3456863

Reputation: 45

input variable into python call subprocess

I have a small python snippet that calls a larger program (I did not write the larger one).

call(['function1', file1,  file2,  'data.labels=abc, xyz'])

The above works.

input ='abc, xyz'

Now I want to input "abc, xyz" as a variable holding this value

call(['function1', file1,  file2,  'data.labels=input'])

but it does not work.

How can I pass a variable value into variable data.labels within call subprocess.

Upvotes: 0

Views: 504

Answers (3)

Robert Jacobs
Robert Jacobs

Reputation: 3360

Or

call(['function1', file1,  file2,  'data.labels=' + input)

If for some reason, input is not a string.

call(['function1', file1,  file2,  'data.labels=' + str(input) )

Upvotes: 1

Raydel Miranda
Raydel Miranda

Reputation: 14360

Another way to do the same:

call(['function1', file1,  file2,  'data.labels={0}'.format(input)])

Upvotes: 0

Jonas K
Jonas K

Reputation: 4315

call(['function1', file1,  file2,  'data.labels=%s' % input])

Upvotes: 2

Related Questions