diff -r cb612c5f30cb Doc/faq/programming.rst --- a/Doc/faq/programming.rst Thu Nov 15 18:22:23 2012 +0000 +++ b/Doc/faq/programming.rst Tue Jul 16 17:49:17 2013 -0400 @@ -1439,15 +1439,12 @@ How do I create a .pyc file? ---------------------------- -When a module is imported for the first time (or when the source is more recent -than the current compiled file) a ``.pyc`` file containing the compiled code -should be created in the same directory as the ``.py`` file. - -One reason that a ``.pyc`` file may not be created is permissions problems with -the directory. This can happen, for example, if you develop as one user but run -as another, such as if you are testing with a web server. Creation of a .pyc -file is automatic if you're importing a module and Python has the ability +A ``.pyc`` file, a byte code cache file, is created when a module is imported +for the first time or when the module source is updated. Creation of a .pyc +file is automatic if you're importing a module (provided Python has the ability (permissions, free space, etc...) to write the compiled module back to the +directory). The ``.pyc`` file is placed in the ``__pycache__`` directory. If the +``__pycache__`` directory does not already exist, it will be created in the package directory. Running Python on a top level script is not considered an import and no ``.pyc`` @@ -1466,7 +1463,7 @@ >>> import py_compile >>> py_compile.compile('abc.py') -This will write the ``.pyc`` to the same location as ``abc.py`` (or you can +This will write the ``.pyc`` to the ``__pycache__`` directory (or you can override that with the optional parameter ``cfile``). You can also automatically compile all files in a directory or directories using @@ -1476,6 +1473,10 @@ python -m compileall . +One reason that a ``.pyc`` file may not be created is permissions problems with +the directory. This can happen, for example, if you develop as one user but run +as another, such as if you are testing with a web server. + How do I find the current module name? --------------------------------------