Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

python classes

Name: Anonymous 2010-01-05 23:50

OK, say I need to create an application that simulates a
family tree.  Each member may have a mom dad and kids.

I need to create a family tree class that contains a
collection of these member class objects and methods for
adding branches, removing members, etc...

I'm mainly having a hard time figuring how to join the
members if that makes sense.

I've got something like...

class member(object):
   
    def __init__(self):
       member.kid = self[0]
       member.dad = self[1]
       etc...


class familyTree(object):

    def __init___(self):
        for m in mlist:
            try:
                m = member(m)

blah blah blah


How to I make the familytree class contain a
collection of member class objects?

Name: Anonymous 2010-01-06 12:37

>>You keep using that word, I don't think you understand what it means.

Well let me expand a bit then.


All I mean by typo was that I was trying to jot down
a rough idea of the code I'm using, not the actual
code since it would be much less readable and is not
essential to the question I'm asking, and in the
process dropped some important aspects of the code.


My question regards whether or not building a family
tree type application using two classes, one being a
member object which represents a single person, and
the other being the actual family tree object is a
sensible way to go.

Alternatives might be to only have one class or heck
I don't know.  This is the way I approached the
problem, I'm curious if others with more experience
with python find it unwise, inefficient or too
complicated.

At some point I will want to be able to add various
methods to add/remove branches and do other things
one would obviously want to be able to do with a
family tree.  e.g. Compare two family trees and if
they share members combine them.  Or combine them
given a marriage (i.e. if one person has a spouse
attribute that matches a member id in another tree
the application could combine them). etc....  It
is a family tree application, that is all.

I hope this clears up all the confusion.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List