Re: [Tutor] Doing the same thing twice. Works first time but not the second.

2012-09-06 Thread Omar Abou Mrad
On Fri, Aug 17, 2012 at 11:11 PM, Matthew Love wrote: > > This is the error: > > Traceback (most recent call last): > File "C:\Users\Matthew\Desktop\test.py", line 16, in > print(player.inventory()) > TypeError: 'list' object is not callable > > The python debugger can also give you a hint

Re: [Tutor] Doing the same thing twice. Works first time but not the second.

2012-09-06 Thread Alan Gauld
On 17/08/12 21:11, Matthew Love wrote: class Player(object): def inventory(self): self.inventory = ["torch"] return self.inventory Notice that you override the name inventory. Initially self.inventory is the inventory() method. But then you change self.inventory to be a

Re: [Tutor] Doing the same thing twice. Works first time but not the second.

2012-09-06 Thread eryksun
On Fri, Aug 17, 2012 at 4:11 PM, Matthew Love wrote: > def inventory(self): > self.inventory = ["torch"] > return self.inventory What is 'self.inventory' before you call inventory(), and what is it afterwards? A quick fix would be to name the list "_inventory" and return self.

[Tutor] Doing the same thing twice. Works first time but not the second.

2012-09-06 Thread Matthew Love
This error is confusing me. I am wondering if anyone can help me out. Using W7 64 Ultimate Using Python 3.1.1 This is the relevant part of the program. class Player(object): def __init__(self): print("Player created.") def inventory(self): self.inventory = ["torch"]