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


Groups > comp.lang.python > #17883

Re: Adding an interface to existing classes

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.025
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'wrong,': 0.09; '25,': 0.12; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'blah': 0.16; 'classes?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'intersection': 0.16; 'subject:Adding': 0.16; 'subject:classes': 0.16; 'subject:interface': 0.16; '\xa0def': 0.16; 'wrote:': 0.18; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'message- id:@mail.gmail.com': 0.28; 'pm,': 0.29; 'class': 0.29; 'sun,': 0.30; 'sort': 0.33; 'this.': 0.33; 'to:addr:python-list': 0.34; 'class.': 0.37; 'two': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'steven': 0.38; 'received:209.85': 0.38; 'received:209': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; 'dealing': 0.69; '11:10': 0.84; 'other):': 0.84; 'point:': 0.84; 'points,': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=4ZZwsu1cvOQvEdbv35NWaESM5/b9DrnC8IL1GVQGkns=; b=nw0WbyIilbu5+hp1IChp9OBygNVNPlUIFFUnXbliRID6X1g6Cu0+ZH/RVydsTSSv8c TYUnffqly7ObIwC/zaQ3xadybgVGskJVt2FC7MgCqJ8a6pMRWzZkLYlpyhVR1qbYMiQd nvgJsbIang0Fvkn7JLvmGdkgk58qkBiPxFVso=
MIME-Version 1.0
In-Reply-To <4ef712c0$0$29973$c3e8da3$5496439d@news.astraweb.com>
References <8f345777-1ef7-46dc-b3fb-a0bea5ebf2c3@r16g2000prr.googlegroups.com> <22ea371a-f282-4d81-89f6-bc3229e2e8b1@a17g2000yqj.googlegroups.com> <4ef712c0$0$29973$c3e8da3$5496439d@news.astraweb.com>
Date Sun, 25 Dec 2011 23:32:41 +1100
Subject Re: Adding an interface to existing classes
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4063.1324816364.27778.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1324816364 news.xs4all.nl 6971 [2001:888:2000:d::a6]:42579
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17883

Show key headers only | View raw


On Sun, Dec 25, 2011 at 11:10 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> class Point:  # An abstract class.
>    def intersect(self, other):
>        blah; blah; blah
>        return Point(x, y)  # No, wrong, bad!!! Don't do this.
>
> Instead:
>
>        return self.__class__(x, y)  # Better.

This would work if you were dealing with the intersection of two
points, but how do you use that sort of trick for different classes?

ChrisA

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


Thread

Adding an interface to existing classes Spencer Pearson <speeze.pearson@gmail.com> - 2011-12-22 00:21 -0800
  Re: Adding an interface to existing classes Terry Reedy <tjreedy@udel.edu> - 2011-12-22 18:13 -0500
    Re: Adding an interface to existing classes Spencer Pearson <speeze.pearson@gmail.com> - 2011-12-24 15:49 -0800
      Re: Adding an interface to existing classes Terry Reedy <tjreedy@udel.edu> - 2011-12-24 20:58 -0500
        Re: Adding an interface to existing classes Spencer Pearson <speeze.pearson@gmail.com> - 2012-01-04 23:55 -0800
  Re: Adding an interface to existing classes Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-24 18:16 -0700
    Re: Adding an interface to existing classes Spencer Pearson <speeze.pearson@gmail.com> - 2012-01-04 23:54 -0800
  Re: Adding an interface to existing classes Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-24 17:24 -0800
    Re: Adding an interface to existing classes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 12:10 +0000
      Re: Adding an interface to existing classes Chris Angelico <rosuav@gmail.com> - 2011-12-25 23:32 +1100
        Re: Adding an interface to existing classes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 13:27 +0000
          Re: Adding an interface to existing classes Chris Angelico <rosuav@gmail.com> - 2011-12-26 00:37 +1100
            Re: Adding an interface to existing classes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 13:46 +0000
              Re: Adding an interface to existing classes Chris Angelico <rosuav@gmail.com> - 2011-12-26 00:55 +1100
              Re: Adding an interface to existing classes Spencer Pearson <speeze.pearson@gmail.com> - 2012-01-04 23:56 -0800

csiph-web