Subclassing int for a revolving control number

Chris Cioffi evenprimes at
Fri Jul 16 22:08:28 CEST 2004

Hello all!

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.  Subclassing int and getting the display like I want
it was trivial, however what's the best way to make it such that:
990 + 1 = 991 
991 + 1 = 992
998 + 1 = 999
999 + 1 = 001

Should I set any of the special functions like __sub__ to raise
NotImpemented and just make my own custom assignment and __add__
functions?  (The other fucntions would make no sense in this

Is there an "on change" kind of meta-function?  (Like the onChange
event in a GUI text control)

Still searching for an even prime > 2!

More information about the Python-list mailing list