What exactly is "pass"? What should it be?
Chris Angelico
rosuav at gmail.com
Thu Nov 17 21:59:13 EST 2011
On Fri, Nov 18, 2011 at 1:18 PM, John Ladasky <ladasky at my-deja.com> wrote:
> def _pass(*args):
> pass
>
> def long_running_process(arg1, arg2, arg_etc, report = _pass):
>
For some compactness at the expense of brevity, you could use a lambda:
def long_running_process(arg1, arg2, arg_etc, report = lambda msg: None):
Other than that, I think it's fine. (Actually, the lambda has a slight
advantage in self-documentation; in the main function's definition it
specifies that the 'report' argument is a function that takes one
argument, the message. (Or whatever that argument is. Name it
appropriately.)
If you call your dummy function something else, it may help
readability/self-documentation too. On the other hand, it may not.
YMMV.
ChrisA
More information about the Python-list
mailing list