the problem is in the return. if you append a print statement to the class function such as print "number is ",number # (properly indented, of course) you'll get 8
On May 12, 2007, at 5:11 PM, John Fouhy wrote: > On 13/05/07, Marilyn Davis <[EMAIL PROTECTED]> wrote: >> #!/usr/bin/env python >> '''An Under10 class, just to fiddle with inheriting from int.''' >> >> class Under10(int): >> >> def __init__(self, number): >> number %= 10 >> int.__init__(self, number) > > Subclassing int and other types is a bit special. Check out this > page; it may help you: > http://www.python.org/download/releases/2.2.3/descrintro/#__new__ > > -- > John. > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor