Top.Mail.Ru
Python
? ?
LiveJournal for python.
View:Personal Journal.
View:Friends.
View:Calendar.
Missed some entries? Then simply jump to the previous day or the next day.

Thursday, October 28th, 2004

Subject:a fun way to simplify code...
Time:1:08 am.
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.
Comments: Read 3 orAdd Your Own.

Subject:Objects held in lists...
Time:10:27 am.
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...
Comments: Read 8 orAdd Your Own.

LiveJournal for python.

View:User Info.
View:Friends.
View:Calendar.
View:Memories.
Missed some entries? Then simply jump to the previous day or the next day.

Image