On 2/24/11, Christopher Brookes <chris.klai...@gmail.com> wrote: > class Character: > def __init__(self, name): > self.name = name > > def ChoosePouvoirUnique(self): > """ Permet de choisir le pouvoir unique du personnage """ > print ("Veuillez choisir votre pouvoir unique dans la liste") > > > for PowerNom,PowerDesc in powerAll: > print (PowerNom, PowerDesc) > > > class Power: > def __init__(self, name, desc): > self.name = name > self.desc = desc > > powerAll = [ > Power('Flammes infernales' , 'Embrase lenemi et le feu bruler'), > Power('Froid devorant', 'Gele lenemi sur place')] > > hero1 = Character("Klaitos") > hero1.ChoosePouvoirUnique() > > im *WANT to display this* : > > Froid devorant : Gele lenemi sur place > Flammes infernales : Embrase lenemi et le feu bruler > > I don't know how to get this ? :( Again, what is the error (traceback) you get when you try to run the code? > > 2011/2/24 Steven D'Aprano <st...@pearwood.info> > >> Alex Hall wrote: >> >>> On 2/24/11, Christopher Brookes <chris.klai...@gmail.com> wrote: >>> >>>> Hi i would like to display all the field of my powerAll like this : >>>> >>>> Choose a power : >>>> Froid devorant : Embrase lenemi et le feu bruler >>>> Flammes infernales : 'Gele lenemi sur place >>>> >>>> ----------------------------- >>>> class Character(): >>>> def ChoosePouvoirUnique(self): >>>> print ("Choose a power") >>>> for Power in powerAll: >>>> print (Power) >>>> >>> >> You need a __init__() function in this class, as with any class. >>> >> >> That's not strictly correct. You don't *need* an __init__ method, unless >> your class needs to be initialised. Most classes will, but some do not. >> >> >> [...] >> >> Also, "for" should be lowercase, though I am >>> honestly not sure that this is a requirement(though I believe it is). >>> >> >> It certainly is. Python is case sensitive, so "for" and "FOR" and "For" >> are >> different. "for" is a Python keyword with special meaning. The others are >> just words with no special meaning. >> >> >> >> >> -- >> Steven >> >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> http://mail.python.org/mailman/listinfo/tutor >> > > > > -- > Brookes Christopher. >
-- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.facebook.com/mehgcap _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor