Concrete classes -- stylistic question

Gerhard Häring gerhard.haering at gmx.de
Thu Oct 10 12:21:19 EDT 2002


Andrew Koenig wrote in comp.lang.python:
> On a few occasions I've wanted to define ``concrete classes'' --
> classes that are so simple that their structure is their interface.
> For example, I might want a little class to hold (x, y) pairs.
> 
> Of course, I can use a tuple, but then I have to remember the meaning
> of each element.  Moreover, if I want to have (x, y) pairs and (r, theta)
> pairs, I don't have an easy way of checking which one is which in case
> I use the wrong one by accident.
> [...]
> My questions:
> 
>         1) Am I reinventing the wheel here?  If so, where is the original?

Check out Alex Martelli's 'bunch' recipe:

'The simple but handy "collector of a bunch of named stuff" class'
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308

-- Gerhard



More information about the Python-list mailing list