On Friday, August 19, 2016 at 6:38:34 PM UTC-4, Chris Angelico wrote: > On Sat, Aug 20, 2016 at 8:31 AM, Lawrence D’Oliveiro > <lawrenced...@gmail.com> wrote: > > On Saturday, August 20, 2016 at 9:56:05 AM UTC+12, codew...@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...@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
Agreed. Besides, just because this technique has limitations, it's still useful for me to improve readability. -- https://mail.python.org/mailman/listinfo/python-list