Dealing with Lists

Dave Angel davea at davea.name
Tue Sep 10 18:32:25 EDT 2013


On 10/9/2013 18:11, stas poritskiy wrote:

Please include some quotation from the message you're replying to.  We
can't tell who this was responding to until the very last line, where
you mention my name.  But since you're using buggy googlegroups, you'd
better also read

 http://wiki.python.org/moin/GoogleGroupsPython

> Those simbols are just for visual representation.
>

Fine.  I just don't know what they represent.

> I need to store each of the first elements of a par, so I can reference to them as to a parent of another group.

Don't know what that means either.

>
> So head is parent of neck,  while neck is parent of arms and so on.

They're just strings, not parents of anything.  But the real question is
whether that list I described is what you wanted:


["head", ["neck", ["arms", ["legs"]]]]

>
> I'm not sure I understand how to apply your chop list example, dave

Call it with a list, and it returns a different one.  if I guessed your
intent, then the returned list will be correct.  If not, then not.

myGroups = ["head", "neck", "arms", "legs"]
my_directory = chop_up(myGroups)

print my_directory

Maybe what you were really intending was to build a class that you can
create several instances, where an attribute of each instance referred
to any children it might have, and a different attribute supplied the
instance's name.

-- 
DaveA





More information about the Python-list mailing list