function pointer

holger krekel pyth at
Wed Sep 11 12:27:13 CEST 2002

Christina wrote:
> Hi!
> Does Python have function pointers? 

yes. Try it on the commandline prompt (type 'python'):

>>> def f(arg):
        print arg

>>> f
<function f at 0x813eeec>

and even better python has bound methods:

>>> class a:
         def f(self, arg):
             print arg

>>> a1=a()
>>> a1.f
<bound method a.f of <__main__.a instance at 0x813ee74>>

you can pass these functions and methods around and apply them
as you wish. Very powerful.


More information about the Python-list mailing list