[Tutor] Display all field of a listuples
Christopher Brookes
chris.klaitos at gmail.com
Fri Feb 25 09:18:23 CET 2011
It's works. Thank you all.
2011/2/25 bob gailer <bgailer at gmail.com>
> 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 = 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
>
>
--
Brookes Christopher.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110225/c983a020/attachment-0001.html>
More information about the Tutor
mailing list