title: Is this MVC in Python?
body: <p>I am new to stackoverflow, so hello!! This is my very first question.</p>
  
  <p>My code is written in <strong>python</strong> and its a console application. Its a project from the book "Object Orientated Programming Design with Python 3" which I am trying to customise and change so that it is MVC so I can progress with my fundamentals. My program currently works perfectly in the console and presents a menu that when I type in a number corresponding to the menu it lets me perform a notebook task.</p>
  
  <p>My question is a conceptual one about Model View Controller.</p>
  
  <p>I have split my program into three different modules. </p>
  
  <ol>
  <li>Notebook (which has my Notebook and Note classes)</li>
  <li>Controller (which has my view logic and has my run method)</li>
  <li>View (which just has my display menu function)
  (I have not included a model as I have no data/database hooked up)</li>
  </ol>
  
  <p>So my question are!</p>
  
  <ol>
  <li>Is this MVC?</li>
  <li>If not how would I structure this to be MVC?</li>
  <li>Would someone please help me understand by refactoring my code (making it mvc so I can understand how its properly implemented?</li>
  <li>How would I integrate the <strong>model</strong> part of MVC (if I wanted to store my memo notes in a database)?  </li>
  </ol>
  
  <p>My different modules code listed below.</p>
  
  <h1>NOTEBOOK MODULE CODE</h1>
  
  <pre><code>import datetime
  
  # store the next available id for all new notes
  last_id = 0
  
  
  class Note:
      """Represents a note in the notebook. Match against
      a string in searches and stores tags for each note.
      """
  
      def __init__(self, memo, tags=''):
          """Initialize a note with a memo and optional
          space - separated tags. Automatically set the note's
          creation date and a unique id."""
          self.memo = memo
          self.tags = tags
          self.creation_date = datetime.date.today()
          global last_id
          last_id += 1
          self.id = last_id
  
      def match(self, filter_notes):
          """
          :param filter_notes: Determine if this note matches the filter
          string.
          :return: Returns True if it matches, False otherwise.
          """
          return filter_notes in self.memo or filter_notes in self.tags
  
  
  class Notebook:
      """ Represents a collection of notes that can be tagged,
      modified, and searched
      """
  
      def __init__(self):
          """
          Initialize a notebook with an empty list
          :return: NOTHING! Just initializes an empty list.
          """
          self.notes = []
  
      def new_note(self, memo, tags=''):
          """
          Create a new note and add it to the list.
          :param memo: input string memo notes
          :param tags: input tag for searching
          :return: Create a new note and adds it to the
          self.notes[] list.
          """
          self.notes.append(Note(memo, tags))
  
      def _find_note(self, note_id):
          """
          Locate the note with a given id. (_FIND_NOTE FUNCTION FOR
          INTERNAL USE ONLY)
          :param note_id: Passed into an if statement for matching
          :return: A matched note if found in the list of notes
          """
          for note in self.notes:
              if str(note_id) == str(note_id):
                  return note
              return None
  
      def modify_memo(self, note_id, memo):
          """Finds the note with the given id and changes its
          memo to the new given value.
          """
          note = self._find_note(note_id)
          if note:
              note.memo = memo
              return True
          return False
  
      def modify_tag(self, note_id, tags):
          """Finds a note with the given id and changes its
          tag to the new given value."""
          tag = self._find_note(note_id)
          if tag:
              tag.tags = tags
              return True
          return False
  
      def search(self, filter_notes):
          """
          Find all notes that match the given filter string.
          :param filter_notes: Filter string passed
          :return: A list of of notes that match the filter string
          """
          return [note for note in self.notes if
                  note.match(filter_notes)]
  </code></pre>
  
  <h1>CONTROLLER MODULE CODE</h1>
  
  <pre><code>from notebook import Notebook, Note
  from view import View
  
  
  class Controller:
      """Display a menu and respond to choices when run."""
  
      def __init__(self):
          self.notebook = Notebook()
          self.view = View()
          self.choices = {
              "1": self.show_notes,
              "2": self.search_notes,
              "3": self.add_notes,
              "4": self.modify_notes,
              "5": self.quit
          }
  
      def run(self):
          """Display the menu and respond to choices."""
          while True:
              self.view.display_menu()
              choices = input("Enter an option: ")
              action = self.choices.get(choices)
              if action:
                  action()
              else:
                  print("{0} is not a valid choice".format(choices))
  
      def show_notes(self, notes=None):
          if not notes:
              notes = self.notebook.notes
              for note in notes:
                  print("{0}: {1}\n{2}".format(
                      note.id, note.tags, note.memo))
  
      def search_notes(self):
          filter_notes = input("Search for: ")
          notes = self.notebook.search(filter_notes)
          self.show_notes(notes)
  
      def add_notes(self):
          memo = input('Enter a memo: ')
          self.notebook.new_note(memo)
          print("Your note has been added.")
  
      def modify_notes(self):
          id = input("Enter a note id: ")
          memo = input("Enter a memo: ")
          tags = input("Enter tags: ")
          if memo:
              self.notebook.modify_memo(id, memo)
          if tags:
              self.notebook.modify_tag(id, tags)
  
      def quit(self):
          print("Thanks for using your notebook today!")
  
  if __name__ == "__main__":
      Controller().run()
  </code></pre>
  
  <h1>VIEW MODULE CODE</h1>
  
  <pre><code>class View:
  
      def display_menu(self):
          print(""" Notebook Menu
  
  1. Show all Notes
  2. Search all Notes
  3. Add Notes
  4. Modify Notes
  5. Quit
  """)
  </code></pre>
  
  <p>Any help, advice and feedback would be greatly appreciated (if I need to clarify further or have not provided enough detail or even to much detail let me know, and I will address it). Also I am saying thanks in advance for anytime spent helping me out! :)</p>