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: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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