python - How do I format a string within a function call? -


i want pass string variable string, in turn gets passwd onto function. had written code below:

not working

env = 'd' myfunction("checking processes a%s/b%s",'')% (env,env) 

error

myfunction("checking processes a%s/b%s",'')% (env,env) typeerror: unsupported operand type(s) %: 'nonetype' , 'tuple' 

since code failed re-wrote below:

working

env = 'd' str = "checking processes a%s/b%s" %(env,env) myfunction(str,'') 

can suggest alternative shorter approaches ?ideally in lines of first attemp mean less loc.

myfunction("checking processes a%s/b%s" % (env,env),'') 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -