On Oct 19, 6:34 am, Nils <[EMAIL PROTECTED]> wrote:
> Use apply(): http://docs.python.org/lib/non-essential-built-in-funcs.html
Did you actually read the title of the page you linked to ("Non-
essential Built-in Functions")?
--
http://mail.python.org/mailman/listinfo/python-list
Sushant napisał(a):
> getattr seems to be converting string into function pointer and I am just
> saying that string cannot be used as a function pointer in Python as may be
> in PHP.
It seems, but it does not. Getattr performs lookup on object's
attributes dict, it does not "convert" anything.
I did not know about getattr and it is the right thing.
getattr seems to be converting string into function pointer and I am just
saying that string cannot be used as a function pointer in Python as may be
in PHP.
I copied the PHP code so I did not replace arrow with dot. Good point :)
-Sush
On Fri, 19 Oct 2007 10:29:12 -0400, Sushant wrote:
> Python will not allow string to be used a function pointer. It is type
> unsafe. Best way is to convert string into function pointers manually.
>
> if dynamicMethod == 'bar':
> method = oFoo->bar
> else:
> method = oFoo->default
> metho
On Fri, 19 Oct 2007 11:34:39 +, Nils wrote:
> Use apply():
> http://docs.python.org/lib/non-essential-built-in-funcs.html
No, don't use apply. Not only does it not solve the original poster's
problem, it is a deprecated function. You shouldn't use it in new code.
--
Steven.
--
http://
Sushant wrote:
> Python will not allow string to be used a function pointer. It is type
> unsafe. Best way is to convert string into function pointers manually.
>
> if dynamicMethod == 'bar':
> method = oFoo->bar
> else:
> method = oFoo->default
> method()
Sorry to say so, but that answe
Python will not allow string to be used a function pointer. It is type unsafe.
Best way is to convert string into function pointers manually.
if dynamicMethod == 'bar':
method = oFoo->bar
else:
method = oFoo->default
method()
On Friday 19 October 2007 7:56 am, Diez B. Roggisch wrote:
> N
Nils wrote:
> On Oct 19, 12:39 pm, [EMAIL PROTECTED] wrote:
>> Hello,
>>
>> Is there any way (other then eval) to invoke a method by passing
>> method name in a string.
>> It's very simple in php:
>> $oFoo = new Foo();
>> $dynamiMethod = "bar";
>> $oFoo->$dynamiMethod();
>>
>> Unfortunately I can'
On Oct 19, 12:39 pm, [EMAIL PROTECTED] wrote:
> Hello,
>
> Is there any way (other then eval) to invoke a method by passing
> method name in a string.
> It's very simple in php:
> $oFoo = new Foo();
> $dynamiMethod = "bar";
> $oFoo->$dynamiMethod();
>
> Unfortunately I can't find a good solution to
[EMAIL PROTECTED] wrote:
> On 19 Oct, 11:45, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>> [EMAIL PROTECTED] napisa³(a):
>>
>> > Is there any way (other then eval) to invoke a method by passing
>> > method name in a string.
>> > It's very simple in php:
>> > $oFoo = new Foo();
>> > $dynamiMethod = "b
On 19 Oct, 11:45, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] napisa³(a):
>
> > Is there any way (other then eval) to invoke a method by passing
> > method name in a string.
> > It's very simple in php:
> > $oFoo = new Foo();
> > $dynamiMethod = "bar";
> > $oFoo->$dynamiMethod();
>
>
[EMAIL PROTECTED] napisał(a):
> Is there any way (other then eval) to invoke a method by passing
> method name in a string.
> It's very simple in php:
> $oFoo = new Foo();
> $dynamiMethod = "bar";
> $oFoo->$dynamiMethod();
>
> Unfortunately I can't find a good solution to do the same thing in
> p
Hello,
Is there any way (other then eval) to invoke a method by passing
method name in a string.
It's very simple in php:
$oFoo = new Foo();
$dynamiMethod = "bar";
$oFoo->$dynamiMethod();
Unfortunately I can't find a good solution to do the same thing in
python. Does it have some build-in functio
13 matches
Mail list logo