On 5/24/10 13:59 , Vincent Pelletier wrote:
> Hi.
>
> I think the example on volatile attributes given in "Advanced ZODB for Python
> Programmers" article[1] shows a bad practice.
>
>> From the article:
> if hasattr(self, '_v_image'):
> return self._v_image
>
> This should be rewritten as:
> try:
> return self._v_image
> except AttributeError:
or better:
marker = []
value = getattr(self, "_v_image", marker)
if value is not marker:
return value
which prevents the exception overhead.
Wichert.
_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/
ZODB-Dev mailing list - [email protected]
https://mail.zope.org/mailman/listinfo/zodb-dev