title: In Python 2.7, how can I return calculations without defining variables in the constructor?
body: <p>My question is about getter/setter-type functionality in Python. I have a class, Week_Of_Meetings, that takes a blob of data from my Google Calendar and does some calculations on it. </p>
  
  <pre><code>wom = Week_Of_Meetings(google_meetings_blob)
  </code></pre>
  
  <p>I want to be able to return something like:</p>
  
  <pre><code>wom.total_seconds_in_meetings() # returns 36000
  </code></pre>
  
  <p>But, I'm not understanding how the getters/setters-type @property decorator can help me do this. In Java, I would use member variables, but you don't interact with them the same way in Python. How can I return calculations without starting with them in the constructor?</p>
  
  <pre><code>Class Week_Of_Meetings:
  
      def __init__(self, google_meetings_blob) 
          self.google_meetings_blob = google_meetings_blob
  
      def get_meetings_list(self, google_meetings_blob):
          meetings_list = []
          for meeting_id, meeting in enumerate(self.google_meetings_blob, 1):
              summary = self._get_summary(meeting)
              start = parse(meeting['start'].get('dateTime', meeting['start'].get('date')))
              end = parse(meeting['end'].get('dateTime', meeting['end'].get('date')))
              duration = end - start
              num_attendees = self._get_num_attendees(meeting.get('attendees'))
  
              m = Meeting(meeting_id, summary, start, end, duration, num_attendees)
              meetings_list.append(m)
          return meetings_list
  
  
      def _get_summary(self, meeting):
          summary = meeting.get('summary', 'No summary given')
          return summary
  
  
      def _get_num_attendees(self, num_attendees):
          if num_attendees == None:
              num_attendees = 1 # if invited only self to meeting
          else:
              num_attendees = len(num_attendees)
          return num_attendees
  </code></pre>
  
  <p>When I add self.total_seconds_in_meetings to the </p>
  
  <pre><code>__init__() 
  </code></pre>
  
  <p>I get "NameError: global name 'total_seconds_in_meetings' is not defined." That makes sense. It hasn't been defined. But I can't define it when it's supposed to be the result of calculations done on the google_meetings_blob. So, I'm confused where the 'total_seconds_in_meetings' goes in the class.</p>
  
  <p>Thank you for the help!</p>