[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 (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Sat Nov 20 16:21:32 CET 2010
- Previous message: [Python-Dev] [Python-checkins] pymigr: Build identification patch is updated, but only for Unix.
- Next message: [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
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.getattrstatic
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
- Previous message: [Python-Dev] [Python-checkins] pymigr: Build identification patch is updated, but only for Unix.
- Next message: [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
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]