Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Descriptors vs Property Date: Sat, 12 Mar 2016 17:05:47 +1100 Lines: 19 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de IH1sa5oHv/ezKrbF1VAVWwxpEIinlrfM8eiBjqlKX5dw== Return-Path: 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: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104672 On Sat, Mar 12, 2016 at 4:59 PM, Veek. M 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