[Tutor] like setattr but for methods...

ali mangaliag rmangaliag@slu.edu.ph
Sat May 24 05:07:00 2003


if i have a class, X, and an instance of X called Y...
i can add attributes to Y in two ways:

a.)
Y.attr1 = 1
Y.attr2 = "test"
Y.attr3 = [1,2,3,4,5]

b.)
setattr(Y,"attr1",1)
setattr(Y,"attr2","test")
setattr(Y,"attr3",[1,2,3,4,5])

is my understanding of this correct???

my second question is... is there a way for me to define a method like the
way i did (or anything similar) with the attributes above???