[Python-checkins] r80854 - python/trunk/Doc/whatsnew/2.7.rst
Nick Coghlan
ncoghlan at gmail.com
Thu May 6 15:27:01 CEST 2010
andrew.kuchling wrote:
> +* New function: :func:`~runpy.run_path` in the :mod:`runpy` module
> + will execute the code at a provided *path* argument. *path* can be
> + the path of a Python source file (:file:`example.py`), a compiled
> + bytecode file (:file:`example.pyc`), a directory
> + (:file:`./package/'), or a zip archive (:file:`example.zip`). If a
> + directory or zip path is provided, it will be added to the front of
> + ``sys.path`` and the module :mod:`__main__` will be imported. It's
> + expected that the directory or zip contains a :file:`__main__.py`;
> + if it doesn't, some other :file:`__main__.py` might be imported from
> + a location later in ``sys.path``. This makes some of the machinery
> + of :mod:`runpy` available to scripts that want to mimic the behaviour
> + of Python's :option:`-m` switch. (Added by Nick Coghlan;
> + :issue:`6816`.)
-m (or, more accurately, it's very close cousin) is already available
through runpy.run_module().
The new function is to make it easier to mimic the way the command line
processes an explicit path name (most notably, the zipfile/directory
execution stuff that was added in 2.6).
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
More information about the Python-checkins
mailing list