Python dynamic function selection
Dragos Chirila
d.chirila at finsiel.ro
Wed May 12 04:55:04 EDT 2004
Hi
for rule in rules:
rule()
because rule it is a function
Regards,
Dragos
----- Original Message -----
From: "Eric" <ekoome at yahoo.com>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Wednesday, May 12, 2004 11:42 AM
Subject: Python dynamic function selection
> The following example will explain what i want to do:
> >>> def func():
> print "true"
> >>> rules=(func,)
> >>> for rule in rules:
> rule
>
> I expect the final function to print true, but instead i have
> <function func at 0x00DC6EB0>
>
> How do i get it to print true. I know if i had parameters in rule
> like:
> >>> def func(var):
> print var
> >>> rules=(func,)
> >>> for rule in rules:
> rule("true")
> it will work. But in my case i don't need to pass any parameters.
>
> How do i get the former method to print instead of returning a
> function?
>
> Eric
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list