I finally found a way to do this.I created a method in class A (Department)
like this
def deleteEmployee(self, employee):
employee_to_delete = employee.key
if employee_to_delete in self.employees:
idx=self.employees.index(employee_to_delete)
del self.employees[idx]
self.put()
and then from the Handler(could also be another method somewhere) where i am deleting the key from the list,i did something like this
class DeleteEmployeeHandler(webapp2.RequestHandler):
def post(self):
employee_name = self.request.get('employee_name')
employee=Employee.get_by_id(employee_name)
emp_dept=employee.department
dept=Department.get_or_insert(emp_dept)
dept.deleteEmployee(employee) #delete employee key from list
employee.key.delete() #then finally delete employee entity