is Python fully object oriented ?

Simon Brunning SBrunning at trisystems.co.uk
Fri Jan 12 08:47:26 EST 2001


> From:	Max Møller Rasmussen [SMTP:maxm at normik.dk]
> From: Simon Brunning [mailto:SBrunning at trisystems.co.uk]
> 
> This came up in this tread recently - see
> <http://www.python.org/doc/FAQ.html#6.7>.
> 
> Yes but it only explains why there is a self at all, not why it has to be
> explicit.
> 
> I really cannot see why the second example here is better than the first.
> 
> class accumulator:
> 
>    def __init__():
>       self.sum = 0  # self is implicit here
> 
>    def add(value):
>       self.sum += value
> 
>    def getSum():
> 	return self.sum
> 
> class accumulator:
> 
>    def __init__(self):# self is explicit
>       self.sum = 0
> 
>    def add(self, value):
>       self.sum += value
> 
>    def getSum(self):
> 	return self.sum
> 
> Well not something I want to start a religious war about, but its annoying
> having an itch you can't scratch ;-)
> 
> Regards Max M
> 
 
Max,
Remember, Pythoneers don't *have* religious wars. We have reasoned
discussions. ;-)

I do see your point. Thing is though, if object instances were not marked in
some way, method locals would have to be. Either way, something would have
an itchy prefix. Putting the prefix on the object instances makes locals
consistent with ordinary, non-class functions.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning at trisystems.co.uk





-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.




More information about the Python-list mailing list