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 2:35

>>4

I appreciate your help.

Sorry I just was dashing something off as an example,
capitalization is not the same as my actual code.  I
wanted to just give a bare bones representation and I
left a lot out.

|self is not a list. What are you doing?

Typo, should be a second arg like...


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


I'm expecting a tuple or something similar which contains a
list of values for kid, dad, mom etc...

|Where have you defined mlist? For that matter, what is it meant to be?

Sorry, another typo.


    newmlist = []
    def __init___(self,mlist):
        for m in mlist:
            try:
                newmlist = member(m)


I mean my actual code has a bit more ugliness.  I was
just curious if this was a good way to go about this.

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