Eric Walker wrote:
> Hello,
> If I have some like the following:
> 
> markersExp = ['big','boss','two','three']
> for mark in markersExp:
>      print y.mark
> 
> Now I have an list of class objects that are in an outerloop. y is how I 
> access it. The attributes names of the class objects match whats in 
> markersExp. Can I do that print statement in a way to allow me to print the 
> value of the class attribute?

Use getattr():
  print getattr(y, mark)

http://docs.python.org/lib/built-in-funcs.html#l2h-31

Kent

-- 
http://www.kentsjohnson.com

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to