[Pythonmac-SIG] silly variable evaluation question
Dante
dante@oz.net
Sat, 27 Nov 1999 12:39:15 -0800
> > I'm beating my head into the monitor trying to do the following:
> >
> > import Res
> > foo = dir(Res)[0]
> > print Res.foo.__doc__
> >
> > this throws an obvious error as foo isn't defined in Res. So how do I
> > evaluate foo in context.<snip>
>
>I think you are trying to do something like the following:
>
>import Res
>for i in dir(Res):
> try:
> print i; print '\t',
> exec( "print Res.%s.__doc__" % i )
> except AttributeError:
> # prevent things like strings from raising exceptions
> print "no docstring"
That seems pretty extravagant, is that really the only way to do
this? Where is the % behavior being exhibited in this documented? The
python documentation appears to be lengthy but organized extremely
poorly.
Dante