Getters and setters in python, common practise
Yermat
loic at fejoz.net
Thu Apr 15 07:48:27 EDT 2004
Petter Holmström wrote:
> Peter Hansen wrote:
>
>>> Having a Delphi/Object Pascal-background, I'm very used to using
>>> getters and setters when designing my classes. What is the common
>>> practise in the Python world? Should one use them or not?
>>
>>
>> Max described the common practice (don't use them until you actually
>> need them) but forgot to mention that in recent versions of Python
>> you can use "properties", in pretty much the same manner as Delphi
>> uses them.
>
>
> I have not found any documentation on this topic. Could you please point
> me to some?
>
> -Petter-
see "property" at http://www.python.org/doc/2.3.3/lib/built-in-funcs.html
You could also look at
http://users.rcn.com/python/download/Descriptor.htm to understand how it
does really work.
--
Yermat
More information about the Python-list
mailing list