W
Wildemar Wildenburger
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 <[email protected]>
To: Wildemar Wildenburger <[email protected]>
References:
<[email protected]>
<[email protected]>
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
read up the current news.
-------- Original Message --------
Subject: Re: managed lists?
Date: Mon, 21 May 2007 21:30:37 +0200
From: Jorgen Bodde <[email protected]>
To: Wildemar Wildenburger <[email protected]>
References:
<[email protected]>
<[email protected]>
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
Jorgen said: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