Classes referencing each other
Manuel Bleichner
manuel at prolink.de
Mon Sep 4 06:42:18 EDT 2006
> Does the "EMCenter" really need to /subclass/ from all of those? Or
> would it be better to make some of those attributes of an EMCenter
> INSTANCE (passing in instances of the others to the __init__() ).
>
> class EMCenter(object):
> def __init__(self, b, r, c, ol):
> self.building = b
> self.researcher = r
> ...
>
> IOW: the difference between:
> an EMCenter IS a building AND
> IS a researcher AND
> IS a constructor AND
> IS a "OnLand"
=> These relations are correct:
the EM Center can build units and research technologies, therefore
it is a researcher and constructor.
> Note that "OnLand" already sounds like an attribute -- and at that,
> maybe an attribute of "Building"
Yes, this one is really an attribute, but it's not yet implemented and
I wasn't sure how to do it when I wrote the template code.
> As soon as you get a recursive definition, you MUST split...
Yes =(
I'll have to try to reduce such relations to a minimum...
It would have just been nice to declare and later define the classes,
but such a feature would bloat the neat python syntax.
Thanks for all the text you wrote, but it all went a bit in the
wrong direction, sorry :)
Manuel
More information about the Python-list
mailing list