Groups | Search | Server Info | Login | Register
Groups > comp.programming > #16784
| From | Lawrence D'Oliveiro <ldo@nz.invalid> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: “Booleans Considered Harmful” |
| Date | 2025-05-23 22:58 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <100quit$a8a5$2@dont-email.me> (permalink) |
| References | <100mhh5$3b9hp$3@dont-email.me> <160socn9anwy0.10vkreil3u9av.dlg@40tude.net> |
On Fri, 23 May 2025 16:56:55 +0700, JJ wrote:
> I don't think he's a versatile programmer, if he expect every code to be
> self explanatory at any point.
His idea of “self-explanatory” seems to be the limiting factor. No
doubt he would throw up his hands in horror at any mention of De
Morgan’s theorems, for example.
Compare the boolean condition here:
def colour_samples(self, to_rgb, from_rgb) :
if (
not isinstance(to_rgb, (list, tuple))
or
not isinstance(from_rgb, (list, tuple))
or
len(to_rgb) != len(from_rgb)
or
len(to_rgb) % 3 != 0
or
len(to_rgb) == 0
) :
raise TypeError("args must be arrays of equal nonzero size, being a multiple of 3")
#end if
self.nr_colour_samples = len(to_rgb) // 3
self._write_stmt("ColorSamples", [conv_num_array.conv(self._parent, to_rgb), conv_num_array.conv(self._parent, from_rgb)], {})
return \
self
#end colour_samples
Would you prefer it written this way?
def colour_samples(self, to_rgb, from_rgb) :
if (
isinstance(to_rgb, (list, tuple))
and
isinstance(from_rgb, (list, tuple))
and
len(to_rgb) == len(from_rgb)
and
len(to_rgb) % 3 == 0
and
len(to_rgb) != 0
) :
self.nr_colour_samples = len(to_rgb) // 3
self._write_stmt("ColorSamples", [conv_num_array.conv(self._parent, to_rgb), conv_num_array.conv(self._parent, from_rgb)], {})
else :
raise TypeError("args must be arrays of equal nonzero size, being a multiple of 3")
#end if
return \
self
#end colour_samples
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar
“Booleans Considered Harmful” Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-05-22 06:51 +0000
Re: “Booleans Considered Harmful” Julio Di Egidio <julio@diegidio.name> - 2025-05-22 11:14 +0200
Re: “Booleans Considered Harmful” Julio Di Egidio <julio@diegidio.name> - 2025-05-22 12:04 +0200
Re: “Booleans Considered Harmful” Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-05-22 22:33 +0000
Re: “Booleans Considered Harmful” Julio Di Egidio <julio@diegidio.name> - 2025-05-23 07:04 +0200
Re: “Booleans Considered Harmful” David Brown <david.brown@hesbynett.no> - 2025-05-22 13:51 +0200
Re: “Booleans Considered Harmful” Julio Di Egidio <julio@diegidio.name> - 2025-05-22 14:43 +0200
Re: “Booleans Considered Harmful” Julio Di Egidio <julio@diegidio.name> - 2025-05-22 14:57 +0200
Re: “Booleans Considered Harmful” Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-05-22 12:27 -0700
Re: “Booleans Considered Harmful” JJ <jj4public@outlook.com> - 2025-05-23 16:56 +0700
Re: “Booleans Considered Harmful” Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-05-23 22:58 +0000
Re: “Booleans Considered Harmful” Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-05-23 22:48 +0000
Re: “Booleans Considered Harmful” c186282 <c186282@nnada.net> - 2025-06-18 02:40 -0400
csiph-web