title: Accessing outer class from inner python
body: <p>Consider this piece of code:</p>
  
  <pre><code>class Page(object):
    def __init__(self, name, title):
      self.name   = name
      self.title  = title
      self.selected = False
    def select(self):                 &lt;-- How can I make this method work?
      for Page in Pages:
          Page.selected = False
      self.selected = True
  class Website(object):
    def __init__(self):
      self.index    = Page("index", "Home")
      self.settings = Page("settings", "Settings")
      self.users    = Page("users", "Users")
      self.logs     = Page("logs", "Logs")
      self.faq      = Page("faq", "FAQ")
    def __iter__(self):
      return iter([self.index, self.settings, self.users, self.logs, self.faq])
  Pages = Website()
  </code></pre>
  
  <p>What I am trying to do seems sort of illegal. Nevertheless, I am sure there is a way to do it. It seems like I might have to rewrite <strong>get</strong> method somewhere. Thank you very much for your help!</p>
  
  <p>Here is the way I was intending to use those classes using Bottlepy:</p>
  
  <p>Setting Pages:</p>
  
  <pre><code>@route('/')
  @route('/&lt;selectedPage&gt;')
  @route('/&lt;selectedPage&gt;/')
  def dynamic_routing(selectedPage='index'):
    for Page in Pages:
       if selectedPage == Page.name:
              Page.select()
    return template('default')
  </code></pre>
  
  <p>Retrieving Page info (inside Bottlepy template):</p>
  
  <pre><code>%for Page in Pages:
      %if Page.selected:
          &lt;title&gt;{{Page.title}}&lt;/title&gt;                
      %else:
          &lt;title&gt;Page Not Found&lt;/title&gt;
      %end
  %end
  </code></pre>
  
  <p>I edited code to a working version now. Thanks everyone for such a fast input!!! You guys rock! Still probably not the best approach but I can not think of another way to solve it at the moment.</p>