I agree with Chris Angelico, branch1 is "the way to go". Maybe you
have to add a default at start, maybe None, and maybe raise an
exception if
res is None. Anyway, despite I'm a pain in the... arse and I usually
activate ALL the possible warnings in the world, I always disable
cyclomatic complexity
On 11/12/19 1:07 AM, Daniel Haude wrote:
Hello Neil,
thanks for the detailed answer.
Question: are there other people/factors who/which should be regarded
as more important than the linter's opinion?
Yes. Mine.
Um, see below...
(unless humor)
I was just puzzled at the linter's output (took
On Fri, 13 Dec 2019 11:34:24 +0100
Antoon Pardon wrote:
> Well if you really want to go this route, you may consider the
> following:
>
> def branch4(a, b, z):
> decision = [
> ((lambda: a > 4 and b == 0), "first"),
> ((lambda: len(z) < 2), "second"),
> ((lambda: b +
On 9/12/19 12:27, Musbur wrote:
> Hello,
>
> I have a function with a long if/elif chain that sets a couple of
> variables according to a bunch of test expressions, similar to
> function branch1() below. I never liked that approach much because it
> is clumsy and repetetive, and pylint thinks so as
Hello Neil,
thanks for the detailed answer.
Question: are there other people/factors who/which should be regarded
as more important than the linter's opinion?
Yes. Mine.
I was just puzzled at the linter's output (took me a while to figure out
what it actually meant), and that got me started
On Wed, Dec 11, 2019 at 12:26 AM Daniel Haude wrote:
> The whole thing is rather academic. Also my efficiency argument doesn't
> hold water because this routine is executed just a few times per hour. I
> like the "condition table" approach for its lower line count but I'll
> stick with if/elif bec
Hello Neil,
thanks for the detailed answer.
Question: are there other people/factors who/which should be regarded
as more important than the linter's opinion?
Yes. Mine.
I was just puzzled at the linter's output (took me a while to figure out
what it actually meant), and that got me started
Musbur wrote:
I like it! I think it's a cute exercise but it doesn't really solve any
problem. The if/elif chain can accomplish the same thing (and much more)
in the same line count for the price of being clunkier. **D
Yep! This is why I wrote half a dozen of switch implementation but never
ac
I like it! I think it's a cute exercise but it doesn't really solve any
problem. The if/elif chain can accomplish the same thing (and much more)
in the same line count for the price of being clunkier. **D
--
https://mail.python.org/mailman/listinfo/python-list
Musbur wrote:
Hello,
I have a function with a long if/elif chain that sets a couple of
variables according to a bunch of test expressions, similar to function
branch1() below. I never liked that approach much because it is clumsy
and repetetive, and pylint thinks so as well. I've come up with
I agree with you, so I'm going to ignore def branch2(a, b, z): and def
branch3(a, b, z) because they appear too contrived - and I guess that's
fair, in that you've contrived to satisfy pylint.
Question: are there other people/factors who/which should be regarded as
more important than the lint
On 2019-12-09 12:27, Musbur wrote:
> def branch1(a, b, z):
> """Inelegant, unwieldy, and pylint complains
> about too many branches"""
> if a > 4 and b == 0:
> result = "first"
> elif len(z) < 2:
> result = "second"
> elif b + a == 10:
> result =
Musbur wrote:
> Hello,
>
> I have a function with a long if/elif chain that sets a couple of
> variables according to a bunch of test expressions, similar to function
> branch1() below. I never liked that approach much because it is clumsy
> and repetetive, and pylint thinks so as well. I've come
On Mon, Dec 9, 2019 at 10:36 PM Musbur wrote:
>
> Hello,
>
> I have a function with a long if/elif chain that sets a couple of
> variables according to a bunch of test expressions, similar to function
> branch1() below. I never liked that approach much because it is clumsy
> and repetetive, and py
Hello,
I have a function with a long if/elif chain that sets a couple of
variables according to a bunch of test expressions, similar to function
branch1() below. I never liked that approach much because it is clumsy
and repetetive, and pylint thinks so as well. I've come up with two
alternati
15 matches
Mail list logo