In <[EMAIL PROTECTED]>, Osiris wrote: > 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.
Is this something that the instances of section "know" or is some external "knowledge" needed to identify those special objects? > 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. Sounds like something like ``sum(section.length() for section in sections)``. Your description is a bit vague. Where and how do you start to treat the objects different. Is it possible to decide at instantiation time to create a `Section` object or a `SpecialSection` object? How much different is the calculation? Do you need two separate classes or just one with a flag or maybe a function as argument to the `__init__()` method? Are you writing the `Section` class(es) just for this calculation or do they contain other behavior too? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list