def mk_getkw(kw, defaults,prefer_passed=False):
    '''
    a helper for generating a function for reading keywords in
    interface functions with a dictionary with defaults

    expects the defaults dictionary to have keywords you request.

    example:
    defaults = dict(a='a',b=3);
    def bigfunc(**kw):
        getkw=mk_getkw(kw,defaults);

        # I want the callers' `a', or the default if s/he doesn't
        # supply it
        a=getkw('a');
        c = [a]*getkw('b');
        return c,c[0]; 

    Option:
        prefer_passed -- use "l in kw" only, not test.
    '''
    def getkw(*ls):
        r = [ kw[l] if test(kw,l) else defaults[l]
              for l in ls ];
        if len(r) == 1: return r[0];
        return r;
    def getkw_prefer_passed(*ls):
        r = [ kw[l] if l in kw else defaults[l]
              for l in ls ];
        if len(r) == 1: return r[0];
        return r;
    return getkw if not prefer_passed else getkw_prefer_passed;
def mk_getkw ( kw , defaults , prefer_passed = False ) : def getkw ( * ls ) : r = [ kw [ l ] if test ( kw , l ) else defaults [ l ] for l in ls ] ; if len ( r ) == 1 : return r [ 0 ] ; return r ; def getkw_prefer_passed ( * ls ) : r = [ kw [ l ] if l in kw else defaults [ l ] for l in ls ] ; if len ( r ) == 1 : return r [ 0 ] ; return r ; return getkw if not prefer_passed else getkw_prefer_passed ;
a helper for generating a function for reading keywords in
    interface functions with a dictionary with defaults

    expects the defaults dictionary to have keywords you request.

    example:
    defaults = dict(a='a',b=3);
    def bigfunc(**kw):
        getkw=mk_getkw(kw,defaults);

        # I want the callers' `a', or the default if s/he doesn't
        # supply it
        a=getkw('a');
        c = [a]*getkw('b');
        return c,c[0]; 

    Option:
        prefer_passed -- use "l in kw" only, not test.