[Python-Dev] [Python-checkins] r86566 - in python/branches/py3k: Doc/glossary.rst Doc/library/inspect.rst Lib/inspect.py Lib/test/test_inspect.py Misc/NEWS Misc/python-wing4.wpr
Nick Coghlan
ncoghlan at gmail.com
Sat Nov 20 16:21:32 CET 2010
On Sun, Nov 21, 2010 at 1:07 AM, michael.foord
<python-checkins at python.org> wrote:
> +Fetching attributes statically
> +------------------------------
> +
> +Both :func:`getattr` and :func:`hasattr` can trigger code execution when
> +fetching or checking for the existence of attributes. Descriptors, like
> +properties, will be invoked and :meth:`__getattr__` and :meth:`__getattribute__`
> +may be called.
> +
> +For cases where you want passive introspection, like documentation tools, this
> +can be inconvenient. `getattr_static` has the same signature as :func:`getattr`
> +but avoids executing code when it fetches attributes.
This description feels a little strong to me - getattr_static still
executes all those things on the metaclass as it retrieves the
information it needs to do the "static" lookup. Leaving this original
description (which assumes metaclass=type) alone and adding a note
near the end of the section to say that metaclass code is still
executed might be an improvement.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev
mailing list