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


Groups > comp.lang.python > #17757

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!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'package,': 0.03; 'function,': 0.07; 'received:verizon.net': 0.07; 'terry': 0.07; 'display,': 0.09; 'pearson': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'sits': 0.09; 'subclasses': 0.09; 'am,': 0.12; 'classes,': 0.13; 'pythonic': 0.16; 'reedy': 0.16; 'subject:Adding': 0.16; 'subject:classes': 0.16; 'subject:interface': 0.16; 'this:': 0.16; 'wrote:': 0.18; 'jan': 0.19; 'header:In-Reply-To:1': 0.22; "i'm": 0.26; 'function': 0.27; 'lines': 0.30; 'seem': 0.30; 'quite': 0.32; 'header:User-Agent:1': 0.33; 'rather': 0.33; 'header:X-Complaints-To:1': 0.33; 'on,': 0.34; 'points': 0.34; 'to:addr:python-list': 0.34; 'things': 0.34; 'two': 0.37; 'but': 0.37; 'options': 0.37; 'received:org': 0.38; 'option': 0.39; "i'd": 0.39; 'to:addr:python.org': 0.40; 'one,': 0.40; 'circles': 0.84; 'elders.': 0.84; 'geometry': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Adding an interface to existing classes
Date Thu, 22 Dec 2011 18:13:42 -0500
References <8f345777-1ef7-46dc-b3fb-a0bea5ebf2c3@r16g2000prr.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-74-109-121-73.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0
In-Reply-To <8f345777-1ef7-46dc-b3fb-a0bea5ebf2c3@r16g2000prr.googlegroups.com>
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.4002.1324595653.27778.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1324595653 news.xs4all.nl 6921 [2001:888:2000:d::a6]:55415
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17757

Show key headers only | View raw


On 12/22/2011 3:21 AM, Spencer Pearson wrote:
> I'm writing a geometry package, with Points and Lines and Circles and
> so on, and eventually I want to be able to draw these things on the
> screen. I have two options so far for how to accomplish this, but
> neither of them sits quite right with me, and I'd like the opinion of
> comp.lang.python's wizened elders.
>
> Option 1. Subclassing.
> The most Pythonic way would seem to be writing subclasses for the
> things I want to display, adding a ".draw(...)" method to each one,
> like this:

> Option 2. A "draw" function, with a function dictionary.

Option 3? Add a draw method to existing classes, rather than subclassing?

-- 
Terry Jan Reedy

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