Two-Dimensional Expression Layout

codewizard at gmail.com codewizard at gmail.com
Fri Aug 19 17:55:52 EDT 2016


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. More reasonable uses would be like <https://developer.blender.org/diffusion/BAC/browse/master/io_export_paper_model.py>:
> 
>     if any(uvface.flipped for uvface in island.faces):
> 
>     if any(island.bounding_box.x > cage_size.x or island.bounding_box.y > cage_size.y for island in self.islands):

You showed examples where you think it would be a good idea to use any/all.
But you didn't say why my examples "may not be such a good idea".
Would you care to elaborate?



More information about the Python-list mailing list