WOW,
Thanks a lot. I got many options to do, and play with. Each one having its
own pros and cons. But for my requirement in project, i will go with
hasattr/getattr/callable and then calling the ref method. It seems fit for
the problem.
Thanks a lot :) again.
On Dec 1, 2007 12:45 AM, Bruno Desthu
George Sakkis a écrit :
> On Nov 26, 2:04 pm, Bruno Desthuilliers
>
> <[EMAIL PROTECTED]> wrote:
>
>>Donn Ingle a écrit :
>>
>>
I see someone already showed you eval. Eval is evil. Don't use it.
Especially if the functions are coming to you from a public URL!
>>
>>>Yes, I suggested to h
On Nov 26, 2:04 pm, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Donn Ingle a écrit :
>
> >>I see someone already showed you eval. Eval is evil. Don't use it.
> >>Especially if the functions are coming to you from a public URL!
>
> > Yes, I suggested to him (by email) this:
>
> > thisinstanc
Donn Ingle a écrit :
>>target =
>>for funcname in funclist:
>>func = getattr(target, funcname, None)
>>if callable(func):
>>func(*args, **kwargs)
>
> Nice. 'callable' is new to me.
What about getattr, then ?-)
And FWIW, callable will disappear in py3k... (anyway, you can just test
if the objec
> target =
> for funcname in funclist:
> func = getattr(target, funcname, None)
> if callable(func):
> func(*args, **kwargs)
Nice. 'callable' is new to me. Live and learn :)
\d
--
http://mail.python.org/mailman/listinfo/python-list
Donn Ingle a écrit :
>>I see someone already showed you eval. Eval is evil. Don't use it.
>>Especially if the functions are coming to you from a public URL!
>
> Yes, I suggested to him (by email) this:
>
> thisinstance = SomeObject.__class__.__dict__
>
This will only get attributes defined
> I see someone already showed you eval. Eval is evil. Don't use it.
> Especially if the functions are coming to you from a public URL!
Yes, I suggested to him (by email) this:
thisinstance = SomeObject.__class__.__dict__
for f in yourlist:
if f in thisinstance: eval(f)(params)
Which would
On Mon, Nov 26, 2007 at 04:07:03PM +0530, Ravi Kumar wrote regarding Need to
call functions/class_methods etc using string ref :How:
>
>Hi,
>First of all, since this is my first mail to Python-List, I want to say
>"Hello world!"
>After that;
>I am
Well, I don't know all the answers, but you can start here:
def boobs(): print "Oohh little birds!"
b="boobs"
>>>eval(b)()
Ohhh little birds!
Naturally, eval is going to run anything... Even code to format your drive.
HTH
\d
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
First of all, since this is my first mail to Python-List, I want to say
"Hello world!"
After that;
I am stuck in a project. Actually I am writing a module (for testing now),
which takes URL, parses it, finds which modules and then which method to
call or which class to initiate and which string
10 matches
Mail list logo