some recommendations for your code
as I understand you could already know this things
loops
You could use iterating instead of range(len(obj))
expression.
|
for i in range(len(lines)): |
|
thisChunk.append(lines[i]) |
|
count += 1 |
|
if count == lines_high: |
|
count = 0 |
|
chunks.append(thisChunk) |
|
thisChunk = [] |
Like this:
for line in lines:
thisChunk.append(line)
count += 1
if count == lines_high:
count = 0
chunks.append(thisChunk)
thisChunk = []
And it looks more readable
If you need i
in this situation I think it will be better to use enumerate
function:
for i, _ in enumerate(lines):
thisChunk.append(lines[i])
count += 1
if count == lines_high:
count = 0
chunks.append(thisChunk)
thisChunk = []
It is just an example. I think the code above is bad because you could just iterate object.
As you code in Python it is not necessary write brackets near the expression:
|
while (total_moved_abs < abs_dx): |
while total_moved_abs < abs_dx:
functions
If you are in situation when every condition must have True
value you can use all
function or
any
if at least one value have True
.
|
return x1 < x2 + w2 and \ |
|
x1 + w1 > x2 and \ |
|
y1 < y2 + h2 and \ |
|
y1 + h1 > y2 |
return all(x1 < x2 + w2,
x1 + w1 > x2,
y1 < y2 + h2,
y1 + h1 > y2)
sorry for my English