Why is the use of len(SEQUENCE) in condition values considered incorrect by Pylint?

Considering this code snippet: from os import walk files = [] for (dirpath, _, filenames) in walk(mydir): # More code that modifies files if len(files) == 0: # <– C1801 return None I was alarmed by Pylint with this message regarding the line with the if statement: [pylint] C1801:Do not use len(SEQUENCE) as condition value … Read more

Replace all elements of Python NumPy Array that are greater than some value

I have a 2D NumPy array and would like to replace all values in it greater than or equal to a threshold T with 255.0. To my knowledge, the most fundamental way would be: shape = arr.shape result = np.zeros(shape) for x in range(0, shape[0]): for y in range(0, shape[1]): if arr[x, y] >= T: … Read more

How to use conditional statement within child attribute of a Flutter Widget (Center Widget)

So far whenever I needed to use a conditional statement within a Widget I have done the following (Using Center and Containers as simplified dummy examples): new Center( child: condition == true ? new Container() : new Container() ) Though when I tried using an if/else statement it would lead to an Dead code warning: … Read more