Browse Source

added internal method _remove_note() to remove note with given id from note list

master
T. Meissner 10 years ago
parent
commit
df2b2469e1
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      python_3_oop/chapter02/notebook.py

+ 14
- 0
python_3_oop/chapter02/notebook.py View File

@ -65,6 +65,20 @@ class Notebook:
return note return note
return None return None
def _remove_note(self, id):
'''Remove note(s) with given id from note list'''
if self._find_note(id):
removed = []
index = 0
for note in self.notes:
if str(note.id) == str(id):
removed.append(self.notes.pop(index))
else:
index += 1
self._set_id()
return removed
return False
def _set_id(self): def _set_id(self):
'''set global last_id to highest id found in notebook''' '''set global last_id to highest id found in notebook'''
id = 1 id = 1


Loading…
Cancel
Save