[Image-SIG] Storing instance of a class in an array

Fredrik Lundh fredrik at pythonware.com
Wed Jun 28 17:47:58 CEST 2006

Ahmad Affzan Abdullah wrote:

> Is there any way to store instances of a class in a 2-dimensional array? How
> do you declare the array? I was thinking something like this
> a = ClassName(arg1, arg2,arg3)
> so that a.arg1 = arg1, a.arg2 = arg2, a.arg3 = arg3
> if I've got 9 of a, how do I store them in a 3x3 array
> I tried to initialize the array as having a 0 value first by typing
> array = zeros((3,3))
> but when I assign array[0][0] = a, it just return an error of bad value type
> If I can store those instances in an array, how do I initialize the array?

if "array" refers to Python list, this question should really have been sent to a general
python forum, and the answer is found here:


if "array" refers to a Numpy array, you may have better luck by asking on a Numpy
support forum.

if "array" refers to a PIL image memory, the answer is "you cannot do that".


More information about the Image-SIG mailing list