title: Python List Index Out of Range When Passing to Child Function
body: <p>I have the following code:</p>
  <pre class="lang-py prettyprint-override"><code>@task()
  def record_racedata(teamname, cron_min):
      def wrapper(teamname):
          team = nitrotype.Team(teamname)    # error here (nitrotype is a valid object)
          
          for members in team.data[&quot;members&quot;]:
              # more things
      
      schedule = crontab(minute=cron_min)
      task_name = 'record_racedata_%s_%s' % (int(time.time()), teamname)
      periodic_task(schedule, name=task_name)(wrapper(teamname))
  
  record_racedata('team1', '*/1')
  </code></pre>
  <p>This throws the following error at the marked line:</p>
  <pre><code>IndexError: list index out of range
  </code></pre>
  <p>I decided to get rid of the <code>teamname</code> argument into the following code <em>and this worked</em>:</p>
  <pre class="lang-py prettyprint-override"><code>@task()
  def record_racedata(teamname, cron_min):  # did not use &quot;teamname&quot; variable
      def wrapper():
          team = nitrotype.Team(&quot;team1&quot;) 
          
          for members in team.data[&quot;members&quot;]:
              # more things
      
      schedule = crontab(minute=cron_min)
      task_name = 'record_racedata_%s_%s' % (int(time.time()), teamname)
      periodic_task(schedule, name=task_name)(wrapper)
  
  record_racedata('team1', '*/1')
  </code></pre>
  <p>Which implies that the library I was using was working, but the error occurred because I somehow passed the argument <code>teamname</code> down incorrectly. Can anybody please help?</p>
  <p>This is the scheduler that I was trying to use: <a href="https://huey.readthedocs.io/en/latest/guide.html#dynamic-periodic-tasks" rel="nofollow noreferrer">link</a></p>
  <p>Thanks in advance.</p>