Feasible in Python ? list of object , with two exeptional objects

Osiris nono at hotmail.com
Wed Dec 27 16:33:35 EST 2006


Is the following intuitively feasible in Python:
I have an array (I come from C) of identical objects, called sections.
These sections have some feature, say a length, measured in mm, which
is calculated by a method A_length of the instantiation of the
Section's class.
Only, two elements in the array (or list ?) have a length that must be
calculated according to a totally different procedure, a different
function or method.
After calculation of ALL the lengths, they must be added together and
output.
The calculation procedure screams for a FOR or a WHILE loop allong the
list of sections, only those two sections mentioned make life
difficult.

I was thinking along the line of building a class Section, instantiate
a list of objects of this class, and then replace 2 of the elements of
the list by instantiations of the special class...
Or maybe replace only the method in question by the special method... 
It would be neat, if I could just walk the FOR loop, constructing the
list and calculate the total length in one go...

Concretely, the situation is a Plone site that passes user "section"
data to  a Python / C server-side to do calculations on the section
data and return the result over the web.



More information about the Python-list mailing list