Polymorphism the Python way
Daniel Klein
danielk at aracnet.com
Tue Sep 2 09:03:25 EDT 2003
On Sun, 31 Aug 2003 10:04:39 +0200, Peter Otten <__peter__ at web.de>
wrote:
>Daniel Klein wrote:
>
>> ...and then somewhere in some script I use...
>>
>> self.getthing()
>>
>> to get whatever 'thing' I want to get.
>>
>> Isn't there a better way to do this in Python? I hate doing these
>> 'get' type methods. The seem ugly to me.
>
>You can use properties, which simplifies the client code at the cost of an
>extra line in the class definition, e. g.:
>
Thanks. You and Alan Gauld provided the same answer, which seems to be
the best approach.
Dan
More information about the Python-list
mailing list