gene tani wrote:
> 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
>
> - ring(circular) buffers overwrite oldest elements when they're flagged
> as at their limit, is that what you want?:
>
> http://www.onlamp.com/lpt/a/5828
>
> you can write whatever type checks you want in the append() methods

the other possible interpret what you're asking is these lists are
read-only so you subclass list and your __init__() either truncates any
more than 5 list elements passed to it, or throws an exception when
this happens.  At this point you've hit the limits of my ability to
read your mind.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to