Excluding a few pawns from the game
userquery5 at gmail.com
userquery5 at gmail.com
Mon Apr 13 07:30:31 EDT 2015
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 ?
More information about the Python-list
mailing list