I'm looking for a wiki site for interchangeable Python variables. I don't know what those are called so i can't look them up.
An example:
template = ['{sti}_Data', '{sti}_OtherData', '{sti}_MaxData']
si = name
What is this method called ?
I'm looking for a wiki site for interchangeable Python variables. I don't know what those are called so i can't look them up.
An example:
template = ['{sti}_Data', '{sti}_OtherData', '{sti}_MaxData']
si = name
What is this method called ?
I think this is basically Python string formatting?
to use your example,
template = ['{}_Data', '{}_OtherData', '{}_MaxData']
si = 'Sauron'
results = [x.format(si) for x in template]
print(results)
# ['Sauron_Data', 'Sauron_OtherData', 'Sauron_MaxData']
There's more here, but I think you'll find much more if you just google Python string fomatting.