(no subject)

Mikael Olofsson mikael at isy.liu.se
Mon Feb 28 09:22:23 EST 2000


On 28-Feb-00 Gregoire Welraeds wrote:
 >  This question is related to OOP approach.
 >  Why do I have to :
 >      def __init__(self, name):
 >              self.__name = name
 >  
 >      def getname(self):
 >              return self.__name
 >  and
 >  x= MyObject.getname()
 >  
 >  instead of 
 >      def __init__(self, name):
 >              name= name
 >  and then
 >  x= MyObject.name

What's wrong with the following?

      def __init__(self, name):
              self.name = name

and then:

x = MyObject.name

/Mikael

-----------------------------------------------------------------------
E-Mail:  Mikael Olofsson <mikael at isy.liu.se>
WWW:     http://www.dtr.isy.liu.se/dtr/staff/mikael
Phone:   +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
Date:    28-Feb-00
Time:    15:20:02

This message was sent by XF-Mail.
-----------------------------------------------------------------------




More information about the Python-list mailing list