Excluding a few pawns from the game
Dave Angel
davea at davea.name
Mon Apr 13 08:15:17 EDT 2015
On 04/13/2015 07:30 AM, userquery5 at gmail.com wrote:
> I am writing a function in python, where the function excludes a list of pawns from the game. The condition for excluding the pawns is whether the pawn is listed in the database DBPawnBoardChart. Here is my code:
>
> def _bring_bigchart_pawns(self, removed_list=set(), playing_amount=0):
> chart_pawns = DBPawnBoardChart.query().fetch()
> chart_pawns_filtered = []
> for bigchart_pawn in chart_pawns:
> pawn_number = bigchart_pawn.key.number()
> db = DBPawn.bring_by_number(pawn_number)
> if db is None:
> chart_pawn.key.delete()
> logging.error('DBPawnBoardChart entry is none for chart_pawn = %s' % pawn_number)
> if pawn_number in chart_pawns:
> chart_pawn.add(pawn_number)
> else:
> exclude_pawn_numbers = ['1,2,3']
> chart_pawns_filtered.append(chart_pawn)
> pawn_numbers = [x.key.number() for x in chart_pawns_filtered]
> return pawn_numbers, chart_pawns, exclude_pawn_numbers
>
> If the pawn is listed in DBPawnBoardChart it should be added to the game or else it should be excluded. I am unable to exclude the pawns,the DBPawnBoardChart contains Boardnumber and Pawnnumber. What necessary changes should I make ?
>
Looks to me like an indentation error. About 9 of those lines probably
need to be included in the for loop, so they have to be indented further in.
--
DaveA
More information about the Python-list
mailing list