functions which take functions

Dave Angel d at davea.name
Wed Apr 11 07:18:33 EDT 2012


On 04/11/2012 06:55 AM, Kiuhnm wrote:
> On 4/10/2012 23:43, Eelco wrote:
>> On Apr 10, 3:36 am, Kiuhnm<kiuhnm03.4t.yahoo.it>  wrote:
>>> On 4/10/2012 14:29, Ulrich Eckhardt wrote:
>>>
>>>> Am 09.04.2012 20:57, schrieb Kiuhnm:
>>>>> Do you have some real or realistic (but easy and self-contained)
>>>>> examples when you had to define a (multi-statement) function and
>>>>> pass it
>>>>> to another function?
>>>
>>>> Take a look at decorators, they not only take non-trivial functions
>>>> but
>>>> also return them. That said, I wonder what your intention behind this
>>>> question is...
>>>
>>>> :)
>>>
>>> That won't do. A good example is when you pass a function to re.sub,
>>> for
>>> instance.
>>>
>>> Kiuhnm
>>
>> Wont do for what? Seems like a perfect example of function-passing to
>> me.
>
> That's more an example of function transformation.
>
>> If you have such a precise notion of what it is you are looking for,
>> why even ask?
>
> As I said, I need real-life examples. Enough with prime numbers and
> recursive qsort...
>
> Kiuhnm

How about any GUI application?  Every gui interface I've seen makes you
register your callbacks as functions, by passing the function object
into some gui function specific to an event or class of events.

Then when the event fires, the function is actually called.

-- 

DaveA




More information about the Python-list mailing list