On Sun, Nov 21, 2010 at 1:07 AM, michael.foord
<python-check...@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   |   ncogh...@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/archive%40mail-archive.com

Reply via email to