Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33427

RE: Lazy Attribute

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <andriy.kornatskyy@live.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'attribute': 0.05; 'case.': 0.05; 'none,': 0.05; '-0500': 0.07; 'parameter': 0.07; '(it': 0.09; 'descriptor': 0.09; 'exception,': 0.09; 'itself,': 0.09; 'raised.': 0.09; 'satisfy': 0.09; 'cases': 0.15; 'object).': 0.16; 'set,': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'translate': 0.20; 'to:name:python-list@python.org': 0.20; 'skip:- 40': 0.21; 'thanks.': 0.21; 'do.': 0.21; 'minor': 0.22; 'to:2**1': 0.23; 'properties': 0.24; 'raise': 0.24; 'thus': 0.24; 'header:In- Reply-To:1': 0.25; 'am,': 0.27; 'mind.': 0.27; "doesn't": 0.28; 'unlikely': 0.29; 'date:': 0.29; 'url:mailman': 0.29; 'objects': 0.29; 'class': 0.29; 'checks': 0.30; 'fri,': 0.30; 'function': 0.30; 'sense': 0.31; 'url:python': 0.32; 'could': 0.32; 'url:listinfo': 0.32; 'from:addr:live.com': 0.33; 'true.': 0.33; 'to:addr:python-list': 0.33; 'nov': 0.35; 'add': 0.36; 'subject:': 0.36; 'but': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'useful': 0.36; 'being': 0.37; 'subject:: ': 0.38; 'from:': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'url:mail': 0.40; 'email name:python-list': 0.62; 'potentially': 0.66; 'realized': 0.71; 'special': 0.73; '99.9%': 0.84; 'actually,': 0.84; 'forced': 0.84; 'outcome:': 0.84; 'to:addr:msn.com': 0.93; 'charset:windows-1251': 0.97
X-Originating-IP [194.44.213.194]
From Andriy Kornatskyy <andriy.kornatskyy@live.com>
To <rouslank@msn.com>, "python-list@python.org" <python-list@python.org>
Subject RE: Lazy Attribute
Date Fri, 16 Nov 2012 13:31:58 +0300
Importance Normal
In-Reply-To <%jops.44$TT7.13@newsfe04.iad>
References <%jops.44$TT7.13@newsfe04.iad>
Content-Type text/plain; charset="windows-1251"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-OriginalArrivalTime 16 Nov 2012 10:31:59.0539 (UTC) FILETIME=[9BF9F830:01CDC3E5]
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3743.1353061987.27098.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1353061987 news.xs4all.nl 6927 [2001:888:2000:d::a6]:47288
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33427

Show key headers only | View raw


This is very minor use case. Unlikely useful to add any checks for None, or translate one exception to the other... with pretty much the same outcome: it makes sense in objects only.

Thanks.

Andriy

----------------------------------------
> From: rouslank@msn.com
> Subject: Re: Lazy Attribute
> Date: Fri, 16 Nov 2012 05:12:11 -0500
> To: python-list@python.org
>
> On 11/16/2012 04:32 AM, Rouslan Korneychuk wrote:
> > On 11/16/2012 02:49 AM, Andriy Kornatskyy wrote:
> >>> If accessing the descriptor on the class object has no special
> >>> meaning, then the custom is to return the descriptor object itself, as
> >>> properties do.
> >>
> >> If I would satisfy this, I will be forced to check for None 99.9% of
> >> the use cases (it is not None, being applied to an object). Thus it
> >> behaves as designed.
> >
> > That's not true. You can use a try-except block to return the descriptor
> > object when an AttributeError is raised.
>
> Actually, never mind. I just realized the function has to be called
> before the attribute can be set, which can not-only raise any exception,
> but could potentially have undesired side-effects given a parameter it
> doesn't expect.
> --
> http://mail.python.org/mailman/listinfo/python-list
 		 	   		  

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

RE: Lazy Attribute Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-16 10:49 +0300
  Re: Lazy Attribute Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-16 09:04 +0000
    RE: Lazy Attribute Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-16 13:27 +0300
  Re: Lazy Attribute Rouslan Korneychuk <rouslank@msn.com> - 2012-11-16 04:32 -0500
    Re: Lazy Attribute Rouslan Korneychuk <rouslank@msn.com> - 2012-11-16 05:12 -0500
      RE: Lazy Attribute Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-16 13:31 +0300

csiph-web