function pointer

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Wed Sep 11 13:25:51 CEST 2002


On Wednesday 11 Sep 2002 10:15 am, Christina wrote:
> Hi!
>
> Does Python have function pointers? If not, is there a possibility to
> emulate them?


Excuse my ignorance but what is a function pointer....  
could this be the answer:-


def aFunction():
    print "aFunction was called"

## call it
aFunction()

## create a reference to it
af=aFunction

## call the reference
af()

## at the python command line:-

[dev]$ python
Python 2.2.1 (#3, May 29 2002, 20:32:44)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def aFunction():
...     print "aFunction was called"
...
>>> aFunction()
aFunction was called
>>> af=aFunction
>>> af()
aFunction was called
>>>


Regards
Martin





More information about the Python-list mailing list