title: Why do I have to use a global for imported variable?
body: <pre><code>import datetime
  from datetime import date
  
  def get_one_week():
      global date
      seven_dates = []
      date = date.today()
      for i in range(7):
          date += datetime.timedelta(days=-1)
          date_str = date.strftime('%Y%m%d')
          seven_dates.append(date_str)
      return seven_dates
  
  print(get_one_week())
  </code></pre>
  <p>This will print out:</p>
  <pre><code>['20220901', '20220831', '20220830', '20220829', '20220828', '20220827', '20220826']
  </code></pre>
  <p>My question, both 'date' and 'datetime' are imported variables, but why do I have use a global declaration for the 'date' but not for the 'datetime' variable?</p>