Skip to main content
added "lang-python" tags to help highlight.js correctly format code
Source Link
Edward
  • 67.3k
  • 4
  • 120
  • 284

Minor (and Python), but I personally find this to be a little confusing:

if (value := board[row][col]) == empty_value: continue r = f'0{row}{value}' c = f'1{col}{value}' b = f'2{row // b_size}{col // b_size}{value}' 
if (value := board[row][col]) == empty_value: continue r = f'0{row}{value}' c = f'1{col}{value}' b = f'2{row // b_size}{col // b_size}{value}' 

You're using an assignment expression to assign a value, but then only use it in the false case. I think this would be much cleaner by using a plain-old assignment statement:

value = board[row][col] if value == empty_value: continue r = f'0{row}{value}' c = f'1{col}{value}' b = f'2{row // b_size}{col // b_size}{value}' 
value = board[row][col] if value == empty_value: continue r = f'0{row}{value}' c = f'1{col}{value}' b = f'2{row // b_size}{col // b_size}{value}' 

I don't think the line saved is worth burying the creation of a variable.

Minor (and Python), but I personally find this to be a little confusing:

if (value := board[row][col]) == empty_value: continue r = f'0{row}{value}' c = f'1{col}{value}' b = f'2{row // b_size}{col // b_size}{value}' 

You're using an assignment expression to assign a value, but then only use it in the false case. I think this would be much cleaner by using a plain-old assignment statement:

value = board[row][col] if value == empty_value: continue r = f'0{row}{value}' c = f'1{col}{value}' b = f'2{row // b_size}{col // b_size}{value}' 

I don't think the line saved is worth burying the creation of a variable.

Minor (and Python), but I personally find this to be a little confusing:

if (value := board[row][col]) == empty_value: continue r = f'0{row}{value}' c = f'1{col}{value}' b = f'2{row // b_size}{col // b_size}{value}' 

You're using an assignment expression to assign a value, but then only use it in the false case. I think this would be much cleaner by using a plain-old assignment statement:

value = board[row][col] if value == empty_value: continue r = f'0{row}{value}' c = f'1{col}{value}' b = f'2{row // b_size}{col // b_size}{value}' 

I don't think the line saved is worth burying the creation of a variable.

Source Link
Carcigenicate
  • 16.6k
  • 3
  • 37
  • 82

Minor (and Python), but I personally find this to be a little confusing:

if (value := board[row][col]) == empty_value: continue r = f'0{row}{value}' c = f'1{col}{value}' b = f'2{row // b_size}{col // b_size}{value}' 

You're using an assignment expression to assign a value, but then only use it in the false case. I think this would be much cleaner by using a plain-old assignment statement:

value = board[row][col] if value == empty_value: continue r = f'0{row}{value}' c = f'1{col}{value}' b = f'2{row // b_size}{col // b_size}{value}' 

I don't think the line saved is worth burying the creation of a variable.