Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'attribute': 0.05; '@property': 0.09; 'cached': 0.09; 'immutable': 0.09; 'objects.': 0.09; 'refresh': 0.09; ';-)': 0.11; 'anyway': 0.11; 'assume': 0.11; 'to:name:python-list': 0.15; 'advocating': 0.16; 'value:': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'mechanism': 0.17; 'stefan': 0.17; 'tests.': 0.17; 'handles': 0.18; 'solution.': 0.18; '>>>': 0.18; 'cc:2**0': 0.23; 'pass': 0.25; 'header:In- Reply-To:1': 0.25; '+0100': 0.27; 'reply.': 0.28; "d'aprano": 0.29; 'received:192.168.1.3': 0.29; 'steven': 0.29; 'date:': 0.29; "i'm": 0.29; 'fri,': 0.30; 'implement': 0.32; 'towards': 0.32; 'to:addr:python-list': 0.33; 'nov': 0.35; 'something': 0.35; 'subject:': 0.36; 'wanted': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'subject:: ': 0.38; 'from:': 0.38; 'url:en': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'header:Message-Id:1': 0.62; 'email name :python-list': 0.62; 'evaluate': 0.62; 'confirm': 0.64; 'decided': 0.65; 'received:at': 0.71; 'arise.': 0.84 Subject: Re: Lazy Attribute Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: "Stefan H. Holek" In-Reply-To: Date: Fri, 16 Nov 2012 13:46:01 +0100 Content-Transfer-Encoding: quoted-printable References: , , <50a6156e$0$29978$c3e8da3$5496439d@news.astraweb.com>, To: python-list X-Mailer: Apple Mail (2.1085) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353069963 news.xs4all.nl 6880 [2001:888:2000:d::a6]:39239 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33434 On 16.11.2012, at 11:54, Andriy Kornatskyy wrote: >> Subject: Re: Lazy Attribute >> From: stefan@epy.co.at >> Date: Fri, 16 Nov 2012 11:45:32 +0100 >> To: python-list@python.org >>=20 >> On 16.11.2012, at 11:29, Steven D'Aprano wrote: >>=20 >>> I'm very vaguely leaning towards this as the least-worst solution to >>> invalidating the cached value: >>>=20 >>> refresh(obj, 'attr') # pass the instance and the name >>=20 >> This it exactly how lazy handles invalidation. = http://lazy.readthedocs.org/en/latest/ >=20 > @property is a solution to evaluate something that is dynamic. = @attribute is good for immutable objects. Even if we assume refresh is a = good idea... how I would know when it is valid to `refresh`? What is = criteria? >=20 > Andriy I had to implement invalidation anyway in order to write tests. I = decided to expose the mechanism to keep users from having to invent = their own SHOULD the need arise. I was not advocating invalidation in = any way with my reply. All I wanted was to confirm the "least bad" = solution. ;-) Stefan --=20 Stefan H. Holek stefan@epy.co.at