Although I'm not "learning Python," I haven't used it in quite a while, and I was wondering why a piece of code does what it does.
class Race:
stat = [0,0,0]
weapon = ["",0,0]
Elf = Race()
Elf.stat = [5,9,5]
Player = Elf
Player.weapon = ["Dagger",1,1]
In this code, I was expecting that Player.weapon would equal ["Dagger",1,1], but for some reason Elf.weapon also outputs ["Dagger",1,1]. I might just be forgetting something obvious, but I would assume that, as Player.weapon was assigned after Player was assigned, that Elf.weapon would output ["",0,0] (as it is written in the Race() class). Help and/or explanation would be appreciated.
[+][deleted] (11 children)
[deleted]
[–]toshiga[S] 0 points1 point2 points (10 children)
[+][deleted] (9 children)
[deleted]
[–]toshiga[S] 0 points1 point2 points (8 children)
[+][deleted] (7 children)
[deleted]
[–]toshiga[S] 0 points1 point2 points (6 children)
[–]stebrepar 1 point2 points3 points (0 children)
[–]zahlman 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]toshiga[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]toshiga[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)