Mailing List Archive

Re: [Python-checkins] peps: Added examples.
On Thu, May 24, 2012 at 8:10 PM, eric.smith <> 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:

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".


Nick Coghlan   |   |   Brisbane, Australia
Python-Dev mailing list
Re: [Python-checkins] peps: Added examples. [ In reply to ]
On May 24, 2012 11:29 PM, "Eric V. Smith" <> wrote:
> Possibly I am being too tricky here by modifying parent.__path__, and I
> should just modify sys.path again, as you suggest. But I was trying to
> show that modifying parent.__path__ will also work.

Modifying namespace package __path__ attributes directly seems like a good
way to accidentally break the auto-updating. We probably don't want to
encourage that.


Sent from my phone, thus the relative brevity :)