"Manuel Bleichner" <[EMAIL PROTECTED]> wrote:

> If anyone of you knows a neat way to solve this, I'd be
> very grateful.

You could use a function:

class A(object):
   @staticmethod
   def connected_to(): return [B, C]
   <other attributes...>

class B(object)
   @staticmethod
   def connected_to(): return [C]
   <other attributes...>

class C(object)
   @staticmethod
   def connected_to(): return [A]
   <other attributes...>

for cls in globals().values():
    if (type(cls) is type and 
        hasattr(cls, 'connected_to') and
        callable(cls.connected_to)):
        cls.connected_to = cls.connected_to()

or just store the names of the classes and do a similar fixup once they are 
all defined:

class A(object):
   connected_to = ['B', 'C']
   <other attributes...>

for cls in globals().values():
    if (type(cls) is type and 
        hasattr(cls, 'connected_to')):
        cls.connected_to = [globals()[c] for c in cls.connected_to ]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to