|
||||
|
here is a recipe that defines an ANY object that will help optimize structural comparisons... UPDATE: slightly updated the recipe to make it a bit more fun! :) thanks. |
||||
|
|
LiveJournal for python.
|
|||||||||
| Thursday, October 28th, 2004 |
|
||||
|
here is a recipe that defines an ANY object that will help optimize structural comparisons... UPDATE: slightly updated the recipe to make it a bit more fun! :) thanks. |
||||
|
|
|
||||
Code:
class Taco:
class Skills:
agility = 1
speed = 1
y=[]
y.append(Taco)
y.append(Taco)
y.append(Taco)
y[0].Skills.agility=4
print y[0].Skills.agility
print y[2].Skills.agility
ouput: 4 4 Why when I change the value of the object @ index 0 does it affect the object @ index 2? Maybe I am missing something here. I am a Python noob, if that's an excuse... |
||||
|
|
LiveJournal for python.
|
|||||||||||