Re: Two-Dimensional Expression Layout

2016-08-21 Thread Lawrence D’Oliveiro
On Sunday, August 21, 2016 at 7:19:49 PM UTC+12, Michael Selik wrote: > > On Sun, Aug 21, 2016, 3:06 AM Lawrence D’Oliveiro wrote: > >> On Sunday, August 21, 2016 at 6:49:19 PM UTC+12, Michael Selik wrote: >> >>> Indeed it is, not sure why. >> >> Moral: It helps to understand the code you’re

Re: Two-Dimensional Expression Layout

2016-08-21 Thread Michael Selik
On Sun, Aug 21, 2016, 3:06 AM Lawrence D’Oliveiro wrote: > On Sunday, August 21, 2016 at 6:49:19 PM UTC+12, Michael Selik wrote: > > > Indeed it is, not sure why. > > Moral: It helps to understand the code you’re criticizing, before you > start criticizing, not after. >

Re: Two-Dimensional Expression Layout

2016-08-21 Thread Lawrence D’Oliveiro
On Sunday, August 21, 2016 at 6:49:19 PM UTC+12, Michael Selik wrote: > Indeed it is, not sure why. Moral: It helps to understand the code you’re criticizing, before you start criticizing, not after. -- https://mail.python.org/mailman/listinfo/python-list

Re: Two-Dimensional Expression Layout

