dir() with string as argument
harold fellermann
harold.fellermann at upf.edu
Thu Jun 16 15:19:06 EDT 2005
On 16.06.2005, at 20:59, Shankar Iyer (siyer at Princeton.EDU) wrote:
> Hi,
>
> Suppose I have a string, sModuleName, that contains the name of a
> module. I now want to see what functions are in that module, but if I
> call dir(sModuleName), I instead get the list of operations that can
> be done on a string. Is there any way to convert the string into a
> format that I could feed to dir to cause the desired effect? I think
> I could modify the string a bit and then use the exec command, but I
> was advised against that on this board last week.
you have to import the module:
name = "sys"
mod = __import__(name)
dir(mod)
- harold -
--
Bitte verlassen Sie diese Welt so,
wie Sie sie vorfinden möchten.
--
More information about the Python-list
mailing list