diff options
| author | Chris McDonough <chrism@plope.com> | 2011-08-12 16:49:51 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-08-12 16:49:51 -0400 |
| commit | e518931f909d31014af5dbbab24d1bfd44e0a19b (patch) | |
| tree | 3ef480ec4e24a01805fa3c0ccb78c75a75e2bf28 /docs/narr/firstapp.rst | |
| parent | d6a5228e6f3c4569fba9a8fff382120cd233baf0 (diff) | |
| download | pyramid-e518931f909d31014af5dbbab24d1bfd44e0a19b.tar.gz pyramid-e518931f909d31014af5dbbab24d1bfd44e0a19b.tar.bz2 pyramid-e518931f909d31014af5dbbab24d1bfd44e0a19b.zip | |
reduce awkwardness of phrasing
Diffstat (limited to 'docs/narr/firstapp.rst')
| -rw-r--r-- | docs/narr/firstapp.rst | 24 |
1 files changed, 13 insertions, 11 deletions
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 |
