Implement python template strings + dict in ```configuration.py``` module

Issue #40 new
blakeca00 repo owner created an issue
from string import Template

t = Template('My first name is ${fname} and my last is ${lname}')

data = {
  "fname": "Blake,
  "lname": "Roberts"
}

str1 = t.substitute(data)
print(str1)

$  My first name is Blake and my last name is Roberts

This change will greatly simplify while increasing clarity and ease of management of the UpdateConfig Class.

Comments (4)

  1. blakeca00 reporter

    Consider defining 1 template for each config menu question. Example:

    from string import Template
    
    q1 = Template('${question1}')
    q2 = Template('${question2}')
    q3 = Template('${question3}')
    
    data = {
      "question1": "lsdkjsdl;kf lskjfdls lskjfsljf",
      "question2": "What is your name?",
      "question3": "How do you spell it?"
    }
    
    # ask questions
    print(q1.substitute(data))
    
  2. Log in to comment