[Tutor] function return values

Phil phillor9 at gmail.com
Fri Dec 3 00:57:34 EST 2021


> Suggest creating another function which returns a boolean. Then use that
> to initiate (or not) the scan. Perhaps along these lines:
>
> if is_pair_in_row( item, row, column_list ):
>      ( item,
>        row,
>        column_list,
>        ) = self.boxPairsInSameRow(candidate_pairs, x , y)
>
That was exactly my first thought dn until I realised that I needed the 
function to return the item, row and a list of the columns where the 
pair was found.

Asking if a pair is on row 0 column 0 and if not then asking if the pair 
is on row 0 col 1 etc would not reduce the complexity of the calling 
function (unless I've misunderstood your reply, which is not unlikely) 
which is the aim of the current exercise.


> NBBB Python's PEP-008 (a guide (maybe) and not a "standard") for naming
> identifiers and functions:
>
> box_pairs_in_same_row()

This was originally isBoxPairsInSameRow, I just dropped the "is" (Pairs 
should have been Pair) since I'm not returning a boolean value. Coming 
up with descriptive names  for functions and variable is not one of my 
strong points and I must check if camel text is acceptable in Python.

-- 

Regards,
Phil



More information about the Tutor mailing list