setup(**config); rookie

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon May 28 19:50:57 EDT 2012


On 2012年5月28日 06:20:06 -0700, cate wrote:
> setup(**config)
>> What is the construct **?

It expands the dict "config" into keyword arguments. A single * expands 
to positional arguments.
A simple example:
args = [1, 2, 3]
kwargs = {'x': 4, 'y': 5}
somefunc(*args, **kwargs)
is expanded to 
somefunc(1, 2, 3, x=4, y=5)
-- 
Steven


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /