Does python always need to compile ENTIRE program before it canstart to run it???

Michael T. Babcock mbabcock at fibrespeed.net
Mon Nov 3 15:45:41 EST 2003


 
>
>
>"Michael T. Babcock" wrote:
>  
>
>>> ... that'll still run 'fine' because you don't use "a"
>>> 
>>> That said, the "compilation" time of a Python program is almost
>>> nonexistant in most cases.  Most of the work is runtime; load a class,
>>> wait for the class to compile, and so on..
>>    
>>
>
>That's not *exactly* true, I'm afraid.  The above example would
>actually raise a NameError, since the name "help" is not defined
>at the time of execution, if you tried constructing an a().
>  
>

You seem to have completely missed my saying 'because you don't use "a"' 
in that message.  In fact, I actually ran that program to check before 
making the post.  For what its worth, if you had "help = " instead of 
just "help", it would raise a SyntaxError on execution.  However, it 
doesn't know if "help" is a valid statement or not yet because it hasn't 
evaluated 'a' and therefore leaves you alone about it.

>Therefore I believe your first statement is actually not true, and
>in fact Python code that "wouldn't compile" actually cannot be run,
>because it has to be compiled prior to running.
>

It does not throw a SyntaxError, and it does in fact run.  Have a go at it.

-- 
Michael T. Babcock
C.T.O., FibreSpeed Ltd.
http://www.fibrespeed.net/~mbabcock







More information about the Python-list mailing list