[Fwd: Re: managed lists?]

Wildemar Wildenburger wildemar at freakmail.de
Mon May 21 15:34:36 EDT 2007


I answered off list (because besically I'm an idiot). So if you like, 
read up the current news. :)

-------- Original Message --------
Subject: 	Re: managed lists?
Date: 	Mon, 21 May 2007 21:30:37 +0200
From: 	Jorgen Bodde <jorgen.maillist at gmail.com>
To: 	Wildemar Wildenburger <wildemar at freakmail.de>
References: 
<11e49df10705211026s3e8f15b8nee32e0aa94b55ee6 at mail.gmail.com> 
<4651DFE1.7010109 at freakmail.de>



Hi Wildemar,

Thanks for the answer. I did make something myself after i could not
find anything, just because it was fun to do :-) I did saw array but
it was not for object, only for small types like int, char, etc to be
used for quick but efficient buffers of raw data (at least it looks
like that).

The list I created uses a strong type check to make sure all objects
in the list are of the same type, like

ol = objlist.ObjList(class_name = SomeClass)

Now only classes that are an instance of SomeClass are allowed in the
array, ObjList mimics a normal list, it can index, iterate, find,
delete, append items so it was basically a drop-in replacement for my
_list = [] solution

If you are interested i can send you the source. I created a py.test
module as well to test every method intensively.

Regards,
- Jorgen


On 5/21/07, Wildemar Wildenburger <wildemar at freakmail.de> wrote:
> Jorgen Bodde wrote:
> > Right now i have a list in a class that I export as a member variable
> > to the outside world, it is a standard list (e.g. [] ) but I wish to
> > have a stronger type checking when adding objects, that only some
> > objects are allowed and others are not. It was quite easy to create
> > it, but I wonder if there is already a standard solution for lists
> > that carry only objects of a single type?
> >
>
> Don't have much time on me right now, so I'll just give you a hint: I
> *think* python has an array-datatype somewhere in its STD-lib (that is:
> in a module you have to import). Not sure, could have been only for
> NumPy or so. A quick look into the docs should clarify that quickly.
>
> bye :)
> W
>




More information about the Python-list mailing list