[BangPypers] design discussion.

Navin Kabra navin.kabra at gmail.com
Fri Jul 17 00:04:50 CEST 2009


On Thu, Jul 16, 2009 at 1:10 PM, Madhubala<madhubalav at infotechsw.com> wrote:
> Posted earlier with wrong description in the subject - sorry.
> Hi,
>
> I would like to put one design for discussion and would like to get
> appropriate solution after discussions. The details are below.
>
> There are  three dictionaries like
> goodObjects    {name:object} # object can be any data type which cannot/need
> not hold its type as good etc.               badObjects     {name:object}
> unknownObjects {name:object}
>
> The requirement here is to display all these objects sorted by name and show
> different colors for good/bad/unknown

This is what I would do:
  l = [(name, object, 'good') for name, object in goodObjects.iteritems()]
  l.extend(((name, object, 'bad') for name, object in badObjects.iteritems()))
  l.extend(((name, object, 'unknown') for name, object in
unknownObjects.iteritems()))
  Now "sorted(l)" will give you the list you want.

But I agree with the earlier poster who implied that you should
consider re-organizing your data structures so you don't find yourself
in this situation.

navin.


More information about the BangPypers mailing list