2

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

2
  • 1
    what is the error you are receiving? Commented May 30, 2018 at 11:38
  • Actually was using it to print the value of object so it was showing - object has no attribute 'current' Commented May 30, 2018 at 11:54

1 Answer 1

2

You can use getattr

getattr(qs, current)

So in the context of your code

f.write("\t" + current + "\t=" + getattr(qs, current) + "\n")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.