High Order Messages in Python

Jp Calderone exarkun at divmod.com
Sat Oct 22 18:00:30 EDT 2005


On 22 Oct 2005 14:12:16 -0700, "eduardo.padoan at gmail.com" <eduardo.padoan at gmail.com> wrote:
>I'm reading about "high order messages" in Ruby by Nat Pryce, and
>thinking if it could be  util and if so, if it could be done in Python.
>Someone already tried?

Here's an example of the idea, in Python:

    def messageA():
        print 'Message A received!'

    def messageB(otherMessage):
        print 'Message B received!  Sending some other message.'
        otherMessage()

    messageB(messageA)

Since this is a basic feature of Python, we usually don't call them messages.  Instead, "functions" or sometimes "methods".

Jp



More information about the Python-list mailing list