[Nipy-devel] more on the slice/list of slices example

Jonathan Taylor jonathan.taylor at stanford.edu
Wed May 31 14:52:59 CDT 2006


i svn up'ed the code and now i don't get the error message, but it 
doesn't seem
that it is actually type checking the list of elements as traits does, 
i.e. it doesn't choke when i set it to a list value of ['abc', 45].. is 
it supposed to?

is it possible to force it to typecheck list elements (i.e. to make it 
only accept a slice or a list of slices) with a different "implements=" 
statement?  is this not a desirable feature for some reason?

-- jonathan

---------------

 >>> from attributes import *
 >>>
 >>> class Test(object):
...     class value(attribute): implements = list, slice
...
 >>>
 >>> a = Test()
 >>> a.value = [slice(0,100,1)]*2
 >>> a.value = slice(0,100,1)
 >>> a.value = ['abc',45]
 >>>
 >>> from attributes import *
 >>>
 >>> class Test(object):
...     class value(attribute): implements = Sequence, slice
...
 >>>
 >>> a = Test()
 >>> a.value = [slice(0,100,1)]*2
 >>> a.value = slice(0,100,1)
 >>> a.value = ['abc',45]
 >>>

---------------

-- 
------------------------------------------------------------------------
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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: jonathan.taylor.vcf
Type: text/x-vcard
Size: 329 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/nipy-devel/attachments/20060531/d22449aa/attachment-0002.vcf 


More information about the Nipy-devel mailing list