Alan Gauld wrote:
> "nibudh" <[EMAIL PROTECTED]> wrote
> 
>> in perl this works:
>>
>> #!/usr/bin/env perl
>> hello("World");
>>
>> sub hello {
>>    print "Hello ". $_[0] . "\n";
>> }
> 
> 
> Perl executes differently to Python in that it does a compilation 
> stage
> before executing. Therefore Perl knows about all the function 
> definitions
> prior to executing any code. Python compiles modules which it imports
> but not scripts which it executes.

Python compiles all scripts to bytecode. For imported modules it saves 
the compiled bytecode in a .pyc file, but not for directly-executed 
scripts. However this has no bearing on the current thread; for both 
imported modules and executed scripts, a function must be defined before 
it can be called.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to