List comprehension for testing **params

Joshua Landau joshua.landau.ws at gmail.com
Mon Nov 12 14:25:17 CET 2012


On 12 November 2012 13:23, Joshua Landau <joshua.landau.ws at gmail.com> wrote:

> Just a few tricks you may have missed:
>
>  On 12 November 2012 10:48, Ulrich Eckhardt <
> ulrich.eckhardt at dominolaser.com> wrote:
>
>> Am 11.11.2012 23:24, schrieb Cantabile:
>
>     if required.intersection(params.**keys()) != required:
>>
>
> if required.issubset(params):
>

*Ahem*: if *not* required.issubset(params):


>
>
>>        missing = required - set(params.keys())
>>
>
> missing = required.difference(params)
>
>
>>        raise Exception("missing arguments {}".format(
>>                        ', '.join(missing)))
>
>
>
> (untested)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121112/7cd00f52/attachment-0001.html>


More information about the Python-list mailing list