Welcome, guest | Sign In | My Account | Store | Cart
def parameters(only=None, exclude=None, ignore='self'):
    """Returns a dictionary of the calling functions 
       parameter names and values.

       The optional arguments can be used to filter the result:

           only           use this to only return parameters 
                          from this list of names.

           exclude        use this to return every parameter 
                          *except* those included in this list
                          of names.

           ignore         use this inside methods to ignore 
                          the calling object's name. For 
                          convenience, it ignores 'self' 
                          by default.

    import inspect
    args, varargs, varkw, defaults = \
    if only is None:
        only = args[:]
        if varkw:
    if exclude is None:
        exclude = []
    return dict([(attrname, defaults[attrname])
        for attrname in only if attrname not in exclude])


  • revision 2 (17 years ago)
  • previous revisions are not available