evaluate a variable
Emile van Sebille
emile at fenx.com
Fri Sep 14 18:40:24 EDT 2001
You might also consider using help:
>>> import pydoc
>>> import sys
>>> pydoc.help(sys)
Help on built-in module sys:
--
Emile van Sebille
emile at fenx.com
---------
<dimitry_snezhkov at yahoo.com> wrote in message
news:mailman.1000475537.30387.python-list at python.org...
> Hi, List
>
> I just started learning Python. Of, course , reading output of
> __doc__
> 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