Two-Dimensional Expression Layout
Chris Angelico
rosuav at gmail.com
Fri Aug 19 18:38:18 EDT 2016
On Sat, Aug 20, 2016 at 8:31 AM, Lawrence D’Oliveiro
<lawrencedo99 at gmail.com> wrote:
> On Saturday, August 20, 2016 at 9:56:05 AM UTC+12, codew... at gmail.com wrote:
>>
>> On Friday, August 19, 2016 at 5:30:22 PM UTC-4, Lawrence D’Oliveiro wrote:
>>
>>> On Saturday, August 20, 2016 at 7:52:09 AM UTC+12, codew... at gmail.com
>>> wrote:
>>>> if any([
>>>> not isinstance(src, Image),
>>>> mask != None and not isinstance(mask, Image),
>>>> not isinstance(dest, Image),
>>>> ]):
>>>> raise TypeError("image args must be Image objects")
>>>>
>>>> Or equivalently:
>>>>
>>>> if not all([
>>>> isinstance(src, Image),
>>>> mask is None or isinstance(mask, Image),
>>>> isinstance(dest, Image),
>>>> ]):
>>>> raise TypeError("image args must be Image objects")
>>>
>>> Using “all” or “any” in this sort of situation may not be such a good
>>> idea.
>>
>> Would you care to elaborate?
>
> There is no short-cut evaluation when constructing tuples and lists.
I'm not sure how that would make difference in these examples. The
three parts are independent - the one place where short-circuiting is
important is indeed short-circuited.
ChrisA
More information about the Python-list
mailing list