Subclassing int for a revolving control number

Chris Cioffi evenprimes at gmail.com
Sat Jul 17 21:40:21 CEST 2004


On Sat, 17 Jul 2004 06:16:18 GMT, Paul McGuire
<ptmcg at austin.rr._bogus_.com> wrote:
> "Chris Cioffi" <evenprimes at gmail.com> wrote in message
> news:mailman.508.1090008510.5135.python-list at python.org...
> >
> > I'm trying to subclass int such that once it reaches a certain value,
> > it flips back to the starting count.  This is for use as an X12
> > control number.
> >  <remaining snipped...>
> 
> Why does this have to subclass int?  I think you are falling into the basic
> object trap of confusing "is-a" and "is-implemented-using-a" that eventually
> turns inheritance hierarchies into a semantic contortion.  Dan Sommers'
> posted class looks to do just what you need, with no extra int baggage.

Paul,

I think you've hit the answer.  I shouldn't think about the control
number as an int.

The whole thing came up b/c I've been wanting to play with classes
derived from built-ins and though that this was a good fit.  Once it's
put in a more realistic context my not so great rationale doesn't
quite make as much sense.

Thanks for the comments all...

Chris
-- 
Still searching for an even prime > 2!



More information about the Python-list mailing list