Делай самое простое, что могло бы сработать - возможно, что-то вроде:
SEGMENTS = (SEGMENT_1, SEGMENT_2) = range(2)
class NeuronRegion(object):
def __init__(self):
self.connection = [None, None]
self.chosen = 0
def choose(self, segment):
assert segment in SEGMENTS
self.chosen = segment
def connect(other_neuron_region):
# remember to reset those to None when they're not needed anymore,
# to avoid cycles that prevent the garbage collector from doing his job:
self.connection[self.chosen] = other_neuron_region
other_neuron_region.connection[other_neuron_region.chosen] = self
class Child1(NeuronRegion):
''' other stuff '''
class Child2(NeuronRegion):
''' other stuff '''
[РЕДАКТИРОВАТЬ] Я должен признать, что мне это не очень нравится, но он делает то, что вы просили, ИМО.