how to repeat function definitions less

MRAB google at mrabarnett.plus.com
Mon Mar 16 00:41:15 CET 2009


alex goretoy wrote:
> ok now for the final result, i decided to split options out to a 
> separate dict of lists, does this look right to every one, I currently 
> have error somewhere else in my code so can't test this right now, Is 
> this a good method to do this? or is there another option?
> 
[snip]
First of all, *don't use "is" and "is not" to test for equality*; use 
"==" and "!=".

When you split the options out like that you get duplication.

You have, for example:

     ...
     "colors": ["c", "cl", "col", ...]
     ...

and:

     ...
     "imp_colors": ["c", "cl", "col", ...]
     ...

Couldn't you put them into one dict, something like:

    ...
    "colors": ("imp_colors", ["c", "cl", "col", ...])
    ...




More information about the Python-list mailing list