title: Inheritance inconsistency
body: <p>Having some trouble working out an inheritance issue within Python. My code is:</p>
  
  <pre><code>class Calendar(object):
      def __init__(self):
          self.norm_year = (365)
          self.leap_year = (366)
  
      def _input_validity(self, args_num, *args):
          if len(args) != args_num: 
              return False
          elif len(args) == 3:  
              args[0] = month
              args[1] = day
              args[2] = year
              if type(month) != str or type(day) != int or type(year) != int:
                  return False
          elif len(args) == 2:
              args[0] = year
              args[1] = doy
              if type(year) != int or type(doy) != int:
                  return False
  
      def _is_leap_year(self, year):
          print(str(self))
          if (type(year) != int) or (year &lt;= 0):
              return
          if (year % 4 == 0):
              if (year % 400 == 0) or (year % 100 != 0):
                  self.days_in_year = self.leap_year
                  self.months = self.months_leap
                  self.length = self.length_leap
                  return True
              else:
                  self.days_in_year = self.norm_year
                  self.months = self.months_norm
                  self.length = self.length_norm
                  return False
          else:
              self.days_in_year = self.norm_year
              self.months = self.months_norm
              self.length = self.length_norm
              return False
  
  
  
      def date_to_day_of_year(self, *args):
  
          pass
  
      def day_of_year_to_date(self, *args):
          args_num = 2
          year = args[0]
          doy = args[1]
          self._is_leap_year(year)
          if self._input_validity == False:
              return
          else:
              month = 1
              for i in self.length:
                  if doy &gt; i:
                      month += 1
                      doy -= i
                  elif doy &lt;= i:
                      day = doy
                      month = self.months[month]
                      return(str(month), day, year)
  
      def date_to_day_of_week(self, *args):
          # This can be called with three arguments such as
          #   obj.date_to_day_of_year("Messidor", 14, 1789)
          # or with two arguments such as
          #   obj.date_to_day_of_year("Midyear"s Day", 1418)
          # You need to determine which by looking at len(args).
  
          pass
  
  class Gregorian_Calendar(Calendar):
      def __init__(self):
          super().__init__()
          self.months_norm = {1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec'}
          self.months_leap = {1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec'}
          self.length_norm = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
          self.length_leap = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
          self.weekdays = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri') 
  
      def day_of_year_to_day_of_week(self, year, doy):
          pass
  
  class Shire_Calendar(Calendar):
      def __init__(self):
          super().__init__()
          self.months_norm = {1: "2 Yule", 2: "Afteryule", 3: "Solmath", 4: "Rethe", 5: "Astron", 6: "Thrimidge", 7: "Forelithe", 8: "1 Lithe", 9: "Midyear's Day", 10: "2 Lithe", 11: "Afterlithe", 12: "Wedmath", 13: "Halimath", 14: "Winterfilth", 15: "Blotmath", 16: "Foreyule", 17: "1 Yule"}
          self.months_leap = {1: "2 Yule", 2: "Afteryule", 3: "Solmath", 4: "Rethe", 5: "Astron", 6: "Thrimidge", 7: "Forelithe", 8: "1 Lithe", 9: "Midyear's Day", 10: "Overlithe", 11: "2 Lithe", 12: "Afterlithe", 13: "Wedmath", 14: "Halimath", 15: "Winterfilth", 16: "Blotmath", 17: "Foreyule", 18: "1 Yule"}
          self.length_norm = (1, 30, 30, 30, 30, 30, 30, 1, 1, 1, 1, 30, 30, 30, 30, 30, 30, 1)
          self.length_leap = (1, 30, 30, 30, 30, 30, 30, 1, 1, 1, 30, 30, 30, 30, 30, 30, 1)
          self.weekdays = ("Sterday", "Sunday", "Monday", "Trewsday", "Hensday", "Mersday", "Highday")
  
      def _is_leap_year(self, year):
          if (year % 4 == 0) and (year % 100 != 0):
              self.days_in_year = self.leap_year
              return True
          else:
              self.days_in_year = self.norm_year
              return False
  
  
      def day_of_year_to_day_of_week(self, year, doy):
          pass
  
  class Calendrier_Républicain(Calendar):
      def __init__(self):
          super().__init__()
          self.months_norm = {"Vendémiaire": 1, "Brumaire": 2, "Frimaire": 3, "Nivôse": 4, "Pluviôse": 5, "Ventôse": 6, "Germinal": 7, "Floréal": 8, "Prairial": 9, "Messidor": 10, "Thermidor": 11, "Fructidor": 12, "Jour de la vertu": 13, "Jour du génie": 14, "Jour du travail": 15, "Jour de l'opinion": 16, "Jour des récompenses": 17}
          self.months = {"Vendémiaire": 1, "Brumaire": 2, "Frimaire": 3, "Nivôse": 4, "Pluviôse": 5, "Ventôse": 6, "Germinal": 7, "Floréal": 8, "Prairial": 9, "Messidor": 10, "Thermidor": 11, "Fructidor": 12, "Jour de la vertu": 13, "Jour du génie": 14, "Jour du travail": 15, "Jour de l'opinion": 16, "Jour des récompenses": 17, "Jour de la Révolution": 18}
          self.length_norm = (30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 1, 1, 1, 1, 1)
          self.length_leap = (30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 1, 1, 1, 1, 1, 1)
          self.weekdays = ("primidi", "duodi", "tridi", "quartidi", "quintidi", "sextidi", "septidi", "octidi", "nonidi", "décadi")
  
      def day_of_year_to_day_of_week(self, year, doy):
          pass
  
  
  
  
  # Basic Testing
  cal = Calendar()
  gcal = Gregorian_Calendar()
  scal = Shire_Calendar()
  rcal = Calendrier_Républicain()
  
  print(scal.day_of_year_to_date(1400, 2))
  print(scal.day_of_year_to_date(1400, 184))
  print(scal.day_of_year_to_date(1404, 184))
  </code></pre>
  
  <p>I'm trying to create a superclass that will be able to handle multiple different types of calendars and perform operations on them. The example I'm showing is a function within the superclass that converts the day of the year to the date by using information from the <code>Shire_Calendar</code> subclass.</p>
  
  <p>In order to handle leap years, I want to assign two different variables for months and days in a month (<code>months_norm</code>, <code>months_leap</code>, <code>length_norm</code>, <code>length_leap</code>), that are specified within the calendar subclass, in this case <code>Shire_Calendar</code>, and then the <code>_is_leap_year</code> function within the superclass reads the year input, determines if it is a leap year, and assigns the appropriate month tuple and days in a month tuple to the general variables <code>months</code> and <code>length</code>. From there, the general variables are passed on to the function <code>day_of_year_to_date</code>.</p>
  
  <p>The problem is that when I try to pass these variables, it spits out a name error that <code>Shire_Calendar</code> has no attribute <code>length</code>. It's as if within the <code>_is_leap_year</code> function, <code>months</code> and <code>length</code> are not being assigned, or being assigned to the wrong place.</p>