[Tutor] Python object

Steve Willoughby steve at alchemy.com
Thu Feb 24 17:25:32 CET 2011


On 24-Feb-11 08:13, James Reynolds wrote:
> I don't understand what you are trying to do?
>
> I'm assuming def GetAllAtrib is a method within a class; perhaps you
> could copy more the code base?
>
> It seems to be locating the three elements you have in that method just
> fine, but I'm guessing you have another print statement somewhere that
> is causing it to print None.

Or perhaps calling the method from an IDE or interactive prompt, where 
the print statements in the method are printing as intended, but the 
interactive environment itself is printing the return value from the 
method?  This could happen if you did this at the prompt:

 >>> print object.GetAllAtrib()

This is a case where giving us more information about what you're doing 
helps us answer your question better.


--steve

>
>
> On Thu, Feb 24, 2011 at 10:48 AM, Christopher Brookes
> <chris.klaitos at gmail.com <mailto:chris.klaitos at gmail.com>> 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 <http://self.name>
>              print self.description
>              print self.type
>              print '-----------------------------------------------'
>
>     give ->>
>
>     -----------------------------------------------
>     Klaitos
>     Soldier very strong
>     Soldier
>     -----------------------------------------------
>     *None *<<<<<<<<-- WHY ARE U HERE ??
>
>     Yours,
>
>
>
>     --
>     Brookes Christopher.
>
>     _______________________________________________
>     Tutor maillist  - Tutor at python.org <mailto:Tutor at python.org>
>     To unsubscribe or change subscription options:
>     http://mail.python.org/mailman/listinfo/tutor
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor


-- 
Steve Willoughby / steve at alchemy.com
"A ship in harbor is safe, but that is not what ships are built for."
PGP Fingerprint 48A3 2621 E72C 31D9 2928 2E8F 6506 DB29 54F7 0F53


More information about the Tutor mailing list