A dictionary containing all keyword arguments whose keyword doesn't correspond to a formal parameter : Varible length parameter : Function PYTHON TUTORIALS


PYTHON TUTORIALS » Function » Varible length parameter »

 

A dictionary containing all keyword arguments whose keyword doesn't correspond to a formal parameter


def cheeseshop(kind, *arguments, **keywords):
    print "- Do you have any", kind, '?'
    print "- I'm sorry, we're all out of", kind
    for arg in arguments: print arg
    print '-'*40
    for kw in keywords.keys(): print kw, ':', keywords[kw]


cheeseshop('Limburger', "It's very runny, sir.",
            "It's really very, VERY runny, sir.",
            client='John Cleese',
            shopkeeper='Michael Palin',
            sketch='Cheese Shop Sketch')



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Function
» Varible length parameter