Dictionary assignment

Christopher Boomer (don't dash!) c-b-o-o-m-e-r at tiscali.co.uk
Mon Aug 18 17:53:11 CEST 2003

"Mark Daley" <mark at diversiform.com> wrote in message
news:mailman.1060979551.16837.python-list at python.org...

Start by making your code a bit more robust.

           for key in current.keys():
                if not format.has_key(lookup):
                    print "No such lookup:",lookup # a debugging warning
                format[self.formats.get()][key] = current[key]

You can work from there, depending on what outcome you want in the event of
an error...

You also have to be sure that the result of get() is a valid key (string,
tuple) not, say, a list, which is why you should avoid statements like
mylist=tuple(temp).  There's a list() like the tuple() you use, so to save
more headahes, avoid list= altogether

And don't mind him. We don't solve problems, but we do tell you how to.  ;-)

Christopher Boomer.

More information about the Python-list mailing list