function pointer

Gerhard Häring gerhard.haering at opus-gmbh.net
Wed Sep 11 06:46:44 EDT 2002


David Brown wrote:
> "Christina" <christina at iaeste.at> wrote in message
> news:ffcedbc9.0209110215.644c1788 at posting.google.com...
>> Hi!
>>
>> Does Python have function pointers? If not, is there a possibility to
> emulate them?
^^

Broken quoting - yuck! Your newsreader is broken. Please repair it (using
third party software) or make Usenet a better place by throwing away that
crapware.

> Functions are first-order objects (is that the right term?)

It is.

> in Python, so you can just assign them to a variable.

If we want to keep the terminology right, Python doesn't have variables. It
has names and values. Values are bound to names. In your case:

For example:

> def foo(x):
>     print x

... you create a function object using the def statement and bind it to the
name 'foo'.

> bar = foo

Here you bind the name 'bar' to the value the name 'foo' refers to.

-- Gerhard



More information about the Python-list mailing list