RE: Lazy Attribute

Discussion in 'Python' started by Andriy Kornatskyy, Nov 16, 2012.

  1. 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:
    > Subject: Re: Lazy Attribute
    > Date: Fri, 16 Nov 2012 05:12:11 -0500
    > To:
    >
    > 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
     
    Andriy Kornatskyy, Nov 16, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Pu
    Replies:
    3
    Views:
    679
    Steven D'Aprano
    Jan 16, 2009
  2. Boris Borcic
    Replies:
    0
    Views:
    559
    Boris Borcic
    Jan 16, 2009
  3. Boris Borcic
    Replies:
    0
    Views:
    552
    Boris Borcic
    Jan 16, 2009
  4. Ian Kelly

    Re: Lazy Attribute

    Ian Kelly, Nov 15, 2012, in forum: Python
    Replies:
    0
    Views:
    183
    Ian Kelly
    Nov 15, 2012
  5. Andriy Kornatskyy

    RE: Lazy Attribute

    Andriy Kornatskyy, Nov 16, 2012, in forum: Python
    Replies:
    3
    Views:
    162
    Rouslan Korneychuk
    Nov 16, 2012
Loading...

Share This Page