What exactly is "pass"? What should it be?
MRAB
python at mrabarnett.plus.com
Fri Nov 18 08:03:28 EST 2011
On 18/11/2011 04:34, Dennis Lee Bieber wrote:
> On Thu, 17 Nov 2011 18:18:11 -0800 (PST), John Ladasky
> <ladasky at my-deja.com> declaimed the following in
> gmane.comp.python.general:
>
>> I'm trying to write tidy, modular code which includes a long-running process. From time to time I MIGHT like to check in on the progress being made by that long-running process, in various ways. Other times, I'll just want to let it run. So I have a section of code which, generally, looks like this:
>>
>> def _pass(*args):
>> pass
>>
> This is the equivalent of
>
> def _pass(*args):
> return None
>
Wouldn't "pass_" be a more Pythonic name?
> (functions with no explicit return statement implicitly return None)
>
>> def long_running_process(arg1, arg2, arg_etc, report = _pass):
>> result1 = do_stuff()
>> report(result1)
>
> So this is a call to a function that just returns a None, which is
> dropped by the interpreter...
>
More information about the Python-list
mailing list