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


Groups > comp.lang.python > #104672

Re: Descriptors vs Property

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Descriptors vs Property
Date Sat, 12 Mar 2016 17:05:47 +1100
Lines 19
Message-ID <mailman.25.1457762756.12893.python-list@python.org> (permalink)
References <nc0b1u$ckq$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de IH1sa5oHv/ezKrbF1VAVWwxpEIinlrfM8eiBjqlKX5dw==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.021
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'essentially': 0.04; 'implements': 0.07; 'cc:addr:python-list': 0.09; '@property': 0.09; 'descriptor': 0.09; '2016': 0.16; '4:59': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'decorator': 0.22; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'message- id:@mail.gmail.com': 0.27; 'sequence': 0.27; 'follows': 0.29; 'methods.': 0.29; 'foo': 0.33; 'this?': 0.34; 'lists': 0.34; 'received:google.com': 0.35; 'interact': 0.35; 'lists.': 0.35; 'protocol': 0.35; 'asking': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; '12,': 0.37; 'received:209.85.213': 0.37; 'doing': 0.38; 'received:209': 0.38; 'why': 0.39; 'mar': 0.65; 'chrisa': 0.84; 'decorator.': 0.84; 'to:none': 0.91; 'do:': 0.91; 'subject:Property': 0.91; 'thing,': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=b6w4r9TmtYYdW1/P3GW/ZlPi0Vf0YPzM2Mi+W4sHJV4=; b=oUMJ5jUG93h02TsjcCEFlFeirnAzHWneCl0Pjt8oJxO2pfo3qe2lgtX13O4hAxeam2 EFaKQO5UsSe1S8KxOWfUKdKNnijstyPeZOAGh49nd55/hf/izf0KmvQAqjpFA6ii4Nt+ QzgdpfmnEd9NyvcY5ti4RB9gJjqETLQTP4Neeu5lBq7TTF6xA88tO07Vs2ml5ymNuJNf aYKADucji8iOXWsxiJuhWbBEp0J9AgqjCu9H0zDaqR0gdIFliv8KyYwKmeo6R0UUHgBD dUDb7htKiLHs27+4Lk2D0HKtaSis3zfL1Ja0SStDzCef2PWH3L7EkP313/wles+QfY+/ AYtg==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=b6w4r9TmtYYdW1/P3GW/ZlPi0Vf0YPzM2Mi+W4sHJV4=; b=gsjHeQF5EsQTdlJ+FlpEyElVoumab3+Q/WZdhfFGc5HbSnJi0jLNCYuvbIZbkldX6k bMjLPi38j6CnblQ1YTxeqqRn78/SNLr3VrZT3rK0rLRTm8ceFXv0fBiwdbx+OHqf7RxT 6zJzKTh6EJHJEYwiUfAL23ONzVF7YmT92Ay2GVEcieeUd2nVnAbTwslLbbldX7ebPKfA n+T8xTFqRp3M6SHt8SxG5SkYzu0AJSBYYdLjoLNp0RPwCtsQk8VtXa4GcNVvcW4itRke AZf5JBjKdzBJ3qMi8jHWBOcrbdT8o0oMxQ8HsK4jgZJNpZNJtLwpU8KD2sroJ9e/aBJp B0WQ==
X-Gm-Message-State AD7BkJJzTQTFFp5Wj/f2pif3w80RO0TZ+qTmo0aKfI0lDsZ98t0L6t+J0dTKnnCSTfj6HkChjZse5w87LuauLg==
X-Received by 10.50.43.168 with SMTP id x8mr8016316igl.92.1457762747388; Fri, 11 Mar 2016 22:05:47 -0800 (PST)
In-Reply-To <nc0b1u$ckq$1@dont-email.me>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:104672

Show key headers only | View raw


On Sat, Mar 12, 2016 at 4:59 PM, Veek. M <vek.m1234@gmail.com> wrote:
> A property uses the @property decorator and has @foo.setter
> @foo.deleter.
>
> A descriptor follows the descriptor protocol and implements the __get__
> __set__ __delete__ methods.
>
> But they both do essentially the same thing, allow us to do:
> foo = 10
> del foo
> x = foo
>
> So why do we have two ways of doing this?

The descriptor protocol is what powers the @property decorator. It's
like asking why we have both lists and sequences; the sequence
protocol is how you interact with lists.

ChrisA

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


Thread

Descriptors vs Property "Veek. M" <vek.m1234@gmail.com> - 2016-03-12 11:29 +0530
  Re: Descriptors vs Property Chris Angelico <rosuav@gmail.com> - 2016-03-12 17:05 +1100
  Re: Descriptors vs Property Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-11 23:12 -0700
    Re: Descriptors vs Property "Veek. M" <vek.m1234@gmail.com> - 2016-03-12 11:54 +0530
      Re: Descriptors vs Property Chris Angelico <rosuav@gmail.com> - 2016-03-12 17:35 +1100
      Re: Descriptors vs Property Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-11 23:37 -0700
  Re: Descriptors vs Property "Veek. M" <vek.m1234@gmail.com> - 2016-03-12 11:50 +0530
    Re: Descriptors vs Property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-12 18:13 +0100
      Re: Descriptors vs Property "Veek. M" <vek.m1234@gmail.com> - 2016-03-13 12:48 +0530
        Re: Descriptors vs Property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-13 10:25 +0100
          Re: Descriptors vs Property "Veek. M" <vek.m1234@gmail.com> - 2016-03-13 15:26 +0530
            Re: Descriptors vs Property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-13 11:35 +0100
              Re: Descriptors vs Property "Veek. M" <vek.m1234@gmail.com> - 2016-03-13 18:50 +0530
                Re: Descriptors vs Property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-13 19:15 +0100
                Re: Descriptors vs Property Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-14 15:34 +0000
                Re: Descriptors vs Property Rustom Mody <rustompmody@gmail.com> - 2016-03-14 10:16 -0700
                Re: Descriptors vs Property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-16 01:53 +0100
  Re: Descriptors vs Property Ethan Furman <ethan@stoneleaf.us> - 2016-03-16 08:15 -0700

csiph-web