Re: Questions about subclassing an int

2008-01-05 Thread Francesco Guerrieri
On Jan 4, 2008 11:55 PM, Steven W. Orr <[EMAIL PROTECTED]> wrote: > class S(int): > def __init__(self, value): >self.value = value > def addStr(self, str): >self.doc = str > The original question has already been answered, I only want to suggest to avoid shadowing builtin

Re: Questions about subclassing an int

2008-01-04 Thread Steven D'Aprano
On Fri, 04 Jan 2008 15:36:27 -0800, Arnaud Delobelle wrote: > > Now it's no longer a syntax error but I don't see why it's different? > > Same as above, though I don't understand why you get a SyntaxError for T > and a TypeError for R. AFAICT both shoult give a TypeError. Probably because it was

Re: Questions about subclassing an int

2008-01-04 Thread Arnaud Delobelle
On Jan 4, 10:55 pm, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > class S(int): >      def __init__(self, value): >         self.value = value >      def addStr(self, str): >         self.doc = str > > s = S(44) > s.addStr('Hello') > > print 's = ', s > print 's.doc = ', s.doc > > class T(int): >