title: Python - create inherited class attribute under condition
body: <pre><code>class WineComponents(object):
  
      def __init__(self, aroma, body, acidity, flavor, color):
          self.aroma = aroma
          self.body = body
          self.acidity = acidity
          self.flavor = flavor
          self.color = color
  </code></pre>
  
  <p>which can be instantiated like so:</p>
  
  <pre><code>wine = Color(aroma='80%', body='30%', acidity='35%', flavor='90%', color='Red')
  </code></pre>
  
  <p>then I want to be able to create specific classes that will inherit <code>WineComponents()</code>:</p>
  
  <pre><code>class Color(WineComponents): 
  
        def receipe(self):
            pass
  </code></pre>
  
  <p>and also to have its own attributes, under certain conditions, like so:</p>
  
  <pre><code>class Color(WineComponents):
  
       if self.color == 'Red':
          region  = 'France'
          type = 'Bordeaux'
  
       def receipe(self):
           pass
  </code></pre>
  
  <p>calling the attribute with:</p>
  
  <pre><code>print wine.region
  </code></pre>
  
  <p>but this does not work: </p>
  
  <pre><code> if self.color == 'Red':
  NameError: name 'self' is not defined
  </code></pre>
  
  <p>is there a workaround this?</p>