it.comp.lang.python
  Home FAQ Contact Sign in
it.comp.lang.python only
 
Advanced search
January 2008
motuwethfrsasuw
 123456 1
78910111213 2
14151617181920 3
21222324252627 4
28293031    5
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
it.comp.lang.python Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Set e get di attributi         


Author: InSa
Date: Jan 14, 2008 07:46

Salve a tutti,

questa è una domanda da niubbo: ho una classe che ha 3 attributi
privati accessibili solamente tramite il metodoi metodi "setter" e
"getter", esiste per caso un "meccanismo" che mi fa tali metodi (quasi)
in automatico oppure devo scrivermeli a mano per tutti e 3 gli
attributi?

Il codice ora come ora è questo:
-------------------------
class Test(object) :
def __init__(self) :
self._item1 = 0
self._item2 = 0
self._item3 = 0

def item1Set(self, newItem) :
self._item1 = newItem

def item1Get(self) :
return self._item1

def item2Set(self, newItem) :
self._item2 = newItem
Show full article (0.92Kb)
7 Comments