Or possibly strange list of object behaviour

IDLE 2.6.2
>>> class Player():
        hand = []

        
>>> Colin = Player()
>>> Alex = Player()
>>>
>>> Players = [Colin, Alex]
>>>
>>> def hands():
        for player in Players:
                player.hand.append("A")

>>> hands()
>>>
>>> Colin.hand
['A', 'A']
>>> Alex.hand
['A', 'A']

I would have expected hand for each object to be simply ['A']. Why
does this not occur and how would I implement the behaviour I
expected/want?

Thanks in advance for your help,
Colin Caine
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to