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


Groups > comp.lang.python > #70552

Re: Moving to an OOP model from an classically imperitive one

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!ecngs!feeder2.ecngs.de!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
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.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'classes,': 0.05; 'irc': 0.05; 'though:': 0.07; 'classes.': 0.09; 'decorator': 0.09; 'method,': 0.09; 'creates': 0.14; '23,': 0.16; 'defined.': 0.16; 'letting': 0.16; 'separated': 0.16; 'subject:OOP': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'email addr:gmail.com&gt;': 0.22; 'separate': 0.22; 'logical': 0.24; "haven't": 0.24; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message- id:@mail.gmail.com': 0.30; 'asked': 0.31; 'class': 0.32; 'another': 0.32; 'becomes': 0.33; 'subject:from': 0.34; 'could': 0.34; 'problem': 0.35; 'received:google.com': 0.35; 'subject:one': 0.36; 'problems': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'tell': 0.60; 'mentioned': 0.61; 'new': 0.61; 'making': 0.63; 'subject:Moving': 0.84
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:to :content-type; bh=M7K1bBTeemcr2BUHwYKhP+WSKT8/VlC6byexhuE8k+w=; b=pD9y0VPdhMjGx+ZXCzBbL8ZyP0omBA9G6AYA6H03QtNuOIAAIWDS1zSdSfibyb381i nhdfjX5z0Lh2VilH/MZLtQQqxfnSoCt1CD1Q9yAjM0QUJbqGIuxNPq10g+8weQRXCWMU v2gGTOhJw22M6UGasr6KdcCHNZVgAMSH4+0XiZE64GAQD9le4egUmVGOfJpK8KzpwIi3 7L3iR/dyGtJnAwi/h+wi3s65W4X0p/dTso+bIHFP4qRJeqgYugjVb4oGxQ8QDoRuKDpU Kgl2vpWEC4B/4dJSNQDXtyOXA78FSb6gifFE4icP2oMz1dkpWmBUWF+oz0UwYL0iruiw CrUQ==
MIME-Version 1.0
X-Received by 10.66.160.34 with SMTP id xh2mr447864pab.109.1398288204980; Wed, 23 Apr 2014 14:23:24 -0700 (PDT)
In-Reply-To <80a82415-fc67-4ccf-8827-27a0ba5459b7@googlegroups.com>
References <80a82415-fc67-4ccf-8827-27a0ba5459b7@googlegroups.com>
Date Wed, 23 Apr 2014 15:23:24 -0600
Subject Re: Moving to an OOP model from an classically imperitive one
From Ian Kelly <ian.g.kelly@gmail.com>
To Python <python-list@python.org>
Content-Type multipart/alternative; boundary=047d7bacb37ec25ff104f7bc57e6
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.9470.1398288213.18130.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1398288213 news.xs4all.nl 2939 [2001:888:2000:d::a6]:41947
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:70552

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Apr 23, 2014 5:01 PM, <tim.thelion@gmail.com> wrote:
> I asked on IRC and it was sugested that I use multiple classes, however I
see no logical way to separate a SubuserProgram object into multiple
classes.

You say you already have the methods logically separated into files. How
about adding one abstract class per file, and then letting SubuserProgram
inherit from each of those individual classes?

As another alternative that you haven't mentioned yet, you could create a
decorator to be applied to each method, which will inject it into the class
at the time it is defined. The explicitness of the decorator solves your
confusion problem of "why does this function use self". It creates a couple
of new problems though: 1) reading the class won't tell you what methods it
contains; and 2) making sure the class is fully constructed before it is
used becomes tricky.

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


Thread

Moving to an OOP model from an classically imperitive one tim.thelion@gmail.com - 2014-04-23 13:57 -0700
  Re: Moving to an OOP model from an classically imperitive one Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-04-23 22:15 +0100
  Re: Moving to an OOP model from an classically imperitive one Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-23 15:23 -0600
    Re: Moving to an OOP model from an classically imperitive one Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-04-24 12:26 +1200
  Re: Moving to an OOP model from an classically imperitive one Ethan Furman <ethan@stoneleaf.us> - 2014-04-23 14:42 -0700
    Re: Moving to an OOP model from an classically imperitive one tim.thelion@gmail.com - 2014-04-24 00:32 -0700
  Re: Moving to an OOP model from an classically imperitive one MRAB <python@mrabarnett.plus.com> - 2014-04-24 00:08 +0100
    Re: Moving to an OOP model from an classically imperitive one tim.thelion@gmail.com - 2014-04-24 00:21 -0700
      Re: Moving to an OOP model from an classically imperitive one Chris Angelico <rosuav@gmail.com> - 2014-04-24 17:36 +1000
      Re: Moving to an OOP model from an classically imperitive one Steven D'Aprano <steve@pearwood.info> - 2014-04-24 09:08 +0000
  Re: Moving to an OOP model from an classically imperitive one Chris Angelico <rosuav@gmail.com> - 2014-04-24 09:12 +1000
  Re: Moving to an OOP model from an classically imperitive one Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-04-24 12:21 +1200
    Re: Moving to an OOP model from an classically imperitive one tim.thelion@gmail.com - 2014-04-24 09:53 -0700
      Re: Moving to an OOP model from an classically imperitive one Amirouche Boubekki <amirouche.boubekki@gmail.com> - 2014-04-25 19:21 +0200
  Re:Moving to an OOP model from an classically imperitive one Dave Angel <davea@davea.name> - 2014-04-23 22:01 -0400

csiph-web