[Tutor] setattr vs __setattr__

Rasjid Wilcox rasjidw at gmail.com
Mon Sep 6 09:27:53 CEST 2010


Hi all,

Suppose we have

class A(object):
    pass

a = A()

Is there any difference between

setattr(a, 'foo', 'bar)

and

a.__setattr__['foo'] = 'bar'

other than syntax?

And which is considered 'better' form in Python?

Cheers,

Rasjid.


More information about the Tutor mailing list