Classes referencing each other
Manuel Bleichner
manuel at prolink.de
Fri Sep 1 06:06:39 EDT 2006
Thanks for the answer.
> You could move all connections to a central location after the
> class definitions, such as
>
> class A: pass
> class B: pass
> class C: pass
>
> connections = {A: (B, C), B: (C,), C: (A,)}
I think I simplified my classes a bit too much :)
Actually there are multiple types of connections between
the classes. for example:
class A(CableConnected, WLANConnected):
name = 'I am class A'
cable_connections = [B, C]
wlan_connections = [D]
class B(CableConnected, RadioConnected):
name = 'I am class B'
cable_connections = [C, A]
radio_connections = [F]
...
And because not all classes have the same types of connections,
it would become extremely unreadable to try to define them
at a central place. Also it seperates attributes from each other;
'name' is defined in the class, the connections somewhere else.
Greetings,
Manuel
More information about the Python-list
mailing list