chop() and empty() functions

John Machin sjmachin at lexicon.net
Fri May 26 17:16:25 EDT 2006


On 27/05/2006 6:41 AM, Paul Rubin wrote:
> John Machin <sjmachin at lexicon.net> writes:
>> What is the use case? Why write something like """empty(foo, 42,
>> cmd="xyzzy")""" when you could merely write "pass" or nothing at all?
> 
> The function might be a parameter to something.

Please bear with me; it's only about 7 a.m. in this neck of the woods 
and I've had only 2 cups of coffee so far :-)

So one is calling some functions defined like:

def something1(..., afunc, ...):
     ...
     if afunc([], 1.23, "plugh") is None:
         ....

and

def something2(bfunc, ...):
     ...
     if bfunc(sys.stdout, "teehee", 0666) is None:
         ....
etc etc

and there are so many xfuncs with different argument signatures and so 
many times that the caller wants to supply a do-nothing xfunc that 
defining a swallow-any-and-all-args empty() function is warranted???

Thanks in advance for any enlightenment,
Cheers,
John



More information about the Python-list mailing list