On Sat, Aug 20, 2016 at 6:21 PM Lawrence D’Oliveiro <lawrenced...@gmail.com> wrote:
> > p0 = (0, 0) > > p1 = (major_dim, 0) > > colour_stops = (0, rect_1_colour), (1, complement(rect_1_colour)) > > rect_1_pattern = qah.Pattern.create_linear(p0, p1, colour_stops) > > That’s an example of what I mean about obscure structure. > To each his own. I was assuming all those variable names meant something to you. If not, then I expect it'd read well with good names. In this example, I think the abbreviations and numbers in the names could be changed to something more meaningful. > >> From <https://github.com/ldo/python_pixman/blob/master/pixman.py>, a > >> complex condition (with redundant parentheses again): > >> > >> if ( > >> not isinstance(src, Image) > >> or > >> mask != None and not isinstance(mask, Image) > >> or > >> not isinstance(dest, Image) > >> ) : > >> raise TypeError("image args must be Image objects") > >> #end if > >> > > > > No need for the separate calls to isinstance, nor the check for None. > > > > if any(not isinstance(obj, Image) for obj in [src, mask, dest]): > > ... > > Spot the bug in your version... > It'd be easier if I ran the code :-) Let's see... - the ``or`` translates to an ``any(...)`` - ``not isinstance(obj, Image)`` is repeated 3 times - ``[src, mask, dest]`` corresponds to the 3 objects - ``mask != None`` is unnecessary, unless somehow None has been registered as an instance of Image. ... can't spot it. Give me a hint? -- https://mail.python.org/mailman/listinfo/python-list