Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53927

Re: Dealing with Lists

Newsgroups comp.lang.python
Date 2013-09-10 14:31 -0700
References <33650fe9-802e-477d-a361-6d4bdeb28762@googlegroups.com>
Message-ID <990d4b72-af39-4f70-9e0d-9d389d1e442e@googlegroups.com> (permalink)
Subject Re: Dealing with Lists
From matt.komyanek@gmail.com

Show all headers | View raw


What you're asking is a Ragged Hierarchy.

On Tuesday, September 10, 2013 5:08:45 PM UTC-4, stas poritskiy wrote:
> Greetings to all!
> 
> 
> 
> i ran into a little logic problem and trying to figure it out.
> 
> 
> 
> my case is as follows:
> 
> 
> 
> i have a list of items each item represents a Group 
> 
> 
> 
> i need to create a set of nested groups,
> 
> 
> 
> so, for example:
> 
> 
> 
> myGroups = ["head", "neck", "arms", "legs"]
> 
> 
> 
> i need to get them to be represented like this:
> 
> (if you can imaging a folder structure)
> 
> 
> 
> head
> 
>   |_> neck
> 
>         |_> arms
> 
>               |_>legs
> 
> 
> 
> and so on until i hit the last element.
> 
> 
> 
> what i thought would work (but don't know really how to advance here) is:
> 
> 
> 
>     def createVNTgroups(self, groupsData):
> 
>         #function recieves the LIST of group elements, INDEX0 is always the
> 
>         #MAIN-ROOT of the tree
> 
> 
> 
>         for i in range(len(groupsData)):
> 
>             print groupsData[i]
> 
>             
> 
>             for q in range(1, len(groupsData)):
> 
>                 
> 
>                 print groupsData[q]
> 
> 
> 
> could someone give me a hint?
> 
> 
> 
> thanks in advance!

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Dealing with Lists stas poritskiy <stascrash@gmail.com> - 2013-09-10 14:08 -0700
  Re: Dealing with Lists stas poritskiy <stascrash@gmail.com> - 2013-09-10 14:10 -0700
  Re: Dealing with Lists matt.komyanek@gmail.com - 2013-09-10 14:31 -0700
  Re: Dealing with Lists Dave Angel <davea@davea.name> - 2013-09-10 21:51 +0000
    Re: Dealing with Lists stas poritskiy <stascrash@gmail.com> - 2013-09-10 15:11 -0700
      Re: Dealing with Lists Roy Smith <roy@panix.com> - 2013-09-10 18:30 -0400
      Re: Dealing with Lists Dave Angel <davea@davea.name> - 2013-09-10 22:32 +0000
  Re: Dealing with Lists Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-11 02:14 +0000
    Re: Dealing with Lists Dave Angel <davea@davea.name> - 2013-09-11 02:24 +0000
      Re: Dealing with Lists Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-11 03:13 +0000
        Re: Dealing with Lists stas poritskiy <stascrash@gmail.com> - 2013-09-10 20:44 -0700
        Re: Dealing with Lists stas poritskiy <stascrash@gmail.com> - 2013-09-10 20:52 -0700
          Re: Dealing with Lists stas poritskiy <stascrash@gmail.com> - 2013-09-11 07:47 -0700
            Re: Dealing with Lists stas poritskiy <stascrash@gmail.com> - 2013-09-11 07:57 -0700
              Re: Dealing with Lists Peter Otten <__peter__@web.de> - 2013-09-11 18:17 +0200

csiph-web