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


Groups > comp.lang.python > #57150

Re: skipping __init__ and using exploiting a class member instead

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jeanpierreda@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'form?': 0.09; 'raises': 0.09; 'subject:using': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'codebase,': 0.16; 'reason.': 0.16; 'subject:class': 0.16; 'subject:member': 0.16; 'twisted': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'pfxlen:0': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; "i've": 0.25; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'wondering': 0.29; 'raise': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'class': 0.32; 'alone': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'pm,': 0.38; 'matter': 0.61; "you're": 0.61; 'times': 0.62; 'to:addr:gmail.com': 0.65; 'idiom': 0.84; 'situations,': 0.84; '2013': 0.98
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 :cc:content-type; bh=0XTCt6F4ue2+UgXGxR0sHiHdJ2oVUpRXGtZqFRrypRo=; b=YF11jTXZd+/+4gHc2dIcCshKesFHh8FiNvARUOq8X0AGcJqsjsv5h1ip5U9zr4wPCK aBNA42FCygwZiKxZmQlTFZcD2QO0l+/KzOhQw6aZ/FdODfbGITobF+lPau6lmJax1qYk m4r/hti9zkh+g0/iYjvY0m80X/+qnkR+DtaW2eWC6NwE6+1IDdvSDXQhwiWHWsvugw86 XfrFHkIVbj7YWzh9AKYV2X3qwULu5HDRtArUq2hF+bvIAxZQKoWWtOL9H3t9SXMqhDcn XSJQiE6jRb93RBPC/1sRH6zr5evBtKJ0z36mqH/Fz+hcrcC8vI8mA7yj4+MRJ6Pr2GKu MZFQ==
X-Received by 10.224.151.140 with SMTP id c12mr2339320qaw.94.1382279287106; Sun, 20 Oct 2013 07:28:07 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <fb1b5b6f-619c-4acd-b1bf-a375ccc6f1a6@googlegroups.com>
References <fb1b5b6f-619c-4acd-b1bf-a375ccc6f1a6@googlegroups.com>
From Devin Jeanpierre <jeanpierreda@gmail.com>
Date Sun, 20 Oct 2013 07:27:27 -0700
Subject Re: skipping __init__ and using exploiting a class member instead
To Peter Cacioppi <peter.cacioppi@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc "comp.lang.python" <python-list@python.org>
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.1284.1382279618.18130.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382279618 news.xs4all.nl 15951 [2001:888:2000:d::a6]:36254
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57150

Show key headers only | View raw


On Sat, Oct 19, 2013 at 2:44 PM, Peter Cacioppi
<peter.cacioppi@gmail.com> wrote:
> Is the following considered poor Python form?
>
> class Foo (object) :
>     _lazy = None
>     def foo(self, x) :
>         self._lazy = self._lazy or self.get_something(x)
>     def get_something(self, x) :
>         # doesn't really matter
>
> I like this idiom for certain situations, just wondering if it will raise the hackles of other Pythonistas.

It raises my hackles, but not for any good reason.

I've seen it a number of times in the Twisted codebase, so you're not
alone in using it.

-- Devin

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


Thread

skipping __init__ and using exploiting a class member instead Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-19 14:44 -0700
  Re: skipping __init__ and using exploiting a class member instead Ned Batchelder <ned@nedbatchelder.com> - 2013-10-19 17:55 -0400
  Re: skipping __init__ and using exploiting a class member instead Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-19 15:11 -0700
  Re: skipping __init__ and using exploiting a class member instead Robert Kern <robert.kern@gmail.com> - 2013-10-19 23:18 +0100
  Re: skipping __init__ and using exploiting a class member instead Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-19 22:30 +0000
  Re: skipping __init__ and using exploiting a class member instead Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-19 17:07 -0700
  Re: skipping __init__ and using exploiting a class member instead Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-19 17:42 -0700
    Re: skipping __init__ and using exploiting a class member instead Ned Batchelder <ned@nedbatchelder.com> - 2013-10-19 21:13 -0400
    Detecting whether a value was passed for a parameter (was: skipping __init__ and using exploiting a class member instead) Ben Finney <ben+python@benfinney.id.au> - 2013-10-20 22:50 +1100
  Re: skipping __init__ and using exploiting a class member instead Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-20 00:09 -0700
    Re: skipping __init__ and using exploiting a class member instead Roy Smith <roy@panix.com> - 2013-10-20 08:55 -0400
    Re: skipping __init__ and using exploiting a class member instead Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-20 14:16 +0100
  Re: skipping __init__ and using exploiting a class member instead Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-20 01:46 -0700
  Re: skipping __init__ and using exploiting a class member instead Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-10-20 07:27 -0700
  Re: skipping __init__ and using exploiting a class member instead Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-20 10:57 -0700
    Re: skipping __init__ and using exploiting a class member instead Roy Smith <roy@panix.com> - 2013-10-20 16:44 -0400
    Re: skipping __init__ and using exploiting a class member instead Chris Angelico <rosuav@gmail.com> - 2013-10-21 07:57 +1100
      Re: skipping __init__ and using exploiting a class member instead Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-20 14:34 -0700
        Re: skipping __init__ and using exploiting a class member instead Roy Smith <roy@panix.com> - 2013-10-20 18:31 -0400
          Re: skipping __init__ and using exploiting a class member instead Ben Finney <ben+python@benfinney.id.au> - 2013-10-21 10:55 +1100
            Re: skipping __init__ and using exploiting a class member instead Neil Cerutti <neilc@norwich.edu> - 2013-10-21 18:47 +0000
  Re: skipping __init__ and using exploiting a class member instead Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-20 21:30 -0700
  Re: skipping __init__ and using exploiting a class member instead Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-20 21:31 -0700
    Re: skipping __init__ and using exploiting a class member instead feedthetroll@gmx.de - 2013-10-21 00:16 -0700

csiph-web