2016-08-21 Thread Michael Selik
On Sun, Aug 21, 2016 at 12:31 AM Lawrence D’Oliveiro wrote: > On Sunday, August 21, 2016 at 12:44:21 PM UTC+12, Michael Selik wrote: > > > > On Sat, Aug 20, 2016 at 6:21 PM Lawrence D’Oliveiro wrote: > > > >>> if any(not isinstance(obj, Image) for obj in [src, mask,

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Lawrence D’Oliveiro
On Sunday, August 21, 2016 at 12:44:21 PM UTC+12, Michael Selik wrote: > > On Sat, Aug 20, 2016 at 6:21 PM Lawrence D’Oliveiro wrote: > >>> if any(not isinstance(obj, Image) for obj in [src, mask, dest]): >>> ... >> >> Spot the bug in your version... > > - ``mask != None`` is

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Steve D'Aprano
Oh wait! The penny drops! On Sun, 21 Aug 2016 10:43 am, Michael Selik wrote: > On Sat, Aug 20, 2016 at 6:21 PM Lawrence D’Oliveiro >> >> if ( >> >> not isinstance(src, Image) >> >> or >> >> mask != None and not isinstance(mask, Image) >> >> or >> >>

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Steve D'Aprano
On Sun, 21 Aug 2016 10:43 am, Michael Selik wrote: > On Sat, Aug 20, 2016 at 6:21 PM Lawrence D’Oliveiro > wrote: > >> > p0 = (0, 0) >> > p1 = (major_dim, 0) >> > colour_stops = (0, rect_1_colour), (1, complement(rect_1_colour)) >> > rect_1_pattern =

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Steve D'Aprano
On Sun, 21 Aug 2016 09:44 am, Lawrence D’Oliveiro wrote: > Why do you think I put in those “#end” lines? Do you really want us to answer that? I don't think you will like the answer. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Steve D'Aprano
On Sun, 21 Aug 2016 08:22 am, Lawrence D’Oliveiro wrote: > Another example, from : the sequence of > values is laid out to allow easy additions/modifications in future. When replying, I normally try to trim unnecessary code snippets down to the critical line or

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Michael Selik
On Sat, Aug 20, 2016 at 8:43 PM Michael Selik wrote: > 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)) >>

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Michael Selik
On Sat, Aug 20, 2016 at 6:21 PM Lawrence D’Oliveiro 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

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Lawrence D’Oliveiro
On Sunday, August 21, 2016 at 10:35:08 AM UTC+12, c...@zip.com.au wrote: > Aye, but beware that the expression is actually correct for the > indentation. > Compare: > >assert \ >( >len(self.points) == 0 >and >not self.points[0].off >or

Re: Two-Dimensional Expression Layout

2016-08-20 Thread cs
On 19Aug2016 16:11, Lawrence D’Oliveiro wrote: On Saturday, August 20, 2016 at 10:38:34 AM UTC+12, Chris Angelico wrote: On Sat, Aug 20, 2016 at 8:31 AM, Lawrence D’Oliveiro wrote: There is no short-cut evaluation when constructing tuples and lists. I'm not sure how

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Lawrence D’Oliveiro
On Friday, August 19, 2016 at 8:56:31 PM UTC+12, I wrote: > It is handy to be able to keep complex expressions together sometimes, when > breaking them up would simply obscure their structure. To avoid lines > getting long, why not take advantage of the two available screen/page > dimensions to

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Lawrence D’Oliveiro
On Sunday, August 21, 2016 at 12:48:46 AM UTC+12, Michael Selik wrote: > > On Fri, Aug 19, 2016 at 5:01 AM Lawrence D’Oliveiro wrote: > >> It is handy to be able to keep complex expressions together sometimes, >> when breaking them up would simply obscure their structure. > > p0 = (0, 0) >

Re: Two-Dimensional Expression Layout

2016-08-20 Thread Michael Selik
On Fri, Aug 19, 2016 at 5:01 AM Lawrence D’Oliveiro wrote: > It is handy to be able to keep complex expressions together sometimes, > when breaking them up would simply obscure their structure. To avoid lines > getting long, why not take advantage of the two available

Re: Two-Dimensional Expression Layout

2016-08-19 Thread Lawrence D’Oliveiro
On Friday, August 19, 2016 at 8:56:31 PM UTC+12, I wrote: > To avoid lines getting long, why not take advantage of the two available > screen/page dimensions to make [expression] structure clearer? Another aspect of this has to do with line length. I regularly set my editor window width to

Re: Two-Dimensional Expression Layout

2016-08-19 Thread Lawrence D’Oliveiro
On Saturday, August 20, 2016 at 10:38:34 AM UTC+12, Chris Angelico wrote: > > On Sat, Aug 20, 2016 at 8:31 AM, Lawrence D’Oliveiro wrote: >> >> 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

Re: Two-Dimensional Expression Layout

2016-08-19 Thread codewizard
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 > 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,

Re: Two-Dimensional Expression Layout

2016-08-19 Thread Chris Angelico
On Sat, Aug 20, 2016 at 8:31 AM, Lawrence D’Oliveiro 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

Re: Two-Dimensional Expression Layout

2016-08-19 Thread Lawrence D’Oliveiro
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),

Re: Two-Dimensional Expression Layout

2016-08-19 Thread codewizard
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

Re: Two-Dimensional Expression Layout

2016-08-19 Thread Lawrence D’Oliveiro
On Saturday, August 20, 2016 at 5:53:22 AM UTC+12, Terry Reedy wrote: > > To me, putting parens and '+' and 'or' on separate lines emphasizes them > too much and makes the layout more, not less, cluttered. So having whitespace around these symbols makes things look *more* cluttered, while

Re: Two-Dimensional Expression Layout

2016-08-19 Thread Lawrence D’Oliveiro
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") >

Re: Two-Dimensional Expression Layout

2016-08-19 Thread codewizard
For some special cases, I prefer the versions below. On Friday, August 19, 2016 at 4:56:31 AM UTC-4, Lawrence D’Oliveiro wrote: > [snip] > > Computing a variable value (using redundant parentheses to avoid > backslash-continuations): > > dest_rect = \ > ( > draw_bounds

Re: Two-Dimensional Expression Layout

2016-08-19 Thread Terry Reedy
On 8/19/2016 4:56 AM, Lawrence D’Oliveiro wrote: It is handy to be able to keep complex expressions together sometimes, when breaking them up would simply obscure their structure. To avoid lines getting long, why not take advantage of the two available screen/page dimensions to make their

Two-Dimensional Expression Layout

2016-08-19 Thread Lawrence D’Oliveiro
It is handy to be able to keep complex expressions together sometimes, when breaking them up would simply obscure their structure. To avoid lines getting long, why not take advantage of the two available screen/page dimensions to make their structure clearer? As a bonus, spacing out parentheses