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


Groups > comp.lang.python > #92822

Re: Classic OOP in Python

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!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.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.05; 'attributes': 0.07; 'cc:addr:python-list': 0.10; 'def': 0.14; 'thu,': 0.15; 'copied,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'non-trivial': 0.16; 'opened,': 0.16; 'subject:OOP': 0.16; 'two,': 0.16; 'wrote:': 0.16; '(or': 0.21; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'doc': 0.22; '2015': 0.23; 'header:In-Reply-To:1': 0.24; 'raise': 0.24; 'sort': 0.25; 'define': 0.27; 'message-id:@mail.gmail.com': 0.28; 'interface': 0.29; 'arguments,': 0.29; 'extending': 0.29; 'oop': 0.29; 'print': 0.31; 'up.': 0.32; 'class': 0.33; 'received:google.com': 0.34; 'cases': 0.36; 'should': 0.37; 'subject:: ': 0.37; 'files': 0.38; 'pm,': 0.39; 'share': 0.60; 'simple': 0.61; 'chrisa': 0.84; 'forced': 0.84; 'subject:Classic': 0.84; 'to:none': 0.90; 'boxes,': 0.91; 'railway': 0.91
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=u1Z8LcgMGCVsZ+5gwcLeHOWE5ErXPIhg4aI+4Bi8qp0=; b=1Fi+Gkkkkf5bmBv3cVoZjvxbtI962wrCTPl6AAblFK5x8hzGEuO6AXEP+Py5DLAYDF b2SHvZCS6U1uRgK4D52Yt474HAOicG27xd6NBLqF6c3p6goRDsEfUvseODuzsTF0AlXU EcJRPDBNqQ/13lxF8XWarS36/Rqkv7FBAVFWRKCgn66Hnc1fO4oOFtpYvKPmDca7zLQU rp9lnerNCF8acuGvUJJP5Uk4D8aK2jFL5CkuGJUfsLC2jf6ZUUe7Y5kvnNtbNE1LL+Ok 809qwCCjBbmaLV1UT5IRTnCjzZum2UEE/Gm5JgG3XoJ3QAJu6HPrc5GBKOpQsJM1Hc24 CzKg==
MIME-Version 1.0
X-Received by 10.50.143.104 with SMTP id sd8mr41314854igb.14.1434627808694; Thu, 18 Jun 2015 04:43:28 -0700 (PDT)
In-Reply-To <mlu8hh$ntr$1@speranza.aioe.org>
References <23b2fae3-91d5-486b-9898-78b34bee486f@googlegroups.com> <f0c76343-7230-499c-ba30-33d7f6513503@googlegroups.com> <mlu8hh$ntr$1@speranza.aioe.org>
Date Thu, 18 Jun 2015 21:43:28 +1000
Subject Re: Classic OOP in Python
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.20+
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.595.1434627811.13271.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1434627811 news.xs4all.nl 2946 [2001:888:2000:d::a6]:42213
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:92822

Show key headers only | View raw


On Thu, Jun 18, 2015 at 9:03 PM, Fabien <fabien.maussion@gmail.com> wrote:
> Would you consider the following kind of program "unpythonic"?
>
> class MovingObject(object):
>     """Great doc about what a moving object is"""
>
>     def move(self):
>         """Great doc about move"""
>         raise NotImplementedError()
>
> class Dog(MovingObject):
>     def move(self):
>         print "Dog is moving"
>
> class Car(MovingObject):
>     def move(self):
>         print "Car is moving"
>
> (Disclaimer: I learned OOP with Java)

Now try extending the concept to two, three, or four such interfaces.
Files can be moved, opened, copied, and unlinked. Should they share
any sort of interface with dogs, boxes, handwriting, and railway
carriages? It's much better to simply define the attributes of each
object separately; most non-trivial cases don't involve simple methods
with no additional arguments, and the chances of an incompatibility
(or worse, a forced compatibility) go up.

ChrisA

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


Thread

Classic OOP in Python "Jason P." <suscricions@gmail.com> - 2015-06-17 12:21 -0700
  Re: Classic OOP in Python Skip Montanaro <skip.montanaro@gmail.com> - 2015-06-17 14:38 -0500
  Re: Classic OOP in Python Ned Batchelder <ned@nedbatchelder.com> - 2015-06-17 12:44 -0700
    Re: Classic OOP in Python Marko Rauhamaa <marko@pacujo.net> - 2015-06-17 23:39 +0300
      Re: Classic OOP in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-17 22:07 +0100
      Re: Classic OOP in Python Ned Batchelder <ned@nedbatchelder.com> - 2015-06-17 14:14 -0700
        Re: Classic OOP in Python Laura Creighton <lac@openend.se> - 2015-06-18 00:33 +0200
          Re: Classic OOP in Python Ned Batchelder <ned@nedbatchelder.com> - 2015-06-17 15:55 -0700
        Re: Classic OOP in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-18 11:50 +0100
        Re: Classic OOP in Python Laura Creighton <lac@openend.se> - 2015-06-19 01:01 +0200
        Re: Classic OOP in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-20 23:52 +0100
        Re: Classic OOP in Python Laura Creighton <lac@openend.se> - 2015-06-21 10:26 +0200
      Re: Classic OOP in Python sohcahtoa82@gmail.com - 2015-06-17 14:33 -0700
        Re: Classic OOP in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-17 22:49 +0100
        Re: Classic OOP in Python Laura Creighton <lac@openend.se> - 2015-06-18 00:22 +0200
        Re: Classic OOP in Python Marco Buttu <marco.buttu@gmail.com> - 2015-06-18 11:00 +0200
      Re: Classic OOP in Python Laura Creighton <lac@openend.se> - 2015-06-18 00:09 +0200
      Re: Classic OOP in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-17 23:27 +0100
      Re: Classic OOP in Python Steven D'Aprano <steve@pearwood.info> - 2015-06-18 08:58 +1000
        Re: Classic OOP in Python Cousin Stanley <cousinstanley@gmail.com> - 2015-06-18 08:10 -0700
      Re: Classic OOP in Python Terry Reedy <tjreedy@udel.edu> - 2015-06-17 19:46 -0400
      Re: Classic OOP in Python Chris Angelico <rosuav@gmail.com> - 2015-06-18 10:07 +1000
      Re: Classic OOP in Python "Jason P." <suscricions@gmail.com> - 2015-06-18 04:24 -0700
    Re: Classic OOP in Python "Jason P." <suscricions@gmail.com> - 2015-06-18 04:21 -0700
      Re: Classic OOP in Python Ned Batchelder <ned@nedbatchelder.com> - 2015-06-18 04:54 -0700
    Re: Classic OOP in Python "Jason P." <suscricions@gmail.com> - 2015-06-18 04:22 -0700
  Re: Classic OOP in Python sohcahtoa82@gmail.com - 2015-06-17 14:16 -0700
    Re: Classic OOP in Python Fabien <fabien.maussion@gmail.com> - 2015-06-18 13:03 +0200
      Re: Classic OOP in Python Marko Rauhamaa <marko@pacujo.net> - 2015-06-18 14:25 +0300
      Re: Classic OOP in Python Chris Angelico <rosuav@gmail.com> - 2015-06-18 21:43 +1000

csiph-web