blob: 9f764ea79713288cd5d2aad797ba48fcc20c33a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
def attributoTraducibile(**dic):
def get(self):
return dic[self.lingua]
def set(self, traduzione):
dic[self.lingua]= traduzione
return property(get, set)
class Oggetto(object):
definizione = attributoTraducibile(it="vaso", en="potter")
tipologia = attributoTraducibile(it="antico", en="ancient")
o = Oggetto()
o.lingua = "it"
print o.definizione
o.lingua = "en"
print o.definizione
o.lingua = "it"
o.definizione = "Vaso"
print o.definizione
o.lingua = "en"
o.definizione = "Potter"
print o.definizione
|