[Tutor] Dynamic change of dictionaries

Andrei Kulakov ak@silmarill.org
Wed, 19 Jun 2002 20:31:33 -0400


On Wed, Jun 19, 2002 at 05:47:51PM -0300, Marc wrote:
> Sean 'Shaleh' Perry (shalehperry@attbi.com) wrote:
> 
> > why not simply ignore 0 count items?
> > 
> > for item in dict:
> >   if dict[item] == 0: continue
> > 
> >   # print status bars
> > 
> > if you want to preen items, the del dict[item] method is reasonable.
> 
> Thanks for reply.
> 
> (And thanks for Lloyd Kvam <pythontutor@venix.com>.The tools you cited
> are overkill right now. Besides, I want to play with python a little
> bit. I didn't received your mail, read it in tutor mail archive.
> I wonder how much fun I have been missing lately :)
> 
> Hehe, no need to "preen" right now, but if u consider it have to be seem
> from across the room, the bars are more than welcome :)
> Your method of ignore item when 0 is nice and have a good side effect: I
> know that an IP acessed the proxy, thus it is alive. However, it makes
> a "graph" with too many lines. That's why I want to delete zeroed items, to
> avoid clutter.

You can skip drawing the graph if it's 0:

if 0:
    continue
else:
    draw_bar()

 - Andrei

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org