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


Groups > comp.lang.python > #104677

Re: Descriptors vs Property

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Descriptors vs Property
Date Fri, 11 Mar 2016 23:37:11 -0700
Lines 26
Message-ID <mailman.28.1457764672.12893.python-list@python.org> (permalink)
References <nc0b1u$ckq$1@dont-email.me> <mailman.26.1457763193.12893.python-list@python.org> <nc0cgs$fvn$2@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de PQP1s3tT9J6BopF6gxh+HwMIjZsjiHb+WPLa2X2Lrwzw==
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'value,': 0.03; 'resulting': 0.04; 'false.': 0.07; 'type,': 0.07; '"default': 0.09; 'typeerror:': 0.09; 'instead.': 0.15; '10:59': 0.16; '2016': 0.16; 'assumptions': 0.16; 'evaluates': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'unwarranted': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'otherwise,': 0.20; 'meant': 0.22; 'arguments': 0.22; 'parameter': 0.22; 'pass': 0.22; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'possibility': 0.27; 'message-id:@mail.gmail.com': 0.27; 'arguments,': 0.29; 'gets': 0.35; 'gives': 0.35; 'received:google.com': 0.35; 'instance': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'whatever': 0.39; 'does': 0.39; 'takes': 0.39; 'to:addr:python.org': 0.40; 'called': 0.40; 'default': 0.61; 'great': 0.63; 'mar': 0.65; 'account': 0.66; 'presumably': 0.84; 'shadows': 0.84; 'to:name:python': 0.84; 'subject:Property': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=IdhMqamYEfbBcpmSQFvtr5DJAVGBYod5WB/kyPjTZKo=; b=BBdWPSL+KNVncAb0ctCIb0q69Ao9tdIyUjHu2xcrREKKWbelwe9+zM6+lxVQ2voMmO UHIGLhT/8opwUUJ9e2YO/R0A3zna0Wlj9wBJbuMgwdwbbxb/YsoTpHYP52tRdoSmKmyC sdkm50CEDKx6IoV9Yq9cDaySTLsHGBanAZRvb4QvOGvYUGHgIR3P5UAk6mvG6x5Z+Sqj +U8F8rhWJQZNBqJ5eIwS+qSEY4nE49bdHHP2nqTv00Ypp/rd4O9QAk2ABAQZgXKWyf1q 6sz1C/H7d5pOah187WlmgJlhn8W0KS5lLfek/CuvON81WVZ1pViQt4QZcQg4GqaTBGKI seGQ==
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:from:date :message-id:subject:to; bh=IdhMqamYEfbBcpmSQFvtr5DJAVGBYod5WB/kyPjTZKo=; b=Yphx84lAgig0PmdkH5uqLObK1Kx2QxdP+lsg+QMKd8jM6w1XOfXuNYZtZ8e+NU4HZU ZTiLUXofYt41XKcgR1Z7jrKkrxD+paPfGOlODdzRvHIHKKqA7JXxRc7Zmqe35tVTH2yQ JwODvAi2DnVz3i2zPS2BsWNQzase1Xw3PH5u3kdIAuxAB1mnQ493soj6ws3+j6l3qy0l 71hAMwe+Ylh/kQ3sc+8oxohCeTPFb/PUqy89f8W3HwzsFFCkAmMMzb9XpzIeCLv4p0eD kmN1U5OUqHtF2bRWytSiR8pN1h3JeRomAsXROqYxx79u0J9zpph/oi/q4RdHAvSNWzIx cOcw==
X-Gm-Message-State AD7BkJKYGbVBe0RiCf23X9cTviEVEVCKuv7DNy/C+4UG1+OZWpopkUbI4QyA7T4ShZyh+bpwJzs+x7OyVveDSw==
X-Received by 10.50.131.201 with SMTP id oo9mr7783801igb.68.1457764670509; Fri, 11 Mar 2016 22:37:50 -0800 (PST)
In-Reply-To <nc0cgs$fvn$2@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:104677

Show key headers only | View raw


On Fri, Mar 11, 2016 at 11:24 PM, Veek. M <vek.m1234@gmail.com> wrote:
> Ian Kelly wrote:
>
>> On Fri, Mar 11, 2016 at 10:59 PM, Veek. M <vek.m1234@gmail.com> wrote:
>>> Also, what's this bit:
>>> self.default = default if default else type()
>>
>> If the default parameter has a truthy value, it gets set to
>> self.default. Otherwise, the type parameter is called with no
>> arguments, and the resulting instance is used as self.default instead.
>
> But type() just gives me:
> TypeError: type() takes 1 or 3 arguments
> on py2,3

You're using the built-in type. In the example, type is the name of
one of the arguments, so its value is whatever was passed in.
Presumably it's meant to be the type that is being checked, and the
result of calling it with no arguments is meant to be a default
instance of that type.

This is not a particularly great example, to be honest. It shadows a
builtin, it makes unwarranted assumptions about the passed-in type,
and the "default if default else type()" expression does not account
for the possibility that the user might actually want to pass in a
default that evaluates as false.

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