[Tutor] Inherit from int?
jim at well.com
Sun May 13 02:32:20 CEST 2007
the problem is in the return.
if you append a print statement to the class function
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 <marilyn at deliberate.com> 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:
> Tutor maillist - Tutor at python.org
More information about the Tutor