> able to glean some information. When you call a script __name__ is
set
> to the "Name" of the script called.  example:   python Hope.py
> __name__ = Hope

Actually no. When you *import* a file its name is set to
the file name(or more acurately the module name) When you run
a file from the command line like

python Hope.py

then  __name__ is set to __main__

> but why would I want to do this   if __name__ == '__main__':

So this line lets you create code that is executed when the file
is run from the command line but not when the file is imported.

Alan G.

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

Reply via email to