<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">I want to use **kwargs to check a list of conditions (if true do this, if false do nothing) besides required parameters ( in sample a and b).&nbsp; Sometimes I want to add a Python object (in example a dictionary and a list). Below is my first **kwargs-brew.<br><br>###START<br><br>def function_with_kwargs(a, b, **kwargs):<br>&nbsp;&nbsp;&nbsp; options = {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'logfile'&nbsp;&nbsp; : None,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'door'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 'kitchendoor',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'roof'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 'tiles',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'mydict'&nbsp;&nbsp;&nbsp; : None,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'mylist'&nbsp;&nbsp;&nbsp; : None, }<br>&nbsp;&nbsp;&nbsp; options.update(kwargs)<br><br>&nbsp;&nbsp;&nbsp; logfile =
 options.get('logfile')<br>&nbsp;&nbsp;&nbsp; if logfile == None:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "No logging"<br>&nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Logging"<br><br>&nbsp;&nbsp;&nbsp; mydict = options.get('mydict')<br>&nbsp;&nbsp;&nbsp; if mydict == None:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Do nothing with dictionary"<br>&nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Do something with dictionary"<br><br>&nbsp;&nbsp;&nbsp; mylist = options.get('mylist')<br>&nbsp;&nbsp;&nbsp; if mylist == None:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Do nothing with list"<br>&nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Do something with list"<br><br>&nbsp;&nbsp;&nbsp; print "END OF FUNCTION\n"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>somedict = { 'a': '1', 'b': '2', }<br>somelist = ['1', '2']<br><br>#DO
 SOMETHING<br>function_with_kwargs(1, 2, logfile='log.txt', door='frontdoor', mydict=somedict, mylist=somelist)<br><br>#DO NOTHING<br>function_with_kwargs(1, 2, door='frontdoor')<br><br><br><br>### END<br><br>I have 2 questions about this code:<br><br>1. Can I use this in Python 3 ?&nbsp; I'm not sure if I can use **kwargs in Python 3 because it uses the "apply" builtin (if I understand it correctly)<br><br>"At this writing, both apply and the special call syntax described in this<br>section can be used freely in Python 2.5, but it seems likely that apply<br>may go away in Python 3.0. If you wish to future-proof your code, use<br>the equivalent special call syntax, not apply."<br><br>2. Are there better ways to achieve what I want to do?<br><br><br><br><br><br><br><br></td></tr></table><br>