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: BBCoder 2010-01-06 2:45

> This is how you quote properly.
This is how you quote properly.

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.

Name: BBCoder 2010-01-06 16:23

>>11 Why don't you listen?

>> This is not how you quote.

>This is now how you god damn quote either.

> Put a [m]>[/m] at the beginning of the line, [b]followed by a space[/b] and then the quote text.
Put a > at the beginning of the line, followed by a space and then the quote text.

And just because I hate when people don't know how to multi-line quote, I'll tell you how to do that too.

> Put it at the end of a line like so: [o]
And then continue the quote on the next line.  You don't need another >.
You must close the tag at the end. [/o]
Put it at the end of a line like so:
And then continue the quote on the next line.  You don't need another >.
You must close each tag at the end.

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