title: Define a function and use it for multiple files or modules in python
body: <p>How to create a function to format excel file which can be used for multiple python files or modules. i can understand the problem with variables. i am expecting python to load variables from main file.</p>
  
  <p>I have defined one function to format the excel sheet. it's working fine when i am using it on the same module. but, i want that function to be used for multiple files. </p>
  
  <p>i have used below code</p>
  
  <pre><code>#my function in a file myfunction
  
  def myformatfunction():
  
      workbook = writer.book
      worksheet = writer.sheets['report']
  
      total_fmt = workbook.add_format({'align': 'right', 'num_format': '$#,##0',
                                   'bold': True, 'bottom':6})
  
      worksheet.set_column('A:F', 20)
      worksheet.set_column('G:G', 20, total_fmt)
  
      writer.save()
  
  </code></pre>
  
  <pre><code>#this is my main file where i want to use defined function
  # i have dataframe which will read excel file
  
  writer = pd.ExcelWriter('E:/FunctionOut2.xlsx', engine='xlsxwriter')
  df.to_excel(writer, index=False, sheet_name='report')
  
  
  myformatfunction()
  
  </code></pre>
  
  <p>this is working fine when i am using it on same module. How to use it for multiple python files?</p>