[Nipy-devel] help with attributes
Jonathan Taylor
jonathan.taylor at stanford.edu
Fri May 19 01:38:18 CDT 2006
>
> This would be accomplished with attributes as follows:
>
> from attributes import readonly
> class Test (object):
> class x (readonly): default=4.
>
> d = Test()
> d.x = 3.
> d.y = 4.
>
Yes, but it won't fail with
d.x = 'a'
which is the commented out example in my script, i.e. there is no type
checking, which I think is another nice feature of traits.
And the two functions I wrote will work for basically any trait, i.e.
type checking will continue, because it uses the default trait's
validate method....
-- Jonathan
--
------------------------------------------------------------------------
I'm part of the Team in Training: please support our efforts for the
Leukemia and Lymphoma Society!
http://www.active.com/donate/tntsvmb/tntsvmbJTaylor
GO TEAM !!!
------------------------------------------------------------------------
Jonathan Taylor Tel: 650.723.9230
Dept. of Statistics Fax: 650.725.8977
Sequoia Hall, 137 www-stat.stanford.edu/~jtaylo
390 Serra Mall
Stanford, CA 94305
More information about the Nipy-devel
mailing list