Mailing List Archive

Re: [Python-checkins] peps: Added examples.
On Thu, May 24, 2012 at 8:10 PM, eric.smith <python-checkins@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@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com
Re: [Python-checkins] peps: Added examples. [ In reply to ]
On May 24, 2012 11:29 PM, "Eric V. Smith" <eric@trueblade.com> 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.

Cheers,
Nick.

--
Sent from my phone, thus the relative brevity :)