On Sun, 27 Jul 2008 10:23:06 +0800, Marcus.CM wrote:

> Well after reading some of these posts on "sacred python cow" on the
> "self" , i would generally feel that most programmers who started with
> C++/Java would find it odd. 

You know, there are some programmers who haven't started with C++ or Java.


> And its true, i agree completely there
> should not be a need to put "self" into every single member function. If
> you were writing an application and one of your classes adds the same
> variable to each of its member function you would do away with it too.

Would I?

How would I do that here?

# untested
class FunnyNumber(int):
    """Silly class that acts like an integer, only one larger."""
    def __add__(self, other):
        return int(self)+1+other
    def __mul__(self, other):
        return (self+1)*other
    def __sub__(self, other):
        return int(self)+1-other



-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to