[Tutor] Python object
Peter Otten
__peter__ at web.de
Thu Feb 24 17:26:20 CET 2011
Christopher Brookes wrote:
> Hi, i'm new in python.
> I'm trying to create a small fight program in object.
>
> I've created __init__ (its works) but when i'm trying to display init
> param i'm getting param and "None" every time. Why ?
>
> def GetAllAtrib(self):
> print '-----------------------------------------------'
> print self.name
> print self.description
> print self.type
> print '-----------------------------------------------'
>
> give ->>
>
> -----------------------------------------------
> Klaitos
> Soldier very strong
> Soldier
> -----------------------------------------------
> *None *<<<<<<<<-- WHY ARE U HERE
My crystall ball says: because you invoke the above method with something
like
print soldier.GetAllAttrib()
instead of just
soldier.GetAllAttrib()
If I'm guessing wrong please provide the relevant source code.
By the way, show_all_attributes() would be a better name for your method as
it would make the problem in your code obvious.
More information about the Tutor
mailing list