make order of function definitions irrelevant

Derrick 'dman' Hudson dman at dman13.dyndns.org
Tue Nov 11 09:28:59 EST 2003


Joerg Schuster <js at cis.uni-muenchen.de> wrote:

> (2) Python functions
> 
> def NP():
>   return sequence(det(), AP(), n())
> 
> def AP():
>   return sequence(plus(adv(), a())

As pointed out, this is perfectly valid python code because the AP
function (and presumably det(), adv(), n(), and a()) is defined before
NP() is called.  The key isn't the order of the definitions in the
file, but the order of execution.  The 'def' statement is executed
like any other, in python.  The function doesn't exist until it is
defined.  This is rather like C, C++, and Java, you just notice it
differently because python provides a way to attempt to call a
non-existant function.  In C, etc., you must define the functions
before compilation will succeed and compiltion is a prereq for
execution.

HTH,
-D

-- 
\begin{humor}
Disclaimer:
If I receive a message from you, you are agreeing that:
   1. I am by definition, "the intended recipient"
   2. All information in the email is mine to do with as I see fit and make
        such financial profit, political mileage, or good joke as it lends
        itself to. In particular, I may quote it on USENET or the WWW.
   3. I may take the contents as representing the views of your company.
   4. This overrides any disclaimer or statement of confidentiality that may
        be included on your message
\end{humor}
 
www: http://dman13.dyndns.org/~dman/            jabber: dman at dman13.dyndns.org




More information about the Python-list mailing list