1

I have this code

keys = {'speed','temp'}

I have the variables like

object.subobj.speed and object.subobj.temp

how can i loop

for key in keys
    print object.subobj.key
3
  • Actually your code should cause a syntax error, the comma should be replaced by a colon Commented Nov 1, 2012 at 9:05
  • which error , its working fine Commented Nov 2, 2012 at 0:38
  • I should have been specific, its valid only for python 2.7+ Commented Nov 2, 2012 at 10:02

1 Answer 1

2
for key in keys:
    print getattr(obj.subobj, key)
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.