user1934146
user1934146

Reputation: 3071

Type error for not enough arguments when 2 arugments are already passed

I am getting the following error,it says not enough arguments,am already passing two arguments...what is wrong here?

   check_call("rm -rf %s/%s/*" % SCRIPT_ROOT % W_ROOT,shell=True)                                
    TypeError: not enough arguments for format string

Upvotes: 0

Views: 86

Answers (2)

Burhan Khalid
Burhan Khalid

Reputation: 174624

check_call('rm -rf {}/{}/*'.format(SCRIPT_ROOT,W_ROOT),shell=True)

Also, make sure you know the implications of shell=True, especially since you seem to be doing a destructive operation.

What happenes if any one of the arguments is ../../?

Upvotes: 2

BrenBarn
BrenBarn

Reputation: 251355

You can't do the formatting in two steps like that. You need to use one % operator and pass a tuple:

"rm -rf %s/%s/*" % (SCRIPT_ROOT, W_ROOT)

Upvotes: 2

Related Questions