Re: [Tutor] Python object

2011-02-24 Thread Steve Willoughby

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
mailto:chris.klai...@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 
 print self.description
 print self.type
 print '---'

give ->>

---
Klaitos
Soldier very strong
Soldier
---
*None *-- WHY ARE U HERE ??

Yours,



--
Brookes Christopher.

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




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



--
Steve Willoughby / st...@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
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python object

2011-02-24 Thread Peter Otten
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.


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


Re: [Tutor] Python object

2011-02-24 Thread James Reynolds
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.


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


[Tutor] Python object

2011-02-24 Thread Christopher Brookes
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
??

Yours,



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