[Tutor] understanding **kwargs syntax

John washakie at gmail.com
Thu Aug 25 10:27:36 CEST 2011


Just a quick question,

is it wrong to use the *args and **kwargs ( the latter in particular)
when DEFINING a function?

def fest(**kwargs):
    """ a function test """
    keys = sorted(kwargs.keys())

    print("You provided {0} keywords::\n".format(len(keys)))
    for kw in keys:
        print("{0} => {1}".format(kw, kwargs[kw]))

Are there some good examples of when this would be a good idea to implement?

--john


More information about the Tutor mailing list