get/set

Bjorn Pettersen BPettersen at NAREX.com
Fri May 10 12:57:54 EDT 2002


> From: William Dode [mailto:wilk at flibuste.net] 
> 
> hi,
> 
> coming from java, i use to do a lot of get set method and 
> make all the variable as private.
> 
> class Toto:
> 	def getA(self): return self._a
> 	def setA(self,v): self._a=v
> 	...
> 
> Shall i do like that in python ?

No, there is no point (in general). If you later decide you need
additional code run when you access a variable, you should look into
properties (new in 2.2).

-- bjorn





More information about the Python-list mailing list