python - Default values for string format use in string (template) -


hope can me below problem have in python. trying use string format of template need how have default values.

template = """ server {isserverrunning} ntp {isntprunning} application {isapprunning} """  test = template.format(isserverrunning='is not running')  print test  output: server not running ntp running application running 

(lets default values 3 paramters should 'is running')

thanks time

can encase in function like:

def test(isserverrunning='is running',          isntprunning='is running',          isapprunning='is running'):           return template.format(              isserverrunning=isserverrunning,               isntprunning=isntprunning,               isapprunning=isapprunning) 

Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -