Learned Something Today

In retrospect, it seems really easy, but I had a fuck of a time with it earlier.

queue = [populated list]
while len(queue):
    this_one = queue.pop(0)
    more_stuff_to_queue = this_one.get(more_stuff)
    for one_more in more_stuff_to_queue:
        queue.append(one_more)

Of course, you could queue.insert(0, one_more) instead of appending, depending on how soon you want to process one_more.

My mind is awash in Python… now that I can process all those things in the queue, how do I make ’em all look pretty on a webpage while maintaining the objects’ relationships? this_one tied to its parent and its children tied to it. Can’t be that hard, but it’ll have to wait until tomorrow. Going out soon.

It’s obvious I have nothing humorous, acerbic or thought-provoking to post… not for lack… but, sometimes the Python just gets in the way.

Advertisements