Modul gotchas:)

Giorgi Lekishvili gleki at gol.ge
Wed Jan 2 17:35:32 EST 2002


Thanx for the hint!

However, when I applied this to the 'math' module, it yielded []...
I must have missed something.

If I have all_func list of the function names, i.e., strings, not
pointers, I can do something like this:

class someClass:
    ....

    def getVector(self, names):
        vector=[]
        import myModule
        all_func=myModule.some_way_to_get_the_names()
        for name in names:
            if name in all_func:
                f=eval('myModule.'+name)
                vector.append(f(self.somthing))
        return vector


the names must be the list of strings...


Wolfgang Strobl wrote:

> Giorgi Lekishvili <gleki at gol.ge> schrieb am Wed, 02 Jan 2002 13:13:44
> -0800:
>
> >How can one get the names of all these functions as list entries?
> >
> >E.g.,
> >
> >all_func=[]
> >
> >import myModule
> >
> >all_func=myModule.functions()
> >
> >of course, this will not work.
> >
> >What is to be done? Some special functions are to be written or, is
> >there a built-in tool?
>
> all_func=filter(lambda x:type(myModule.__dict__[x])==\
> type(lambda x:x),myModule.__dict__.keys())
>
> Now the question is: what are you going to do with that list?
>
> --
> #define print void main(){ printf(
> print "signature under construction"
> #define pass );}
> pass




More information about the Python-list mailing list