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

Alan Gauld alan.gauld at btinternet.com
Thu Sep 6 11:00:20 CEST 2012

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 list.

So the next time you call player.inventory() you are
trying to execute the list hence the error.

You need to change the name of the inventory attribute
to something like theInventory...

Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list