On Thu, Nov 12, 2009 at 6:26 PM, bob gailer <bgai...@gmail.com> wrote: > Stefan Lesicnik wrote: >> >> Hi guys, >> >> Im trying to do something and hit a bit of a wall, potentially im >> going about this the wrong way. Essentially the problem is: >> >> features file contains >> rt='''text''' >> >> import features >> >> a = 'rt' >> print features.rt #this works >> print features.a #this fails >> >> I need to use features.a as i am iterating through a list and a would >> be the different features i want to check if they exist, and then use >> the variable. >> >> I hope that makes sense, or if anyone has any suggestion on how >> properly to do this! >> > > Even though Alan missed your point, I understood it. So your explanation was > OK (for me). > > print getattr(features, a)
Thanks Bob! That works. I hadn't heard about getattr Much appreciated stefan _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor