evaluate a variable

dimitry_snezhkov at yahoo.com dimitry_snezhkov at yahoo.com
Fri Sep 14 15:51:36 CEST 2001

Hi, List

I just started learning Python. Of, course , reading  output of
is very pleasant. I decided to output documentation for every def in 
a module. How do I evaluate a variable that is dynamicaly generated.
Sort of hello.$bye.see_ya in Perl :

Here's my code :
    import sys

    for each in range(len(dir(sys))):
        method='sys' + '.' + dir(sys)[each] + '.' + '__doc__'
        ## i cannot do  
        print method.__doc__
        ## this doesn't evaluate method properly.
        ## Does eval work in this situation?

Also, please, let me know if what I am trying to do is awkward way of
doing it. How does Python approach such evaluation.

Thanks you.

More information about the Python-list mailing list