On 2/24/2011 4:54 PM, Christopher Brookes 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)

class Power:
    def __init__(self, name, desc):
self.name <http://self.name> = name
        self.desc = desc




powerAll = [
 Power('Flammes infernales' , 'Embrase lenemi et le feu bruler'),
 Power('Froid devorant', 'Gele lenemi sur place')]


But he won't display it :(

i've try   For PowerName,PowerDesc in powerAll:
                print (PowerName, PowerDesc)

but it doesn't work !

When something "does not work" always show us what results you got as well as what you wanted.

Also get in the habit of using Capitalized names for classes and unCapitalized names for variables and functions.

powerAll is a list of class instaces. You must (in some way) identify the attributes of those instances. One way:

for power in powerAll:
  print (power.name, power.desc)

--
Bob Gailer
919-636-4239
Chapel Hill NC

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to