Reputation: 910
eg. correct sample -
f.write("\t" +connection_name+ "\t =" + qs.connection_name + "\n")
what I'm trying to do -
f.write("\t" +current+ "\t=" +qs.current+ "\n")
//here current = 'connection_name'
How to concatenate in this kind - qs.current
so that it prints as qs.connection_name
's value
Upvotes: 2
Views: 49
Reputation: 117856
You can use getattr
getattr(qs, current)
So in the context of your code
f.write("\t" + current + "\t=" + getattr(qs, current) + "\n")
Upvotes: 2