(original) (raw)
Given that we're also allowing customization of \_\_dir\_\_ I wouldn't want to link this to \_\_dir\_\_. But maybe you meant to say that vars() is the public interface for \_\_dict\_\_. Even if it were, in the case of specifying this particular customization for this PEP, I strongly prefer to write it in terms of \_\_dict\_\_.
On Sun, Nov 19, 2017 at 6:34 PM, Steven D'Aprano <steve@pearwood.info> wrote:
On Sun, Nov 19, 2017 at 05:34:35PM -0800, Guido van Rossum wrote:
\> On Sun, Nov 19, 2017 at 4:57 PM, Steven D'Aprano <steve@pearwood.info>
\> wrote:
> > A minor point: this should(?) be written in terms of the public
\> > interface for accessing namespaces, namely:
\> >
\> > getter = vars(mod)\["\_\_getattr\_\_"\]
\>
\> Should it? The PEP is not proposing anything for other namespaces. What
\> difference do you envision this way of specifying it would make?
I don't know if it should -- that's why I included the question mark.
But my idea is that \_\_dict\_\_ is the implementation and vars() is the
interface to \_\_dir\_\_, and we should prefer using the interface rather
than the implementation unless there's a good reason not to.
(I'm not talking here about changing the actual name lookup code to go
through vars(). I'm just talking about how we write the equivalent
recipe.)
Its not a big deal either way, \_\_dict\_\_ is already heavily used and
vars() poorly known. Call it a matter of taste, if you like, but in my
opinion the fewer times we directly reference dunders, the better.
\--
Steve
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/ guido%40python.org
--
--Guido van Rossum (python.org/\~guido)