title: Does python allow me to pass dynamic variables to a decorator at runtime?
body: <p>I am attempting to integrate a very old system and a newer system at work. The best I can do is to utilize an RSS firehouse type feed the system utilizes. The goal is to use this RSS feed to make the other system perform certain actions when certain people do things. </p>
  
  <p>My idea is to wrap a decorator around certain functions to check if the user (a user ID provided in the RSS feed) has permissions in the new system. </p>
  
  <p>My current solution has a lot of functions that look like this, which are called based on an <code>action</code> field in the feed:</p>
  
  <pre><code>actions_dict = {
      ...
      'action1': function1
  }
  
  actions_dict[RSSFEED['action_taken']](RSSFEED['user_id'])
  
  def function1(user_id):
      if has_permissions(user_id):
           # Do this function
  </code></pre>
  
  <p>I want to create a <code>has_permissions</code> decorator that takes the <code>user_id</code> so that I can remove this redundant <code>has_permissions</code> check in each of my functions. </p>
  
  <pre><code>@has_permissions(user_id)
  def function1():
      # Do this function
  </code></pre>
  
  <p>Unfortunately, I am not sure how to write such a decorator. All the tutorials I see have the <code>@has_permissions()</code> line with a hardcoded value, but in my case it needs to be passed at runtime and will be different each time the function is called.</p>
  
  <p>How can I achieve this functionality?</p>