From e518931f909d31014af5dbbab24d1bfd44e0a19b Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 12 Aug 2011 16:49:51 -0400 Subject: reduce awkwardness of phrasing --- docs/narr/firstapp.rst | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'docs') diff --git a/docs/narr/firstapp.rst b/docs/narr/firstapp.rst index 66632e123..62389ec5f 100644 --- a/docs/narr/firstapp.rst +++ b/docs/narr/firstapp.rst @@ -166,17 +166,19 @@ Configurator Construction The ``if __name__ == '__main__':`` line in the code sample above represents a Python idiom: the code inside this if clause is not invoked unless the script -containing this code is run directly from the command line. For example, if -the file named ``helloworld.py`` contains the entire script body, the code -within the ``if`` statement will only be invoked when ``python -helloworld.py`` is executed from the operating system command line. - -``helloworld.py`` in this case is a Python :term:`module`. Using the ``if`` -clause is necessary -- or at least best practice -- because code in any -Python module may be imported by another Python module. By using this idiom, -the script is indicating that it does not want the code within the ``if`` -statement to execute if this module is imported; the code within the ``if`` -block should only be run during a direct script execution. +containing this code is run directly from the operating system command +line. For example, if the file named ``helloworld.py`` contains the entire +script body, the code within the ``if`` statement will only be invoked when +``python helloworld.py`` is executed from the command line. + +Using the ``if`` clause is necessary -- or at least best practice -- because +code in a Python ``.py`` file may be eventually imported via the Python +``import`` statement by another ``.py`` file. ``.py`` files that are +imported by other ``.py`` files are referred to as *modules*. By using the +``if __name__ == 'main':`` idiom, the script above is indicating that it does +not want the code within the ``if`` statement to execute if this module is +imported from another; the code within the ``if`` block should only be run +during a direct script execution. The ``config = Configurator()`` line above creates an instance of the :class:`~pyramid.config.Configurator` class. The resulting ``config`` object -- cgit v1.2.3