Limiting the size of List and making it Homogeneous

Mike C. Fletcher mcfletch at rogers.com
Fri Jan 13 09:45:23 EST 2006


Little class that does restrictions/checks on adding to a list (simply 
subclass and put your restrictions in the beforeAdd or beforeMultipleAdd 
methods).

http://pytable.sourceforge.net/pydoc/basictypes.rlist.html
http://cvs.sourceforge.net/viewcvs.py/basicproperty/properties/basictypes/rlist.py?view=markup

Note, however, that if you goal is to create a simple C-level pointer of 
machine ints you'll need to use Numpy or a similar system that 
implements such a type.

Have fun,
Mike

ankit wrote:

>Is it possible to limit the size of list in python.
>I want to make list of 5 elements. How can I achieve this thing in
>python. And one more thing can we declare list to store elements of
>same type as in c, C++ we can declare an
>array which can have 5 elements of type int.
>C, C++:
>   int intarr[5] 
>How can I achieve this kind of behavior ? 
>
>Thanks
>  
>
-- 
________________________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com




More information about the Python-list mailing list