Lazy Attribute

Andriy Kornatskyy andriy.kornatskyy at live.com
Fri Nov 16 11:31:58 CET 2012


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 at msn.com
> Subject: Re: Lazy Attribute
> Date: Fri, 16 Nov 2012 05:12:11 -0500
> To: python-list at 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
 		 	   		  


More information about the Python-list mailing list