[Tutor] basic import question

Chris Kassopulo ckasso@sprynet.com
Thu Jul 10 18:29:02 2003


 > "Jeff Shannon" <jeff@ccvcorp.com>  wrote:
 > Chris Kassopulo wrote:
 > 
 > >def main():
 > >    print "hello world"
 > >main() 
 > >
 > 
 > There's two code blocks in this file.  (Any line followed by a series of 
 > further-indented lines can be seen as a code block.)  Everything in the 
 > block that starts "def main():" is processed to create a function 
 > object, which is bound to the name "main", but it does *not* get 
 > executed at the time that it's defined.  The second code block consists 
 > of the single statement "main()", which then executes the function 
 > object that was previously created.
 > 
 > Hope that makes a bit more sense now...
 > 
   Yes it does.  For some reason I was forgeting about what
   the def main() statement does and thought that an import
   would just execute the rest of the code.  As Magnus asked,
   "what made you think importing it would make it behave
   differently?".  It doesn't.  Thank you all for the
   clarification.
   
   Chris