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:54

I'm curious if others with more experience
with python find it unwise, inefficient or too
complicated.
No. This isn't about python. It's about programming skills in general.

Alternatives might be to only have one class or heck
I don't know.
Well then think about it a little. What kinds of data are you going to use?

add/remove branches
Cool, but family trees aren't actually trees, they're digraphs (with cycles, possibly).

BTW, if it were a tree, you usually represent one using a root node which can have children nodes which can have children nodes and so on.

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