class Etichette: def etichetta_en(self): return "Product:" def etichetta_it(self): return "Prodotto:" class Cestino_spesa(Etichette): """Classe per la gestione della spesa""" LISTA_SPESA_INTERNA = "" def __init__(self, lista_spesa_passata): self.LISTA_SPESA_INTERNA = lista_spesa_passata def listato_spesa(self, ling): """Funzione che stampa i singoli prodotti di spesa""" self.ling = ling et = Etichette() for i in self.LISTA_SPESA_INTERNA: if self.ling == 'it': print et.etichetta_it(), i elif self.ling == 'en': print et.etichetta_en(), i else: print et.etichetta_en(), i mia_lista = ["mele", "pere", "pasta", "salsiccia"] cs = Cestino_spesa(mia_lista) cs.listato_spesa('it')
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question