What is the most pythonic way to get around the following problem? From the interactive shell:
>>> def f(a=False):
... if a:
..
In many circumstances you can just use
f(kw)
as keyword arguments don't have to be specified as keywords, if you specify all arguments before them.
Python 3 has a syntax for keyword only arguments, but that's not what they are by default.
Or, building on @zeekay's answer,
kw = 'a'
f(**{kw: True})
if you don't want to store kw as a dict, for example if you're also using it as a key in a dictionary lookup elsewhere.
Use keyword argument unpacking:
>>> kw = {'a': True}
>>> f(**kw)
<<< 'a was True'