Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17757
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Adding an interface to existing classes |
| Date | 2011-12-22 18:13 -0500 |
| References | <8f345777-1ef7-46dc-b3fb-a0bea5ebf2c3@r16g2000prr.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4002.1324595653.27778.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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