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


Groups > comp.lang.python > #75774

Re: Making every no-arg method a property?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@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; 'argument': 0.05; 'plenty': 0.07; 'stops': 0.07; 'suddenly': 0.07; 'methods,': 0.09; 'raises': 0.09; 'subject:method': 0.09; 'violates': 0.09; 'worse': 0.09; 'cc:addr:python-list': 0.11; '10:49': 0.16; 'argument,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'pop()': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'breaking': 0.31; "d'aprano": 0.31; 'idea,': 0.31; 'steven': 0.31; 'class': 0.32; 'info': 0.35; 'something': 0.35; 'usual': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'really': 0.36; 'object,': 0.36; 'method': 0.36; 'subject:?': 0.36; 'being': 0.38; 'list,': 0.38; 'anything': 0.39; 'bad': 0.39; 'even': 0.60; 'skip:* 10': 0.61; 'name': 0.63; 'more': 0.64; 'default': 0.69; 'subject:Making': 0.84; 'careful': 0.91; 'info,': 0.91; 'to:none': 0.92
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 :content-type; bh=CXRLUUGJ9rT208RTRbBeBaeSQyw8zu/kdMVSU5vIzJ4=; b=D5jiRsGksklldyA/aETVRSJFOslvHs20uQyLLnozPNgNvojRRLNeYk7Mcw5CDoZYzm FUpzLCGQwYD570E7HrBx9vEu1w4m/QhreWcG5hdm9+Gsyn2F6kJw1FLgGE7bEPx3etWp oPgCMJpbKWOB4REVjbC6ff0TssgUkgYDBgRBXSZZyaw9uqiTadyrc8gd1Duwb3K+7YdM qFoGxmSyUryDOPNR5HMR3e5V9hQfMSQWA6KFbQv/AFbsmHNqGB9CH9B4+fzDysG4QBAW cl0YGZZ0OM/rDdc6yoc7mBHuervHIzXUXhaEnISqf3FqIbgh6zELcY8UIvY41JFL+HJ2 XQ9g==
MIME-Version 1.0
X-Received by 10.50.138.195 with SMTP id qs3mr13139987igb.14.1407290878727; Tue, 05 Aug 2014 19:07:58 -0700 (PDT)
In-Reply-To <53e17b95$0$29981$c3e8da3$5496439d@news.astraweb.com>
References <mailman.12674.1407271813.18130.python-list@python.org> <53e17b95$0$29981$c3e8da3$5496439d@news.astraweb.com>
Date Wed, 6 Aug 2014 12:07:58 +1000
Subject Re: Making every no-arg method a property?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.12684.1407291183.18130.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1407291184 news.xs4all.nl 2959 [2001:888:2000:d::a6]:56132
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75774

Show key headers only | View raw


On Wed, Aug 6, 2014 at 10:49 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> A
> plethora of argument-less methods is a code smell -- that doesn't mean it's
> *necessarily* a bad idea, but the class design really needs a careful
> review.

There are plenty of no-argument mutator methods, where the name of the
method (and the target object, obviously) is all the info you need.
You can clear() or copy() something with any more info, reverse() a
list, pop() from a list, etc. (Okay, the last one has a default
argument, but that raises an even worse point: adding a defaulted
argument to a no-argument method suddenly stops it from being a
property, which violates the usual rule that you can add a defaulted
argument to anything without breaking anything.)

ChrisA

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


Thread

Making every no-arg method a property? Christian Calderon <calderon.christian760@gmail.com> - 2014-08-05 12:39 -0700
  Re: Making every no-arg method a property? Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-08-05 13:57 -0700
  Re: Making every no-arg method a property? Grant Edwards <invalid@invalid.invalid> - 2014-08-05 21:14 +0000
    Re: Making every no-arg method a property? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-08-06 10:34 +1200
      Re: Making every no-arg method a property? Grant Edwards <invalid@invalid.invalid> - 2014-08-06 05:13 +0000
        Re: Making every no-arg method a property? Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-08-06 09:53 -0700
      Re: Making every no-arg method a property? alister <alister.nospam.ware@ntlworld.com> - 2014-08-06 10:09 +0000
        Re: Making every no-arg method a property? Terry Reedy <tjreedy@udel.edu> - 2014-08-06 15:04 -0400
  Re: Making every no-arg method a property? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-06 10:49 +1000
    Re: Making every no-arg method a property? Chris Angelico <rosuav@gmail.com> - 2014-08-06 12:07 +1000
      Re: Making every no-arg method a property? Steven D'Aprano <steve@pearwood.info> - 2014-08-06 09:15 +0000
        Re: Making every no-arg method a property? Chris Angelico <rosuav@gmail.com> - 2014-08-06 21:26 +1000
  Re: Making every no-arg method a property? alister <alister.nospam.ware@ntlworld.com> - 2014-08-06 10:12 +0000

csiph-web