[Tutor] Class Nesting

Greg Nielsen gollumgreg407366 at gmail.com
Tue Feb 7 02:17:05 CET 2012


Hello List,

     My name is Greg, and while working on a project I've come across a
rather interesting problem. I'm trying to create a rough model of a star
cluster and all of the stars and planets contained within. Kind of a cool
project; hopefully it should work a little like this. I create a Star
Cluster object, which goes through a list of positions and decides if it
should build a Star System there. If it does, it then creates a Star System
object at that position which in turn calls upon and creates several Planet
objects to reside inside of it. All in all, about 64 positions to check, on
average 24 Star Systems, each with between 2 and 9 planets.
     So here is the problem, to create an object, you need to assign it to
a variable, and you need to know what that variable is to call upon it
later, so to have a object build a second object, it would need to somehow
create a variable name, and you would somehow have to know what name it
picked. Unless perhaps you had a Star Cluster list which had all of your
created Star System objects, each with their own list of Planets which you
could use list to call upon maybe....
     I have a general grasp on the idea of nesting and calling upon objects
which you don't know the name of, but this goes far beyond my level of
understanding. Can anyone shed some light on how this would work, or
perhaps point me in the right direction of some documentation on this?
Thanks for the help, and I hope this is not too difficult of a question.

Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120206/b321c798/attachment.html>


More information about the Tutor mailing list