[Python-checkins] peps: Added examples.

Nick Coghlan ncoghlan at gmail.com
Thu May 24 14:47:14 CEST 2012


On Thu, May 24, 2012 at 8:10 PM, eric.smith <python-checkins at python.org> wrote:
> +   Lib/test/namspace_pkgs

Typo: s/namspace/namespace/

> +Here we add the parent directories to ``sys.path``, and show that the
> +portions are correctly found::
> +
> +    >>> import sys
> +    >>> sys.path += ['Lib/test/namespace_pkgs/parent1/parent', 'Lib/test/namespace_pkgs/parent2/parent']

The trailing "/parent" shouldn't be there on either of these paths.
The comments that refer back to these also need the same adjustment.

> +   Lib/test/namspace_pkgs

Same typo as above.

> +    # add the first two parent paths to sys.path
> +    >>> import sys
> +    >>> sys.path += ['Lib/test/namespace_pkgs/parent1/parent', 'Lib/test/namespace_pkgs/parent2/parent']

Again, need to lose the last directory from these paths and the
comments that refer to them.

> +    # now add parent3 to the parent's __path__:
> +    >>> parent.__path__.append('Lib/test/namespace_pkgs/parent3/parent')

This modification is incorrect, it should be:
    sys.path.append('Lib/test/namespace_pkgs/parent3')

and both parent.__path__ and parent.child.__path__ should pick up
their extra portions on the next import attempt.

Also, I suggest renaming "parent1", "parent2" and "parent3" to
"project1", "project2" and "project3".

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-checkins mailing list