Re: Add a method to the int class
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How can I add a method to the int class? You can't. The closest is to subclass int and add your method. -- http://mail.python.org/mailman/listinfo/python-list
Re: Add a method to the int class
[EMAIL PROTECTED] wrote: > How can I add a method to the int class? sub class it >>> class MyInt(int): >>>def times(self,multiple): >>> return self * multiple >>> >>> a = 2 >>> print a 2 >>> a = MyInt(2) >>> print a >>> 2 >>> print a.times(2) 4 --Cheers -- h