What can you do in LISP that you can't do in Python
Alex Martelli
aleaxit at yahoo.com
Wed May 23 05:22:18 EDT 2001
<James_Althoff at i2.com> wrote in message
news:mailman.990565593.9251.python-list at python.org...
...
> def doValidation():
> queryForm.validate()
> . . .
>
> def execQuery():
> queryForm.execQuery()
> . . .
>
> def doQuery():
> window.showStatusDuring(
> msg="Validating Query Form ...",
> function=doValidation())
I suspect you don't want the parentheses after doValidation:
you're passing the function, not calling it. A closer analogy
to your hypothetical-unnamed-block later example would of
course be achieved by moving the def statements for doValidation
and execQuery INSIDE doQuery, each just before its use.
> window.showStatusDuring(
> msg="Getting Results ...",
> function=execQuery())
>
> window.showBusyCursorDuring(function=doQuery)
The use of a named-actual-argument 'function' may be a
good idea (I like it...), but it's a further divergence
from your following hypothetical example, where the
anonymous codeblock is being passed with an unspecified
argument-name.
> as contrasted with (in theory):
>
> window.showBusyCursorDuring():
> window.showStatusDuring(msg="Validating Query Form ..."):
> queryForm.validate()
> . . .
> window.showStatusDuring(msg="Getting Results ..."):
> queryForm.execQuery()
> . . .
So, in all, I might recode (while admitting there ARE
still differences!) as:
def doQuery():
def doValidation():
queryForm.validate()
...
window.showStatusDuring("Validating Query Form", doValidation)
def execQuery():
queryForm.execQuery()
...
window.showStatusDuring("Getting Results", execQuery)
window.showBusyCursorDuring(doQuery)
The def-before-you-pass-it need may be best met by defining
JUST-before-you-pass-it.
Alex
More information about the Python-list
mailing list