[Python-ideas] Really support custom types for global namespace

Chris Angelico rosuav at gmail.com
Fri Jun 20 01:07:17 CEST 2014


On Fri, Jun 20, 2014 at 5:26 AM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> "it must be a dictionary" implies to me the exclusion of subclasses.

This is something where the docs and most code disagree. When you call
isinstance(), it assumes LSP and accepts a subclass, but the Python
docs tend to be explicit about accepting subclasses. That's fine when
they do (eg https://docs.python.org/3/reference/simple_stmts.html#raise
says "subclass or an instance of BaseException"), but less clear when
not.

Would it be worth adding a few words to the docs saying this?

"""If only globals is provided, it must be a dictionary, which will be
used..."""
-->
"""If only globals is provided, it must be (exactly) a dict, which
will be used...""" with the word dict being a link to
stdtypes.html#mapping-types-dict ?

ChrisA


More information about the Python-ideas mailing list