title: Python - Use class or modules when you share some data dictionary across functions
body: <p>I'm suffering of <i> too many classes syndrome</i>, struggling to identify when is properly justified use a class in python.</p>
  
  <p>I have a function which its code escalated very quickly up to around 350 lines of code and in order to have comprehensive tests and more control over the code itself, refactoring pop up into my mind. </p>
  
  <p>Just after starting refactoring, I've split the code into several small functions but they are dependent of some variables and data dictionary that now must be passed as parameters.</p>
  
  <p>The original code looks like the following : </p>
  
  <pre><code>def process_rooms_json(path, country, json_dict):
  
      # Create Dict from json_dict 
      rooms_dict = dict()
      # Create another 
      employee_dict = dict()
  
      list_meetings = []
  
      # Iterate over the folder
      for file_name in [f for f in os.listdir(path)]:
  
          with open(folder + '/' + file_name, 'r', encoding='utf-8') as f:
  
              # Extract contect
              set_apps = function_which_creates_list(f.read())
  
                  for app in set_apps:
                      # Block of code which extracts certain info
                      # Block of code which build  a dictionary
                      list_meetings.append(result_of_big_code)
  
      return list_meetings
  </code></pre>
  
  <p>and now it's something like </p>
  
  <pre><code>def process_rooms_json(path, country, json_dict):
  
      # Create Dict from json_dict 
      rooms_dict = dict()
  
      # Create another 
      employee_dict = dict()
  
      list_meetings = []
  
      # Iterate over the folder
      for file_name in [f for f in os.listdir(path)]:
  
          with open(folder + '/' + file_name, 'r', encoding='utf-8') as f:
  
              # Extract content
              set_apps = function_which_creates_list(f.read())
  
                  for app in set_apps:
  
  
                      # Block of code which extracts certain info
  
                      new_dict = do_a_lot_of_stuff_1(employee_dict, country, filename)
                      new_dict2 = do_a_lot_of_stuff_2(new_dict['some_list'])
                      new_dict3 = do_a_lot_of_stuff_3(employee_dict, country)
                      new_dict4 = do_a_lot_of_stuff_4(rooms_dict, country, file_name)
                      new_dict5 = do_a_lot_of_stuff_5(rooms_dict, employee_dict)
  
                      # Create result
                      return_dict = dict()
                      return_dict['some_filed'] = new_dict['another field']
                      ...
  
                      list_meetings.append(return_didct)
      return list_meetings
  </code></pre>
  
  <p>I'm really tempted to create a class, let say RoomProcessor, and encapsulate in self the path, json dictionaries and country code. I don't know in which extent this is correct or if I'm totally loosing the point.</p>
  
  <p>In terms of maintainability, code readability and proper python idiomatic approach, is sharing same data_dictionary across "functions" proper justification to create a class ? </p>