7stud wrote: > On Feb 21, 11:19 am, Neal Becker <[EMAIL PROTECTED]> wrote: >> I'm working on a simple extension. Following the classic 'noddy' >> example. >> >> In [15]: cmplx_int32 >> Out[15]: <type 'numpy.cmplx_int32'> >> >> Now I want to add an attribute to this type. More precisely, I want a >> class attribute. >> >> cmplx_int32.test = 0 >> --------------------------------------------------------------------------- >> TypeError Traceback (most recent call >> last) >> >> /home/nbecker/numpy/<ipython console> in <module>() >> >> TypeError: can't set attributes of built-in/extension >> type 'numpy.cmplx_int32' >> >> What am I missing? > > > class Dog(object): > def __setattr__(self, attr, val): > print "TypeError: can't set attributes of built-in/extension" > print "type 'Dog.cmplx_int32'" > > d = Dog() > d.test = 0 > > --output:-- > TypeError: can't set attributes of built-in/extension > type 'Dog.cmplx_int32'
Not quite, I'm setting a class attribute, not an attribute on an instance. -- http://mail.python.org/mailman/listinfo/python-list